From f2cce78db24a0f0a53b8ca41ff112968a5f2d86b Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Fri, 19 Dec 2014 20:02:47 +0000 Subject: Actman 2.0 is moved to deprecated, Actman 3.0 is a new default Actman (with database settings converter from older version) git-svn-id: http://svn.miranda-ng.org/main/trunk@11533 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Actman/actman.dpr | 197 --- plugins/Actman/actman30.dpr | 245 ++++ plugins/Actman/ask.rc | 20 + plugins/Actman/ask.res | Bin 0 -> 456 bytes plugins/Actman/dlgshare.pas | 73 ++ plugins/Actman/dlgshare.rc | 13 + plugins/Actman/dlgshare.res | Bin 0 -> 22652 bytes plugins/Actman/global.pas | 8 + plugins/Actman/hooks.res | Bin 0 -> 688 bytes plugins/Actman/hooks/hooks.pas | 8 +- plugins/Actman/hooks/i_hook.inc | 2 +- plugins/Actman/hooks/i_opt_dlg.inc | 96 +- plugins/Actman/i_action.inc | 951 -------------- plugins/Actman/i_actlow.inc | 836 ------------- plugins/Actman/i_cnst_call.inc | 23 + plugins/Actman/i_cnst_chain.inc | 6 + plugins/Actman/i_cnst_contact.inc | 6 + plugins/Actman/i_cnst_database.inc | 17 + plugins/Actman/i_cnst_dlgshare.inc | 11 + plugins/Actman/i_cnst_ini.inc | 13 + plugins/Actman/i_cnst_inout.inc | 17 + plugins/Actman/i_cnst_jump.inc | 15 + plugins/Actman/i_cnst_message.inc | 17 + plugins/Actman/i_cnst_notes.inc | 3 + plugins/Actman/i_cnst_program.inc | 13 + plugins/Actman/i_cnst_settings.inc | 12 + plugins/Actman/i_cnst_storage.inc | 5 + plugins/Actman/i_cnst_text.inc | 4 + plugins/Actman/i_const.inc | 190 +-- plugins/Actman/i_contact.inc | 113 -- plugins/Actman/i_dlglists.inc | 75 -- plugins/Actman/i_inoutxm.inc | 1212 ------------------ plugins/Actman/i_opt_dlg.inc | 175 +-- plugins/Actman/i_opt_dlg2.inc | 2438 ++++++++++++------------------------ plugins/Actman/i_options.inc | 716 +++++------ plugins/Actman/i_services.inc | 304 ++++- plugins/Actman/i_vars.inc | 31 - plugins/Actman/i_visual.inc | 1073 ---------------- plugins/Actman/iac_.pas | 155 +++ plugins/Actman/iac_call.pas | 948 ++++++++++++++ plugins/Actman/iac_call.rc | 38 + plugins/Actman/iac_call.res | Bin 0 -> 3492 bytes plugins/Actman/iac_chain.pas | 384 ++++++ plugins/Actman/iac_chain.rc | 18 + plugins/Actman/iac_chain.res | Bin 0 -> 3144 bytes plugins/Actman/iac_contact.pas | 313 +++++ plugins/Actman/iac_contact.rc | 18 + plugins/Actman/iac_contact.res | Bin 0 -> 3120 bytes plugins/Actman/iac_database.rc | 35 + plugins/Actman/iac_database.res | Bin 0 -> 3564 bytes plugins/Actman/iac_dbrw.pas | 778 ++++++++++++ plugins/Actman/iac_global.pas | 571 +++++++++ plugins/Actman/iac_ini.pas | 432 +++++++ plugins/Actman/iac_ini.rc | 27 + plugins/Actman/iac_ini.res | Bin 0 -> 3416 bytes plugins/Actman/iac_inout.pas | 699 +++++++++++ plugins/Actman/iac_inout.rc | 30 + plugins/Actman/iac_inout.res | Bin 0 -> 3432 bytes plugins/Actman/iac_jump.pas | 764 +++++++++++ plugins/Actman/iac_jump.rc | 32 + plugins/Actman/iac_jump.res | Bin 0 -> 3448 bytes plugins/Actman/iac_messagebox.pas | 388 ++++++ plugins/Actman/iac_messagebox.rc | 36 + plugins/Actman/iac_messagebox.res | Bin 0 -> 3760 bytes plugins/Actman/iac_notes.pas | 173 +++ plugins/Actman/iac_notes.rc | 13 + plugins/Actman/iac_notes.res | Bin 0 -> 2844 bytes plugins/Actman/iac_program.pas | 520 ++++++++ plugins/Actman/iac_program.rc | 31 + plugins/Actman/iac_program.res | Bin 0 -> 3652 bytes plugins/Actman/iac_service.pas | 676 ++++++++++ plugins/Actman/iac_service.rc | 11 + plugins/Actman/iac_service.res | Bin 0 -> 2820 bytes plugins/Actman/iac_settings.pas | 175 +++ plugins/Actman/iac_settings.rc | 27 + plugins/Actman/iac_settings.res | Bin 0 -> 3636 bytes plugins/Actman/iac_storage.pas | 297 +++++ plugins/Actman/iac_storage.rc | 16 + plugins/Actman/iac_storage.res | Bin 0 -> 2976 bytes plugins/Actman/iac_text.pas | 521 ++++++++ plugins/Actman/iac_text.rc | 14 + plugins/Actman/iac_text.res | Bin 0 -> 2912 bytes plugins/Actman/ico/advance.ico | Bin 1150 -> 2550 bytes plugins/Actman/ico/apply.ico | Bin 1150 -> 1406 bytes plugins/Actman/ico/call.ico | Bin 0 -> 2550 bytes plugins/Actman/ico/chain.ico | Bin 1150 -> 2550 bytes plugins/Actman/ico/contact.ico | Bin 1150 -> 2550 bytes plugins/Actman/ico/delete.ico | Bin 1150 -> 2550 bytes plugins/Actman/ico/down.ico | Bin 1150 -> 2550 bytes plugins/Actman/ico/export.ico | Bin 1150 -> 2550 bytes plugins/Actman/ico/format.ico | Bin 1150 -> 2550 bytes plugins/Actman/ico/import.ico | Bin 1150 -> 2550 bytes plugins/Actman/ico/ini.ico | Bin 0 -> 2550 bytes plugins/Actman/ico/insert.ico | Bin 1150 -> 2550 bytes plugins/Actman/ico/jump.ico | Bin 0 -> 2550 bytes plugins/Actman/ico/message.ico | Bin 1150 -> 2550 bytes plugins/Actman/ico/new.ico | Bin 1150 -> 2550 bytes plugins/Actman/ico/notes.ico | Bin 0 -> 2550 bytes plugins/Actman/ico/program.ico | Bin 1150 -> 2550 bytes plugins/Actman/ico/reload.ico | Bin 1150 -> 2550 bytes plugins/Actman/ico/rw.ico | Bin 1150 -> 2550 bytes plugins/Actman/ico/service.ico | Bin 1150 -> 2550 bytes plugins/Actman/ico/settings.ico | Bin 0 -> 2550 bytes plugins/Actman/ico/storage.ico | Bin 0 -> 2550 bytes plugins/Actman/ico/test.ico | Bin 1150 -> 2550 bytes plugins/Actman/ico/text.ico | Bin 0 -> 2550 bytes plugins/Actman/ico/up.ico | Bin 1150 -> 2550 bytes plugins/Actman/ico/vcheck.ico | Bin 1150 -> 0 bytes plugins/Actman/ico/vuncheck.ico | Bin 1150 -> 0 bytes plugins/Actman/inoutini.pas | 153 +++ plugins/Actman/inoutxml.pas | 155 +++ plugins/Actman/lowlevelc.pas | 296 +++++ plugins/Actman/mApiCard.res | Bin 0 -> 1052 bytes plugins/Actman/m_actions.inc | 193 --- plugins/Actman/m_actman.h | 96 ++ plugins/Actman/options.rc | 278 +--- plugins/Actman/options.res | Bin 32904 -> 1004 bytes plugins/Actman/question.pas | 11 +- plugins/Actman/readme.txt | 2 +- plugins/Actman/services.ini | 124 +- plugins/Actman/sparam.res | Bin 0 -> 624 bytes plugins/Actman/structopts.res | Bin 0 -> 12408 bytes plugins/Actman/tasks.res | Bin 0 -> 1288 bytes plugins/Actman/tasks/i_opt_dlg.inc | 11 +- plugins/Actman/tasks/i_options.inc | 1 + plugins/Actman/tasks/scheduler.pas | 24 +- plugins/Actman/ua.res | Bin 0 -> 3944 bytes plugins/Actman/ua/action.ico | Bin 1150 -> 2550 bytes plugins/Actman/ua/i_inoutjson.inc | 361 ++++++ plugins/Actman/ua/i_inoutxm.inc | 14 +- plugins/Actman/ua/i_opt_dlg.inc | 471 ++++--- plugins/Actman/ua/i_options.inc | 93 +- plugins/Actman/ua/i_ua.inc | 100 +- plugins/Actman/ua/i_uaplaces.inc | 108 +- plugins/Actman/ua/i_uavars.inc | 15 +- plugins/Actman/ua/i_uconst.inc | 40 +- plugins/Actman/ua/ua.pas | 69 +- plugins/Actman/ua/ua.rc | 47 +- plugins/Actman/ua/ua.res | Bin 2512 -> 3992 bytes 139 files changed, 11906 insertions(+), 7834 deletions(-) delete mode 100644 plugins/Actman/actman.dpr create mode 100644 plugins/Actman/actman30.dpr create mode 100644 plugins/Actman/ask.rc create mode 100644 plugins/Actman/ask.res create mode 100644 plugins/Actman/dlgshare.pas create mode 100644 plugins/Actman/dlgshare.rc create mode 100644 plugins/Actman/dlgshare.res create mode 100644 plugins/Actman/hooks.res delete mode 100644 plugins/Actman/i_action.inc delete mode 100644 plugins/Actman/i_actlow.inc create mode 100644 plugins/Actman/i_cnst_call.inc create mode 100644 plugins/Actman/i_cnst_chain.inc create mode 100644 plugins/Actman/i_cnst_contact.inc create mode 100644 plugins/Actman/i_cnst_database.inc create mode 100644 plugins/Actman/i_cnst_dlgshare.inc create mode 100644 plugins/Actman/i_cnst_ini.inc create mode 100644 plugins/Actman/i_cnst_inout.inc create mode 100644 plugins/Actman/i_cnst_jump.inc create mode 100644 plugins/Actman/i_cnst_message.inc create mode 100644 plugins/Actman/i_cnst_notes.inc create mode 100644 plugins/Actman/i_cnst_program.inc create mode 100644 plugins/Actman/i_cnst_settings.inc create mode 100644 plugins/Actman/i_cnst_storage.inc create mode 100644 plugins/Actman/i_cnst_text.inc delete mode 100644 plugins/Actman/i_contact.inc delete mode 100644 plugins/Actman/i_dlglists.inc delete mode 100644 plugins/Actman/i_inoutxm.inc delete mode 100644 plugins/Actman/i_vars.inc delete mode 100644 plugins/Actman/i_visual.inc create mode 100644 plugins/Actman/iac_.pas create mode 100644 plugins/Actman/iac_call.pas create mode 100644 plugins/Actman/iac_call.rc create mode 100644 plugins/Actman/iac_call.res create mode 100644 plugins/Actman/iac_chain.pas create mode 100644 plugins/Actman/iac_chain.rc create mode 100644 plugins/Actman/iac_chain.res create mode 100644 plugins/Actman/iac_contact.pas create mode 100644 plugins/Actman/iac_contact.rc create mode 100644 plugins/Actman/iac_contact.res create mode 100644 plugins/Actman/iac_database.rc create mode 100644 plugins/Actman/iac_database.res create mode 100644 plugins/Actman/iac_dbrw.pas create mode 100644 plugins/Actman/iac_global.pas create mode 100644 plugins/Actman/iac_ini.pas create mode 100644 plugins/Actman/iac_ini.rc create mode 100644 plugins/Actman/iac_ini.res create mode 100644 plugins/Actman/iac_inout.pas create mode 100644 plugins/Actman/iac_inout.rc create mode 100644 plugins/Actman/iac_inout.res create mode 100644 plugins/Actman/iac_jump.pas create mode 100644 plugins/Actman/iac_jump.rc create mode 100644 plugins/Actman/iac_jump.res create mode 100644 plugins/Actman/iac_messagebox.pas create mode 100644 plugins/Actman/iac_messagebox.rc create mode 100644 plugins/Actman/iac_messagebox.res create mode 100644 plugins/Actman/iac_notes.pas create mode 100644 plugins/Actman/iac_notes.rc create mode 100644 plugins/Actman/iac_notes.res create mode 100644 plugins/Actman/iac_program.pas create mode 100644 plugins/Actman/iac_program.rc create mode 100644 plugins/Actman/iac_program.res create mode 100644 plugins/Actman/iac_service.pas create mode 100644 plugins/Actman/iac_service.rc create mode 100644 plugins/Actman/iac_service.res create mode 100644 plugins/Actman/iac_settings.pas create mode 100644 plugins/Actman/iac_settings.rc create mode 100644 plugins/Actman/iac_settings.res create mode 100644 plugins/Actman/iac_storage.pas create mode 100644 plugins/Actman/iac_storage.rc create mode 100644 plugins/Actman/iac_storage.res create mode 100644 plugins/Actman/iac_text.pas create mode 100644 plugins/Actman/iac_text.rc create mode 100644 plugins/Actman/iac_text.res create mode 100644 plugins/Actman/ico/call.ico create mode 100644 plugins/Actman/ico/ini.ico create mode 100644 plugins/Actman/ico/jump.ico create mode 100644 plugins/Actman/ico/notes.ico create mode 100644 plugins/Actman/ico/settings.ico create mode 100644 plugins/Actman/ico/storage.ico create mode 100644 plugins/Actman/ico/text.ico delete mode 100644 plugins/Actman/ico/vcheck.ico delete mode 100644 plugins/Actman/ico/vuncheck.ico create mode 100644 plugins/Actman/inoutini.pas create mode 100644 plugins/Actman/inoutxml.pas create mode 100644 plugins/Actman/lowlevelc.pas create mode 100644 plugins/Actman/mApiCard.res delete mode 100644 plugins/Actman/m_actions.inc create mode 100644 plugins/Actman/m_actman.h create mode 100644 plugins/Actman/sparam.res create mode 100644 plugins/Actman/structopts.res create mode 100644 plugins/Actman/tasks.res create mode 100644 plugins/Actman/ua.res create mode 100644 plugins/Actman/ua/i_inoutjson.inc (limited to 'plugins/Actman') diff --git a/plugins/Actman/actman.dpr b/plugins/Actman/actman.dpr deleted file mode 100644 index e2a67414f5..0000000000 --- a/plugins/Actman/actman.dpr +++ /dev/null @@ -1,197 +0,0 @@ -{$include compilers.inc} -{$IFDEF COMPILER_16_UP} - {$WEAKLINKRTTI ON} - {.$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])} -{$ENDIF} -{$IMAGEBASE $13200000} -library actman; -{%ToDo 'actman.todo'} -{%File 'i_actlow.inc'} -{%File 'm_actions.inc'} -{%File 'm_actman.inc'} -{%File 'i_action.inc'} -{%File 'i_const.inc'} -{%File 'i_contact.inc'} -{%File 'i_opt_dlg2.inc'} -{%File 'i_opt_dlg.inc'} -{%File 'i_visual.inc'} -{%File 'i_options.inc'} -{%File 'i_services.inc'} -{%File 'i_vars.inc'} -{%File 'i_inoutxm.inc'} -{%File 'tasks\i_opt_dlg.inc'} -{%File 'tasks\i_options.inc'} -{%File 'tasks\i_task.inc'} -{%File 'hooks\i_options.inc'} -{%File 'hooks\i_hook.inc'} -{%File 'hooks\i_opt_dlg.inc'} -{%File 'ua\i_opt_dlg.inc'} -{%File 'ua\i_inoutxm.inc'} -{%File 'ua\i_options.inc'} -{%File 'ua\i_ua.inc'} -{%File 'ua\i_uaplaces.inc'} -{%File 'ua\i_uconst.inc'} - -uses - m_api, - Windows, - messages, - commctrl, - common, - wrapper, - io, - dbsettings, - mirutils, - syswin, - question, - mApiCardM, - mircontacts, - global, - sedit, - strans, - ua in 'ua\ua.pas', - hooks in 'hooks\hooks.pas', - scheduler in 'tasks\scheduler.pas'; - -{$r options.res} - -const - PluginName = 'Action Manager'; -var - hHookShutdown, - onloadhook, - opthook:cardinal; - hevaction,hHookChanged,hevinout:cardinal; - hsel,hinout,hfree,hget,hrun,hrung,hrunp:cardinal; - -{$include m_actions.inc} -{$include m_actman.inc} - - -function MirandaPluginInfoEx(mirandaVersion:DWORD):PPLUGININFOEX; cdecl; -begin - result:=@PluginInfo; - PluginInfo.cbSize :=SizeOf(TPLUGININFOEX); - PluginInfo.shortName :='Action manager'; - PluginInfo.version :=$00020001; - PluginInfo.description:='Plugin for manage hotkeys to open contact window, insert text, '+ - 'run program and call services'; - PluginInfo.author :='Awkward'; - PluginInfo.authorEmail:='panda75@bk.ru; awk1975@ya.ru'; - PluginInfo.copyright :='(c) 2007-2012 Awkward'; - PluginInfo.homepage :='http://code.google.com/p/delphi-miranda-plugins/'; - PluginInfo.flags :=UNICODE_AWARE; - PluginInfo.uuid :=MIID_ACTMAN; -end; - -{$include i_const.inc} -{$include i_vars.inc} - -{$include i_action.inc} -{$include i_actlow.inc} -{$include i_options.inc} -{$include i_contact.inc} -{$include i_opt_dlg.inc} -{$include i_inoutxm.inc} -{$include i_services.inc} - -function PreShutdown(wParam:WPARAM;lParam:LPARAM):int;cdecl; -var - ptr:pActionLink; -begin - result:=0; - - ptr:=ActionLink; - while ptr<>nil do - begin - if @ptr^.DeInit<>nil then - ptr^.DeInit; - ptr:=ptr^.Next; - end; - - FreeGroups; - - UnhookEvent(hHookShutdown); - UnhookEvent(opthook); - - DestroyHookableEvent(hHookChanged); - DestroyHookableEvent(hevinout); - DestroyHookableEvent(hevaction); - - DestroyServiceFunction(hfree); - DestroyServiceFunction(hget); - DestroyServiceFunction(hrun); - DestroyServiceFunction(hrung); - DestroyServiceFunction(hrunp); - DestroyServiceFunction(hinout); - DestroyServiceFunction(hsel); -end; - -// This function implements autostart action execution after all others plugins loading -function DoAutostart(wParam:WPARAM;lParam:LPARAM):int;cdecl; -begin - Result:=0; - UnhookEvent(onloadhook); - - CallService(MS_ACT_RUNBYNAME,TWPARAM(AutoStartName),0); -end; - -function OnModulesLoaded(wParam:WPARAM;lParam:LPARAM):int;cdecl; -var - ptr:pActionLink; -begin - Result:=0; - UnhookEvent(onloadhook); - - LoadGroups; - RegisterIcons; - - opthook :=HookEvent(ME_OPT_INITIALISE ,@OnOptInitialise); - hHookShutdown:=HookEvent(ME_SYSTEM_SHUTDOWN{ME_SYSTEM_OKTOEXIT},@PreShutdown); - NotifyEventHooks(hHookChanged,twparam(ACTM_LOADED),0); - - IsMultiThread:=true; - // Load additional modules - ptr:=ActionLink; - while ptr<>nil do - begin - if @ptr^.Init<>nil then - ptr^.Init; - ptr:=ptr^.Next; - end; - - onloadhook:=HookEvent(ME_SYSTEM_MODULESLOADED,@DoAutostart); -end; - -function Load():int; cdecl; -begin - Result:=0; - Langpack_register; - - hHookChanged:=CreateHookableEvent(ME_ACT_CHANGED); - hevinout :=CreateHookableEvent(ME_ACT_INOUT); - hevaction :=CreateHookableEvent(ME_ACT_ACTION); - - hfree :=CreateServiceFunction(MS_ACT_FREELIST ,@ActFreeList); - hget :=CreateServiceFunction(MS_ACT_GETLIST ,@ActGetList); - hrun :=CreateServiceFunction(MS_ACT_RUNBYID ,@ActRun); - hrung :=CreateServiceFunction(MS_ACT_RUNBYNAME,@ActRunGroup); - hrunp :=CreateServiceFunction(MS_ACT_RUNPARAMS,@ActRunParam); - hinout:=CreateServiceFunction(MS_ACT_INOUT ,@ActInOut); - hsel :=CreateServiceFunction(MS_ACT_SELECT ,@ActSelect); - - onloadhook:=HookEvent(ME_SYSTEM_MODULESLOADED,@OnModulesLoaded); -end; - -function Unload: int; cdecl; -begin - Result:=0; -end; - -exports - Load, Unload, MirandaPluginInfoEx; - -initialization - DisableThreadLibraryCalls(hInstance); - -end. diff --git a/plugins/Actman/actman30.dpr b/plugins/Actman/actman30.dpr new file mode 100644 index 0000000000..6e7e2d6f3c --- /dev/null +++ b/plugins/Actman/actman30.dpr @@ -0,0 +1,245 @@ +{$include compilers.inc} +{$IFDEF COMPILER_16_UP} + {$WEAKLINKRTTI ON} + {.$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])} +{$ENDIF} +{$IMAGEBASE $13200000} +library actman; +{%File 'i_const.inc'} +{%File 'i_opt_dlg2.inc'} +{%File 'i_opt_dlg.inc'} +{%File 'i_options.inc'} +{%File 'i_services.inc'} +{%File 'i_vars.inc'} +{%File 'i_inoutxm.inc'} +{%File 'tasks\i_opt_dlg.inc'} +{%File 'tasks\i_options.inc'} +{%File 'tasks\i_task.inc'} +{%File 'hooks\i_options.inc'} +{%File 'hooks\i_hook.inc'} +{%File 'hooks\i_opt_dlg.inc'} +{%File 'ua\i_opt_dlg.inc'} +{%File 'ua\i_inoutxm.inc'} +{%File 'ua\i_options.inc'} +{%File 'ua\i_ua.inc'} +{%File 'ua\i_uaplaces.inc'} +{%File 'ua\i_uconst.inc'} + +uses +// fastmm4, + Windows, + m_api, + messages, + commctrl, + common, + wrapper, + dbsettings, + mirutils, + global, + lowlevelc, + dlgshare, + iac_global, + iac_settings, + iac_storage, + iac_dbrw, + iac_messagebox, + iac_text, + iac_jump, + iac_inout, + iac_service, + iac_program, + iac_chain, + iac_contact, + iac_call, + iac_ini, + iac_notes, + inoutxml, + ua in 'ua\ua.pas', + hooks in 'hooks\hooks.pas', + scheduler in 'tasks\scheduler.pas'; + +{$r options.res} + +const + PluginName = 'Action Manager'; +var + hevaction,hHookChanged,hevinout:THANDLE; + + +function MirandaPluginInfoEx(mirandaVersion:dword):PPLUGININFOEX; cdecl; +begin + result:=@PluginInfo; + PluginInfo.cbSize :=SizeOf(TPLUGININFOEX); + PluginInfo.shortName :='Action manager'; + PluginInfo.version :=$00030001; + PluginInfo.description:='Plugin for manage hotkeys to open contact window, insert text, '+ + 'run program and call services'; + PluginInfo.author :='Awkward'; + PluginInfo.authorEmail:='panda75@bk.ru; awk1975@ya.ru'; + PluginInfo.copyright :='(c) 2007-2013 Awkward'; + PluginInfo.homepage :='http://code.google.com/p/delphi-miranda-plugins/'; + PluginInfo.flags :=UNICODE_AWARE; + PluginInfo.uuid :=MIID_ACTMAN; +end; + +{$include i_const.inc} + +{$include i_options.inc} +{$include i_services.inc} +{$include i_opt_dlg.inc} +{.$include i_inoutxm.inc} + +function PreShutdown(wParam:WPARAM;lParam:LPARAM):int;cdecl; +var + ptr:pActionLink; +begin + result:=0; + + ptr:=ActionLink; + while ptr<>nil do + begin + if @ptr^.DeInit<>nil then + ptr^.DeInit; + ptr:=ptr^.Next; + end; + + MacroList.Clear; + MacroList.Free; + + DestroyHookableEvent(hHookChanged); + DestroyHookableEvent(hevinout); + DestroyHookableEvent(hevaction); + +end; + +procedure RegisterActTypes; +var + p:pActModule; + sid:TSKINICONDESC; + buf:array [0..63] of AnsiChar; + pc:pAnsiChar; +// ii:tIconItem; +begin + FillChar(sid,SizeOf(sid),0); + sid.cbSize:=SizeOf(sid); + sid.cx:=16; + sid.cy:=16; + sid.szSection.a:='Actions'; + sid.pszName :=@buf; + pc:=StrCopyE(buf,IcoLibPrefix); + p:=ModuleLink; +{ + ii.size :=0; + ii.hIcolib:=0; + ii.szName :=@buf; +} + while p<>nil do + begin + if p^.Hash=0 then + p^.Hash:=Hash(p^.Name,StrLen(p^.Name)); + //!! must add icon registration in icolib +{ + StrCopy(pc,p^.Name); + ii.szDescr :=p^.Name; + ii.DefIconID:=; + Icon_Register(hInstance,'Actions',@ii,1); +} + sid.hDefaultIcon :=LoadImageA(hInstance,p^.Icon,IMAGE_ICON,16,16,0); + sid.szDescription.a:=p^.Name; + StrCopy(pc,p^.Name); + Skin_AddIcon(@sid); + DestroyIcon(sid.hDefaultIcon); + + p:=p^.Next; + end; +end; + +// This function implements autostart action execution after all others plugins loading +function DoAutostart(wParam:WPARAM;lParam:LPARAM):int;cdecl; +var + i:integer; + Macro:pMacroRecord; + section:array [0..127] of AnsiChar; + p,p1:pAnsiChar; +begin + Result:=0; + CallService(MS_ACT_RUNBYNAME,TWPARAM(AutoStartName),0); + + p1:=StrCopyE(section,opt_group); + for i:=0 to MacroList.Count-1 do + begin + Macro:=MacroList[i]; + if (Macro^.flags and ACF_FIRSTRUN)<>0 then + begin + CallService(MS_ACT_RUNBYID,TWPARAM(Macro^.id),0); + Macro^.flags:=Macro^.flags and not ACF_FIRSTRUN; + p:=StrEnd(IntToStr(p1,i)); + p^:='/'; inc(p); + StrCopy(p,opt_flags); DBWriteDWord(0,DBBranch,section,Macro^.flags); + end; + end; + +end; + +function OnModulesLoaded(wParam:WPARAM;lParam:LPARAM):int;cdecl; +var + ptr:pActionLink; +begin + Result:=0; + + RegisterActTypes; + + LoadMacros; + RegisterIcons; + + HookEvent(ME_OPT_INITIALISE ,@OnOptInitialise); + HookEvent(ME_SYSTEM_PRESHUTDOWN{ME_SYSTEM_OKTOEXIT},@PreShutdown); + NotifyEventHooks(hHookChanged,twparam(ACTM_LOADED),0); + + IsMultiThread:=true; + // Load additional modules + ptr:=ActionLink; + while ptr<>nil do + begin + if @ptr^.Init<>nil then + ptr^.Init; + ptr:=ptr^.Next; + end; + + // cheat + HookEvent(ME_SYSTEM_MODULESLOADED,@DoAutostart); +// DoAutostart(0,0); +end; + +function Load:int; cdecl; +begin + Result:=0; + Langpack_Register; + + hHookChanged:=CreateHookableEvent(ME_ACT_CHANGED); + hevinout :=CreateHookableEvent(ME_ACT_INOUT); + hevaction :=CreateHookableEvent(ME_ACT_ACTION); + + CreateServiceFunction(MS_ACT_FREELIST ,@ActFreeList); + CreateServiceFunction(MS_ACT_GETLIST ,@ActGetList); + CreateServiceFunction(MS_ACT_RUNBYID ,@ActRun); + CreateServiceFunction(MS_ACT_RUNBYNAME,@ActRunGroup); + CreateServiceFunction(MS_ACT_RUNPARAMS,@ActRunParam); +//!! CreateServiceFunction(MS_ACT_INOUT ,@ActInOut); + CreateServiceFunction(MS_ACT_SELECT ,@ActSelect); + + HookEvent(ME_SYSTEM_MODULESLOADED,@OnModulesLoaded); +end; + +function Unload: int; cdecl; +begin + Result:=0; +end; + +exports + Load, Unload, + MirandaPluginInfoEx; + +begin + DisableThreadLibraryCalls(hInstance); +end. diff --git a/plugins/Actman/ask.rc b/plugins/Actman/ask.rc new file mode 100644 index 0000000000..cb36bcf8ee --- /dev/null +++ b/plugins/Actman/ask.rc @@ -0,0 +1,20 @@ +#include "i_const.inc" + +LANGUAGE 0,0 + +IDD_ASK DIALOGEX 0, 0, 276, 72, 0 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_CONTROLPARENT +CAPTION "Choose action" +FONT 8, "MS Shell Dlg", 0, 0 +{ + CTEXT "", IDC_ASK,4,4,268,42,SS_CENTERIMAGE + + CONTROL "", -1, "STATIC", SS_ETCHEDHORZ, 2, 50, 272, 2 + + DEFPUSHBUTTON "&Yes" , IDOK , 4, 54, 40, 16 + PUSHBUTTON "&No" , IDCANCEL , 52, 54, 40, 16 + PUSHBUTTON "A&ppend" , IDC_APPEND, 100, 54, 52, 16 + PUSHBUTTON "Yes to &All", IDC_YESALL, 160, 54, 52, 16 + PUSHBUTTON "N&o to All" , IDC_NOALL , 220, 54, 52, 16 +} diff --git a/plugins/Actman/ask.res b/plugins/Actman/ask.res new file mode 100644 index 0000000000..15a00e0218 Binary files /dev/null and b/plugins/Actman/ask.res differ diff --git a/plugins/Actman/dlgshare.pas b/plugins/Actman/dlgshare.pas new file mode 100644 index 0000000000..0fc89a975b --- /dev/null +++ b/plugins/Actman/dlgshare.pas @@ -0,0 +1,73 @@ +unit dlgshare; + +interface + +uses windows,lowlevelc; + +var + MacroListWindow, + ActionListWindow:HWND; +var + EditMacroList:tMacroList; + +const + ACI_APPLY = 0; + ACI_NEW = 1; + ACI_DELETE = 2; + ACI_UP = 3; + ACI_DOWN = 4; + ACI_TEST = 5; + ACI_IMPORT = 6; + ACI_EXPORT = 7; + ACI_REFRESH = 8; + +procedure RegisterIcons; +function OptSetButtonIcon(btn:HWND;num:integer):HICON; +procedure OptFillContactList(wnd:HWND); + +implementation + +uses messages, m_api, dbsettings, mircontacts, common, global; + +{$include i_cnst_dlgshare.inc} +{$resource dlgshare.res} + +const + IconAmount = 9; +const + Icons:array [0..IconAmount-1] of tIconItem = ( + (szDescr: 'Apply' ; szName: 'Apply' ; defIconID: IDI_APPLY ; size: 0; hIcolib: 0;), + (szDescr: 'New' ; szName: 'New' ; defIconID: IDI_NEW ; size: 0; hIcolib: 0;), + (szDescr: 'Delete' ; szName: 'Delete'; defIconID: IDI_DELETE; size: 0; hIcolib: 0;), + (szDescr: 'Up' ; szName: 'Up' ; defIconID: IDI_UP ; size: 0; hIcolib: 0;), + (szDescr: 'Down' ; szName: 'Down' ; defIconID: IDI_DOWN ; size: 0; hIcolib: 0;), + (szDescr: 'Test' ; szName: 'Test' ; defIconID: IDI_TEST ; size: 0; hIcolib: 0;), + (szDescr: 'Import' ; szName: 'Import'; defIconID: IDI_IMPORT; size: 0; hIcolib: 0;), + (szDescr: 'Export' ; szName: 'Export'; defIconID: IDI_EXPORT; size: 0; hIcolib: 0;), + (szDescr: 'Reload/Refresh'; szName: 'Reload'; defIconID: IDI_RELOAD; size: 0; hIcolib: 0;) + ); + + +procedure RegisterIcons; +begin + Icon_Register(hInstance,'Actions',@Icons,IconAmount,'ACI'); +end; + +function OptSetButtonIcon(btn:HWND;num:integer):HICON; +begin + result:=CallService(MS_SKIN2_GETICONBYHANDLE,0,LPARAM(Icons[num].hIcolib)); + SendMessage(btn,BM_SETIMAGE,IMAGE_ICON,result); +end; + +procedure OptFillContactList(wnd:HWND); +var + fCLformat:pWideChar; + fCLfilter:byte; +begin + fCLfilter:=DBReadByte (0,DBBranch,'CLfilter',BST_UNCHECKED); + fCLformat:=DBReadUnicode(0,DBBranch,'CLformat'); + FillContactList(wnd, fCLfilter<>BST_UNCHECKED, fCLformat); + mFreeMem(fCLformat); +end; + +end. diff --git a/plugins/Actman/dlgshare.rc b/plugins/Actman/dlgshare.rc new file mode 100644 index 0000000000..dfeb197281 --- /dev/null +++ b/plugins/Actman/dlgshare.rc @@ -0,0 +1,13 @@ +#include "i_cnst_dlgshare.inc" + +LANGUAGE 0,0 + +IDI_NEW ICON "ico\new.ico" +IDI_UP ICON "ico\up.ico" +IDI_DOWN ICON "ico\down.ico" +IDI_DELETE ICON "ico\delete.ico" +IDI_RELOAD ICON "ico\reload.ico" +IDI_TEST ICON "ico\test.ico" +IDI_EXPORT ICON "ico\export.ico" +IDI_IMPORT ICON "ico\import.ico" +IDI_APPLY ICON "ico\apply.ico" diff --git a/plugins/Actman/dlgshare.res b/plugins/Actman/dlgshare.res new file mode 100644 index 0000000000..13c4bf49cd Binary files /dev/null and b/plugins/Actman/dlgshare.res differ diff --git a/plugins/Actman/global.pas b/plugins/Actman/global.pas index 50254b383e..276f71dea7 100644 --- a/plugins/Actman/global.pas +++ b/plugins/Actman/global.pas @@ -2,6 +2,14 @@ unit global; interface +const + DBBranch = 'ActMan'; +const + ACF_SELECTED = $08000000; + ACF_EXPORT = ACF_SELECTED; + ACF_IMPORT = ACF_SELECTED; + ACF_OVERLOAD = $01000000; + type tAddOption = function(var tmpl:pAnsiChar;var proc:pointer;var name:PAnsiChar):integer; type diff --git a/plugins/Actman/hooks.res b/plugins/Actman/hooks.res new file mode 100644 index 0000000000..1cf202f414 Binary files /dev/null and b/plugins/Actman/hooks.res differ diff --git a/plugins/Actman/hooks/hooks.pas b/plugins/Actman/hooks/hooks.pas index b3309c327a..0bfa508afe 100644 --- a/plugins/Actman/hooks/hooks.pas +++ b/plugins/Actman/hooks/hooks.pas @@ -2,21 +2,15 @@ unit hooks; interface -procedure Init; -procedure DeInit; -function AddOptionPage(var tmpl:pAnsiChar;var proc:pointer;var name:PAnsiChar):integer; - implementation uses windows, commctrl, messages, - mirutils, common, dbsettings, io, m_api, wrapper, + mirutils, common, dbsettings, m_api, wrapper, global, mApiCardM; {$R hooks.res} -{$include m_actman.inc} - {$include i_hook.inc} {$include i_hconst.inc} {$include i_options.inc} diff --git a/plugins/Actman/hooks/i_hook.inc b/plugins/Actman/hooks/i_hook.inc index 8b7b487d98..7bdf64fd47 100644 --- a/plugins/Actman/hooks/i_hook.inc +++ b/plugins/Actman/hooks/i_hook.inc @@ -108,7 +108,7 @@ begin end; end; -function HookWndProc(Dialog:HWnd;hMessage:UINT;wParam:WPARAM;lParam:LPARAM):lresult; stdcall; +function HookWndProc(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; var p:pHookRec; ap:tAct_Param; diff --git a/plugins/Actman/hooks/i_opt_dlg.inc b/plugins/Actman/hooks/i_opt_dlg.inc index d208ec4384..23adcf0848 100644 --- a/plugins/Actman/hooks/i_opt_dlg.inc +++ b/plugins/Actman/hooks/i_opt_dlg.inc @@ -133,7 +133,9 @@ end; procedure SaveHookData(Dialog:HWND; item:integer=-1); var wnd:HWND; - li:LV_ITEM; + li:LV_ITEMW; + p:pAnsiChar; + buf:array [0..127] of WideChar; begin wnd:=GetDlgItem(Dialog,IDC_HOOKLIST); if item<0 then @@ -146,9 +148,23 @@ begin SendMessageW(wnd,LVM_SETITEMW,0,LPARAM(@li)); li.mask :=LVIF_TEXT; li.iSubItem :=1; - li.pszText :=GetDlgText(Dialog,IDC_EVENTLIST); + p:=ApiCard.NameFromList(GetDlgItem(Dialog,IDC_EVENTLIST)); + li.pszText :=FastAnsitoWideBuf(p,buf); SendMessageW(wnd,LVM_SETITEMW,0,LPARAM(@li)); - mFreeMem(li.pszText); +end; + +procedure CheckButtons(Dialog:HWND); +var + b:bool; +begin + b:=SendDlgItemMessage(Dialog,IDC_HOOKLIST,LVM_GETITEMCOUNT, 0, 0)>0; + + EnableWindow(GetDlgItem(Dialog,IDC_EVENTLIST ),b); + EnableWindow(GetDlgItem(Dialog,IDC_ACTIONLIST ),b); + EnableWindow(GetDlgItem(Dialog,IDC_HOOK_DELETE),b); + EnableWindow(GetDlgItem(Dialog,IDC_HOOK_APPLY ),b); + EnableWindow(GetDlgItem(Dialog,IDC_EVENT_CHELP),b); + EnableWindow(GetDlgItem(Dialog,IDC_EVENT_HELP ),b); end; function NewHook(Dialog:HWND;item:integer=-1):integer; @@ -165,25 +181,33 @@ begin li.iSubItem:=0; li.pszText :=TranslateW('hook sample'); result:=SendMessageW(wnd,LVM_INSERTITEMW,0,LPARAM(@li)); + Listview_SetItemState(wnd,result, + LVIS_FOCUSED or LVIS_SELECTED, + LVIS_FOCUSED or LVIS_SELECTED); + CheckButtons(Dialog); end; function DeleteHook(Dialog:HWND):integer; var wnd:HWND; - i:integer; + i,j:integer; begin result:=0; wnd:=GetDlgItem(Dialog,IDC_HOOKLIST); - for i:=ListView_GetItemCount(wnd)-1 downto 0 do + j:=SendMessage(wnd,LVM_GETITEMCOUNT,0,0); + for i:=j-1 downto 0 do begin - if ListView_GetItemState(wnd,i,LVIS_SELECTED)<>0 then + if SendMessage(wnd,LVM_GETITEMSTATE,i,LVIS_SELECTED)<>0 then SendMessage(wnd,LVM_DELETEITEM,i,0); end; - Listview_SetItemState(wnd,0,LVIS_FOCUSED or LVIS_SELECTED, - LVIS_FOCUSED or LVIS_SELECTED); + Listview_SetItemState(wnd,0, + LVIS_FOCUSED or LVIS_SELECTED, + LVIS_FOCUSED or LVIS_SELECTED); + + CheckButtons(Dialog); end; -function NewHKTableProc(Dialog:HWnd;hMessage:UINT;wParam:WPARAM;lParam:LPARAM):lresult; stdcall; +function NewHKTableProc(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; var i:integer; begin @@ -254,10 +278,31 @@ begin SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,LPARAM(@ti)); end; -function DlgProcOpt(Dialog:HWnd;hMessage:UINT;wParam:WPARAM;lParam:LPARAM):lresult; stdcall; +procedure CreateHKTable(Dialog:HWND); var wnd:HWND; lv:LV_COLUMNW; +begin + wnd:=GetDlgItem(Dialog,IDC_HOOKLIST); + SendMessage(wnd,LVM_SETUNICODEFORMAT,1,0); + FillChar(lv,SizeOf(lv),0); + lv.mask :=LVCF_TEXT or LVCF_WIDTH; + lv.pszText:=TranslateW('Description'); + lv.cx :=110; + SendMessageW(wnd,LVM_INSERTCOLUMNW ,0,TLPARAM(@lv)); + lv.pszText:=TranslateW('Name'); + lv.cx :=110; + SendMessageW(wnd,LVM_INSERTCOLUMNW ,1,TLPARAM(@lv)); + SendMessageW(wnd,LVM_SETCOLUMNWIDTH,1,LVSCW_AUTOSIZE_USEHEADER); +// SendMessage (wnd,LVM_SETEXTENDEDLISTVIEWSTYLE,LVS_EX_CHECKBOXES,LVS_EX_CHECKBOXES); + SendMessage (wnd,LVM_SETEXTENDEDLISTVIEWSTYLE,0, + LVS_EX_FULLROWSELECT or LVS_EX_CHECKBOXES or LVS_EX_GRIDLINES); + SendMessage(wnd,LVM_SETUNICODEFORMAT,1,0); + OldTableProc:=pointer(SetWindowLongPtrW(wnd,GWL_WNDPROC,LONG_PTR(@NewHKTableProc))); +end; + +function DlgProcOpt(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; +var i:integer; tmp:pAnsiChar; buf:array [0..255] of AnsiChar; @@ -274,36 +319,29 @@ begin WM_INITDIALOG: begin ApiCard:=CreateEventCard(Dialog); - wnd:=GetDlgItem(Dialog,IDC_HOOKLIST); - SendMessage(wnd,LVM_SETUNICODEFORMAT,1,0); - FillChar(lv,SizeOf(lv),0); - lv.mask :=LVCF_TEXT or LVCF_WIDTH; - lv.pszText:=TranslateW('Description'); - lv.cx :=110; - SendMessageW(wnd,LVM_INSERTCOLUMNW ,0,TLPARAM(@lv)); - lv.pszText:=TranslateW('Name'); - lv.cx :=110; - SendMessageW(wnd,LVM_INSERTCOLUMNW ,1,TLPARAM(@lv)); - SendMessageW(wnd,LVM_SETCOLUMNWIDTH,1,LVSCW_AUTOSIZE_USEHEADER); -// SendMessage (wnd,LVM_SETEXTENDEDLISTVIEWSTYLE,LVS_EX_CHECKBOXES,LVS_EX_CHECKBOXES); - SendMessage (wnd,LVM_SETEXTENDEDLISTVIEWSTYLE,0, - LVS_EX_FULLROWSELECT or LVS_EX_CHECKBOXES or LVS_EX_GRIDLINES); - SendMessage(wnd,LVM_SETUNICODEFORMAT,1,0); - OldTableProc:=pointer(SetWindowLongPtrW(wnd,GWL_WNDPROC,LONG_PTR(@NewHKTableProc))); TranslateDialogDefault(Dialog); SetIcons(Dialog); - ApiCard.FillList(GetDlgItem(Dialog,IDC_EVENTLIST)); + ApiCard.FillList(GetDlgItem(Dialog,IDC_EVENTLIST), + DBReadByte(0,DBBranch,'SrvListMode')); + FillActionList(GetDlgItem(Dialog,IDC_ACTIONLIST)); - FillHookList(wnd); + + CreateHKTable(Dialog); + FillHookList(GetDlgItem(Dialog,IDC_HOOKLIST)); ShowHookData(Dialog); + CheckButtons(Dialog); + onactchanged:=HookEvent(ME_ACT_CHANGED,@ActListChange); settings:=Dialog; end; WM_HELP: begin + tmp:=ApiCard.NameFromList(GetDlgItem(Dialog,IDC_EVENTLIST)); + ApiCard.Event:=tmp; + mFreeMem(tmp); ApiCard.Show; end; @@ -350,7 +388,7 @@ begin BN_CLICKED: begin case loword(wParam) of - IDC_EVENT_CHELP: ; + IDC_EVENT_CHELP: SendMessage(Dialog,WM_HELP,0,0); IDC_EVENT_HELP : ; IDC_HOOK_NEW : NewHook(Dialog); IDC_HOOK_DELETE: DeleteHook(Dialog); diff --git a/plugins/Actman/i_action.inc b/plugins/Actman/i_action.inc deleted file mode 100644 index 01b02d1b2f..0000000000 --- a/plugins/Actman/i_action.inc +++ /dev/null @@ -1,951 +0,0 @@ -{Action code} -const - rtInt = 1; - rtWide = 2; - -const - SST_BYTE = 0; - SST_WORD = 1; - SST_DWORD = 2; - SST_QWORD = 3; - SST_NATIVE = 4; - SST_BARR = 5; - SST_WARR = 6; - SST_BPTR = 7; - SST_WPTR = 8; - SST_LAST = 9; - SST_PARAM = 10; - -const - protostr = ''; - -const - BufferSize = 8192; - -function DBRW(act:pHKAction;hContact:THANDLE;avalue:uint_ptr; - last,restype:uint_ptr):uint_ptr; -var - buf ,buf1 :array [0..127] of AnsiChar; - sbuf:array [0..127] of AnsiChar; - module,setting:pAnsiChar; - tmp:pWideChar; - tmpa,tmpa1:pAnsichar; -begin - module :=act^.dbmodule; - setting:=act^.dbsetting; - - with act^ do - begin - if restype=rtWide then - FastWideToAnsiBuf(pWideChar(last),@sbuf) - else - IntToStr(sbuf,last); - - if (flags2 and ACF2_RW_MVAR)<>0 then module :=ParseVarString(module ,hContact,sbuf); - if (flags2 and ACF2_RW_SVAR)<>0 then setting:=ParseVarString(setting,hContact,sbuf); - StrCopy(buf,module); - StrReplace(buf,protostr,GetContactProtoAcc(hContact)); - - StrReplace(buf,'',sbuf); - StrCopy(buf1,setting); - StrReplace(buf1,'',sbuf); - - if (flags2 and ACF2_RW_TVAR)<>0 then - pWideChar(avalue):=ParseVarString(pWideChar(avalue),hContact,@sbuf); - - if ((flags and ACF_DBUTEXT)=0) and - ((flags2 and ACF2_RW_TVAR)<>0) then - begin - tmp:=pWideChar(avalue); - avalue:=StrToInt(tmp); - mFreeMem(tmp); - end; - - if (flags and ACF_DBDELETE)<>0 then - begin - result:=DBDeleteSetting(hContact,buf,setting); - end - else if (flags and ACF_DBWRITE)<>0 then - begin - if (flags and ACF_DBANSI)=ACF_DBANSI then - begin - WideToAnsi(pWideChar(avalue),tmpa,MirandaCP); - DBWriteString(hContact,buf,buf1,tmpa); - mFreeMem(tmpa); - if (flags2 and ACF2_RW_TVAR)=0 then - StrDupW(pWideChar(avalue),pWideChar(avalue)); - end - else if (flags and ACF_DBBYTE )=ACF_DBBYTE then DBWriteByte(hContact,buf,setting,avalue) - else if (flags and ACF_DBWORD )=ACF_DBWORD then DBWriteWord(hContact,buf,setting,avalue) - else if (flags and ACF_DBUTEXT)=ACF_DBUTEXT then - begin - DBWriteUnicode(hContact,buf,buf1,pWideChar(avalue)); - if (flags2 and ACF2_RW_TVAR)=0 then - StrDupW(pWideChar(avalue),pWideChar(avalue)); - end - else DBWriteDWord(hContact,buf,setting,avalue); - - result:=avalue; - end - else - begin - if (flags and ACF_DBANSI)=ACF_DBANSI then - begin - WideToAnsi(pWideChar(avalue),tmpa1,MirandaCP); - tmpa:=DBReadString(hContact,buf,buf1,tmpa1); - AnsiToWide(tmpa,PWideChar(result),MirandaCP); - mFreeMem(tmpa1); - mFreeMem(tmpa); - - if (flags2 and ACF2_RW_TVAR)<>0 then - mFreeMem(avalue); - end - else if (flags and ACF_DBBYTE )=ACF_DBBYTE then result:=DBReadByte(hContact,buf,setting,avalue) - else if (flags and ACF_DBWORD )=ACF_DBWORD then result:=DBReadWord(hContact,buf,setting,avalue) - else if (flags and ACF_DBUTEXT)=ACF_DBUTEXT then - begin - result:=uint_ptr(DBReadUnicode(hContact,buf,buf1,pWideChar(avalue))); - if (flags2 and ACF2_RW_TVAR)<>0 then - mFreeMem(avalue); - end - else result:=DBReadDWord(hContact,buf,setting,avalue); - - end; - if (flags2 and ACF2_RW_MVAR)<>0 then mFreeMem(module); - if (flags2 and ACF2_RW_SVAR)<>0 then mFreeMem(setting); - end; -end; - -function OpenContact(hContact:THANDLE):THANDLE; -begin - ShowContactDialog(hContact); -{ - if CallService(MS_DB_CONTACT_IS,hContact,0)<>0 then - begin - if ServiceExists(MS_MSG_CONVERS)<>0 then - begin - CallService(MS_MSG_CONVERS,hContact,0) - end - else - CallService(MS_MSG_SENDMESSAGE,hContact,0) - end; -} - result:=hContact; -end; - -function replany(var str:pWideChar;aparam:LPARAM;alast:pWideChar):boolean; -var - buf:array [0..31] of WideChar; - tmp:pWideChar; -begin - if StrScanW(str,'<')<>nil then - begin - result:=true; - mGetMem(tmp,2048); - StrCopyW(tmp,str); - StrReplaceW(tmp,'',IntToStr(buf,aparam)); - StrReplaceW(tmp,'' ,alast); - - str:=tmp; - end - else - result:=false; -end; - -function RunProgram(act:pHKAction;aparam:LPARAM;alast:pWideChar):dword; -var - tmp,tmpp,lpath:PWideChar; - replPrg ,replArg :PWideChar; - replPrg1,replArg1:PWideChar; - pd:LPARAM; - vars1,vars2,prgs,argss:boolean; -begin - with act^ do - begin - - replPrg:=prgname; - prgs :=replany(replPrg,aparam,alast); - - replArg:=args; - argss :=replany(replArg,aparam,alast); - - if ((flags2 and ACF2_PRG_PRG)<>0) or - ((flags2 and ACF2_PRG_ARG)<>0) then - begin - pd:=WndToContact(WaitFocusedWndChild(GetForegroundwindow){GetFocus}); - if (pd=0) and (CallService(MS_DB_CONTACT_IS,aparam,0)<>0) then - pd:=aparam; - end; - - if (flags2 and ACF2_PRG_ARG)<>0 then - begin - vars2:=true; - tmp :=ParseVarString(replArg,pd,alast); - end - else - begin - vars2:=false; - tmp :=replArg; - end; - - if (flags2 and ACF2_PRG_PRG)<>0 then - begin - vars1:=true; - tmpp :=ParseVarString(replPrg,pd,alast); - end - else - begin - vars1:=false; - tmpp:=replPrg; - end; - - if StrScanW(tmpp,'%')<>nil then - begin - mGetMem(replPrg1,8192*SizeOf(WideChar)); - ExpandEnvironmentStringsW(tmpp,replPrg1,8191); - if vars1 then mFreeMem(tmpp); - if prgs then mFreeMem(replPrg); - tmpp :=replPrg1; - prgs :=false; - vars1:=true; - end; - if StrScanW(tmp,'%')<>nil then - begin - mGetMem(replArg1,8192*SizeOf(WideChar)); - ExpandEnvironmentStringsW(tmp,replArg1,8191); - if vars2 then mFreeMem(tmp); - if argss then mFreeMem(replArg); - tmp :=replArg1; - argss:=false; - vars2:=true; - end; - - if (flags and ACF_CURPATH)=0 then - lpath:=ExtractW(tmpp,false) - else - lpath:=nil; - - if (flags and ACF_PRTHREAD)<>0 then - time:=0 - else if time=0 then - time:=INFINITE; - result:=ExecuteWaitW(tmpp,tmp,lpath,show,time,@pd); - - if vars2 then mFreeMem(tmp); - if vars1 then mFreeMem(tmpp); - - if prgs then mFreeMem(replPrg); - if argss then mFreeMem(replArg); - end; - mFreeMem(lpath); -end; -{ -function MakeStructure(txt:pWideChar;aparam,alast:LPARAM; - var code,alen:integer;var ofs:int_ptr; restype:integer=rtInt):pointer; forward; -procedure FreeStructure(var struct;descr:pWideChar); forward; -} -function RunService(act:pHKAction;LastResult,Param:LPARAM;var restype:dword):uint_ptr; -var - res:int_ptr; - buf:array [0..255] of AnsiChar; - cc:integer; - lservice:pAnsiChar; - lwparam,llparam:LPARAM; - tmp1,tmp2:pWideChar; - code,len:integer; -begin - result:=uint_ptr(-1); - - lservice:=act^.service; - lwparam :=act^.wparam; - llparam :=act^.lparam; - with act^ do - begin - if (flags2 and ACF2_SRV_SRVC)<>0 then - lservice:=ParseVarString(lservice,Param); - - StrCopy(buf,lservice); - if StrPos(lservice,protostr)<>nil then - if CallService(MS_DB_CONTACT_IS,Param,0)=0 then - begin - if (flags2 and ACF2_SRV_SRVC)<>0 then - mFreeMem(lservice); - exit - end - else - StrReplace(buf,protostr,GetContactProtoAcc(Param)); - - if ServiceExists(buf)<>0 then - begin - - cc:=-1; - - tmp1:=nil; - tmp2:=nil; - code:=-1; - if (flags and ACF_WSTRUCT)<>0 then - begin - lwparam:=twParam(MakeStructure(pAnsiChar(lwparam),Param,LastResult,restype)) - end - else if (flags and ACF_WPARAM)<>0 then - begin - lwparam:=Param; - end - else if (flags and ACF_WRESULT)<>0 then - begin - lwparam:=LastResult; - end - else if (flags and ACF_WCURRENT)<>0 then - begin - cc:=WndToContact(WaitFocusedWndChild(GetForegroundwindow){GetFocus}); - lwparam:=cc; - end - else if (flags2 and ACF2_SRV_WPAR)<>0 then - begin - if (flags and ACF_WPARNUM)=0 then - begin - if (flags and ACF_WUNICODE)=0 then - lwparam:=uint_ptr(ParseVarString(pAnsiChar(lwparam),Param)) - else - lwparam:=uint_ptr(ParseVarString(pWideChar(lwparam),Param)) - end - else - begin - tmp1:=ParseVarString(pWideChar(lwparam),Param); - lwparam:=StrToInt(tmp1); - end; - end; - - if (flags and ACF_LSTRUCT)<>0 then - begin - llparam:=tlParam(MakeStructure(pAnsiChar(llparam),Param,LastResult,restype)) - end - else if (flags and ACF_LPARAM)<>0 then - begin - llparam:=Param; - end - else if (flags and ACF_LRESULT)<>0 then - begin - llparam:=LastResult; - end - else if (flags and ACF_LCURRENT)<>0 then - begin - if cc<>-1 then - llparam:=cc - else - llparam:=WndToContact(WaitFocusedWndChild(GetForegroundwindow){GetFocus}); - end - else if (flags2 and ACF2_SRV_LPAR)<>0 then - begin - if (flags and ACF_LPARNUM)=0 then - begin - if (flags and ACF_LUNICODE)=0 then - llparam:=uint_ptr(ParseVarString(pAnsiChar(llparam),Param)) - else - llparam:=uint_ptr(ParseVarString(pWideChar(llparam),Param)) - end - else - begin - tmp2:=ParseVarString(pWideChar(llparam),Param); - llparam:=StrToInt(tmp2); - end; - end; - - res:=CallServiceSync(buf,lwparam,llparam); - result:=res; - if (flags and ACF_STRING)<>0 then - begin -//!! delete old or not? - if (flags and ACF_UNICODE)=0 then - begin - AnsiToWide(pAnsiChar(res),pWideChar(result),MirandaCP); - if (flags2 and ACF2_FREEMEM)<>0 then - mFreeMem(pAnsiChar(res)); - end - else if (flags2 and ACF2_FREEMEM)=0 then - StrDupW(pWideChar(result),pWideChar(res)); - restype:=rtWide; - end - else if (flags and ACF_STRUCT)=0 then - restype:=rtInt; - - if (flags and ACF_WSTRUCT)<>0 then - begin - if (flags and ACF_STRUCT)<>0 then - begin - result:=GetStructureResult(lwparam,@code,@len); - case code of - SST_LAST: begin - result:=LastResult; - end; - SST_PARAM: begin - result:=Param; - restype:=rtInt; - end; - SST_BYTE,SST_WORD,SST_DWORD, - SST_QWORD,SST_NATIVE: begin - restype:=rtInt; - end; - SST_BARR: begin -{ - mGetMem(pAnsiChar(res),len+1); - StrCopy(pAnsiChar(res),pAnsiChar(ofs),len); -} - StrDup(pAnsiChar(res),pAnsiChar(result),len); - AnsiToWide(pAnsiChar(res),PWideChar(result),MirandaCP); - mFreeMem(pAnsiChar(res)); - restype:=rtWide; - end; - SST_WARR: begin -{ - mGetMem(pWideChar(result),len+2); - len:= len div 2; - StrCopyW(pWideChar(result),pWideChar(ofs),len); -} - StrDupW(pWideChar(result),pWideChar(result),len); - restype:=rtWide; - end; - SST_BPTR: begin - AnsiToWide(pAnsiChar(result),pWideChar(result),MirandaCP); - restype:=rtWide; - end; - SST_WPTR: begin - StrDupW(pWideChar(result),pWideChar(result)); - restype:=rtWide; - end; - end; - end; - code:=SST_UNKNOWN; - FreeStructure(lwparam); - res:=result; - end - else if (flags2 and ACF2_SRV_WPAR)<>0 then - begin - if (flags and ACF_LPARNUM)=0 then - mFreeMem(pAnsiChar(lwparam)) - else - mFreeMem(tmp1); - end; - - if (flags and ACF_LSTRUCT)<>0 then - begin - if (flags and ACF_STRUCT)<>0 then - begin - result:=GetStructureResult(llparam,@code,@len); - case code of - SST_LAST: begin - result:=LastResult; - end; - SST_PARAM: begin - result:=Param; - restype:=rtInt; - end; - SST_BYTE,SST_WORD,SST_DWORD, - SST_QWORD,SST_NATIVE: begin - restype:=rtInt; - end; - SST_BARR: begin -{ - mGetMem(pAnsiChar(res),len+1); - StrCopy(pAnsiChar(res),pAnsiChar(ofs),len); -} - StrDup(pAnsiChar(res),pAnsiChar(result),len); - AnsiToWide(pAnsiChar(res),PWideChar(result),MirandaCP); - mFreeMem(pAnsiChar(res)); - restype:=rtWide; - end; - SST_WARR: begin -{ - mGetMem(pWideChar(result),len+2); - len:= len div 2; - StrCopyW(pWideChar(result),pWideChar(ofs),len); -} - StrDupW(pWideChar(result),pWideChar(result),len); - restype:=rtWide; - end; - SST_BPTR: begin - AnsiToWide(pAnsiChar(result),pWideChar(result),MirandaCP); - restype:=rtWide; - end; - SST_WPTR: begin - StrDupW(pWideChar(result),pWideChar(result)); - restype:=rtWide; - end; - end; - end; - code:=SST_UNKNOWN; - FreeStructure(llparam); - res:=result; - end - else if (flags2 and ACF2_SRV_LPAR)<>0 then - begin - if (flags and ACF_LPARNUM)=0 then - mFreeMem(pAnsiChar(llparam)) - else - mFreeMem(tmp2); - end; - - if (flags and (ACF_INSERT or ACF_MESSAGE or ACF_POPUP))<>0 then - begin - if restype=rtInt then - begin - if (flags and ACF_HEX)<>0 then - IntToHex(pWideChar(@buf),result) - else if ((flags and ACF_SIGNED)<>0) and (res<0) then - begin - pWideChar(@buf)[0]:='-'; - IntToStr(PWideChar(@buf)+1,-result); - end - else - IntToStr(pWideChar(@buf),result); - res:=int_ptr(@buf); - end - else - res:=result; - end; - - if (flags and ACF_INSERT )<>0 then SendMessageW(WaitFocusedWndChild(GetForegroundwindow){GetFocus},EM_REPLACESEL,0,res); - if (flags and ACF_POPUP )<>0 then ShowPopupW(PWideChar(res)); - if (flags and ACF_MESSAGE)<>0 then MessageBoxW(0,PWideChar(res),'',0); - - end; - if (flags2 and ACF2_SRV_SRVC)<>0 then - mFreeMem(lservice); - end; -end; - -procedure PasteClipboard(dst:pWideChar); -var - p:pWideChar; - fh:tHandle; -begin - if StrPosW(dst,'^v')<>nil then - begin -{ - p:=PasteFromClipboard(false); - StrReplaceW(dst,'^v',p); - mFreeMem(p); -} - if OpenClipboard(0) then - begin - fh:=GetClipboardData(cf_UnicodeText); - p:=GlobalLock(fh); - StrReplaceW(dst,'^v',p); - GlobalUnlock(fh); - CloseClipboard; - end - end -end; - -type - trec = record - text:PAnsiChar; - one, two:integer; - end; - -function GetFileString(fname:PAnsiChar;linenum:integer):pWideChar; -var - pc,FileBuf,CurLine:PAnsiChar; - f:THANDLE; - NumLines, j:integer; -begin - f:=Reset(fname); - if f<>INVALID_HANDLE_VALUE then - begin - j:=FileSize(f); - mGetMem(FileBuf,j+1); - BlockRead(f,FileBuf^,j); - while (FileBuf+j)^<' ' do dec(j); - (FileBuf+j+1)^:=#0; - CloseHandle(f); - pc:=FileBuf; - CurLine:=pc; - NumLines:=1; - while pc^<>#0 do // count number of lines - begin - if pc^=#13 then - begin - if linenum=NumLines then - break; - inc(pc); - if pc^=#10 then - inc(pc); - inc(NumLines); - CurLine:=pc; - end - else - inc(pc); - end; - if (linenum>NumLines) or (linenum=0) then //ls - lastline - else if linenum<0 then - begin - randomize; - linenum:=random(NumLines)+1; - pc:=FileBuf; - NumLines:=1; - CurLine:=pc; - repeat - if (pc^=#13) or (pc^=#0) then - begin - if linenum=NumLines then - break; - if pc^<>#0 then - begin - inc(pc); - if pc^=#10 then - inc(pc); - end; - inc(NumLines); - CurLine:=pc; - end - else - inc(pc); - until false; - end; - pc^:=#0; - StrReplace(CurLine,'\n',#13#10); - StrReplace(CurLine,'\t',#09); - AnsiToWide(CurLine,result,CP_ACP); - mFreeMem(FileBuf); - end - else - result:=nil; -end; - -function Split(buf:PWideChar;macro:PWideChar;var r:trec):integer; -type - tconv = packed record - case boolean of - false: (res:int); - true: (lo,hi:word); - end; -var - i:integer; - p,pp,lp:pWideChar; - ls:array [0..511] of WideChar; -begin - result:=0; - i:=StrIndexW(buf,macro); - if i>0 then - begin - dec(i); - p:=buf+i+StrLenW(macro); - pp:=p; - while (p^<>#0) and (p^<>')') do - inc(p); - ls[0]:=#0; - if p^<>#0 then // correct syntax - begin - lp:=ls; - while (pp<>p) and (pp^<>',') do // filename - begin - lp^:=pp^; - inc(lp); - inc(pp); - end; - lp^:=#0; - WideToAnsi(ls,r.text,MirandaCP); - r.one:=-1; - r.two:=-1; - if pp^=',' then - begin - inc(pp); - r.one:=StrToInt(pp); - while (pp<>p) and (pp^<>',') do inc(pp); - if pp^=',' then - begin - inc(pp); - r.two:=StrToInt(pp); - end; - end; - tconv(result).lo:=p-buf-i+1; // length - tconv(result).hi:=i; // position - end; - end; -end; - -procedure PasteFileString(dst:pWideChar); -var - i:integer; - lp:pWideChar; - buf:array [0..511] of AnsiChar; - r:trec; -begin - repeat - i:=Split(dst,'^f(',r); - if i>0 then - begin - StrDeleteW(dst,i shr 16,loword(i)); - ConvertFileName(r.text,buf); - lp:=GetFileString(@buf,r.one); - if lp<>nil then - begin - StrInsertW(lp,dst,i shr 16); - mFreeMem(lp); - end; - end - else - break; - until false; -end; - -procedure PasteSelectedText(wnd:hwnd;dst:pWideChar); -var - sel:integer; - buf:pWideChar; -begin - if (StrPosW(dst,'^s')<>nil) and (wnd<>0) then - begin - sel:=SendMessageW(wnd,EM_GETSEL,0,0); - if loword(sel)=(sel shr 16) then - StrReplaceW(dst,'^s',nil) - else - begin - buf:=GetDlgText(wnd,false); -//!! next line was active. why? -// SendMessageW(wnd,WM_GETTEXT,4095,dword(@buf)); - buf[sel shr 16]:=#0; - StrReplaceW(dst,'^s',buf+loword(sel)); - mFreeMem(buf); - end; - end; -end; - -function CheckAuto(dst:pWideChar):bool; -var - p:PWideChar; -begin - result:=false; - if dst<>nil then - begin - p:=StrEndW(dst); - if (p-dst)>2 then - begin - dec(p,2); - if (p^='^') and ((p+1)^='a') then - begin - result:=true; - p^:=#0; - end; - end; - end; -end; - -function InsertText(act:pHKAction;param:LPARAM;last:pWideChar):uint_ptr; -var - tmp:PWideChar; - blob,p:PAnsiChar; - w:PWideChar; - hContact:THANDLE; - wnd:HWND; - fexist,autosend:bool; - dbei:TDBEVENTINFO; - i:cardinal; - cp:integer; - fh:THANDLE; - lstr:pWideChar; - llen:integer; - buf:array [0..31] of WideChar; - b,b1:array [0..MAX_PATH] of AnsiChar; -begin - result:=uint_ptr(last); - with act^ do - begin - if (flags and ACF_CLIPBRD)<>0 then - begin - if (flags and ACF_COPYTO)<>0 then - CopyToClipboard(last,false) - else - result:=uint_ptr(PasteFromClipboard(false)); - exit; - end; - - hContact:=0; - if (flags and ACF_FILE)=0 then - begin - wnd:=WaitFocusedWndChild(GetForegroundWindow){GetFocus}; - if wnd<>0 then - hContact:=WndToContact(wnd); - end - else - wnd:=0; - - if hContact=0 then - begin - if CallService(MS_DB_CONTACT_IS,param,0)<>0 then - hContact:=param; - end; - - if (flags and (ACF_FILE or ACF_FAPPEND or ACF_FWRITE))<>ACF_FILE then - begin - mGetMem (w ,BufferSize*SizeOf(WideChar)); - FillChar(w^,BufferSize*SizeOf(WideChar),0); - StrCopyW(w,text); - PasteClipboard(w); // ^v - PasteFileString(w); // ^f - PasteSelectedText(wnd,w); // ^s - autosend:=CheckAuto(w); // ^a - StrReplaceW(w,'^l',last); // ^l - StrReplaceW(w,'^h',IntToHex(buf,StrToInt(last))); // ^h - StrReplaceW(w,'^t',#9); // ^t - StrReplaceW(w,'^e',nil); // ^e - end - else - autosend:=false; - - if (flags2 and ACF2_TXT_TEXT)<>0 then - begin - tmp:=ParseVarString(w,hContact,last); - mFreeMem(w); - w:=tmp; - end; - - if (flags and ACF_FILE)<>0 then - begin - cp:=0; - if (flags and ACF_ANSI)=ACF_ANSI then cp:=1 - else if (flags and (ACF_UTF8 or ACF_SIGN))=ACF_UTF8 then cp:=2 - else if (flags and (ACF_UTF8 or ACF_SIGN))=ACF_SIGN then cp:=4 - else if (flags and (ACF_UTF8 or ACF_SIGN))=(ACF_UTF8 or ACF_SIGN) then cp:=3; - - if (flags2 and ACF2_TXT_FILE)<>0 then - tmp:=ParseVarString(tfile,hContact,last) - else - tmp:=tfile; - - if (flags and (ACF_FAPPEND or ACF_FWRITE))<>0 then - begin - case cp of - 1: begin - llen:=StrLen(WideToAnsi(w,pAnsiChar(lstr),MirandaCP)); - end; - 2,3: begin - llen:=StrLen(WideToUTF8(w,pAnsiChar(lstr))); - end; - else - lstr:=w; - llen:=StrLenW(lstr)*SizeOf(WideChar); - end; - end - else - llen:=0; - - fexist:=FileExists(tmp); - if fexist and ((flags and ACF_FAPPEND)<>0) then - begin - fh:=Append(tmp); - if fh<>THANDLE(INVALID_HANDLE_VALUE) then - begin - BlockWrite(fh,lstr^,llen); - end; - if (cp<>0) and (cp<>4) then - mFreeMem(lstr); - end - else if ((flags and ACF_FWRITE)<>0) or - (not fexist and ((flags and ACF_FAPPEND)<>0)) then - begin - fh:=ReWrite(tmp); - if fh<>THANDLE(INVALID_HANDLE_VALUE) then - begin - if cp=3 then - begin - i:=SIGN_UTF8; - BlockWrite(fh,i,3); // UTF8 sign - end - else if cp=4 then - begin - i:=SIGN_UNICODE; - BlockWrite(fh,i,2); // UTF16 sign - end; - - BlockWrite(fh,lstr^,llen); - if (cp<>0) and (cp<>4) then - mFreeMem(lstr); - end; - end - else - begin - if StrPosW(tmp,'://')<>nil then // remote - begin - GetTempPathA(MAX_PATH,b); - GetTempFileNameA(b,'wat',GetCurrentTime,b1); - GetFile(FastWideToAnsiBuf(tmp,b),b1); - if tmp<>tfile then - mFreeMem(tmp); - FastAnsiToWide(b1,tmp); - end - else - b1[0]:=#0; - fh:=Reset(tmp); - if fh<>THANDLE(INVALID_HANDLE_VALUE) then - begin - i:=GetFSize(tmp); - mGetMem (w ,i+SizeOf(WideChar)); - FillChar(w^,i+SizeOf(WideChar),0); - BlockRead(fh,w^,i); - if (flags and ACF_ANSI)<>0 then - begin - AnsiToWide(pAnsiChar(w),lstr,MirandaCP); - mFreeMem(w); - w:=lstr; - end - else if (flags and ACF_UTF8)<>0 then - begin - if (pdword(w)^ and $FFFFFF)=SIGN_UTF8 then - p:=pAnsiChar(w)+3 - else - p:=pAnsiChar(w); - mFreeMem(w); - UTF8ToWide(p,w); - end - else - ChangeUnicode(w); - end; - if b1[0]<>#0 then - DeleteFileA(b1); - end; - if fh<>THANDLE(INVALID_HANDLE_VALUE) then - CloseHandle(fh); - if tmp<>tfile then - mFreeMem(tmp); - end; - - result:=uint_ptr(w); - - if (flags and ACF_FILE)=0 then - begin - if autosend then - begin - if hContact=0 then exit; - p:=GetContactProtoAcc(hContact); - cp:=DBReadDWord(hContact,'Tab_SRMsg','ANSIcodepage',MirandaCP); - if DBReadByte(hContact,p,'ChatRoom',0)<>1 then - begin - i:=WideToCombo(w,blob,cp); - // if CallContactService(hContact,PSS_MESSAGEW,0,dword(blob))= - // ACKRESULT_FAILED then - CallContactService(hContact,PSS_MESSAGE,PREF_UNICODE,tlparam(blob)); - dbei.cbSize :=sizeof(dbei); - dbei.cbBlob :=i; - dbei.pBlob :=pByte(blob); - dbei.eventType:=EVENTTYPE_MESSAGE; - dbei.timestamp:=GetCurrentTime; - dbei.szModule :=p; - dbei.flags :=DBEF_SENT; - db_event_add(hContact, @dbei); - mFreeMem(blob); - end - else - SendToChat(hContact,w); - end - else - begin - GetWindowThreadProcessId(GetForegroundWindow,@i); - if (i=GetCurrentProcessId) and (wnd<>0) then - SendMessageW(wnd,EM_REPLACESEL,1,tlparam(w)) - else - SendString(0,w); - end; - end; - end; -end; diff --git a/plugins/Actman/i_actlow.inc b/plugins/Actman/i_actlow.inc deleted file mode 100644 index a620471398..0000000000 --- a/plugins/Actman/i_actlow.inc +++ /dev/null @@ -1,836 +0,0 @@ -{Lowlevel actions work: clone, create, delete, execute} - -type - tAdvExpr = (aeNot,aeAdd,aeSub,aeMul,aeDiv,aeMod,aeAnd,aeOr,aeXor,aeSet); - -function GetActNameById(id:dword):PWideChar; -var - i:integer; -begin - for i:=0 to MaxGroups-1 do - begin - if ((GroupList^[i].flags and ACF_ASSIGNED)<>0) and - (id=GroupList^[i].id) then - begin - result:=GroupList^[i].descr; - exit; - end; - end; - result:=nil; -end; - -function GetActIdByName(name:PWideChar):integer; -var - i:integer; -begin - for i:=0 to MaxGroups-1 do - begin - if ((GroupList^[i].flags and ACF_ASSIGNED)<>0) and - (StrCmpW(name,GroupList^[i].descr)=0) then - begin - result:=GroupList^[i].id; - exit; - end; - end; - result:=0; -end; - -function GetActIdxByName(name:PWideChar):integer; -var - i:integer; -begin - for i:=0 to MaxGroups-1 do - begin - if ((GroupList^[i].flags and ACF_ASSIGNED)<>0) and - (StrCmpW(name,GroupList^[i].descr)=0) then - begin - result:=i; - exit; - end; - end; - result:=-1; -end; - -function GetActIdxById(id:dword):integer; -var - i:integer; -begin - for i:=0 to MaxGroups-1 do - begin - if ((GroupList^[i].flags and ACF_ASSIGNED)<>0) and - (id=GroupList^[i].id) then - begin - result:=i; - exit; - end; - end; - result:=-1; -end; - -function FreeAction(act:pHKAction):dword; -begin - result:=act^.next; - with act^ do - begin - if (flags and ACF_ASSIGNED)<>0 then - begin - mFreeMem(descr); - case actionType of - ACT_SERVICE: begin - mFreeMem(service); - if (flags and (ACF_WPARNUM or ACF_WRESULT or ACF_WPARAM))=0 then - mFreeMem(pointer(wparam)); - if ((flags and ACF_WPARNUM)<>0) and ((flags2 and ACF2_SRV_WPAR)<>0) then - mFreeMem(pointer(wparam)); - if (flags and (ACF_LPARNUM or ACF_LRESULT or ACF_LPARAM))=0 then - mFreeMem(pointer(lparam)); - if ((flags and ACF_LPARNUM)<>0) and ((flags2 and ACF2_SRV_LPAR)<>0) then - mFreeMem(pointer(lparam)); - end; - ACT_PROGRAM: begin - mFreeMem(prgname); - mFreeMem(args); - end; - ACT_TEXT: begin - if (flags and ACF_CLIPBRD)=0 then - begin - mFreeMem(text); - if (flags and ACF_FILE)<>0 then - mFreeMem(tfile); - end; - end; - ACT_ADVANCE: begin - mFreeMem(varval); - if (action and ADV_ACT_POST)=ADV_ACT_JUMP then - mFreeMem(operval); - end; - ACT_CHAIN: begin - if (flags and ACF_BYNAME)<>0 then - mFreeMem(actname); - end; - ACT_RW: begin - mFreeMem(dbmodule); - mFreeMem(dbsetting); - if (flags and ACF_DBUTEXT)<>0 then - mFreeMem(dbvalue) - else if (flags2 and ACF2_RW_TVAR)<>0 then - mFreeMem(dbvalue); - end; - ACT_MESSAGE: begin - mFreeMem(msgtitle); - mFreeMem(msgtext); - end; - end; - end; - end; - FillChar(act^,SizeOf(act^),0); -end; - -procedure FreeActions(list:pActList;idx:cardinal); -begin - while idx<>0 do - idx:=FreeAction(@list^[idx]); -end; - -procedure FreeActionsContinued(act:pHKAction); -var - act_org:pHKAction; -begin - act_org:=act; - repeat - FreeAction(act); - if act^.next<>0 then - inc(act) - else - break; - until false; - FreeMem(act_org); -end; - -procedure DestroyActions(act:pActList;count:integer); -var - pact:pHKAction; -begin - pact:=@act^; - while count>0 do - begin - FreeAction(pact); - inc(pact); - dec(count); - end; - FreeMem(act); -end; - -procedure CloneAction(dst,src:pHKAction); -begin - move(src^,dst^,SizeOf(tHKAction)); - with dst^ do - begin - if (flags and ACF_ASSIGNED)<>0 then - begin - StrDupW(descr,descr); - case actionType of - ACT_SERVICE: begin - StrDup(service,service); - if (flags and ACF_WPARNUM)=0 then - begin - if (flags and ACF_WSTRUCT)<>0 then - StrDupW(pWideChar(wparam),pWideChar(wparam)) - else if (flags and ACF_WUNICODE)<>0 then - StrDupW(pWideChar(wparam),pWideChar(wparam)) - else - StrDup(PAnsiChar(wparam),PAnsiChar(wparam)); - end - else if (flags2 and ACF2_SRV_WPAR)<>0 then - StrDupW(pWideChar(wparam),pWideChar(wparam)); - - if (flags and ACF_LPARNUM)=0 then - begin - if (flags and ACF_LSTRUCT)<>0 then - StrDupW(pWideChar(lparam),pWideChar(lparam)) - else if (flags and ACF_LUNICODE)<>0 then - StrDupW(pWideChar(lparam),pWideChar(lparam)) - else - StrDup(PAnsiChar(lparam),PAnsiChar(lparam)); - end - else if (flags2 and ACF2_SRV_LPAR)<>0 then - StrDupW(pWideChar(lparam),pWideChar(lparam)); - end; - - ACT_PROGRAM: begin - StrDupW(prgname,prgname); - StrDupW(args,args); - end; - - ACT_TEXT: begin - if (flags and ACF_CLIPBRD)=0 then - begin - StrDupW(text,text); - if (flags and ACF_FILE)<>0 then - StrDupW(tfile,tfile); - end; - end; - - ACT_ADVANCE: begin - StrDupW(varval,varval); - if (action and ADV_ACT_POST)=ADV_ACT_JUMP then - StrDupW(operval,operval); - end; - - ACT_CHAIN: begin - if (flags or ACF_BYNAME)<>0 then - StrDupW(actname,actname); - end; - - ACT_RW: begin - StrDup(dbmodule,dbmodule); - StrDup(dbsetting,dbsetting); - if (flags and ACF_DBUTEXT)<>0 then - StrDupW(pWideChar(dbvalue),pWideChar(dbvalue)) - else if (flags2 and ACF2_RW_TVAR)<>0 then - StrDupW(pWideChar(dbvalue),pWideChar(dbvalue)); - end; - - ACT_MESSAGE: begin - StrDupW(msgtitle,msgtitle); - StrDupW(msgtext,msgtext); - end; - end; - end; - end; -end; - -function CloneActions(idx:cardinal):pointer; -var - i,count:integer; - aList:pHKAction; -begin - count:=0; - i:=idx; - while i<>0 do - begin - inc(count); - i:=ActionList^[i].next; - end; - if count>0 then - begin - GetMem(result,count*SizeOf(tHKAction)); - aList:=result; - i:=idx; - while i<>0 do - begin - CloneAction(aList,@ActionList^[i]); - i:=ActionList^[i].next; - inc(aList); - end; - end - else - result:=nil; -end; - -function DoAction(action:dword;aparam:LPARAM;var last:uint_ptr;restype:dword):integer; -var - tmpact,act,act_org:pHKAction; - val,prelast:uint_ptr; - b:boolean; - i:integer; - lContact:THANDLE; - buf:array [0..31] of WideChar; - tmpc,tmpc1,tmpc2,tmpcv1,tmpcv2:pWideChar; - oldrestype:integer; -begin - if action<>0 then - begin - act:=CloneActions(action); - // if act=nil then exit; - act_org :=act; - oldrestype:=restype; - prelast :=0; - repeat - if (act^.flags and ACF_DISABLED)=0 then - begin - - if (oldrestype=rtWide) and (last<>prelast) then - mFreeMem(prelast); - oldrestype:=restype; - prelast:=last; - - with act^ do - begin - case actionType of - - ACT_CONTACT: begin - if (flags and ACF_KEEPONLY)=0 then - last:=OpenContact(contact) - else - last:=contact; - - restype:=rtInt; - end; - - ACT_SERVICE: begin - last:=RunService(act,last,aparam,restype); -{ - if (flags and ACF_STRING)<>0 then - begin - if (flags and ACF_UNICODE)=0 then - begin - val:=last; - AnsiToWide(pAnsiChar(val),pWideChar(last),MirandaCP); - mFreeMem(val); - end - else - StrDupW(pWideChar(last),pWideChar(last)); - restype:=rtWide; - end - else - restype:=rtInt; -} - end; - - ACT_PROGRAM: begin - if restype=rtInt then - last:=uint_ptr(IntToStr(buf,last)); - - last:=RunProgram(act,aparam,pWideChar(last)); - - restype:=rtInt; - end; - - ACT_TEXT: begin - if restype=rtInt then - last:=uint_ptr(IntToStr(buf,last)); - - last:=InsertText(act,aparam,pWideChar(last)); - - restype:=rtWide; - end; - - ACT_ADVANCE: begin - if restype=rtWide then - val:=StrToInt(pWideChar(last)) - else - val:=last; - - case condition and not ADV_COND_NOT of - ADV_COND_EQ: b:=val=value; - ADV_COND_GT: b:=integer(val)>integer(value); - ADV_COND_LT: b:=integer(val)0) and (condition<>ADV_COND_NOP) then - b:=not b; - if b then - begin - case action and ADV_ACTION of - - ADV_ACT_MATH: begin - case tAdvExpr(oper) of - aeNot: last:= not val; - aeAdd: last:= integer(val) + integer(mathval); - aeSub: last:= integer(val) - integer(mathval); - aeMul: last:= integer(val) * integer(mathval); - aeDiv: last:= integer(val) div integer(mathval); - aeMod: last:= val mod mathval; - aeAnd: last:= val and mathval; - aeOr : last:= val or mathval; - aeXor: last:= val xor mathval; - aeSet: last:= mathval; - end; - restype:=rtInt; - end; - - ADV_ACT_VARS: begin -//!! need to clear 'Last' if was string? - if (varval<>NIL) and (varval^<>#0) then - begin - if CallService(MS_DB_CONTACT_IS,aparam,0)<>0 then - lContact:=aparam - else - lContact:=0; - if restype=rtInt then - last:=uint_ptr(IntToStr(buf,last)); - - pWideChar(last):=ParseVarString(varval,lContact,pWideChar(last)); - - if (flags and ACF_VARASINT)<>0 then - begin - tmpc:=pWideChar(last); - last:=StrToInt(tmpc); - mFreeMem(tmpc); - restype:=rtInt; - end - else - restype:=rtWide; - end; - end; - - end; - case action and ADV_ACT_POST of - - ADV_ACT_JUMP : begin - tmpact:=act_org; - repeat - if StrCmpW(tmpact^.descr,operval)=0 then - begin - act:=tmpact; - tmpact:=nil; - break; - end; - if tmpact^.next=0 then - break; - inc(tmpact); - until false; - if tmpact=nil then continue; - end; - - ADV_ACT_BREAK: break; - end; - end; - end;//last:=MakeAdvanced(act,last); - - ACT_CHAIN: begin - if (flags and ACF_BYNAME)<>0 then - i:=GetActIdxByName(actname) - else - i:=GetActIdxById(id); - - if i>=0 then - begin - restype:=DoAction(GroupList^[i].firstAction,aparam,last,restype); - // cleared in called Action - oldrestype:=rtInt; - prelast:=0; - end - else - begin - restype:=rtInt; - last:=0; - end; - end; - - ACT_RW: begin - if (flags and ACF_CURRENT)<>0 then i:=0 - else if (flags and ACF_PARAM )<>0 then i:=aparam - else if (flags and ACF_RESULT )<>0 then i:=last - else - i:=dbcontact; - if (flags and ACF_LAST)=0 then - val:=dbvalue - else - begin - val:=last; - if (flags and ACF_DBUTEXT)<>0 then - begin - if restype=rtInt then - val:=uint_ptr(IntToStr(buf,val)); - end - else - begin - if restype=rtWide then - val:=StrToInt(pWideChar(val)); - end; - end; - - last:=DBRW(act,i,val,last,restype); - - if (flags and ACF_DBUTEXT)<>0 then - restype:=rtWide - else - restype:=rtInt; - end; - - ACT_MESSAGE: begin - if restype=rtWide then - tmpc:=PWideChar(last) - else - begin - IntToStr(buf,last); - tmpc:=@buf; - end; - - if StrPosW(msgtitle,'')<>nil then - begin - mGetMem(tmpc1,8192); - StrCopyW(tmpc1,msgtitle); - StrReplaceW(tmpc1,'',tmpc); - end - else - tmpc1:=msgtitle; - if StrPosW(msgtext,'')<>nil then - begin - mGetMem(tmpc2,8192); - StrCopyW(tmpc2,msgtext); - StrReplaceW(tmpc2,'',tmpc); - end - else - tmpc2:=msgtext; - - if (flags2 and ACF2_MSG_TTL)<>0 then - tmpcv1:=ParseVarString(tmpc1,aparam,tmpc) - else - tmpcv1:=tmpc1; - if (flags2 and ACF2_MSG_TXT)<>0 then - tmpcv2:=ParseVarString(tmpc2,aparam,tmpc) - else - tmpcv2:=tmpc2; - - i:=MessageBoxW(0,tmpcv2,tmpcv1,boxopts); - - if (flags and ACF_MSG_KEEP)=0 then - begin - restype:=rtInt; - last:=i - end; - - if tmpcv1<>tmpc1 then mFreeMem(tmpcv1); - if tmpcv2<>tmpc2 then mFreeMem(tmpcv2); - if tmpc1 <>msgtitle then mFreeMem(tmpc1); - if tmpc2 <>msgtext then mFreeMem(tmpc2); - end; - - else - last:=0; - end; - end; - end; - if (act_org^.flags and ACF_DOBREAK)<>0 then - break; - if act^.next=0 then - break; - inc(act); - until false; - FreeActionsContinued(act_org); - if (oldrestype=rtWide) and (last<>prelast) then - mFreeMem(prelast); - end; - result:=restype; -end; - -type - pActStartData = ^tActStartData; - tActStartData = record - event :THANDLE; - action:dword; - param :LPARAM; - group :pHKRecord; - last :LPARAM; - end; - -procedure ThDoAction(arg:pActStartData); cdecl; -var - ltmp:uint_ptr; - res:integer; -begin - ltmp:=arg^.last; - - if arg^.group<>nil then - begin - NotifyEventHooks(hevaction,arg^.group.id,0); // started - arg^.group.flags:=arg^.group.flags or ACF_USEDNOW; - end; - - res:=DoAction(arg^.action,arg^.param,ltmp,rtInt); - - if arg^.group<>nil then - begin - arg^.group.flags:=arg^.group.flags and not ACF_USEDNOW; - NotifyEventHooks(hevaction,arg^.group.id,1); // finished - end; - - if arg^.event<>0 then - begin - arg^.last:=ltmp; - SetEvent(arg^.event); - end - else if res=rtWide then - begin - mFreeMem(ltmp); - end; -end; - -function ActionStarterWait(action:dword;aparam:LPARAM=0;group:pHKRecord=nil;alast:LPARAM=0):LPARAM; -var - tmp:pActStartData; -begin - mGetMem(tmp,SizeOf(tActStartData)); - tmp^.action:=action; - tmp^.param :=aparam; - tmp^.group :=group; - tmp^.last :=alast; - tmp^.event :=CreateEvent(nil,FALSE,FALSE,nil); - mir_forkthread(@ThDoAction,tmp); - WaitForSingleObjectEx(tmp.event,INFINITE,true); - CloseHandle(tmp^.event); - result:=tmp^.last; -end; - -function ActionStarter(action:dword;aparam:dword=0;group:pHKRecord=nil;alast:dword=0):integer; -var - tmp:pActStartData; -begin - result:=0; - mGetMem(tmp,SizeOf(tActStartData)); - tmp^.action:=action; - tmp^.param :=aparam; - tmp^.group :=group; - tmp^.last :=alast; - tmp^.event :=0; - mir_forkthread(@ThDoAction,tmp); -end; - -procedure ReallocActionList(var ActList:pActList;var MaxAct:cardinal); -var - i:cardinal; - tmp:pActList; -begin - i:=(MaxAct+ActListPage)*SizeOf(tHKAction); - GetMem(tmp,i); - FillChar(tmp^,i,0); - if MaxAct>0 then - begin - move(ActList^,tmp^,MaxAct*SizeOf(tHKAction)); - FreeMem(ActList); - end; - ActList:=tmp; - inc(MaxAct,ActListPage); -end; - -function NewAction(var ActList:pActList;var MaxAct:cardinal):cardinal; -var - i:cardinal; - pAct:pHKAction; -begin - i:=1; - pAct:=@ActList^; - inc(pAct); // skip zero - while i0 then - begin - move(HKList^,tmp^,MaxHK*SizeOf(tHKRecord)); - FreeMem(HKList); - end; - HKList:=tmp; - inc(MaxHK,HKListPage); -end; - -procedure InitGroupValue(pHK:pHKRecord); -var -// time:TSYSTEMTIME; - tmp:int64; -begin - with pHK^ do - begin - StrDupW(descr,NoDescription); -{ - GetSystemTime(time); - id :=time.wSecond+time.wMinute*60+time.wHour*3600+time.wMilliseconds*86400; -} - QueryPerformanceCounter(tmp); - id :=tmp and $FFFFFFFF; - firstAction:=0; - active :=nil; - flags :=ACF_ASSIGNED; - end; -end; - -// Root,Size,MaxCount(Page,flag) -function NewGroup(var HKList:pHKList;var MaxHK:cardinal):cardinal; -var - i:cardinal; - pHK:pHKRecord; -begin - i:=0; - pHK:=@HKList^; - while i0 then - begin - flags:=0; - mFreeMem(descr); - FreeActions(ActionList,firstAction); - end; - end; -end; - -procedure FreeGroups; -var - i:integer; -begin - for i:=0 to MaxGroups-1 do - begin - FreeGroup(i); - end; - MaxGroups:=0; - FreeMem(GroupList); - FreeMem(ActionList); - GroupList:=nil; - ActionList:=nil; -end; - -procedure DestroyGroups(HKList:pHKList;count:integer); -var - pHK:pHKRecord; -begin - pHK:=@HKList^; - while count>0 do - begin - if (pHK^.flags and ACF_ASSIGNED)<>0 then - mFreeMem(pHK^.descr); - inc(pHK); - dec(count); - end; - FreeMem(HKList); -end; - -function CloneActionList:pActList; -var - src,dst:pHKAction; - i:integer; -begin - i:=MaxActions; - GetMem(result,i*SizeOf(tHKAction)); - src:=@ActionList^; - dst:=@result^; - while i>0 do - begin - CloneAction(dst,src); - inc(src); - inc(dst); - dec(i); - end; -end; - -procedure CloneGroup(dst,src:pHKRecord); -begin - move(src^,dst^,SizeOf(tHKRecord)); - if (src^.flags and ACF_ASSIGNED)<>0 then - StrDupW(dst^.descr,src^.descr); -end; - -function CloneGroupList:pHKList; -var - src,dst:pHKRecord; - i:integer; -begin - i:=MaxGroups; - GetMem(result,i*SizeOf(tHKRecord)); - src:=@GroupList^; - dst:=@result^; - while i>0 do - begin - CloneGroup(dst,src); - inc(src); - inc(dst); - dec(i); - end; -end; - -function ActSelect(wParam:WPARAM;lParam:LPARAM):int;cdecl; -begin - if (wParam and ACCF_ID)<>0 then - result:=GetActIdxById(lParam) - else - result:=GetActIdxByName(pWideChar(lParam)); - if result=-1 then - exit; - with GroupList^[result] do - begin - if (wParam and ACCF_CLEAR)<>0 then - flags:=flags and not (uint_ptr(wParam) and ACCF_FLAGS) - else - flags:=flags or (uint_ptr(wParam) and ACCF_FLAGS); - end; -end; diff --git a/plugins/Actman/i_cnst_call.inc b/plugins/Actman/i_cnst_call.inc new file mode 100644 index 0000000000..8b8118ed28 --- /dev/null +++ b/plugins/Actman/i_cnst_call.inc @@ -0,0 +1,23 @@ +{resource constants} +const + IDC_LIST_FUNC = 2101; + IDC_LIST_DLL = 2102; + IDC_CDECL = 2103; + IDC_STDCALL = 2104; + IDC_ARGCOUNT = 2105; + IDC_ARGSTAT = 2106; + + IDC_ARGNUM = 2110; + IDC_FLAG_PAR = 2111; + IDC_EDIT_PAR = 2112; + IDC_STRUCT = 2113; + + IDC_DLL = 2115; + IDC_DLL_CACHE = 2116; +{ + IDC_DLL_IMM = 2116; + IDC_DLL_MACRO = 2117; + IDC_DLL_END = 2118; +} + IDC_CLOSE_ARG = 2119; + IDC_CLOSE_RES = 2120; diff --git a/plugins/Actman/i_cnst_chain.inc b/plugins/Actman/i_cnst_chain.inc new file mode 100644 index 0000000000..477d8ce137 --- /dev/null +++ b/plugins/Actman/i_cnst_chain.inc @@ -0,0 +1,6 @@ +{resource constants} +const + IDC_MACRO_LIST = 2501; + IDC_MACRO_NOWAIT = 2502; + IDC_MACRO_KEEPOLD = 2503; + IDC_MACRO_SAMETHREAD = 2504; diff --git a/plugins/Actman/i_cnst_contact.inc b/plugins/Actman/i_cnst_contact.inc new file mode 100644 index 0000000000..5b2cf3991d --- /dev/null +++ b/plugins/Actman/i_cnst_contact.inc @@ -0,0 +1,6 @@ +{resource constants} +const + IDC_CONTACTLIST = 2141; + IDC_CNT_KEEP = 2142; + IDC_CNT_GET = 2143; + IDC_CNT_REFRESH = 2147; diff --git a/plugins/Actman/i_cnst_database.inc b/plugins/Actman/i_cnst_database.inc new file mode 100644 index 0000000000..0727d68451 --- /dev/null +++ b/plugins/Actman/i_cnst_database.inc @@ -0,0 +1,17 @@ +{resource constants} +const + IDC_RW_READ = 2601; + IDC_RW_WRITE = 2602; + IDC_RW_DELETE = 2603; + IDC_RW_MODULE = 2606; + IDC_RW_SETTING = 2608; + IDC_RW_VALUE = 2610; + IDC_RW_DATATYPE = 2611; + + IDC_CONTACTTYPE = 2614; + + IDC_RW_LAST = 2620; + IDC_RW_SAVE = 2621; + + IDC_CONTACTLIST = 2141; + IDC_CNT_REFRESH = 2142; diff --git a/plugins/Actman/i_cnst_dlgshare.inc b/plugins/Actman/i_cnst_dlgshare.inc new file mode 100644 index 0000000000..396499e68a --- /dev/null +++ b/plugins/Actman/i_cnst_dlgshare.inc @@ -0,0 +1,11 @@ +{all dialogs icons} +const + IDI_NEW = 1025; + IDI_UP = 1026; + IDI_DOWN = 1027; + IDI_DELETE = 1028; + IDI_RELOAD = 1029; + IDI_TEST = 1037; + IDI_EXPORT = 1038; + IDI_IMPORT = 1039; + IDI_APPLY = 1044; diff --git a/plugins/Actman/i_cnst_ini.inc b/plugins/Actman/i_cnst_ini.inc new file mode 100644 index 0000000000..85212e9c56 --- /dev/null +++ b/plugins/Actman/i_cnst_ini.inc @@ -0,0 +1,13 @@ +{INI file processing} +const + IDC_INI_READ = 2701; + IDC_INI_WRITE = 2702; + IDC_INI_DELETE = 2703; + IDC_INI_PATH = 2704; + IDC_INI_INIBTN = 2705; + IDC_INI_SECTION = 2706; + IDC_INI_PARAM = 2707; + IDC_INI_TYPE = 2708; + IDC_INI_VALUE = 2709; + IDC_INI_LR = 2710; + IDC_INI_UTF = 2711; diff --git a/plugins/Actman/i_cnst_inout.inc b/plugins/Actman/i_cnst_inout.inc new file mode 100644 index 0000000000..ff1cf50d7c --- /dev/null +++ b/plugins/Actman/i_cnst_inout.inc @@ -0,0 +1,17 @@ +{clipboard/file} +const + IDC_FLAG_CLIP = 2454; + IDC_FLAG_MESSAGE = 2455; + IDC_CLIP_COPYTO = 2456; + IDC_CLIP_PASTE = 2457; + IDC_FILE_ENC = 2459; +// IDC_CLIP_ANSI = 2459; +// IDC_CLIP_WIDE = 2460; + IDC_FLAG_FILE = 2461; + IDC_FILE_PATH = 2462; + IDC_FILE_FILEBTN = 2463; + IDC_FILE_READ = 2464; + IDC_FILE_WRITE = 2465; + IDC_FILE_APPEND = 2466; + + IDC_TEXT_SEND = 2453; diff --git a/plugins/Actman/i_cnst_jump.inc b/plugins/Actman/i_cnst_jump.inc new file mode 100644 index 0000000000..9782c9a9d3 --- /dev/null +++ b/plugins/Actman/i_cnst_jump.inc @@ -0,0 +1,15 @@ +{resource constants} +const + IDC_FLAG_MATH = 2506; + IDC_FLAG_TEXT = 2507; + IDC_FLAG_NOP = 2509; + IDC_FLAG_NOT = 2510; + + IDC_JMP_MATH = 2511; + IDC_JMP_TEXT = 2512; + IDC_JMP_VALUE = 2513; + IDC_FLAG_CASE = 2514; + IDC_FLAG_BACK = 2515; + IDC_JMP_ACTLIST = 2522; + IDC_FLAG_BREAK = 2523; + IDC_FLAG_JUMP = 2524; diff --git a/plugins/Actman/i_cnst_message.inc b/plugins/Actman/i_cnst_message.inc new file mode 100644 index 0000000000..02db4c3d9b --- /dev/null +++ b/plugins/Actman/i_cnst_message.inc @@ -0,0 +1,17 @@ +{resource constants} +const + IDC_MSG_TITLE = 2703; + IDC_MSG_TEXT = 2704; + IDC_MSGB_ARI = 2706; + IDC_MSGB_OK = 2707; + IDC_MSGB_OC = 2708; + IDC_MSGB_RC = 2709; + IDC_MSGB_YN = 2710; + IDC_MSGB_YNC = 2711; + IDC_MSGI_NONE = 2713; + IDC_MSGI_WARN = 2714; + IDC_MSGI_INFO = 2715; + IDC_MSGI_QUEST = 2716; + IDC_MSGI_ERROR = 2717; + IDC_MSG_RTL = 2718; + IDC_MSG_RIGHT = 2719; diff --git a/plugins/Actman/i_cnst_notes.inc b/plugins/Actman/i_cnst_notes.inc new file mode 100644 index 0000000000..d7e779210d --- /dev/null +++ b/plugins/Actman/i_cnst_notes.inc @@ -0,0 +1,3 @@ +{text data} +const + IDC_TXT_TEXT = 2190; diff --git a/plugins/Actman/i_cnst_program.inc b/plugins/Actman/i_cnst_program.inc new file mode 100644 index 0000000000..93d2ed5d0b --- /dev/null +++ b/plugins/Actman/i_cnst_program.inc @@ -0,0 +1,13 @@ +{resource constants} +const + IDC_FLAG_MINIMIZE = 2350; + IDC_EDIT_PRGPATH = 2352; + IDC_PROGRAM = 2353; + IDC_EDIT_PRGARGS = 2355; + IDC_EDIT_PROCTIME = 2356; + IDC_FLAG_NORMAL = 2360; + IDC_FLAG_HIDDEN = 2361; + IDC_FLAG_MAXIMIZE = 2362; + IDC_FLAG_CURPATH = 2363; + IDC_FLAG_PARALLEL = 2364; + IDC_FLAG_CONTINUE = 2365; diff --git a/plugins/Actman/i_cnst_settings.inc b/plugins/Actman/i_cnst_settings.inc new file mode 100644 index 0000000000..c8c495a24a --- /dev/null +++ b/plugins/Actman/i_cnst_settings.inc @@ -0,0 +1,12 @@ +{resource constants} +const + IDC_EDIT_FORMAT = 2144; + IDC_CNT_FILTER = 2145; + IDC_CNT_APPLY = 2146; + + IDC_SERVICELIST = 2150; + IDC_SRV_APPLY = 2151; + + IDC_FR_FLAG = 2155; + IDC_HC_WPAR = 2156; + IDC_VL_FLAG = 2157; diff --git a/plugins/Actman/i_cnst_storage.inc b/plugins/Actman/i_cnst_storage.inc new file mode 100644 index 0000000000..adaa7690c6 --- /dev/null +++ b/plugins/Actman/i_cnst_storage.inc @@ -0,0 +1,5 @@ +{resource constants} +const + IDC_STORAGELIST = 2141; + IDC_FLAG_TO = 2142; + IDC_FLAG_FROM = 2143; diff --git a/plugins/Actman/i_cnst_text.inc b/plugins/Actman/i_cnst_text.inc new file mode 100644 index 0000000000..b25f155ef2 --- /dev/null +++ b/plugins/Actman/i_cnst_text.inc @@ -0,0 +1,4 @@ +{text data} +const + IDC_TXT_TEXT = 2190; + IDC_TXT_POST = 2191; diff --git a/plugins/Actman/i_const.inc b/plugins/Actman/i_const.inc index 3e9950414f..baf5b5edf3 100644 --- a/plugins/Actman/i_const.inc +++ b/plugins/Actman/i_const.inc @@ -2,49 +2,8 @@ const // dialogs IDD_ACTION = 1025; - IDD_STRUCTURE = 1027; IDD_ASK = 1028; - // icons - IDI_NEW = 1025; - IDI_UP = 1026; - IDI_DOWN = 1027; - IDI_DELETE = 1028; - IDI_RELOAD = 1029; - IDI_CONTACT = 1030; - IDI_SERVICE = 1031; - IDI_PROGRAM = 1032; - IDI_INSERT = 1033; - IDI_ADVANCE = 1034; - IDI_CHAIN = 1035; - IDI_RW = 1036; - IDI_TEST = 1037; - IDI_EXPORT = 1038; - IDI_IMPORT = 1039; - IDI_MESSAGE = 1040; - IDI_VAR_CHECKED = 1041; - IDI_VAR_UNCHECKED = 1042; - IDI_FORMAT = 1043; - IDI_APPLY = 1044; - - // Structure editor - IDC_DATA_FULL = 2001; - IDC_DATA_TYPE = 2002; - IDC_DATA_EDIT = 2005; - IDC_DATA_LEN = 2006; - IDC_DATA_HELP = 2007; - - IDC_DATA_NEW = 2008; - IDC_DATA_DELETE = 2009; - IDC_DATA_UP = 2010; - IDC_DATA_DOWN = 2011; - IDC_DATA_CHANGE = 2012; - IDC_DATA_VARS = 2013; - IDC_DATA_PACKED = 2014; - - // Action page -// IDC_RESET = 2001; - IDC_ACTION_TYPE = 2005; IDC_STAT_ACTION = 2006; @@ -54,7 +13,7 @@ const IDC_ACTION_UP = 2010; IDC_ACTION_DOWN = 2011; - IDC_ACTION_GROUP = 2012; + IDC_MACRO_LIST = 2012; IDC_GROUP_NEW = 2015; IDC_GROUP_RELOAD = 2016; IDC_GROUP_DELETE = 2017; @@ -65,153 +24,6 @@ const IDC_GROUP_IMPORT = 2022; IDC_ACTION_HELP = 2023; - IDC_STAT_CONTACT = 2140; - IDC_CONTACTLIST = 2141; - IDC_CNT_KEEP = 2142; - IDC_STAT_FORMAT = 2143; - IDC_EDIT_FORMAT = 2144; - IDC_CNT_FILTER = 2145; - IDC_CNT_APPLY = 2146; - IDC_STAT_FHELP = 2147; - - IDC_STAT_WPAR1 = 2150; - IDC_STAT_LPAR1 = 2151; - IDC_STAT_WPAR = 2152; - IDC_STAT_LPAR = 2153; - IDC_FLAG_WPAR = 2154; - IDC_FLAG_LPAR = 2155; - IDC_EDIT_WPAR = 2156; - IDC_EDIT_LPAR = 2157; - IDC_STAT_SERVICE = 2158; - IDC_EDIT_SERVICE = 2159; - IDC_WSTRUCT = 2160; - IDC_LSTRUCT = 2161; - - IDC_RES_POPUP = 2251; - IDC_RES_MESSAGE = 2252; - IDC_RES_INSERT = 2253; - IDC_SRV_RESSTAT = 2254; - IDC_SRV_RESULT = 2255; - IDC_RES_FREEMEM = 2256; - IDC_RES_UNICODE = 2257; - IDC_RES_SIGNED = 2258; - IDC_RES_GROUP = 2259; - - IDC_FLAG_MINIMIZE = 2350; - IDC_STAT_PRGPATH = 2351; - IDC_EDIT_PRGPATH = 2352; - IDC_PROGRAM = 2353; - IDC_STAT_PRGARGS = 2354; - IDC_EDIT_PRGARGS = 2355; - IDC_EDIT_PROCTIME = 2356; - IDC_PROCESS_GROUP = 2357; - IDC_STAT_PROCTIME = 2358; - IDC_PRSTART_GROUP = 2359; - IDC_FLAG_NORMAL = 2360; - IDC_FLAG_HIDDEN = 2361; - IDC_FLAG_MAXIMIZE = 2362; - IDC_FLAG_CURPATH = 2363; - IDC_FLAG_PARALLEL = 2364; - IDC_FLAG_CONTINUE = 2365; - IDC_HLP_FVARS = 2366; - - IDC_HLP_VARS = 2451; - IDC_STAT_INSERT = 2452; - IDC_EDIT_INSERT = 2453; - - IDC_FLAG_CLIP = 2454; - IDC_FLAG_MESSAGE = 2455; - IDC_CLIP_COPYTO = 2456; - IDC_CLIP_PASTE = 2457; - IDC_CLIP_GROUP = 2458; - IDC_FILE_ENC = 2459; -// IDC_CLIP_ANSI = 2459; -// IDC_CLIP_WIDE = 2460; - IDC_FLAG_FILE = 2461; - IDC_FILE_PATH = 2462; - IDC_FILE_FILEBTN = 2463; - IDC_FILE_READ = 2464; - IDC_FILE_WRITE = 2465; - IDC_FILE_APPEND = 2466; - IDC_FILE_GROUP = 2467; - - IDC_STAT_GROUPS = 2500; - IDC_GROUP_LIST = 2501; - - IDC_CONDITION = 2505; - IDC_FLAG_GT = 2506; - IDC_FLAG_LT = 2507; - IDC_FLAG_EQ = 2508; - IDC_FLAG_NOP = 2509; - IDC_FLAG_NOT = 2510; - - IDC_OPERATION = 2511; - IDC_FLAG_BREAK = 2512; - IDC_FLAG_JUMP = 2513; - IDC_FLAG_ANOP = 2514; - IDC_ADV_VALUE = 2515; - IDC_STAT_VAL = 2516; - - IDC_FLAG_MATH = 2519; - IDC_ADV_OPER = 2520; - IDC_ADV_VAL1 = 2521; - IDC_ADV_VAL2 = 2522; - IDC_FLAG_VARS = 2523; - IDC_ADV_VARS = 2524; - IDC_ADV_HVARS = 2526; - IDC_ADV_ASINT = 2527; - - IDC_RW_READ = 2601; - IDC_RW_WRITE = 2602; - IDC_RW_DELETE = 2603; - IDC_RW_STATM = 2605; - IDC_RW_MODULE = 2606; - IDC_RW_STATS = 2607; - IDC_RW_SETTING = 2608; - IDC_RW_TEXT = 2609; - IDC_RW_VALUE = 2610; - IDC_RW_DATATYPE = 2611; - IDC_RW_CURRENT = 2614; - IDC_RW_PARAM = 2615; - IDC_RW_MANUAL = 2616; - IDC_RW_OPER = 2617; - IDC_RW_VAL = 2618; - IDC_RW_RESULT = 2619; - IDC_RW_LAST = 2620; - - IDC_MSG_STAT1 = 2701; - IDC_MSG_STAT2 = 2702; - IDC_MSG_TITLE = 2703; - IDC_MSG_TEXT = 2704; - IDC_MSG_BTNS = 2705; - IDC_MSGB_ARI = 2706; - IDC_MSGB_OK = 2707; - IDC_MSGB_OC = 2708; - IDC_MSGB_RC = 2709; - IDC_MSGB_YN = 2710; - IDC_MSGB_YNC = 2711; - IDC_MSG_ICONS = 2712; - IDC_MSGI_NONE = 2713; - IDC_MSGI_WARN = 2714; - IDC_MSGI_INFO = 2715; - IDC_MSGI_QUEST = 2716; - IDC_MSGI_ERROR = 2717; - IDC_MSG_KEEP = 2718; - -// Variables buttons - IDC_SRV_WPAR = 3000; - IDC_SRV_LPAR = 3001; - IDC_SRV_SRVC = 3002; - IDC_PRG_PRG = 3003; - IDC_PRG_ARG = 3004; - IDC_TXT_FILE = 3005; - IDC_TXT_TEXT = 3006; - IDC_RW_MVAR = 3008; - IDC_RW_SVAR = 3009; - IDC_RW_TVAR = 3010; - IDC_MSG_TTL = 3011; - IDC_MSG_TXT = 3012; - // Question IDC_ASK = 1025; IDC_YESALL = 1026; diff --git a/plugins/Actman/i_contact.inc b/plugins/Actman/i_contact.inc deleted file mode 100644 index c73df31435..0000000000 --- a/plugins/Actman/i_contact.inc +++ /dev/null @@ -1,113 +0,0 @@ -{hkContact} -const - defformat = '%name% - %uid% (%account%:%group%)'; - -procedure FillContactList(list:hwnd; filter:boolean=true;format:pWideChar=nil); -var - hContact:THANDLE; - buf:array [0..511] of WideChar; - buf1:array [0..63] of WideChar; - p:PWideChar; - uid:pAnsiChar; - ldbv:TDBVARIANT; - acc:pAnsiChar; - lName, - lGroup, - lAccount, - lUID:boolean; -begin - if format=nil then format:=defformat; - - SendMessage(list,CB_RESETCONTENT,0,0); - hContact:=db_find_first(); - - lName :=StrPosW(format,'%name%')<>nil; - lGroup :=StrPosW(format,'%group%')<>nil; - lAccount:=StrPosW(format,'%account%')<>nil; - lUID :=StrPosW(format,'%uid%')<>nil; - - while hContact<>0 do - begin - if ((not filter) and ((IsContactActive(hContact)+1)>=0)) or // + disabled (not deleted) - (filter and (IsContactActive(hContact) >=0)) then - begin - StrCopyW(buf,format); - if lName then - StrReplaceW(buf,'%name%', - PWideChar(CallService(MS_CLIST_GETCONTACTDISPLAYNAME,hContact,GCDNF_UNICODE))); - - if lGroup then - begin - p:=DBReadUnicode(hContact,strCList,'Group',nil); - StrReplaceW(buf,'%group%',p); - mFreeMem(p); - end; - - if lAccount then - begin - acc:=GetContactProtoAcc(hContact); - StrReplaceW(buf,'%account%',FastAnsiToWideBuf(acc,buf1)); - end - else - acc:=nil; - - if lUID then - begin - if acc=nil then - acc:=GetContactProtoAcc(hContact); - if IsChat(hContact) then - begin - p:=DBReadUnicode(hContact,acc,'ChatRoomID'); - StrReplaceW(buf,'%uid%',p); - mFreeMem(p); - end - else - begin - uid:=pAnsiChar(CallProtoService(acc,PS_GETCAPS,PFLAG_UNIQUEIDSETTING,0)); - if uid <> pAnsiChar(CALLSERVICE_NOTFOUND) then - begin - if DBReadSetting(hContact,acc,uid,@ldbv)=0 then - begin - case ldbv._type of - DBVT_DELETED: p:='[deleted]'; - DBVT_BYTE : p:=IntToStr(buf1,ldbv.bVal); - DBVT_WORD : p:=IntToStr(buf1,ldbv.wVal); - DBVT_DWORD : p:=IntToStr(buf1,ldbv.dVal); - DBVT_UTF8 : UTF8ToWide(ldbv.szVal.A,p); - DBVT_ASCIIZ : AnsiToWide(ldbv.szVal.A,p,MirandaCP); - DBVT_WCHAR : p:=ldbv.szVal.W; - DBVT_BLOB : p:='blob'; - end; - StrReplaceW(buf,'%uid%',p); - if ldbv._type in [DBVT_UTF8,DBVT_ASCIIZ] then - mFreeMem(p); - DBFreeVariant(@ldbv); - end; - end; - StrReplaceW(buf,'%uid%',nil); - end; - end; - - SendMessage(list,CB_SETITEMDATA, - SendMessageW(list,CB_ADDSTRING,0,tlparam(@buf)), - hContact); - end; - hContact:=db_find_next(hContact); - end; -end; - -function FindContact(list:hwnd;contact:THANDLE):integer; -var - i,j:integer; -begin - result:=0; - j:=SendMessage(list,CB_GETCOUNT,0,0); - for i:=0 to j-1 do - begin - if THANDLE(SendMessage(list,CB_GETITEMDATA,i,0))=contact then - begin - result:=i; - break; - end; - end; -end; diff --git a/plugins/Actman/i_dlglists.inc b/plugins/Actman/i_dlglists.inc deleted file mode 100644 index 52808e63cd..0000000000 --- a/plugins/Actman/i_dlglists.inc +++ /dev/null @@ -1,75 +0,0 @@ -{Dialog list filling} - procedure InsertString(wnd:HWND;num:dword;str:PAnsiChar); - var - buf:array [0..127] of WideChar; - begin - SendMessageW(wnd,CB_SETITEMDATA, - SendMessageW(wnd,CB_ADDSTRING,0, - lparam(TranslateW(FastAnsiToWideBuf(str,buf)))), - num); - { - SendMessageW(wnd,CB_INSERTSTRING,num, - LPARAM(TranslateW(FastAnsiToWideBuf(str,buf)))); - } - end; - - procedure MakeMathOperList(wnd:HWND); - begin - SendMessage(wnd,CB_RESETCONTENT,0,0); - InsertString(wnd,cardinal(aeNot),'! not'); - InsertString(wnd,cardinal(aeAdd),'+ add'); - InsertString(wnd,cardinal(aeSub),'- sub'); - InsertString(wnd,cardinal(aeMul),'* mul'); - InsertString(wnd,cardinal(aeDiv),'/ div'); - InsertString(wnd,cardinal(aeMod),'% mod'); - InsertString(wnd,cardinal(aeAnd),'& and'); - InsertString(wnd,cardinal(aeOr ),'| or'); - InsertString(wnd,cardinal(aeXor),'^ xor'); - InsertString(wnd,cardinal(aeSet),'= set'); - SendMessage(wnd,CB_SETCURSEL,0,0); - end; - - procedure MakeParamTypeList(wnd:HWND); - begin - SendMessage(wnd,CB_RESETCONTENT,0,0); - InsertString(wnd,ptNumber ,'number value'); - InsertString(wnd,ptString ,'ANSI string'); - InsertString(wnd,ptUnicode,'Unicode string'); - InsertString(wnd,ptCurrent,'current contact'); - InsertString(wnd,ptResult ,'last result'); - InsertString(wnd,ptParam ,'parameter'); - InsertString(wnd,ptStruct ,'structure'); - SendMessage(wnd,CB_SETCURSEL,0,0); - end; - - procedure MakeResultTypeList(wnd:HWND); - begin - SendMessage(wnd,CB_RESETCONTENT,0,0); - InsertString(wnd,sresInt ,'Integer'); - InsertString(wnd,sresHex ,'Hexadecimal'); - InsertString(wnd,sresString,'String'); - InsertString(wnd,sresStruct,'Structure'); - SendMessage(wnd,CB_SETCURSEL,0,0); - end; - - procedure MakeFileEncList(wnd:HWND); - begin - SendMessage(wnd,CB_RESETCONTENT,0,0); - InsertString(wnd,0,'Ansi'); - InsertString(wnd,1,'UTF8'); - InsertString(wnd,2,'UTF8+sign'); - InsertString(wnd,3,'UTF16'); - InsertString(wnd,4,'UTF16+sign'); - SendMessage(wnd,CB_SETCURSEL,0,0); - end; - - procedure MakeDataTypeList(wnd:HWND); - begin - SendMessage(wnd,CB_RESETCONTENT,0,0); - InsertString(wnd,0,'Byte'); - InsertString(wnd,1,'Word'); - InsertString(wnd,2,'DWord'); - InsertString(wnd,3,'Ansi'); - InsertString(wnd,4,'Unicode'); - SendMessage(wnd,CB_SETCURSEL,0,0); - end; diff --git a/plugins/Actman/i_inoutxm.inc b/plugins/Actman/i_inoutxm.inc deleted file mode 100644 index 41e705f418..0000000000 --- a/plugins/Actman/i_inoutxm.inc +++ /dev/null @@ -1,1212 +0,0 @@ -{} -var - xmlparser:TXML_API_W; -const - // Nodes - ioRoot :PWideChar = 'ActMan_Export'; - ioAction :PWideChar = 'Action'; - ioSubAction :PWideChar = 'SubAction'; - ioContactWindow:PWideChar = 'Contact'; - ioCallService :PWideChar = 'Service'; - ioRunProgram :PWideChar = 'Program'; - ioInsertText :PWideChar = 'In/Out'; - ioAdvanced :PWideChar = 'Jump'; - ioLinkAction :PWideChar = 'Chain'; - ioProfile :PWideChar = 'Database'; - ioMessageBox :PWideChar = 'MessageBox'; - ioWParam :PWideChar = 'WPARAM'; - ioLParam :PWideChar = 'LPARAM'; - ioItem :PWideChar = 'ITEM'; - ioPost :PWideChar = 'POST'; - ioIf :PWideChar = 'IF'; - ioAct :PWideChar = 'ACT'; - ioOutput :PWideChar = 'OUTPUT'; - ioClass :PWideChar = 'class'; - // Attributes - ioType :PWideChar = 'type'; - ioInverse :PWideChar = 'inverse'; - ioName :PWideChar = 'name'; - ioDisabled :PWideChar = 'disabled'; - ioVolatile :PWideChar = 'volatile'; - ioLast :PWideChar = 'last'; - ioWindow :PWideChar = 'window'; - ioParallel :PWideChar = 'parallel'; - ioArgs :PWideChar = 'args'; - ioWait :PWideChar = 'wait'; - ioObject :PWideChar = 'object'; - ioOper :PWideChar = 'oper'; - ioMessage :PWideChar = 'message'; -// ioDest :PWideChar = 'dest'; - ioEnc :PWideChar = 'enc'; - ioValue :PWideChar = 'value'; - ioService :PWideChar = 'service'; - ioNot :PWideChar = 'not'; - ioCond :PWideChar = 'cond'; - ioVariables :PWideChar = 'variables'; - ioFileVariable :PWideChar = 'modvariables'; - ioArgVariable :PWideChar = 'argvariables'; - ioModule :PWideChar = 'module'; - ioSetting :PWideChar = 'setting'; - ioCProto :PWideChar = 'cproto'; - ioCUIDType :PWideChar = 'cuidtype'; - ioCUID :PWideChar = 'cuid'; - ioIsChat :pWideChar = 'ischat'; - ioTitle :PWideChar = 'title'; - ioFile :PWideChar = 'file'; - ioAsInt :PWideChar = 'asint'; - ioKeepOnly :PWideChar = 'keeponly'; - ioKeepLast :PWideChar = 'keeplast'; - ioReturn :PWideChar = 'return'; - ioLength :PWideChar = 'length'; - ioFree :PWideChar = 'free'; - ioPacked :PWideChar = 'packed'; - - // Values - ioNumber :PWideChar = 'number'; - ioCurrent :PWideChar = 'current'; - ioContact :PWideChar = 'contact'; - ioStruct :PWideChar = 'struct'; - ioResult :PWideChar = 'result'; - ioParam :PWideChar = 'param'; - ioByte :PWideChar = 'byte'; - ioWord :PWideChar = 'word'; - ioDword :PWideChar = 'dword'; - ioAnsi :PWideChar = 'ansi'; - ioUnicode :PWideChar = 'unicode'; -// ioWStruct :PWideChar = 'wordstruct'; -// ioBStruct :PWideChar = 'bytestruct'; - ioHex :PWideChar = 'hex'; - ioInt :PWideChar = 'int'; - ioSigned :PWideChar = 'signed'; - ioPopup :PWideChar = 'popup'; - ioMsgBox :PWideChar = 'msgbox'; - ioHidden :PWideChar = 'hidden'; - ioMinimized :PWideChar = 'minimized'; - ioMaximized :PWideChar = 'maximized'; - ioNormal :PWideChar = 'normal'; - ioClipboard :PWideChar = 'clipboard'; - ioCopy :PWideChar = 'copy'; - ioPaste :PWideChar = 'paste'; - ioBreak :PWideChar = 'break'; - ioJump :PWideChar = 'jump'; - ioNop :PWideChar = 'nop'; -// ioArray :PWideChar = 'array'; - ioScript :PWideChar = 'script'; - ioWrite :PWideChar = 'write'; - ioRead :PWideChar = 'read'; - ioAppend :PWideChar = 'append'; - ioDelete :PWideChar = 'delete'; - -const - imp_yes = 1; - imp_yesall = 2; - imp_no = 3; - imp_noall = 4; - imp_append = 5; - -function ReadStruct(act:HXML):int_ptr; -{ -var - child,i:integer; - tmp:pWideChar; - sub:HXML; - typ:pWideChar; -} -begin - result:=0; -(* - mGetMem (tmp ,32768); - FillChar(tmp^,32768,0); - result:=int_ptr(tmp); - with xmlparser do - begin -{ - typ:=getAttrValue(act,ioPacked); - if (typ<>nil) and (typ^<>#0) and (typ^<>'0') then - begin - tmp^:=char_packed; inc(tmp); - end; -} - child:=0; - repeat - sub:=getNextChild(act,ioItem,@child); - if sub=0 then break; - - typ:=getAttrValue(sub,ioType); - for i:=0 to MaxStructTypes-1 do - begin - if lstrcmpiw(typ,StructElems[i].short)=0 then break; - end; - if StrToInt(getAttrValue(sub,ioReturn))=1 then - begin - tmp^:=char_return; inc(tmp); - end; - if StrToInt(getAttrValue(sub,ioScript))=1 then - begin - tmp^:=char_script; inc(tmp); - end; - tmp:=StrCopyEW(tmp,typ); - tmp^:=' '; inc(tmp); - case StructElems[i].typ of - SST_LAST, SST_PARAM: ; - SST_BYTE, - SST_WORD, - SST_DWORD, - SST_QWORD, - SST_NATIVE: begin - tmp:=StrCopyEW(tmp,getAttrValue(sub,ioValue)); - end; - SST_BARR, SST_WARR, - SST_BPTR, SST_WPTR: begin - tmp:=StrCopyEW(tmp,getAttrValue(sub,ioLength)); - tmp^:=' '; inc(tmp); - tmp:=StrCopyEW(tmp,getAttrValue(sub,ioValue)); - end; - end; - tmp^:='|'; inc(tmp); - until false; - dec(tmp); tmp^:=#0; - end; -*) -end; - -function ReadParam(act:HXML; var param:int_ptr;isvar:boolean):dword; -var - tmp:pWideChar; -begin - result:=0; - if act=0 then - exit; - with xmlparser do - begin - tmp:=getAttrValue(act,ioType); - if lstrcmpiw(tmp,ioCurrent)=0 then result:=result or ACF_WCURRENT - else if lstrcmpiw(tmp,ioResult )=0 then result:=result or ACF_WRESULT - else if lstrcmpiw(tmp,ioParam )=0 then result:=result or ACF_WPARAM - else if lstrcmpiw(tmp,ioNumber )=0 then - begin - result:=result or ACF_WPARNUM; - tmp:=getAttrValue(act,ioValue); - if isvar then - StrDupW(pWideChar(param),tmp) - else - param:=StrToInt(tmp); - end - else if lstrcmpiw(tmp,ioStruct)=0 then - begin - result:=result or ACF_WSTRUCT; - param:=ReadStruct(act); - end - else if lstrcmpiw(tmp,ioUnicode)=0 then - begin - result:=result or ACF_WUNICODE; - StrDupW(pWideChar(param),getAttrValue(act,ioValue)); - end - else if lstrcmpiw(tmp,ioAnsi)=0 then - begin - WideToAnsi(getAttrValue(act,ioValue),pAnsiChar(param),MirandaCP); - end; - end; -end; - -function ImportContact(node:HXML):THANDLE; -var - proto:pAnsiChar; - tmpbuf:array [0..63] of AnsiChar; - dbv:TDBVARIANT; - is_chat:boolean; - bufLen:int; -begin - with xmlparser do - begin - proto:=FastWideToAnsiBuf(getAttrValue(node,ioCProto),tmpbuf); - if (proto=nil) or (proto^=#0) then - begin - result:=0; - exit; - end; - is_chat:=StrToInt(getAttrValue(node,ioIsChat))<>0; - - if is_chat then - begin - dbv.szVal.W:=getAttrValue(node,ioCUID); - end - else - begin - FillChar(dbv,SizeOf(TDBVARIANT),0); - dbv._type:=StrToInt(getAttrValue(node,ioCUIDType)); - case dbv._type of - DBVT_BYTE : dbv.bVal:=StrToInt(getAttrValue(node,ioCUID)); - DBVT_WORD : dbv.wVal:=StrToInt(getAttrValue(node,ioCUID)); - DBVT_DWORD : dbv.dVal:=StrToInt(getAttrValue(node,ioCUID)); - DBVT_ASCIIZ: FastWideToAnsi(getAttrValue(node,ioCUID),dbv.szVal.A); - DBVT_UTF8 : WideToUTF8(getAttrValue(node,ioCUID),dbv.szVal.A); - DBVT_WCHAR : StrDupW(dbv.szVal.W,getAttrValue(node,ioCUID)); - DBVT_BLOB : begin - dbv.pbVal := mir_base64_decode(FastWideToAnsi(getAttrValue(node,ioCUID),pAnsiChar(dbv.pbVal)), bufLen); - dbv.cpbVal := bufLen; - end; - end; - end; - end; - result:=FindContactHandle(proto,dbv,is_chat); - if not is_chat then - case dbv._type of - DBVT_WCHAR, - DBVT_ASCIIZ, - DBVT_UTF8 : mFreeMem(dbv.szVal.A); - DBVT_BLOB : mFreeMem(dbv.pbVal); - end; -end; - -function ImportAction(actnode:HXML):integer; -var - tmp:pWideChar; - act:tHKAction; - sub:HXML; -begin - FillChar(act,SizeOf(act),0); - with xmlparser,act do - begin - flags:=ACF_ASSIGNED; - if StrToInt(getAttrValue(actnode,ioDisabled))=1 then - flags:=flags or ACF_DISABLED; - - StrDupW(descr,getAttrValue(actnode,ioName)); - - actnode:=getChild(actnode,0); - tmp:=getName(actnode); -//MessageBoxW(0,tmp,'node',0); - - // CONTACT - if StrCmpW(tmp,ioContactWindow)=0 then - begin - actionType:=ACT_CONTACT; - contact:=ImportContact(actnode); -// contact:=StrToInt(getAttrValue(actnode,ioNumber)); - if StrToInt(getAttrValue(actnode,ioKeepOnly))=1 then - flags:=flags or ACF_KEEPONLY; - end - - // SERVICE - else if StrCmpW(tmp,ioCallService)=0 then - begin - actionType:=ACT_SERVICE; - FastWideToAnsi(getAttrValue(actnode,ioService),service); -//MessageBoxA(0,service,'service',0); - if StrToInt(getAttrValue(actnode,ioVariables))=1 then - flags2:=flags2 or ACF2_SRV_SRVC; - - sub:=getNthChild(actnode,ioWParam,0); - if StrToInt(getAttrValue(sub,ioVariables))=1 then - flags2:=flags2 or ACF2_SRV_WPAR; - if StrToInt(getAttrValue(sub,ioHex))=1 then - flags2:=flags2 or ACF2_SRV_WHEX; - flags:=flags or ReadParam(sub,int_ptr(wparam),(flags2 and ACF2_SRV_WPAR)<>0); - - sub:=getNthChild(actnode,ioLParam,0); - if StrToInt(getAttrValue(sub,ioVariables))=1 then - flags2:=flags2 or ACF2_SRV_LPAR; - if StrToInt(getAttrValue(sub,ioHex))=1 then - flags2:=flags2 or ACF2_SRV_LHEX; - flags:=flags or (ReadParam(sub,lparam,(flags2 and ACF2_SRV_LPAR)<>0) shl 1); - - sub:=getNthChild(actnode,ioOutput,0); - if StrToInt(getAttrValue(sub,ioMessage))=1 then flags:=flags or ACF_INSERT; - if StrToInt(getAttrValue(sub,ioPopup ))=1 then flags:=flags or ACF_POPUP; - if StrToInt(getAttrValue(sub,ioMsgBox ))=1 then flags:=flags or ACF_MESSAGE; - - if StrToInt(getAttrValue(sub,ioFree))=1 then flags2:=flags2 or ACF2_FREEMEM; - - tmp:=getAttrValue(sub,ioType); - if lstrcmpiw(tmp,ioUnicode)=0 then flags:=flags or ACF_UNICODE+ACF_STRING - else if lstrcmpiw(tmp,ioAnsi )=0 then flags:=flags or ACF_STRING - else if lstrcmpiw(tmp,ioSigned )=0 then flags:=flags or ACF_SIGNED - else if lstrcmpiw(tmp,ioHex )=0 then flags:=flags or ACF_HEX - else if lstrcmpiw(tmp,ioStruct )=0 then flags:=flags or ACF_STRUCT - else if lstrcmpiw(tmp,ioInt )=0 then ; -//MessageBoxW(0,'','end',0); - end - - // PROGRAM - else if StrCmpW(tmp,ioRunProgram)=0 then - begin - actionType:=ACT_PROGRAM; - StrDupW(prgname,getText(actnode)); - StrDupW(args,getAttrValue(actnode,ioArgs)); - if StrToInt(getAttrValue(actnode,ioCurrent))=1 then - flags:=flags or ACF_CURPATH; - - if StrToInt(getAttrValue(actnode,ioParallel))=1 then - flags:=flags or ACF_PRTHREAD - else - time:=StrToInt(getAttrValue(actnode,ioWait)); - - if StrToInt(getAttrValue(actnode,ioFileVariable))=1 then - flags2:=flags2 or ACF2_PRG_PRG; - - if StrToInt(getAttrValue(actnode,ioArgVariable))=1 then - flags2:=flags2 or ACF2_PRG_ARG; - - tmp:=getAttrValue(actnode,ioWindow); - if lstrcmpiw(tmp,ioHidden )=0 then show:=SW_HIDE - else if lstrcmpiw(tmp,ioMinimized)=0 then show:=SW_SHOWMINIMIZED - else if lstrcmpiw(tmp,ioMaximized)=0 then show:=SW_SHOWMAXIMIZED - else show:=SW_SHOWNORMAL; - end - - // INSERT TEXT - else if StrCmpW(tmp,ioInsertText)=0 then - begin - actionType:=ACT_TEXT; - tmp:=getAttrValue(actnode,ioObject); - if lstrcmpiw(tmp,ioClipboard)=0 then - begin - flags:=flags or ACF_CLIPBRD; - tmp:=getAttrValue(actnode,ioOper); - if lstrcmpiw(tmp,ioCopy)=0 then flags:=flags or ACF_COPYTO; -// else if lstrcmpiw(tmp,'paste')=0 then ; - tmp:=getAttrValue(actnode,ioEnc); - if lstrcmpiw(tmp,ioAnsi)=0 then flags:=flags or ACF_ANSI; -// else if lstrcmpiw(tmp,'unicode')=0 then ; - end - else - begin - StrDupW(text,getText(actnode)); - - if StrToInt(getAttrValue(actnode,ioVariables))=1 then - flags2:=flags2 or ACF2_TXT_TEXT; - - if lstrcmpiw(tmp,ioFile)=0 then - begin - - if StrToInt(getAttrValue(actnode,ioFileVariable))=1 then - flags2:=flags2 or ACF2_TXT_FILE; - - flags:=flags or ACF_FILE; - StrDupW(tfile,getAttrValue(actnode,ioFile)); - tmp:=getAttrValue(actnode,ioOper); - if lstrcmpiw(tmp,ioWrite )=0 then flags:=flags or ACF_FWRITE - else if lstrcmpiw(tmp,ioAppend)=0 then flags:=flags or ACF_FAPPEND; - case StrToInt(getAttrValue(actnode,ioEnc)) of - 0: flags:=flags or ACF_ANSI; - 1: flags:=flags or ACF_UTF8; - 2: flags:=flags or ACF_UTF8 or ACF_SIGN; - 3: flags:=flags or 0; - 4: flags:=flags or ACF_SIGN; - end; - end; - end; - end - - // ADVANCED - else if StrCmpW(tmp,ioAdvanced)=0 then - begin - actionType:=ACT_ADVANCE; - sub:=getNthChild(actnode,ioIf,0); - if sub<>0 then - begin - tmp:=getAttrValue(sub,ioCond); - if lstrcmpiw(tmp,'gt' )=0 then condition:=condition or ADV_COND_GT - else if lstrcmpiw(tmp,'lt' )=0 then condition:=condition or ADV_COND_LT - else if lstrcmpiw(tmp,'eq' )=0 then condition:=condition or ADV_COND_EQ - else if lstrcmpiw(tmp,ioNop)=0 then ; - - if StrToInt(getAttrValue(sub,ioNot))=1 then - condition:=condition or ADV_COND_NOT; - - value:=StrToInt(getAttrValue(sub,ioValue)); - end; - - sub:=getNthChild(actnode,ioAct,0); - tmp:=getAttrValue(sub,ioType); - if lstrcmpiw(tmp,ioValue)=0 then - begin - action:=action or ADV_ACT_MATH; - tmp:=getAttrValue(sub,ioOper); - if lstrcmpiw(tmp,ioInverse)=0 then - oper:=Cardinal(aeNot) - else - begin - case tmp^ of - '+': oper:=Cardinal(aeAdd); - '-': oper:=Cardinal(aeSub); - '*': oper:=Cardinal(aeMul); - '\': oper:=Cardinal(aeDiv); - '%': oper:=Cardinal(aeMod); - '&': oper:=Cardinal(aeAnd); - '|': oper:=Cardinal(aeOr ); - '^': oper:=Cardinal(aeXor); - '=': oper:=Cardinal(aeSet); - end; - mathval:=StrToInt(getAttrValue(sub,ioValue)); - end; - end - else if lstrcmpiw(tmp,ioScript)=0 then - begin - if StrToInt(getAttrValue(sub,ioAsInt))<>0 then - flags:=flags or ACF_VARASINT; - action:=action or ADV_ACT_VARS; - StrDupW(varval,getText(sub)); - end; - - sub:=getNthChild(actnode,ioPost,0); - if sub<>0 then - begin - tmp:=getAttrValue(sub,ioOper); - if lstrcmpiw(tmp,ioBreak)=0 then action:=action or ADV_ACT_BREAK - else if lstrcmpiw(tmp,ioJump )=0 then action:=action or ADV_ACT_JUMP - else if lstrcmpiw(tmp,ioNop )=0 then ; - - tmp:=getAttrValue(sub,ioValue); - case action and ADV_ACT_POST of - ADV_ACT_JUMP: StrDupW(operval,tmp); - end; - end; - end - - // CHAIN - else if StrCmpW(tmp,ioLinkAction)=0 then - begin - actionType:=ACT_CHAIN; - StrDupW(actname,getText(actnode)); - flags:=flags or ACF_BYNAME; - end - - // DBRW - else if StrCmpW(tmp,ioProfile)=0 then - begin - actionType:=ACT_RW; - tmp:=getAttrValue(actnode,ioOper); - if lstrcmpiw(tmp,ioDelete)=0 then flags:=flags or ACF_DBDELETE - else if lstrcmpiw(tmp,ioWrite )=0 then flags:=flags or ACF_DBWRITE; -// else if lstrcmpiw(tmp,ioRead)=0 then ; - tmp:=getAttrValue(actnode,ioContact); - if lstrcmpiw(tmp,ioCurrent)=0 then flags:=flags or ACF_CURRENT - else if lstrcmpiw(tmp,ioResult )=0 then flags:=flags or ACF_RESULT - else if lstrcmpiw(tmp,ioParam )=0 then flags:=flags or ACF_PARAM - else if lstrcmpiw(tmp,ioContact)=0 then - begin - contact:=ImportContact(actnode); - end; - - FastWideToAnsi(getAttrValue(actnode,ioModule ),dbmodule); - FastWideToAnsi(getAttrValue(actnode,ioSetting),dbsetting); - - if StrToInt(getAttrValue(actnode,ioFileVariable))=1 then flags2:=flags2 or ACF2_RW_MVAR; - if StrToInt(getAttrValue(actnode,ioArgVariable ))=1 then flags2:=flags2 or ACF2_RW_SVAR; - if StrToInt(getAttrValue(actnode,ioVariables ))=1 then flags2:=flags2 or ACF2_RW_TVAR; - if StrToInt(getAttrValue(actnode,ioHex ))=1 then flags2:=flags2 or ACF2_RW_HEX; - - tmp:=getAttrValue(actnode,ioType); - if lstrcmpiw(tmp,ioByte )=0 then flags:=flags or ACF_DBBYTE - else if lstrcmpiw(tmp,ioWord )=0 then flags:=flags or ACF_DBWORD - else if lstrcmpiw(tmp,ioDword)=0 then - else // if lstrcmpiw(tmp,ioUnicode)=0 then - begin - if lstrcmpiw(tmp,ioAnsi)=0 then - flags:=flags or ACF_DBANSI - else - flags:=flags or ACF_DBUTEXT; - StrDupW(pWideChar(dbvalue),getText(actnode)); - end; - - if StrToInt(getAttrValue(actnode,ioLast))=1 then - flags:=flags or ACF_LAST - else if (flags and ACF_DBUTEXT)=0 then - begin - if (flags2 and ACF2_RW_TVAR)<>0 then - StrDupW(pWideChar(dbvalue),getText(actnode)) - else - dbvalue:=StrToInt(getAttrValue(actnode,ioValue)); - end; - end - - // MessageBox - else if StrCmpW(tmp,ioMessageBox)=0 then - begin - actionType:=ACT_MESSAGE; - StrDupW(msgtitle,getAttrValue(actnode,ioTitle)); - StrDupW(msgtext,getText(actnode)); - boxopts:=StrToInt(getAttrValue(actnode,ioType)); - if StrToInt(getAttrValue(actnode,ioArgVariable))=1 then flags2:=flags2 or ACF2_MSG_TXT; - if StrToInt(getAttrValue(actnode,ioVariables ))=1 then flags2:=flags2 or ACF2_MSG_TTL; - if StrToInt(getAttrValue(actnode,ioKeepLast ))=1 then flags :=flags or ACF_MSG_KEEP; - end - - else - begin - actionType:=ACT_UNKNOWN; - result:=0; - Exit; - end; - end; - result:=NewAction(ActionList,MaxActions); - move(act,ActionList^[result],SizeOf(tHKAction)); -end; - -function Import(fname:PWideChar;aflags:dword):integer; -var - f:THANDLE; - i,j:integer; - tmp,res:pWideChar; - root,actnode:HXML; - last,next:integer; - impact:integer; - buf:array [0..511] of WideChar; - oldid:dword; -begin - result:=0; - for i:=0 to MaxGroups-1 do - with GroupList[i] do - if (flags and (ACF_IMPORT or ACF_ASSIGNED))= - (ACF_IMPORT or ACF_ASSIGNED) then - flags:=flags and not (ACF_IMPORT or ACF_OVERLOAD); - - if (fname=nil) or (fname^=#0) then - exit; - i:=GetFSize(fname); - if i=0 then - exit; - mGetMem (res ,i+SizeOf(WideChar)); - FillChar(res^,i+SizeOf(WideChar),0); - f:=Reset(fname); - BlockRead(f,res^,i); - CloseHandle(f); - -//MessageBoxW(0,res,'SRC',0); - xmlparser.cbSize:={XML_API_SIZEOF_V1;//}SizeOf(TXML_API_W); - CallService(MS_SYSTEM_GET_XI,0,lparam(@xmlparser)); - with xmlparser do - begin - root:=parseString(ChangeUnicode(res),@i,nil); - j:=0; - impact:=imp_yes; - repeat - actnode:=getNthChild(root,ioAction,j); - if actnode=0 then break; -//MessageBoxW(0,'not zero','actnode',0); -//?? if StrCmpW(getName(actnode),ioAction)<>0 then break; - tmp:=getAttrValue(actnode,ioName); -//MessageBoxW(0,tmp,'nodename',0); - if tmp<>nil then //!! - begin - i:=GetActIdxByName(tmp); - oldid:=$FFFFFFFF; - if i>=0 then - begin - if (impact<>imp_yesall) and (impact<>imp_noall) then - begin - StrCopyW(buf,TranslateW('Action "$" exists, do you want to rewrite it?')); - impact:=DialogBoxParam(hInstance,MAKEINTRESOURCE(IDD_ASK),0, - @QuestionDlg,TLPARAM(StrReplaceW(buf,'$',tmp))); - end; - if (impact=imp_yesall) or (impact=imp_yes) then - begin - oldid:=GroupList^[i].id; - FreeGroup(i); - end; - end; - if (i<0) or (impact=imp_yesall) or (impact=imp_yes) or (impact=imp_append) then - begin - with GroupList^[NewGroup(GroupList,MaxGroups)] do - begin - if (i>=0) and (oldid<>$FFFFFFFF) then // set old id to keep UseAction setting - begin - flags:=flags or ACF_IMPORT or ACF_OVERLOAD; - id:=oldid; - end; - flags:=flags or ACF_IMPORT; - if StrToInt(getAttrValue(actnode,ioDisabled))=1 then flags:=flags or ACF_DISABLED; - if StrToInt(getAttrValue(actnode,ioVolatile))=1 then flags:=flags or ACF_VOLATILE; - mFreeMem(descr); - StrDupW(descr,tmp); - i:=0; - last:=-1; -//MessageBoxW(0,descr,'descr',0); - repeat - next:=ImportAction(getChild(actnode,i)); - if next=0 then - break; - if last<0 then - firstAction:=next - else - ActionList[last].next:=next; - last:=next; - inc(i); - until false; - inc(result); - end; - end; - end; - inc(j); - until false; - DestroyNode(root); - end; - mFreeMem(res); -end; - -//-------------------------- - -procedure WriteStruct(node:HXML;struct:PWideChar); -{var - sub:HXML; - ppc,value,lsrc,p,pc:pWideChar; - i,len:integer; - typ:integer; -} -begin -(* - if struct=nil then exit; - - mGetMem(pc,4096); - lsrc:=pWideChar(struct); - with xmlparser do - begin -{ - if lsrc^=char_packed then - begin - AddAttrInt(node,ioPacked,1); - inc(lsrc); - end; -} - while lsrc^<>#0 do - begin - sub:=AddChild(node,ioItem,nil); - p:=StrScanW(lsrc,'|'); - StrCopyW(pc,lsrc,p-lsrc); - - ppc:=pc; - if ppc^=char_return then - begin - AddAttrInt(sub,ioReturn,1); - inc(ppc); - end; - - if ppc^=char_script then - begin - AddAttrInt(sub,ioScript,1); - inc(ppc); - end; - - typ:=GetOneElement(ppc,len,value); - - i:=0; - while i0 then - begin - s:=ioNumber; - if (flags2 and ACF2_SRV_WPAR)<>0 then - AddAttr(node,ioValue,PWideChar(param)) - else - AddAttrInt(node,ioValue,param); - end - else if (flags and ACF_WCURRENT)<>0 then - begin - s:=ioCurrent; - end - else if (flags and ACF_WRESULT)<>0 then - begin - s:=ioResult; - end - else if (flags and ACF_WPARAM)<>0 then - begin - s:=ioParam; - end - else if (flags and ACF_WSTRUCT)<>0 then - begin - s:=ioStruct; - WriteStruct(node,pointer(param)); - end - else if (flags and ACF_WUNICODE)<>0 then - begin - s:=ioUnicode; - AddAttr(node,ioValue,PWideChar(param)); - end - else - begin - s:=ioAnsi; - AddAttr(node,ioValue,AnsiToWide(PAnsiChar(param),tmp)); - mFreeMem(tmp); - end; - AddAttr(node,ioType,s); - end; -end; - -function ExportContact(node:HXML;hContact:THANDLE):integer; -var - proto,uid:pAnsiChar; - cws:TDBVARIANT; - p1:pAnsiChar; - p:pWideChar; - tmpbuf:array [0..63] of WideChar; - is_chat:boolean; -begin - result:=0; - proto:=GetContactProtoAcc(hContact); - if proto<>nil then - begin - is_chat:=IsChat(hContact); - if is_chat then - begin - with xmlparser do - begin - p:=DBReadUnicode(hContact,proto,'ChatRoomID'); - addAttr(node,ioCUID,p); - mFreeMem(p); - end; - result:=1; - end - else - begin - uid:=pAnsiChar(CallProtoService(proto,PS_GETCAPS,PFLAG_UNIQUEIDSETTING,0)); - if DBReadSetting(hContact,proto,uid,@cws)=0 then - begin - result:=1; - with xmlparser do - begin - addAttrInt(node,ioCUIDType,cws._type); - case cws._type of - DBVT_BYTE : AddAttrInt(node,ioCUID,cws.bVal); - DBVT_WORD : AddAttrInt(node,ioCUID,cws.wVal); - DBVT_DWORD : AddAttrInt(node,ioCUID,cws.dVal); - DBVT_ASCIIZ: begin - AddAttr(node,ioCUID,FastAnsiToWide(cws.szVal.A,p)); - mFreeMem(p); - end; - DBVT_UTF8 : begin - AddAttr(node,ioCUID,UTF8ToWide(cws.szVal.A,p)); - // AddAttr(node,'cuid',FastAnsiToWide(cws.szVal.A,p)); - mFreeMem(p); - end; - DBVT_WCHAR : AddAttr(node,ioCUID,cws.szVal.W); - DBVT_BLOB : begin - p1:=mir_base64_encode(cws.pbVal,cws.cpbVal); - AddAttr(node,ioCUID,FastAnsiToWide(p1,p)); - mir_free(p1); - mFreeMem(p); - end; - end; - end; - end; - DBFreeVariant(@cws); - end; - if result<>0 then - begin - with xmlparser do - begin - addAttr (node,ioCProto,FastAnsiToWideBuf(proto,tmpbuf)); - addAttrInt(node,ioIsChat,ord(is_chat)); - end; - end; - end; -end; - -procedure WriteAction(actnode:HXML;idx:integer); -var - sub, act: HXML; - s:PWideChar; - i:integer; - tmp:pWideChar; -begin - with xmlparser,ActionList[idx] do - begin - actnode:=AddChild(actnode,ioSubAction,nil); - if descr<>nil then - AddAttr(actnode,ioName,descr); - if (flags and ACF_DISABLED)<>0 then - AddAttrInt(actnode,ioDisabled,1); - - case actionType of -// ----- CONTACT ----- - ACT_CONTACT: begin - AddAttr(actnode,ioClass,ioContactWindow); - sub:=actnode; -// sub:=AddChild(actnode,ioContactWindow,nil); - ExportContact(sub,contact); -// AddAttrInt(sub,ioNumber,0); // contact - if (flags and ACF_KEEPONLY)<>0 then AddAttrInt(sub,ioKeepOnly,1); - end; -// ----- SERVICE ----- - ACT_SERVICE: begin - AddAttr(actnode,ioClass,ioCallService); - sub:=actnode; -// sub:=AddChild(actnode,ioCallService,nil); - AddAttr(sub,ioService,FastAnsiToWide(service,tmp)); - if (flags2 and ACF2_SRV_SRVC)<>0 then AddAttrInt(sub,ioVariables,1); - mFreeMem(tmp); - act:=AddChild(sub,ioWParam,nil); WriteParam(act,flags ,wparam,flags2); - if (flags2 and ACF2_SRV_WPAR)<>0 then AddAttrInt(act,ioVariables,1); - if (flags2 and ACF2_SRV_WHEX)<>0 then AddAttrInt(act,ioHex ,1); - act:=AddChild(sub,ioLParam,nil); WriteParam(act,flags shr 1,lparam,flags2 shr 1); - if (flags2 and ACF2_SRV_LPAR)<>0 then AddAttrInt(act,ioVariables,1); - if (flags2 and ACF2_SRV_LHEX)<>0 then AddAttrInt(act,ioHex ,1); - - act:=AddChild(sub,ioOutput,nil); - if (flags and (ACF_MESSAGE+ACF_POPUP+ACF_INSERT))<>0 then - begin - if (flags and ACF_INSERT )<>0 then AddAttrInt(act,ioMessage,1); - if (flags and ACF_POPUP )<>0 then AddAttrInt(act,ioPopup ,1); - if (flags and ACF_MESSAGE)<>0 then AddAttrInt(act,ioMsgBox ,1); - end; - - if (flags2 and ACF2_FREEMEM)<>0 then AddAttrInt(sub,ioFree,1); - - if (flags and ACF_STRUCT)<>0 then - s:=ioStruct - else if (flags and ACF_STRING)<>0 then - begin - if (flags and ACF_UNICODE)<>0 then - s:=ioUnicode - else - s:=ioAnsi; - end - else - begin - if (flags and ACF_SIGNED)<>0 then s:=ioSigned - else if (flags and ACF_HEX )<>0 then s:=ioHex - else s:=ioInt; - end; - AddAttr(act,ioType,s); - end; -// ----- PROGRAM ----- - ACT_PROGRAM: begin - AddAttr(actnode,ioClass,ioRunProgram); - setText(actnode,prgname); - sub:=actnode; -// sub:=AddChild(actnode,ioRunProgram,prgname); - if args<>nil then - AddAttr(sub,ioArgs,args); - if (flags and ACF_CURPATH)<>0 then AddAttrInt(sub,ioCurrent,1); - if (flags and ACF_PRTHREAD)=0 then AddAttrInt(sub,ioWait,time) - else AddAttrInt(sub,ioParallel,1); - - if (flags2 and ACF2_PRG_PRG)<>0 then AddAttrInt(sub,ioFileVariable,1); - if (flags2 and ACF2_PRG_ARG)<>0 then AddAttrInt(sub,ioArgVariable ,1); - - case show of - SW_HIDE : s:=ioHidden; - SW_SHOWMINIMIZED: s:=ioMinimized; - SW_SHOWMAXIMIZED: s:=ioMaximized; - else - s:=ioNormal; - end; - AddAttr(sub,ioWindow,s); - end; -// ----- TEXT ----- - ACT_TEXT: begin - if (flags and ACF_CLIPBRD)<>0 then - begin - AddAttr(actnode,ioClass,ioInsertText); - end - else - begin - if (flags and ACF_FILE)<>0 then - AddAttr(actnode,ioClass,ioInsertText) - else - begin - AddAttr(actnode,ioClass,'Text'); - setText(actnode,text); - end; - end; - sub:=actnode; -// sub:=AddChild(actnode,ioInsertText,tmp); - if (flags and ACF_CLIPBRD)<>0 then - begin - AddAttr(sub,ioObject,ioClipboard); - if (flags and ACF_COPYTO)<>0 then - s:=ioCopy - else - s:=ioPaste; - AddAttr(sub,ioOper,s); - if (flags and ACF_ANSI)=0 then - s:=ioUnicode - else - s:=ioAnsi; - AddAttr(sub,ioEnc,s); - end - else - begin - if (flags and ACF_FILE)<>0 then - begin - if (flags2 and ACF2_TXT_FILE)<>0 then - AddAttrInt(sub,ioFileVariable,1); - AddAttr(sub,ioObject,ioFile); - AddAttr(sub,ioFile,tfile); - if (flags and ACF_FWRITE )<>0 then AddAttr(sub,ioOper,ioWrite) - else if (flags and ACF_FAPPEND)<>0 then AddAttr(sub,ioOper,ioAppend); - - if (flags and ACF_ANSI)<>0 then - i:=0 - else if (flags and ACF_UTF8)<>0 then - begin - if (flags and ACF_SIGN)<>0 then - i:=2 - else - i:=1; - end - else if (flags and ACF_SIGN)<>0 then - i:=4 - else - i:=3; - AddAttrInt(sub,ioEnc,i); - end - else - AddAttr(sub,ioObject,ioWindow); - - if (flags2 and ACF2_TXT_TEXT)<>0 then - AddAttrInt(sub,ioVariables,1); - end; - end; -// ----- ADVANCED ----- - ACT_ADVANCE: begin - AddAttr(actnode,ioClass,ioAdvanced); - sub:=actnode; -// sub:=AddChild(actnode,ioAdvanced,nil); - if lobyte(condition)<>0 then - begin - act:=AddChild(sub,ioIf,nil); - if (lobyte(condition) and ADV_COND_NOT)<>0 then - AddAttrInt(act,ioNot,1); - case lobyte(condition) and not ADV_COND_NOT of - ADV_COND_GT: s:='gt'; - ADV_COND_LT: s:='lt'; - ADV_COND_EQ: s:='eq'; - else - s:=ioNop; - end; - AddAttr(act,ioOper,'math'); - AddAttr(act,ioCond,s); - AddAttrInt(act,ioValue,value); - end; - - if (action and not 3)<>ADV_ACT_VARS then - tmp:=nil - else - tmp:=varval; - act:=AddChild(sub,ioAct,tmp); - case action and ADV_ACTION of - ADV_ACT_MATH: begin - AddAttr(act,ioType,ioValue); - if tAdvExpr(oper)=aeNot then - AddAttr(act,ioOper,ioInverse) - else - begin - case tAdvExpr(oper) of - aeAdd: s:='+'; - aeSub: s:='-'; - aeMul: s:='*'; - aeDiv: s:='\'; - aeMod: s:='%'; - aeAnd: s:='&'; - aeOr : s:='|'; - aeXor: s:='^'; - aeSet: s:='='; - else - s:=nil; - end; - AddAttr(act,ioOper,s); - AddAttrInt(act,ioValue,mathval); - end; - end; - ADV_ACT_VARS: begin - if (flags and ACF_VARASINT)<>0 then - AddAttrInt(act,ioAsInt,1); - AddAttr(act,ioType,ioScript); - end; - end; - - if (action and ADV_ACT_POST)<>0 then - begin - act:=AddChild(sub,ioPost,nil); - case action and ADV_ACT_POST of - ADV_ACT_BREAK: s:=ioBreak; - ADV_ACT_JUMP : begin - s:=ioJump; - AddAttr(act,ioValue,operval); - end; - else - s:=ioNop - end; - AddAttr(act,ioOper,s); - end; - //!! - end; -// ----- LINK ----- - ACT_CHAIN: begin - if (flags and ACF_BYNAME)<>0 then - s:=actname - else - s:=GetActNameById(id); - AddAttr(actnode,ioClass,ioLinkAction); - setText(actnode,s); -// AddChild(actnode,ioLinkAction,s); - end; -// ----- DATABASE ----- - ACT_RW: begin - if ((flags and ACF_DBUTEXT)=0) and ((flags2 and ACF2_RW_TVAR)=0) then - tmp:=nil - else - tmp:=pWideChar(dbvalue); - AddAttr(actnode,ioClass,ioProfile); - setText(actnode,tmp); - sub:=actnode; -// sub:=AddChild(actnode,ioProfile,tmp); - if (flags and ACF_DBDELETE)<>0 then s:=ioDelete - else if (flags and ACF_DBWRITE )<>0 then s:=ioWrite - else s:=ioRead; - AddAttr(sub,ioOper,s); - if (flags and ACF_CURRENT)<>0 then s:=ioCurrent - else if (flags and ACF_RESULT )<>0 then s:=ioResult - else if (flags and ACF_PARAM )<>0 then s:=ioParam - else - begin - s:=ioContact; - ExportContact(sub,dbcontact); - end; - AddAttr(sub,ioContact,s); - AddAttr(sub,ioModule ,FastAnsiToWide(dbmodule ,tmp)); mFreeMem(tmp); - AddAttr(sub,ioSetting,FastAnsiToWide(dbsetting,tmp)); mFreeMem(tmp); - - if (flags and ACF_DBANSI )=ACF_DBANSI then s:=ioAnsi - else if (flags and ACF_DBBYTE )=ACF_DBBYTE then s:=ioByte - else if (flags and ACF_DBWORD )=ACF_DBWORD then s:=ioWord - else if (flags and ACF_DBUTEXT)= 0 then s:=ioDword - else s:=ioUnicode; - AddAttr(sub,ioType,s); - - if (flags2 and ACF2_RW_MVAR)<>0 then AddAttrInt(sub,ioFileVariable,1); - if (flags2 and ACF2_RW_SVAR)<>0 then AddAttrInt(sub,ioArgVariable ,1); - if (flags2 and ACF2_RW_TVAR)<>0 then AddAttrInt(sub,ioVariables ,1); - if (flags2 and ACF2_RW_HEX )<>0 then AddAttrInt(sub,ioHex ,1); - - if ( flags and ACF_LAST )<>0 then AddAttrInt(sub,ioLast ,1) - else if ((flags and ACF_DBUTEXT )=0) and - ((flags2 and ACF2_RW_TVAR)=0) then AddAttrInt(sub,ioValue,dbvalue); - end; -// ----- MESSAGEBOX ----- - ACT_MESSAGE: begin - AddAttr(actnode,ioClass,ioMessageBox); - setText(actnode,msgtext); - sub:=actnode; -// sub:=AddChild(actnode,ioMessageBox,msgtext); - if (flags2 and ACF2_MSG_TTL)<>0 then AddAttrInt(sub,ioVariables ,1); - if (flags2 and ACF2_MSG_TXT)<>0 then AddAttrInt(sub,ioArgVariable,1); - if (flags and ACF_MSG_KEEP)<>0 then AddAttrInt(sub,ioKeepLast ,1); - AddAttr (sub,ioTitle,msgtitle); - AddAttrInt(sub,ioType ,boxopts); - end; - end; - end; -end; - -procedure Export({act:integer;}fname:pWideChar;aflags:dword); -var - i:integer; - f:THANDLE; - root,actnode:HXML; - res:pWideChar; - act:integer; -begin - xmlparser.cbSize:={XML_API_SIZEOF_V1;//}SizeOf(TXML_API_W); - CallService(MS_SYSTEM_GET_XI,0,lparam(@xmlparser)); - root:=0; - with xmlparser do - begin - i:=0; - if (aflags and ACIO_APPEND)<>0 then - begin - i:=GetFSize(fname); - if i<>0 then - begin - mGetMem (res ,i+SizeOf(WideChar)); - FillChar(res^,i+SizeOf(WideChar),0); - f:=Reset(fname); - BlockRead(f,res^,i); - CloseHandle(f); - root:=parseString(res,@i,nil); - mFreeMem(res); - i:=1; - end; - end; - if i=0 then // new file - root:=CreateNode(ioRoot,nil,false); - - for act:=0 to MaxGroups-1 do - if ((aflags and ACIO_SELECTED)=0) or - ((GroupList[act].flags and (ACF_EXPORT or ACF_ASSIGNED))= - (ACF_EXPORT or ACF_ASSIGNED)) then - begin -// GroupList[act].flags:=GroupList[act].flags and not ACF_EXPORT; - actnode:=addChild(root,ioAction,nil); - AddAttr(actnode,ioName,GroupList[act].descr); - if (GroupList[act].flags and ACF_DISABLED)<>0 then - AddAttrInt(actnode,ioDisabled,1); - - i:=GroupList[act].firstAction; - if i<>0 then - repeat - WriteAction(actnode,i); - i:=ActionList[i].next; - until i=0; - end; - - res:=toString(root,@i); - if i>0 then - begin - f:=Rewrite(fname); - BlockWrite(f,res^,i*SizeOf(WideChar)); - CloseHandle(f); - end; - xmlparser.FreeMem(res); - DestroyNode(root); - end; -end; - -function ActInOut(wParam:WPARAM;lParam:LPARAM):int_ptr; cdecl; -begin - if (wParam and ACIO_EXPORT)=0 then - begin - result:=Import(pWideChar(lParam),wParam); - end - else - begin - result:=1; - Export(pWideChar(lParam),wParam); - end; - NotifyEventHooks(hevinout,wParam,lParam); -end; diff --git a/plugins/Actman/i_opt_dlg.inc b/plugins/Actman/i_opt_dlg.inc index 3e07cd97ae..e7a9e206ef 100644 --- a/plugins/Actman/i_opt_dlg.inc +++ b/plugins/Actman/i_opt_dlg.inc @@ -1,173 +1,9 @@ {} -const - etHK = 1; // Groups changed - etACT = 2; // Actions changed -const - ACI_APPLY :PAnsiChar = 'ACI_Apply'; - ACI_NEW :PAnsiChar = 'ACI_New'; - ACI_UP :PAnsiChar = 'ACI_Up'; - ACI_DOWN :PAnsiChar = 'ACI_Down'; - ACI_DELETE :PAnsiChar = 'ACI_Delete'; - ACI_RELOAD :PAnsiChar = 'ACI_Reload'; - ACI_TEST :PAnsiChar = 'ACI_Test'; - ACI_IMPORT :PAnsiChar = 'ACI_Import'; - ACI_EXPORT :PAnsiChar = 'ACI_Export'; -const - ACI_CONTACT = 'ACI_Contact'; - ACI_SERVICE = 'ACI_Service'; - ACI_PROGRAM = 'ACI_Program'; - ACI_INSERT = 'ACI_Insert'; - ACI_ADVANCE = 'ACI_Advanced'; - ACI_CHAIN = 'ACI_Chain'; - ACI_RW = 'ACI_Database'; - ACI_MESSAGE = 'ACI_Message'; - - ACI_FORMAT = 'ACI_Format'; - - ACI_VAR_UNCHECKED = 'ACI_VarUnChecked'; - ACI_VAR_CHECKED = 'ACI_VarChecked'; - -const - sresInt = 0; - sresHex = 1; - sresString = 2; - sresStruct = 3; -type - tActId = record - code:dword; - id :dword; - icon:PAnsiChar; - text:PAnsiChar; - end; -const - ActIds:array [0..ACT_MAXTYPE-1] of tActId = ( - (code:ACT_CONTACT; id:IDI_CONTACT; icon:ACI_CONTACT; text:'Open contact window'), - (code:ACT_SERVICE; id:IDI_SERVICE; icon:ACI_SERVICE; text:'Call service'), - (code:ACT_PROGRAM; id:IDI_PROGRAM; icon:ACI_PROGRAM; text:'Execute program'), - (code:ACT_TEXT ; id:IDI_INSERT ; icon:ACI_INSERT ; text:'Insert text'), - (code:ACT_ADVANCE; id:IDI_ADVANCE; icon:ACI_ADVANCE; text:'Advanced'), - (code:ACT_CHAIN ; id:IDI_CHAIN ; icon:ACI_CHAIN ; text:'Link to action'), - (code:ACT_RW ; id:IDI_RW ; icon:ACI_RW ; text:'Profile'), - (code:ACT_MESSAGE; id:IDI_MESSAGE; icon:ACI_MESSAGE; text:'MessageBox')); - -procedure RegisterIcon(var sid:TSKINICONDESC;id:uint_ptr;name:PAnsiChar;descr:PAnsiChar); var - buf:array [0..63] of WideChar; -begin - sid.hDefaultIcon :=LoadImage(hInstance,MAKEINTRESOURCE(id),IMAGE_ICON,16,16,0); - sid.pszName :=name; - sid.szDescription.w:=FastAnsiToWideBuf(descr,buf); - Skin_AddIcon(@sid); - DestroyIcon(sid.hDefaultIcon); -end; - -procedure RegisterIcons; -var - sid:TSKINICONDESC; - i:integer; -begin - FillChar(sid,SizeOf(TSKINICONDESC),0); - sid.cbSize :=SizeOf(TSKINICONDESC); - sid.cx :=16; - sid.cy :=16; - sid.flags :=SIDF_UNICODE; - sid.szSection.w:='Actions'; - - RegisterIcon(sid,IDI_APPLY ,ACI_APPLY ,'Apply'); - RegisterIcon(sid,IDI_NEW ,ACI_NEW ,'New'); - RegisterIcon(sid,IDI_DELETE ,ACI_DELETE ,'Delete'); - RegisterIcon(sid,IDI_UP ,ACI_UP ,'Up'); - RegisterIcon(sid,IDI_DOWN ,ACI_DOWN ,'Down'); - RegisterIcon(sid,IDI_RELOAD ,ACI_RELOAD ,'Reload'); - RegisterIcon(sid,IDI_TEST ,ACI_TEST ,'Test'); - RegisterIcon(sid,IDI_IMPORT ,ACI_IMPORT ,'Import'); - RegisterIcon(sid,IDI_EXPORT ,ACI_EXPORT ,'Export'); - - RegisterIcon(sid,IDI_FORMAT ,ACI_FORMAT ,'Contact list format'); - - for i:=0 to ACT_MAXTYPE-1 do - with ActIds[i] do - RegisterIcon(sid,id,icon,text); - - sid.cx:=8; - sid.cy:=8; - RegisterIcon(sid,IDI_VAR_CHECKED ,ACI_VAR_CHECKED ,'Use Variables'); - RegisterIcon(sid,IDI_VAR_UNCHECKED,ACI_VAR_UNCHECKED,'Don''t use Variables'); -end; - -procedure SetStart; -begin - if NewGroupList=nil then - begin - NewGroupList:=GroupList; - NewMaxGroups:=MaxGroups; - end; - if NewActionList=nil then - begin - NewActionList:=ActionList; - NewMaxActions:=MaxActions; - end; -end; - -procedure SetChanged(wnd:HWND;atype:integer); -begin - SendMessage(GetParent(wnd),PSM_CHANGED,0,0); - if ((atype and etHK )<>0) and (NewGroupList =GroupList ) then NewGroupList :=CloneGroupList; - if ((atype and etACT)<>0) and (NewActionList=ActionList) then NewActionList:=CloneActionList; -end; - -procedure SetSave(Dialog:HWND;curIdx:integer); -var - i,j:integer; - li:LV_ITEMW; - wnd:HWND; -begin - if NewGroupList<>GroupList then - begin - - DestroyGroups(GroupList,MaxGroups); - wnd:=GetDlgItem(Dialog,IDC_ACTION_GROUP); - j:=SendMessageW(wnd,LVM_GETITEMCOUNT,0,0); - MaxGroups:=j; - if j>0 then - begin - GetMem (GroupList ,MaxGroups*SizeOf(tHKRecord)); - FillChar(GroupList^,MaxGroups*SizeOf(tHKRecord),0); - li.mask :=LVIF_PARAM; - li.iSubItem:=0; - for i:=0 to j-1 do - begin - li.iItem:=i; - SendMessageW(wnd,LVM_GETITEMW,0,lparam(@li)); // GetLParam(wnd,i); - move(NewGroupList^[li.lParam],GroupList^[i],SizeOf(tHKRecord)); - li.lParam:=i; - SendMessageW(wnd,LVM_SETITEMW,0,lparam(@li)); - end; - end - else - GroupList:=nil; - - FreeMem(NewGroupList); - NewGroupList:=GroupList; - NewMaxGroups:=MaxGroups; - end; -end; - -procedure SetCancel; -begin - if NewActionList<>nil then - begin - if (NewActionList<>ActionList) then - DestroyActions(NewActionList,NewMaxActions); - NewActionList:=nil; - end; - if NewGroupList<>nil then - begin - if (NewGroupList<>GroupList) then - DestroyGroups(NewGroupList,NewMaxGroups); - NewGroupList:=nil; - end; -end; + xmlfilename:array [0..511] of WideChar; +const + etMacro = 1; // Groups changed + etACT = 2; // Actions changed {$include i_opt_dlg2.inc} @@ -181,7 +17,8 @@ var i:integer; begin result:=0; - NoDescription :=TranslateW('No description'); + NoDescription:=TranslateW('No description'); + StrCopyW(xmlfilename,'c:\export.xml'); DoInitCommonControls(ICC_USEREX_CLASSES); diff --git a/plugins/Actman/i_opt_dlg2.inc b/plugins/Actman/i_opt_dlg2.inc index 4462c12d7d..75e1a51685 100644 --- a/plugins/Actman/i_opt_dlg2.inc +++ b/plugins/Actman/i_opt_dlg2.inc @@ -2,189 +2,534 @@ const inoutfilter:pWideChar = 'XML files'#0'*.xml'#0'All files'#0'*.*'#0#0; -const - NoChainText:PWideChar = 'not defined'; -const - ActionNames:array [0..ACT_MAXTYPE] of pWideChar=( - 'Unknown','Contact','Service','Program','Text','Advanced','Action','Profile','Message'); -const - checknames:array [BST_UNCHECKED..BST_CHECKED] of PAnsiChar=( - ACI_VAR_UNCHECKED,ACI_VAR_CHECKED); const MaxDescrLen = 128; const - hlpContact = 0; - hlpService = 1; - hlpProgram = 2; - hlpText = 3; - hlpAdvance = 4; - hlpChain = 5; - hlpDBRW = 6; - hlpMessage = 7; hlpVariables = 30; hlpAdvVariables = 31; -const - ptNumber = 0; - ptString = 1; - ptUnicode = 2; - ptCurrent = 3; - ptResult = 4; - ptParam = 5; - ptStruct = 6; var - wstruct,lstruct:pAnsiChar; DontReact:bool; OldGroupTableProc, OldActTableProc:pointer; - ChMask:dword; + EventMask:dword; -function GetNumValue(wnd:HWND;usevar:boolean;var dst):boolean; +procedure ChangeListNotify(list:integer); var - tmp:pWideChar; + p:pActModule; begin - result:=false; - pWideChar(dst):=GetDlgText(wnd); - if Pointer(dst)=nil then exit; - if not usevar then + p:=ModuleLink; + while p<>nil do begin - tmp:=PWideChar(dst); - if pWideChar(dst)^='$' then - begin - integer(dst):=HexToInt(pWideChar(dst)+1); - result:=true; - end - else - integer(dst):=StrToInt(pWideChar(dst)); - mFreeMem(tmp); + SendMessage(p^.DlgHandle,WM_ACT_LISTCHANGE,list,0); + p:=p^.Next; end; end; -function GetGroupName(id:dword):pWideChar; +procedure ResetDialogs; var - i:integer; + p:pActModule; +begin + p:=ModuleLink; + while p<>nil do + begin + SendMessage(p^.DlgHandle,WM_ACT_RESET,0,0); + p:=p^.Next; + end; +end; + +procedure ClearDialogData; +var + p:pActModule; +begin + p:=ModuleLink; + while p<>nil do + begin + if p^.DlgHandle<>0 then ShowWindow(p^.DlgHandle,SW_HIDE); + p:=p^.Next; + end; +end; + +function CheckChanges:dword; +var + i,j:integer; + found:boolean; begin - for i:=0 to NewMaxGroups-1 do + result:=0; + // 1 - search new items (EditMacroList elements which don't exists in MacroList) + found:=true; + for i:=0 to EditMacroList.Count-1 do begin - if ((NewGroupList^[i].flags and ACF_ASSIGNED)<>0) and (id=NewGroupList^[i].id) then + if (EditMacroList[i]^.flags and ACF_ASSIGNED)<>0 then begin - result:=NewGroupList^[i].descr; - exit; + found:=false; + for j:=0 to MacroList.Count-1 do + begin + if (MacroList[j]^.flags and ACF_ASSIGNED)<>0 then + begin + if EditMacroList[i]^.id=MacroList[j]^.id then + begin + found:=true; + break; + end; + end; + end; + if not found then break; + end; + end; + if not found then + result:=result or ACTM_NEW; + // 2 - search deleted items (MacroList elements which don't exists in EditMacroList) + found:=true; + for i:=0 to MacroList.Count-1 do + begin + if (MacroList[i]^.flags and ACF_ASSIGNED)<>0 then + begin + found:=false; + for j:=0 to EditMacroList.Count-1 do + begin + if (EditMacroList[j]^.flags and ACF_ASSIGNED)<>0 then + begin + if MacroList[i]^.id=EditMacroList[j]^.id then + begin + found:=true; + break; + end; + end; + end; + if not found then break; end; end; - result:=NoChainText; + if not found then + result:=result or ACTM_DELETE; + // 3 - resort? (maybe ANY EditMacroList position changes) +end; + +procedure SetChanged(wnd:HWND;atype:integer); +begin + SendMessage(GetParent(wnd),PSM_CHANGED,0,0); +// if ((atype and etMacro)<>0) and (NewGroupList =GroupList ) then NewGroupList :=CloneGroupList; +// if ((atype and etACT )<>0) and (NewActionList=ActionList) then NewActionList:=CloneActionList; +end; + +procedure SetStart; +begin + EditMacroList:=MacroList.Clone(); +end; + +// Cancel button pressed OR Edit window closed (After apply action) +// No main list changed (except flags clearance - not necessary) +// Edit macro list freeing with actions marked as introduced +procedure SetCancel; +var + i,j:integer; +begin + // Delete changed data + EditMacroList.Clear(ACF_INTRODUCED); + EditMacroList.Free; + + // Clear editing flags + for i:=0 to MacroList.Count-1 do + begin + with MacroList[i]^ do + if (flags and ACF_ASSIGNED)<>0 then + begin + for j:=0 to ActionCount-1 do + begin + ActionList^[j].flags:=ActionList^[j].flags and not ACF_REPLACED; + end; + end; + end; end; -function AddGroup(Dialog:HWND;HKnum:dword):integer; +// SAVE: fill edit macro list by dialog options, +// Free main macro list with actions marked as replaced +// copy content to main macro list (state as at option editing start) +// clear "introduced" and "replaced" flags +procedure SetSave(Dialog:HWND); var + i,j:integer; + TmpMacroList:tMacroList; + TmpMacroCount:integer; + wnd:HWND; li:LV_ITEMW; - list:HWND; begin - with NewGroupList^[HKnum] do + wnd:=MacroListWindow; + TmpMacroCount:=SendMessageW(wnd,LVM_GETITEMCOUNT,0,0); + + // need to clear flags and resort + if TmpMacroCount>0 then begin - if (flags and ACF_ASSIGNED)<>0 then + // Clear actions editing flags + for i:=0 to EditMacroList.Count-1 do + begin + with EditMacroList[i]^ do + if (flags and ACF_ASSIGNED)<>0 then + begin + for j:=0 to ActionCount-1 do + begin + ActionList^[j].flags:=ActionList^[j].flags and not ACF_INTRODUCED; + end; + end; + end; + + TmpMacroList:=tMacroList.Create(TmpMacroCount); + + // resort/copy macros + li.mask :=LVIF_PARAM; + li.iSubItem:=0; + for i:=0 to TmpMacroCount-1 do begin - list:=GetDlgItem(Dialog,IDC_ACTION_GROUP); - li.mask :=LVIF_PARAM+LVIF_TEXT; - li.iItem :=SendMessage(list,LVM_GETNEXTITEM,-1,LVNI_FOCUSED)+1; - li.iSubItem :=0; - li.lParam :=HKnum; - if descr=nil then - li.pszText:=NoDescription + li.iItem:=i; + SendMessageW(wnd,LVM_GETITEMW,0,lparam(@li)); // GetLParam(wnd,i); + move(EditMacroList[loword(li.lParam)]^,TmpMacroList[i]^,SizeOf(tMacroRecord)); + if (li.lParam and ACF_FIRSTRUN)<>0 then + TmpMacroList[i]^.flags:=TmpMacroList[i]^.flags or ACF_FIRSTRUN else - li.pszText:=descr; - li.iItem :=SendMessageW(list,LVM_INSERTITEMW,0,lparam(@li)); - if li.iItem>0 then - dec(li.iItem); - ListView_SetItemState(list,li.iItem,LVIS_FOCUSED or LVIS_SELECTED, - LVIS_FOCUSED or LVIS_SELECTED); - result:=li.iItem; - end - else - result:=-1; + TmpMacroList[i]^.flags:=TmpMacroList[i]^.flags and not ACF_FIRSTRUN; + li.lParam:=(li.lParam and (not $FFFF)) or i; + SendMessageW(wnd,LVM_SETITEMW,0,lparam(@li)); + end; + + EditMacroList.Free; + EditMacroList:=TmpMacroList; end; + + MacroList.Clear(ACF_REPLACED); + MacroList.Free; + MacroList:=EditMacroList.Clone; end; // Fill action type combobox -procedure FillActTypeList(list:hwnd); +function FillActTypeList(list:HWND):HWND; var cbei:TCOMBOBOXEXITEMW; il:HIMAGELIST; i:integer; buf:array [0..127] of WideChar; + p:pActModule; + rc:TRECT; + dlg:HWND; begin - SendMessage(list,CB_RESETCONTENT,0,0); il:=ImageList_Create(16,16,ILC_COLOR32 or ILC_MASK,0,1); + SendMessage(list,CB_RESETCONTENT,0,0); - cbei.mask:=CBEIF_IMAGE or CBEIF_SELECTEDIMAGE or CBEIF_TEXT; //!! - for i:=0 to ACT_MAXTYPE-1 do + FillChar(cbei,SizeOf(cbei),0); + cbei.mask:=CBEIF_IMAGE or CBEIF_SELECTEDIMAGE or CBEIF_TEXT or CBEIF_LPARAM; + p:=ModuleLink; + i:=0; + // initial action dialogs position + SetRect(rc,134,22,0,0); + dlg:=GetParent(list); + MapDialogRect(dlg,rc); + while p<>nil do begin - ImageList_AddIcon(il,CallService(MS_SKIN2_GETICON,0,lparam(ActIds[i].icon))); + StrCopy(StrCopyE(@buf,IcoLibPrefix),p^.Name); + ImageList_ReplaceIcon(il,-1,CallService(MS_SKIN2_GETICON,0,lparam(@buf))); - cbei.pszText :=TranslateW(FastAnsiToWideBuf(ActIds[i].text,buf)); + cbei.pszText :=TranslateW(FastAnsiToWideBuf(p^.Name,buf)); cbei.iItem :=i; + cbei.lParam :=p^.Hash; cbei.iImage :=i; cbei.iSelectedImage:=i; - if SendMessageW(list,CBEM_INSERTITEMW,0,lparam(@cbei))=-1 then break; + if SendMessageW(list,CBEM_INSERTITEMW,0,lparam(@cbei))=-1 then + break; + p^.DlgHandle:=p^.Dialog(dlg); + SetWindowPos(p^.DlgHandle,0,rc.left,rc.top,0,0,SWP_NOZORDER or SWP_NOSIZE or SWP_HIDEWINDOW); + p:=p^.Next; + inc(i); end; ImageList_Destroy(SendMessage(list,CBEM_SETIMAGELIST,0,il)); + SendMessage(list,CB_SETCURSEL,0,0); + result:=GetLink(CB_GetData(list,0))^.DlgHandle; +end; + +//----- Action list stuff ----- + +procedure SHActButtons(Dialog:HWND;mode:integer); +begin + ShowWindow(GetDlgItem(Dialog,IDC_STAT_ACTION),mode); + ShowWindow(GetDlgItem(Dialog,IDC_ACTION_TYPE),mode); + if mode=SW_HIDE then + ClearDialogData; +end; + +procedure CheckActListDirectionButtons(Dialog:HWND); +var + wnd:HWND; + dir:integer; + okup,okdown:boolean; +begin + wnd:=ActionListWindow; + + dir:=LV_CheckDirection(wnd); + okup :=odd(loword(dir)); + okdown:=(loword(dir) and 2)<>0; + + EnableWindow(GetDlgItem(Dialog,IDC_ACTION_UP ),okup); + EnableWindow(GetDlgItem(Dialog,IDC_ACTION_DOWN),okdown); + SendMessage(wnd,LVM_ENSUREVISIBLE,hiword(dir)-1,0); +end; + +procedure CheckActListButtons(Dialog:HWND); +var + mode:integer; + wnd:HWND; + b:boolean; +begin + wnd:=ActionListWindow; + b:=SendMessage(wnd,LVM_GETITEMCOUNT,0,0)>0; + if b then +{ + ListView_SetItemState(wnd,next, + LVIS_FOCUSED or LVIS_SELECTED, + LVIS_FOCUSED or LVIS_SELECTED); +} + mode:=SW_SHOW + else + mode:=SW_HIDE; + + SHActButtons(Dialog,mode); + + EnableWindow(wnd,b); + EnableWindow(GetDlgItem(Dialog,IDC_ACTION_HELP ),b); + EnableWindow(GetDlgItem(Dialog,IDC_GROUP_TEST ),b); + EnableWindow(GetDlgItem(Dialog,IDC_ACTION_DELETE),b); + EnableWindow(GetDlgItem(Dialog,IDC_ACTION_TYPE ),b); + + CheckActListDirectionButtons(Dialog); +end; + +// Fill dialog fields by choosen action +procedure FillAction(Dialog:HWND;act:tBaseAction); +var + p:pActModule; + i:LRESULT; + wnd:HWND; +begin + if act<>nil then + begin + p:=GetLink(act.UID); + if p<>nil then + SendMessage(p^.DlgHandle,WM_ACT_SETVALUE,0,tlparam(act)); + end + // for newly added and activated action + else + p:=ModuleLink; + + if p<>nil then + begin + wnd:=GetDlgItem(Dialog,IDC_ACTION_TYPE); + i:=CB_SelectData(wnd,tlparam(p^.Hash)); + ShowWindow(p^.DlgHandle,SW_SHOW); + // Saving "normal" action type + if p^.Hash>10 then + begin + SetWindowLongPtrW(wnd,GWLP_USERDATA,i); + end; + end; end; -procedure FillSubList(Dialog:hwnd); +// Fill Chain list +procedure FillActionList(Dialog:HWND;Macro:pMacroRecord); var - list,wnd:HWND; - i,act:integer; - arr:array [0..127] of WideChar; + idx:integer; + wnd:HWND; li:LV_ITEMW; begin - wnd:=GetDlgItem(Dialog,IDC_ADV_VAL2); + wnd:=ActionListWindow; + SendMessage(wnd,LVM_DELETEALLITEMS,0,0); - SendMessage(wnd,CB_RESETCONTENT,0,0); + if (Macro<>nil) and (Macro^.ActionCount>0) then + begin + li.mask :=LVIF_TEXT or LVIF_PARAM; + li.iSubitem:=0; + idx:=0; + while idx=0 then + begin + li.iSubItem:=0; + // getting SubAction number + li.mask:=LVIF_PARAM; + SendMessage(wnd,LVM_GETITEM,0,tlparam(@li)); + + // changing to default name + if str=nil then + begin + str:=StrCopyEW(@buf,TranslateW('Action')); + str^:=' '; inc(str); + IntToStr(str,SendMessage(wnd,LVM_GETITEMCOUNT,0,0)); + str:=@buf; + end; + + li.mask :=LVIF_TEXT; + li.pszText:=str; + SendMessageW(wnd,LVM_SETITEMW,0,tlparam(@li)); + end; +end; + +procedure SaveAction(Dialog:HWND;listnum:integer;actptr:tBaseAction); +var + wnd:HWND; +// li:LV_ITEMW; +// arr: array [0..255] of WideChar; + p:pActModule; +begin + wnd:=GetDlgItem(Dialog,IDC_ACTION_TYPE); + p:=GetLink(CB_GetData(wnd)); + if p^.Hash<10 then + begin + p:=GetLink(CB_GetData(wnd,GetWindowLongPtrW(wnd,GWLP_USERDATA))); + end; + + wnd:=ActionListWindow; + + if listnum<0 then + begin + listnum:=SendMessageW(wnd,LVM_GETNEXTITEM,-1,LVNI_FOCUSED); + if listnum<0 then + exit; + actptr:=tBaseAction(LV_GetLParam(wnd,listnum)); + end; + + // changed existing action + if actptr<>nil then + begin + if (actptr.flags and ACF_INTRODUCED)<>0 then // new but changed + actptr.Free + else // old + actptr.flags:=actptr.flags or ACF_REPLACED; + end; + + // Action saving + actptr:=p.Create; + SendMessage(p.DlgHandle,WM_ACT_SAVE,0,tlparam(actptr)); + actptr.flags:=actptr.flags or ACF_INTRODUCED; +{ maybe do it at full chain saving? + + li.iItem :=listnum; li.mask :=LVIF_TEXT; li.iSubItem :=0; li.pszText :=@arr; li.cchTextMax:=SizeOf(arr) div SizeOf(WideChar); - while i=0 then // we have macro to save begin - if (NewGroupList^[i].flags and (ACF_ASSIGNED or ACF_VOLATILE))=ACF_ASSIGNED then + SaveAction(Dialog,-1,nil); + + with EditMacroList[idx]^ do + begin + if ActionCount>0 then + begin + ActionCount:=0; + FreeMem(ActionList); + ActionList:=nil; + end; + end; + + wnd:=ActionListWindow; + with EditMacroList[idx]^ do begin - SendMessage(wnd,CB_SETITEMDATA, - SendMessageW(wnd,CB_ADDSTRING,0,lparam(NewGroupList^[i].descr)), - NewGroupList^[i].id); + ActionCount:=SendMessageW(wnd,LVM_GETITEMCOUNT,0,0); + if ActionCount>0 then // have some actions - need to build list + begin + // fix count for empty actions + item:=0; + idx:=0; + while item0 then + Inc(idx); + Inc(item); + end; + // if REAL amount to save>0 (macro not empty) + if idx>0 then + begin + GetMem(ActionList,SizeOf(tBaseAction)*idx); + + li.mask :=LVIF_TEXT; + li.iSubItem :=0; + li.pszText :=@arr; + li.cchTextMax:=SizeOf(arr) div SizeOf(WideChar); + + idx:=0; + for item:=0 to ActionCount-1 do + begin + ActionList^[idx]:=tBaseAction(LV_GetLParam(wnd,item)); + if ActionList^[idx]<>nil then + begin + // set name and enabled/disabled flag + li.iItem:=item; + SendDlgItemMessageW(Dialog,IDC_ACTION_LIST,LVM_GETITEMW,0,tlparam(@li)); + mFreeMem(ActionList^[idx].ActionDescr); + StrDupW(ActionList^[idx].ActionDescr,arr); + + if ListView_GetCheckState(wnd,item)=0 then + ActionList^[idx].flags:=ActionList^[item].flags or ACF_DISABLED + else + ActionList^[idx].flags:=ActionList^[item].flags and not ACF_DISABLED; + inc(idx); + end; + end; + end; + ActionCount:=idx; // fix for empty actions + end; end; end; end; -// action group table procedure (key hook) -function NewGroupTableProc(Dialog:HWnd;hMessage:uint;wParam:WPARAM;lParam:LPARAM):lresult; stdcall; +// action (chain) table procedure (key hook) +function NewActTableProc(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; var i:integer; begin @@ -200,37 +545,39 @@ begin PostMessageW(Dialog,LVM_EDITLABELW,i,0); exit; end; - VK_INSERT: begin - PostMessage(GetParent(Dialog),WM_COMMAND,(BN_CLICKED shl 16)+IDC_GROUP_NEW,0); - exit; - end; - VK_DELETE: begin - PostMessage(GetParent(Dialog),WM_COMMAND,(BN_CLICKED shl 16)+IDC_GROUP_DELETE,0); - exit; - end; VK_UP: begin if (GetKeyState(VK_CONTROL) and $8000)<>0 then begin - PostMessage(GetParent(Dialog),WM_COMMAND,(BN_CLICKED shl 16)+IDC_GROUP_UP,0); + PostMessage(GetParent(Dialog),WM_COMMAND,(BN_CLICKED shl 16)+IDC_ACTION_UP,0); exit; end; end; VK_DOWN: begin if (GetKeyState(VK_CONTROL) and $8000)<>0 then begin - PostMessage(GetParent(Dialog),WM_COMMAND,(BN_CLICKED shl 16)+IDC_GROUP_DOWN,0); + PostMessage(GetParent(Dialog),WM_COMMAND,(BN_CLICKED shl 16)+IDC_ACTION_DOWN,0); exit; end; end; + VK_INSERT: begin + PostMessage(GetParent(Dialog),WM_COMMAND,(BN_CLICKED shl 16)+IDC_ACTION_NEW,0); + exit; + end; + VK_DELETE: begin + PostMessage(GetParent(Dialog),WM_COMMAND,(BN_CLICKED shl 16)+IDC_ACTION_DELETE,0); + exit; + end; end; end; end; end; - result:=CallWindowProc(OldGroupTableProc,Dialog,hMessage,wParam,lParam); + result:=CallWindowProc(OldActTableProc,Dialog,hMessage,wParam,lParam); end; -// action (chain) table procedure (key hook) -function NewActTableProc(Dialog:HWnd;hMessage:uint;wParam:WPARAM;lParam:LPARAM):lresult; stdcall; +//----- Macro list stuff ----- + +// action group table procedure (key hook) +function NewGroupTableProc(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; var i:integer; begin @@ -246,197 +593,59 @@ begin PostMessageW(Dialog,LVM_EDITLABELW,i,0); exit; end; + VK_INSERT: begin + PostMessage(GetParent(Dialog),WM_COMMAND,(BN_CLICKED shl 16)+IDC_GROUP_NEW,0); + exit; + end; + VK_DELETE: begin + PostMessage(GetParent(Dialog),WM_COMMAND,(BN_CLICKED shl 16)+IDC_GROUP_DELETE,0); + exit; + end; VK_UP: begin if (GetKeyState(VK_CONTROL) and $8000)<>0 then begin - PostMessage(GetParent(Dialog),WM_COMMAND,(BN_CLICKED shl 16)+IDC_ACTION_UP,0); + PostMessage(GetParent(Dialog),WM_COMMAND,(BN_CLICKED shl 16)+IDC_GROUP_UP,0); exit; end; end; VK_DOWN: begin if (GetKeyState(VK_CONTROL) and $8000)<>0 then begin - PostMessage(GetParent(Dialog),WM_COMMAND,(BN_CLICKED shl 16)+IDC_ACTION_DOWN,0); + PostMessage(GetParent(Dialog),WM_COMMAND,(BN_CLICKED shl 16)+IDC_GROUP_DOWN,0); exit; end; end; - VK_INSERT: begin - PostMessage(GetParent(Dialog),WM_COMMAND,(BN_CLICKED shl 16)+IDC_ACTION_NEW,0); - exit; - end; - VK_DELETE: begin - PostMessage(GetParent(Dialog),WM_COMMAND,(BN_CLICKED shl 16)+IDC_ACTION_DELETE,0); - exit; - end; end; end; end; end; - result:=CallWindowProc(OldActTableProc,Dialog,hMessage,wParam,lParam); + result:=CallWindowProc(OldGroupTableProc,Dialog,hMessage,wParam,lParam); end; -// miranda button icon paint -procedure SetButtonIcons2(Dialog:HWND); +function AddMacro(Dialog:HWND;MacroNum:cardinal):integer; var - ti:TTOOLINFOW; - hwndTooltip:HWND; + li:LV_ITEMW; + list:HWND; begin - hwndTooltip:=CreateWindowW(TOOLTIPS_CLASS,nil,TTS_ALWAYSTIP, - integer(CW_USEDEFAULT),integer(CW_USEDEFAULT), - integer(CW_USEDEFAULT),integer(CW_USEDEFAULT), - Dialog,0,hInstance,nil); + with EditMacroList[MacroNum]^ do + begin + list:=MacroListWindow; + li.mask :=LVIF_PARAM+LVIF_TEXT; + li.iItem :=SendMessage(list,LVM_GETNEXTITEM,-1,LVNI_FOCUSED)+1; + li.iSubItem :=0; + li.lParam :=MacroNum; + li.pszText :=@descr; + li.iItem :=SendMessageW(list,LVM_INSERTITEMW,0,lparam(@li)); + if li.iItem>0 then + dec(li.iItem); + ListView_SetItemState(list,li.iItem, + LVIS_FOCUSED or LVIS_SELECTED, + LVIS_FOCUSED or LVIS_SELECTED); + result:=li.iItem; + end; +end; - FillChar(ti,SizeOf(ti),0); - ti.cbSize :=sizeof(TOOLINFO); - ti.uFlags :=TTF_IDISHWND or TTF_SUBCLASS; - ti.hwnd :=Dialog; - ti.hinst :=hInstance; - - ti.uId :=GetDlgItem(Dialog,IDC_ACTION_HELP); - ti.lpszText:=TranslateW('Help'); - SendMessage(ti.uId,BM_SETIMAGE,IMAGE_ICON, - CallService(MS_SKIN_LOADICON,SKINICON_OTHER_HELP,0)); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); - - ti.uId :=GetDlgItem(Dialog,IDC_ACTION_NEW); - ti.lpszText:=TranslateW('New'); - SetButtonIcon(ti.uId,ACI_NEW); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); - - ti.uId :=GetDlgItem(Dialog,IDC_GROUP_NEW); - SetButtonIcon(ti.uId,ACI_NEW); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); - - ti.uId :=GetDlgItem(Dialog,IDC_ACTION_UP); - ti.lpszText:=TranslateW('Up'); - SetButtonIcon(ti.uId,ACI_UP); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); - - ti.uId :=GetDlgItem(Dialog,IDC_GROUP_UP); - SetButtonIcon(ti.uId,ACI_UP); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); - - ti.uId :=GetDlgItem(Dialog,IDC_ACTION_DOWN); - ti.lpszText:=TranslateW('Down'); - SetButtonIcon(ti.uId,ACI_DOWN); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); - - ti.uId :=GetDlgItem(Dialog,IDC_GROUP_DOWN); - SetButtonIcon(ti.uId,ACI_DOWN); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); - - ti.uId :=GetDlgItem(Dialog,IDC_ACTION_DELETE); - ti.lpszText:=TranslateW('Delete'); - SetButtonIcon(ti.uId,ACI_DELETE); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); - - ti.uId :=GetDlgItem(Dialog,IDC_GROUP_DELETE); - SetButtonIcon(ti.uId,ACI_DELETE); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); - - ti.uId :=GetDlgItem(Dialog,IDC_GROUP_RELOAD); - ti.lpszText:=TranslateW('Reload'); - SetButtonIcon(ti.uId,ACI_RELOAD); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); - - ti.uId :=GetDlgItem(Dialog,IDC_GROUP_TEST); - ti.lpszText:=TranslateW('Test'); - SetButtonIcon(ti.uId,ACI_TEST); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); - - ti.uId :=GetDlgItem(Dialog,IDC_CNT_APPLY); - ti.lpszText:=TranslateW('Apply format'); - SetButtonIcon(ti.uId,ACI_FORMAT); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); - - ti.uId :=GetDlgItem(Dialog,IDC_GROUP_IMPORT); - ti.lpszText:=TranslateW('Import'); - SetButtonIcon(ti.uId,ACI_IMPORT); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); - - ti.uId :=GetDlgItem(Dialog,IDC_GROUP_EXPORT); - ti.lpszText:=TranslateW('Export'); - SetButtonIcon(ti.uId,ACI_EXPORT); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); - - ti.lpszText:=TranslateW('Use Variables'); - ti.uId:=GetDlgItem(Dialog,IDC_SRV_WPAR); - SetButtonIcon(ti.uId,ACI_VAR_UNCHECKED); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); - -{ - pc:=TranslateW(''); - wnd:=GetDlgItem(Dialog,IDC_NEW); - SendMessage(hNew,BUTTONADDTOOLTIP,TWPARAM(pc),BATF_UNICODE); - SetButtonIcon(wnd,QS_NEW); -} - ti.uId:=GetDlgItem(Dialog,IDC_SRV_LPAR); - SetButtonIcon(ti.uId,ACI_VAR_UNCHECKED); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); - - ti.uId:=GetDlgItem(Dialog,IDC_SRV_SRVC); - SetButtonIcon(ti.uId,ACI_VAR_UNCHECKED); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); - - ti.uId:=GetDlgItem(Dialog,IDC_PRG_PRG); - SetButtonIcon(ti.uId,ACI_VAR_UNCHECKED); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); - - ti.uId:=GetDlgItem(Dialog,IDC_PRG_ARG); - SetButtonIcon(ti.uId,ACI_VAR_UNCHECKED); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); - - ti.uId:=GetDlgItem(Dialog,IDC_TXT_FILE); - SetButtonIcon(ti.uId,ACI_VAR_UNCHECKED); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); - - ti.uId:=GetDlgItem(Dialog,IDC_TXT_TEXT); - SetButtonIcon(ti.uId,ACI_VAR_UNCHECKED); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); - - ti.uId:=GetDlgItem(Dialog,IDC_RW_MVAR); - SetButtonIcon(ti.uId,ACI_VAR_UNCHECKED); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); - - ti.uId:=GetDlgItem(Dialog,IDC_RW_SVAR); - SetButtonIcon(ti.uId,ACI_VAR_UNCHECKED); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); - - ti.uId:=GetDlgItem(Dialog,IDC_RW_TVAR); - SetButtonIcon(ti.uId,ACI_VAR_UNCHECKED); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); - - ti.uId:=GetDlgItem(Dialog,IDC_MSG_TTL); - SetButtonIcon(ti.uId,ACI_VAR_UNCHECKED); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); - - ti.uId:=GetDlgItem(Dialog,IDC_MSG_TXT); - SetButtonIcon(ti.uId,ACI_VAR_UNCHECKED); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); - -end; - -function MoveLVItem(list:HWND;num:integer;incr:integer):integer; -var - li:LV_ITEM; - buf:array [0..127] of WideChar; -begin - li.mask :=LVIF_PARAM+LVIF_STATE+LVIF_TEXT; - li.iItem :=num; - li.iSubItem :=0; - li.StateMask :=dword(-1); - li.pszText :=@buf; - li.cchTextMax:=127; - SendMessageW(list,LVM_GETITEMW,0,lparam(@li)); - SendMessageW(list,LVM_DELETEITEM,li.iItem,0); - inc(li.iItem,incr); - - SendMessageW(list,LVM_INSERTITEMW,0,lparam(@li)); - SendMessageW(list,LVM_SETITEMSTATE,li.iItem,lparam(@li)); - result:=li.iItem; -end; - -function MoveGroup(list:HWND;num:integer=-1;incr:integer=0):integer; +function MoveMacro(list:HWND;num:integer;incr:integer):integer; var i,j:integer; begin @@ -450,9 +659,8 @@ begin begin if SendMessage(list,LVM_GETITEMSTATE,i,LVIS_SELECTED)<>0 then begin - if i=0 then break; + if i=0 then break; // first selected is first already, nothing to move LV_MoveItem(list,incr,i); -// MoveLVItem(list,i,incr); if result<0 then result:=i+incr; end; end; @@ -463,1076 +671,297 @@ begin begin if SendMessage(list,LVM_GETITEMSTATE,i,LVIS_SELECTED)<>0 then begin - if i=j then break; + if i=j then break; // last selected is last already, nothing to move LV_MoveItem(list,incr,i); -// MoveLVItem(list,i,incr); if result<0 then result:=i+incr; end; end; end; - end - else - begin - MoveLVItem(list,num,incr); - result:=num; - end; -end; - -{$include i_dlglists.inc} - -procedure SetNumValue(wnd:HWND;value:dword;isvar:boolean;ishex:boolean); -var - buf:array [0..31] of WideChar; -begin - if isvar then - SendMessageW(wnd,WM_SETTEXT,0,value) - else if ishex then - begin - buf[0]:='$'; - IntToHex(PWideChar(@buf[1]),value); - SendMessageW(wnd,WM_SETTEXT,0,tlparam(@buf)); - end - else - SendMessageW(wnd,WM_SETTEXT,0,tlparam(IntToStr(buf,value))); -end; - -function DlgProcOpt2(Dialog:HWnd;hMessage:uint;wParam:WPARAM;lParam:LPARAM):lresult; stdcall; - - {$include i_visual.inc} - - procedure ShowHelp(code:integer); - var - buf:PAnsiChar; - vhi:TVARHELPINFO; - begin - case code of - hlpVariables: begin - FillChar(vhi,SizeOf(vhi),0); - with vhi do - begin - cbSize:=SizeOf(vhi); - flags:=VHF_NOINPUTDLG; - end; - CallService(MS_VARS_SHOWHELPEX,Dialog,tlparam(@vhi)); - end; - hlpAdvVariables: begin - FillChar(vhi,SizeOf(vhi),0); - with vhi do - begin - cbSize :=SizeOf(vhi); - flags :=VHF_FULLDLG or VHF_SETLASTSUBJECT; - hwndCtrl :=GetDlgItem(Dialog,IDC_ADV_VARS); - szSubjectDesc:='test your variables'; - end; - CallService(MS_VARS_SHOWHELPEX,Dialog,tlparam(@vhi)); - end; - hlpContact: begin - MessageBoxW(0, - TranslateW('Select contact to open its window'), - TranslateW('Contacts'),0); - end; - hlpService: begin - buf:=GetDlgText(Dialog,IDC_EDIT_SERVICE,true); -//!! if buf<>nil then - begin - ApiCard.Service:=buf; - mFreeMem(buf); - ApiCard.Show; - end; - end; - hlpProgram: begin - MessageBoxW(0, - TranslateW('Text replacing'#13#10+ - 'by last result'#13#10#13#10+ - 'Text replacing'#13#10+ - 'by parameter'), - TranslateW('Text'),0); - end; - hlpText: begin - MessageBoxW(0, - TranslateW('^s - selected (and replaced) part'#13#10+ - '^e - replaced by empty string'#13#10+ - '^v - paste text from Clipboard'#13#10+ - '^t - replaced by tabulation'#13#10+ - '^l - replaced by last result as unicode'#13#10+ - '^h - replaced by last result as hex'#13#10+ - '^a - in the end: autosend'#13#10+ - '^f(name[,str])'#13#10+ - ' paste line from text file.'#13#10+ - ' brackets contents must be w/o spaces'), - TranslateW('Text'),0); - end; - hlpAdvance: begin - end; - hlpChain: begin - MessageBoxW(0, - TranslateW('You can select another group from combobox, '+ - 'then it will be executed, after that current '+ - 'action group will be continued.'), - TranslateW('Macros'),0); - end; - hlpDBRW: begin - end; - hlpMessage: begin - MessageBoxW(0, - TranslateW( - 'Text replacing'#13#10+ - 'by last result'#13#10#13#10+ - 'Returns:'#13#10+ - '--------'#13#10+ - 'OK'#9'= 1'#13#10+ - 'CANCEL'#9'= 2'#13#10+ - 'ABORT'#9'= 3'#13#10+ - 'RETRY'#9'= 4'#13#10+ - 'IGNORE'#9'= 5'#13#10+ - 'YES'#9'= 6'#13#10+ - 'NO'#9'= 7'#13#10+ - 'CLOSE'#9'= 8'), - TranslateW('MessageBox'),0); - end; - end; - end; - - // enable/disable navigation chain buttons - procedure CheckGrpList(num:integer=-1); - var - wnd:HWND; - dir:integer; - okup,okdown:boolean; - begin - wnd:=GetDlgItem(Dialog,IDC_ACTION_GROUP); -// if num<0 then - begin - dir:=LV_CheckDirection(wnd); - okup :=odd(loword(dir)); - okdown:=(loword(dir) and 2)<>0; - end; -{ - else - begin - okup :=num>0; - okdown:=(num+1)0); - EnableWindow(GetDlgItem(Dialog,IDC_GROUP_DOWN), - (num+1)0; - end; -{ - else - begin - okup :=num>0; - okdown:=(num+1)0); - EnableWindow(GetDlgItem(Dialog,IDC_ACTION_DOWN), - (num+1)=0 then - begin - li.iSubItem:=0; - // getting SubAction number - li.mask:=LVIF_PARAM; - SendMessage(wnd,LVM_GETITEM,0,tlparam(@li)); - - // changing to default name - if str=nil then - begin - if num>=0 then // new item - screen only - str1:=TranslateW(ActionNames[ACT_CONTACT]) - else // change action type - begin - str1:=NewActionList[li.lParam].descr; - if str1=nil then // not in memory yet - str1:=TranslateW(ActionNames[acttype]) - else - exit; - end; - end - else // rename - begin - str1:=str; - mFreeMem(NewActionList[li.lParam].descr); - StrDupW (NewActionList[li.lParam].descr,str); - end; - -// screen - li.mask :=LVIF_TEXT; - li.pszText:=str1; - SendMessageW(wnd,LVM_SETITEMW,0,tlparam(@li)); - end; - end; - - // Fill Chain list - procedure MakeActionList(HK:pHKRecord); - var - i,idx:integer; - wnd:HWND; - li:LV_ITEMW; - p:pWideChar; - begin - wnd:=GetDlgItem(Dialog,IDC_ACTION_LIST); - SendMessage(wnd,LVM_DELETEALLITEMS,0,0); - - EnableWindow(GetDlgItem(Dialog,IDC_ACTION_UP),false); - if (HK=nil) or (HK^.firstAction=0) then - begin - SHWindows; - SHActButtons(SW_HIDE); - EnableWindow(GetDlgItem(Dialog,IDC_ACTION_LIST ),false); - EnableWindow(GetDlgItem(Dialog,IDC_GROUP_TEST ),false); - EnableWindow(GetDlgItem(Dialog,IDC_ACTION_HELP ),false); - EnableWindow(GetDlgItem(Dialog,IDC_ACTION_DELETE),false); - EnableWindow(GetDlgItem(Dialog,IDC_ACTION_DOWN ),false); - exit; - end; - SHActButtons(SW_SHOW); - - li.mask :=LVIF_TEXT or LVIF_PARAM; - li.iSubitem:=0; - i:=HK^.firstAction; - idx:=0; - repeat - p:=NewActionList^[i].descr; - if p=nil then - p:=TranslateW(ActionNames[NewActionList^[i].actionType]); - li.pszText:=p; - li.iItem :=idx; - li.lParam :=i; - SendMessageW(wnd,LVM_INSERTITEMW,0,tlparam(@li)); - ListView_SetCheckState(wnd,idx,(NewActionList^[i].flags and ACF_DISABLED)=0); - - i:=NewActionList^[i].next; - inc(idx); - until i=0; - - Listview_SetItemState(wnd,0, - LVIS_FOCUSED or LVIS_SELECTED, - LVIS_FOCUSED or LVIS_SELECTED); - EnableWindow(GetDlgItem(Dialog,IDC_ACTION_LIST ),true); - EnableWindow(GetDlgItem(Dialog,IDC_GROUP_TEST ),true); - EnableWindow(GetDlgItem(Dialog,IDC_ACTION_HELP ),true); - EnableWindow(GetDlgItem(Dialog,IDC_ACTION_DELETE),true); - EnableWindow(GetDlgItem(Dialog,IDC_ACTION_DOWN),idx>1); -// FillSubList(Dialog); - FillAction(HK^.firstAction); - CheckActList(0); - end; - - procedure SaveAction(listnum,actnum:integer); - var - wnd:HWND; - i:integer; - tmp:pWideChar; - arr: array [0..255] of WideChar; - li:LV_ITEMW; - begin - if (ChMask and ACTM_ACT)=0 then exit; - ChMask:=ChMask and not ACTM_ACT; - wnd:=GetDlgItem(Dialog,IDC_ACTION_LIST); - if listnum<0 then - begin - listnum:=SendMessageW(wnd,LVM_GETNEXTITEM,-1,LVNI_FOCUSED); - if listnum<0 then - exit; - end; - if actnum<0 then - actnum:=LV_GetLParam(wnd,listnum); - StrDupW(tmp,NewActionList^[actnum].descr); // keeping old name - FreeAction(@NewActionList^[actnum]); - with NewActionList^[actnum] do - begin - flags :=ACF_ASSIGNED; - flags2:=0; - - descr:=tmp; - if descr=nil then - begin - li.iItem :=listnum; - li.mask :=LVIF_TEXT; - li.iSubItem :=0; - li.pszText :=@arr; - li.cchTextMax:=SizeOf(arr) div SizeOf(WideChar); - SendDlgItemMessageW(Dialog,IDC_ACTION_LIST,LVM_GETITEMW,0,tlparam(@li)); - StrDupW(descr,arr); - end; - - if ListView_GetCheckState(wnd,listnum)=0 then - flags:=flags or ACF_DISABLED; - - actionType:=ActIds[SendDlgItemMessage(Dialog,IDC_ACTION_TYPE,CB_GETCURSEL,0,0)].code; - case actionType of - ACT_CONTACT: begin - contact:=SendDlgItemMessage(Dialog,IDC_CONTACTLIST,CB_GETITEMDATA, - SendDlgItemMessage(Dialog,IDC_CONTACTLIST,CB_GETCURSEL,0,0),0); - if IsDlgButtonChecked(Dialog,IDC_CNT_KEEP)=BST_CHECKED then - flags:=flags or ACF_KEEPONLY; - end; - - ACT_SERVICE: begin - if IsDlgButtonChecked(Dialog,IDC_SRV_WPAR)=BST_CHECKED then - flags2:=flags2 or ACF2_SRV_WPAR; - if IsDlgButtonChecked(Dialog,IDC_SRV_LPAR)=BST_CHECKED then - flags2:=flags2 or ACF2_SRV_LPAR; - if IsDlgButtonChecked(Dialog,IDC_SRV_SRVC)=BST_CHECKED then - flags2:=flags2 or ACF2_SRV_SRVC; - - case CB_GetData(GetDlgItem(Dialog,IDC_FLAG_WPAR)) of - ptParam: begin - flags:=flags or ACF_WPARAM - end; - ptResult: begin - flags:=flags or ACF_WRESULT - end; - ptCurrent: begin - flags:=flags or ACF_WPARNUM or ACF_WCURRENT - end; - ptNumber: begin - flags:=flags or ACF_WPARNUM; - if GetNumValue(GetDlgItem(Dialog,IDC_EDIT_WPAR), - (flags2 and ACF2_SRV_WPAR)<>0,wparam) then - flags2:=flags2 or ACF2_SRV_WHEX; -// wparam:=GetDlgItemInt(Dialog,IDC_EDIT_WPAR,pbool(nil)^,true); - end; - ptStruct: begin - flags:=flags or ACF_WSTRUCT; - StrDup(pAnsiChar(wparam),wstruct); - end; - ptUnicode: begin - flags:=flags or ACF_WUNICODE; - pointer(wparam):=GetDlgText(Dialog,IDC_EDIT_WPAR); - end; - ptString: pointer(wparam):=GetDlgText(Dialog,IDC_EDIT_WPAR,true); - end; - - case CB_GetData(GetDlgItem(Dialog,IDC_FLAG_LPAR)) of - ptParam: begin - flags:=flags or ACF_LPARAM - end; - ptResult: begin - flags:=flags or ACF_LRESULT - end; - ptCurrent: begin - flags:=flags or ACF_LPARNUM or ACF_LCURRENT - end; - ptNumber: begin - flags:=flags or ACF_LPARNUM; - if GetNumValue(GetDlgItem(Dialog,IDC_EDIT_LPAR), - (flags2 and ACF2_SRV_LPAR)<>0,lparam) then - flags2:=flags2 or ACF2_SRV_LHEX; -// lparam:=GetDlgItemInt(Dialog,IDC_EDIT_LPAR,pbool(nil)^,true); - end; - ptStruct: begin - flags:=flags or ACF_LSTRUCT; - StrDup(pAnsiChar(lparam),lstruct); - end; - ptUnicode: begin - flags:=flags or ACF_LUNICODE; - pointer(lparam):=GetDlgText(Dialog,IDC_EDIT_LPAR); - end; - ptString: pointer(lparam):=GetDlgText(Dialog,IDC_EDIT_LPAR,true); - end; - - if IsDlgButtonChecked(Dialog,IDC_RES_INSERT)=BST_CHECKED then - flags:=flags or ACF_INSERT; - if IsDlgButtonChecked(Dialog,IDC_RES_MESSAGE)=BST_CHECKED then - flags:=flags or ACF_MESSAGE; - if IsDlgButtonChecked(Dialog,IDC_RES_POPUP)=BST_CHECKED then - flags:=flags or ACF_POPUP; - - case CB_GetData(GetDlgItem(Dialog,IDC_SRV_RESULT)) of - sresHex: flags:=flags or ACF_HEX; - sresInt: begin - if IsDlgButtonChecked(Dialog,IDC_RES_SIGNED)=BST_CHECKED then - flags:=flags or ACF_SIGNED; - end; - sresString: begin - flags:=flags or ACF_STRING; - if IsDlgButtonChecked(Dialog,IDC_RES_UNICODE)=BST_CHECKED then - flags:=flags or ACF_UNICODE; - if IsDlgButtonChecked(Dialog,IDC_RES_FREEMEM)=BST_CHECKED then - flags2:=flags2 or ACF2_FREEMEM; - end; - sresStruct: flags:=flags or ACF_STRUCT; - end; - - service:=GetDlgText(Dialog,IDC_EDIT_SERVICE,true); - - end; - - ACT_PROGRAM: begin - prgname:=GetDlgText(Dialog,IDC_EDIT_PRGPATH); - args:=GetDlgText(Dialog,IDC_EDIT_PRGARGS); - if IsDlgButtonChecked(Dialog,IDC_FLAG_PARALLEL)=BST_CHECKED then - flags:=flags or ACF_PRTHREAD; - if IsDlgButtonChecked(Dialog,IDC_FLAG_CURPATH)=BST_CHECKED then - flags:=flags or ACF_CURPATH; - time:=GetDlgItemInt(Dialog,IDC_EDIT_PROCTIME,pbool(nil)^,false); - if IsDlgButtonChecked(Dialog,IDC_FLAG_MINIMIZE)=BST_CHECKED then - show:=SW_SHOWMINIMIZED - else if IsDlgButtonChecked(Dialog,IDC_FLAG_MAXIMIZE)=BST_CHECKED then - show:=SW_SHOWMAXIMIZED - else if IsDlgButtonChecked(Dialog,IDC_FLAG_HIDDEN)=BST_CHECKED then - show:=SW_HIDE - else //if IsDlgButtonChecked(Dialog,IDC_FLAG_NORMAL)=BST_CHECKED then - show:=SW_SHOWNORMAL; - - if IsDlgButtonChecked(Dialog,IDC_PRG_PRG)=BST_CHECKED then - flags2:=flags2 or ACF2_PRG_PRG; - if IsDlgButtonChecked(Dialog,IDC_PRG_ARG)=BST_CHECKED then - flags2:=flags2 or ACF2_PRG_ARG; - end; - - ACT_TEXT: begin - if IsDlgButtonChecked(Dialog,IDC_FLAG_CLIP)<>BST_UNCHECKED then - begin - flags:=flags or ACF_CLIPBRD; - if IsDlgButtonChecked(Dialog,IDC_CLIP_COPYTO)<>BST_UNCHECKED then - flags:=flags or ACF_COPYTO; - end - else - begin - if IsDlgButtonChecked(Dialog,IDC_TXT_TEXT)=BST_CHECKED then - flags2:=flags2 or ACF2_TXT_TEXT; - text:=GetDlgText(Dialog,IDC_EDIT_INSERT); - if IsDlgButtonChecked(Dialog,IDC_FLAG_FILE)<>BST_UNCHECKED then - begin - flags:=flags or ACF_FILE; - case CB_GetData(GetDlgItem(Dialog,IDC_FILE_ENC)) of - 0: flags:=flags or ACF_ANSI; - 1: flags:=flags or ACF_UTF8; - 2: flags:=flags or ACF_UTF8 or ACF_SIGN; - 3: flags:=flags or 0; - 4: flags:=flags or ACF_SIGN; - end; - - if IsDlgButtonChecked(Dialog,IDC_TXT_FILE)=BST_CHECKED then - flags2:=flags2 or ACF2_TXT_FILE; - tfile:=GetDlgText(Dialog,IDC_FILE_PATH); - if IsDlgButtonChecked(Dialog,IDC_FILE_APPEND)<>BST_UNCHECKED then - flags:=flags or ACF_FAPPEND - else if IsDlgButtonChecked(Dialog,IDC_FILE_WRITE)<>BST_UNCHECKED then - flags:=flags or ACF_FWRITE; - end; - end; - end; - - ACT_ADVANCE: begin - condition:=ADV_COND_NOP; - if IsDlgButtonChecked(Dialog,IDC_FLAG_GT )=BST_CHECKED then - condition:=ADV_COND_GT - else if IsDlgButtonChecked(Dialog,IDC_FLAG_LT )=BST_CHECKED then - condition:=ADV_COND_LT - else if IsDlgButtonChecked(Dialog,IDC_FLAG_EQ )=BST_CHECKED then - condition:=ADV_COND_EQ; - value:=GetDlgItemInt(Dialog,IDC_ADV_VALUE,pbool(nil)^,false); - - if IsDlgButtonChecked(Dialog,IDC_FLAG_NOT)=BST_CHECKED then - condition:=condition or ADV_COND_NOT; - - if IsDlgButtonChecked(Dialog,IDC_FLAG_BREAK)=BST_CHECKED then - action:=ADV_ACT_BREAK - else if IsDlgButtonChecked(Dialog,IDC_FLAG_JUMP )=BST_CHECKED then - action:=ADV_ACT_JUMP - else - action:=ADV_ACT_NOP; - - case action of - ADV_ACT_JUMP: operval:=GetDlgText(Dialog,IDC_ADV_VAL2); - end; - - if IsDlgButtonChecked(Dialog,IDC_FLAG_VARS)<>BST_UNCHECKED then - begin - varval:=GetDlgText(Dialog,IDC_ADV_VARS); - action:=action or ADV_ACT_VARS; - if IsDlgButtonChecked(Dialog,IDC_ADV_ASINT)<>BST_UNCHECKED then - flags:=flags or ACF_VARASINT; - end -;{//!!executively!! - else }if IsDlgButtonChecked(Dialog,IDC_FLAG_MATH)=BST_CHECKED then - begin - mathval:=GetDlgItemInt(Dialog,IDC_ADV_VAL1,pbool(nil)^,true); - action :=action or ADV_ACT_MATH; - oper :=CB_GetData(GetDlgItem(Dialog,IDC_ADV_OPER)); -// oper :=SendDlgItemMessage(Dialog,IDC_ADV_OPER,CB_GETCURSEL,0,0); - end; - end; - - ACT_CHAIN: begin - wnd:=GetDlgItem(Dialog,IDC_GROUP_LIST); - i:=SendMessage(wnd,CB_GETCURSEL,0,0); - if i>0 then - id:=SendMessage(wnd,CB_GETITEMDATA,i,0) - else - id:=0; - end; - - ACT_RW: begin - if IsDlgButtonChecked(Dialog,IDC_RW_CURRENT)=BST_CHECKED then - flags:=flags or ACF_CURRENT - else if IsDlgButtonChecked(Dialog,IDC_RW_RESULT)=BST_CHECKED then - flags:=flags or ACF_RESULT - else if IsDlgButtonChecked(Dialog,IDC_RW_PARAM)=BST_CHECKED then - flags:=flags or ACF_PARAM - else - dbcontact:=SendDlgItemMessage(Dialog,IDC_CONTACTLIST,CB_GETITEMDATA, - SendDlgItemMessage(Dialog,IDC_CONTACTLIST,CB_GETCURSEL,0,0),0); - dbmodule :=GetDlgText(Dialog,IDC_RW_MODULE ,true); - dbsetting:=GetDlgText(Dialog,IDC_RW_SETTING,true); - if IsDlgButtonChecked(Dialog,IDC_RW_MVAR)=BST_CHECKED then - flags2:=flags2 or ACF2_RW_MVAR; - if IsDlgButtonChecked(Dialog,IDC_RW_SVAR)=BST_CHECKED then - flags2:=flags2 or ACF2_RW_SVAR; - - if IsDlgButtonChecked(Dialog,IDC_RW_WRITE)=BST_CHECKED then - flags:=flags or ACF_DBWRITE - else if IsDlgButtonChecked(Dialog,IDC_RW_DELETE)=BST_CHECKED then - flags:=flags or ACF_DBDELETE; - - if IsDlgButtonChecked(Dialog,IDC_RW_LAST)=BST_CHECKED then - flags:=flags or ACF_LAST; - - if IsDlgButtonChecked(Dialog,IDC_RW_TVAR)=BST_CHECKED then - flags2:=flags2 or ACF2_RW_TVAR; - - i:=CB_GetData(GetDlgItem(Dialog,IDC_RW_DATATYPE)); - case i of - 0: flags:=flags or ACF_DBBYTE; - 1: flags:=flags or ACF_DBWORD; - 2: flags:=flags or 0; - 3: flags:=flags or ACF_DBANSI; - 4: flags:=flags or ACF_DBUTEXT; - end; - if i<3 then - begin - if (flags and ACF_LAST)=0 then - begin - if GetNumValue(GetDlgItem(Dialog,IDC_RW_VALUE), - (flags2 and ACF2_RW_TVAR)<>0,dbvalue) then - flags2:=flags2 or ACF2_RW_HEX; - end; - end - else - begin - if (flags and ACF_LAST)=0 then - pWideChar(dbvalue):=GetDlgText(Dialog,IDC_RW_TEXT); - end; - - if (IsDlgButtonChecked(Dialog,IDC_RW_LAST)=BST_CHECKED) or - ((flags and ACF_LAST)<>0) then - flags:=flags or ACF_LAST; - end; - - ACT_MESSAGE: begin - pWideChar(msgtitle):=GetDlgText(Dialog,IDC_MSG_TITLE); - pWideChar(msgtext ):=GetDlgText(Dialog,IDC_MSG_TEXT); - if IsDlgButtonChecked(Dialog,IDC_MSG_KEEP)=BST_CHECKED then - flags:=flags or ACF_MSG_KEEP; - if IsDlgButtonChecked(Dialog,IDC_MSG_TTL)=BST_CHECKED then - flags2:=flags2 or ACF2_MSG_TTL; - if IsDlgButtonChecked(Dialog,IDC_MSG_TXT)=BST_CHECKED then - flags2:=flags2 or ACF2_MSG_TXT; - - if IsDlgButtonChecked(Dialog,IDC_MSGB_OC )=BST_CHECKED then boxopts:=MB_OKCANCEL - else if IsDlgButtonChecked(Dialog,IDC_MSGB_ARI)=BST_CHECKED then boxopts:=MB_ABORTRETRYIGNORE - else if IsDlgButtonChecked(Dialog,IDC_MSGB_YNC)=BST_CHECKED then boxopts:=MB_YESNOCANCEL - else if IsDlgButtonChecked(Dialog,IDC_MSGB_YN )=BST_CHECKED then boxopts:=MB_YESNO - else if IsDlgButtonChecked(Dialog,IDC_MSGB_RC )=BST_CHECKED then boxopts:=MB_RETRYCANCEL - else{if IsDlgButtonChecked(Dialog,IDC_MSGB_OK )=BST_CHECKED then}boxopts:=MB_OK; - - if IsDlgButtonChecked(Dialog,IDC_MSGI_ERROR)=BST_CHECKED then boxopts:=boxopts or MB_ICONHAND - else if IsDlgButtonChecked(Dialog,IDC_MSGI_QUEST)=BST_CHECKED then boxopts:=boxopts or MB_ICONQUESTION - else if IsDlgButtonChecked(Dialog,IDC_MSGI_WARN )=BST_CHECKED then boxopts:=boxopts or MB_ICONWARNING - else if IsDlgButtonChecked(Dialog,IDC_MSGI_INFO )=BST_CHECKED then boxopts:=boxopts or MB_ICONINFORMATION - ;//else if IsDlgButtonChecked(Dialog,IDC_MSGI_NONE)=BST_CHECKED then ; - end; - - end; - end; - end; - - procedure BuildActionChain(group:integer=-1); - var - i,j,item:integer; - wnd:HWND; - act:pHKAction; - idx:integer; - begin - if (ChMask and ACTM_ACTS)=0 then exit; - ChMask:=ChMask and not ACTM_ACTS; - SaveAction(-1,-1); - wnd:=GetDlgItem(Dialog,IDC_ACTION_LIST); - i:=SendMessageW(wnd,LVM_GETITEMCOUNT,0,0); - idx:=LV_GetLParam(GetDlgItem(Dialog,IDC_ACTION_GROUP),group); - if i>0 then - begin - j:=LV_GetLParam(wnd,0); - NewGroupList^[idx].firstAction:=j; - act:=@NewActionList^[j]; - for item:=1 to i-1 do - begin - j:=LV_GetLParam(wnd,item); - act^.next:=j; - act:=@NewActionList^[j]; - end; - act^.next:=0; - end - else - begin - if idx>=0 then - NewGroupList^[idx].firstAction:=0; - end; - end; - - procedure CheckActionList(next:integer); - var - i:integer; - wnd:HWND; - begin - wnd:=GetDlgItem(Dialog,IDC_ACTION_LIST); - i:=SendMessage(wnd,LVM_GETITEMCOUNT,0,0); - if i>0 then - begin - EnableWindow(GetDlgItem(Dialog,IDC_ACTION_HELP),true); - if next=i then - dec(next); - ListView_SetItemState(wnd,next, - LVIS_FOCUSED or LVIS_SELECTED, - LVIS_FOCUSED or LVIS_SELECTED); - end - else - begin - SHWindows; - SHActButtons(SW_HIDE); - EnableWindow(wnd,false); - EnableWindow(GetDlgItem(Dialog,IDC_ACTION_HELP ),false); - EnableWindow(GetDlgItem(Dialog,IDC_GROUP_TEST ),false); - EnableWindow(GetDlgItem(Dialog,IDC_ACTION_DELETE),false); - next:=0; - end; - CheckActList(next); - end; - - procedure CheckGroupList(next:integer); - var - i:integer; - wnd:HWND; - li:LV_ITEMW; - begin - wnd:=GetDlgItem(Dialog,IDC_ACTION_GROUP); - i:=SendMessage(wnd,LVM_GETITEMCOUNT,0,0); - if i>0 then - begin - if next=i then - dec(next); - ListView_SetItemState(wnd,next,LVIS_FOCUSED or LVIS_SELECTED, - LVIS_FOCUSED or LVIS_SELECTED); - li.iItem :=next; - li.iSubItem:=0; - li.mask :=LVIF_PARAM; - SendMessage(wnd,LVM_GETITEM,0,tlparam(@li)); - end - else - begin - EnableWindow(wnd,false); - EnableWindow(GetDlgItem(Dialog,IDC_GROUP_DELETE),false); - CheckActionList(0); - EnableWindow(GetDlgItem(Dialog,IDC_ACTION_NEW),false); - end; - CheckGrpList(next); + end + else + begin + LV_MoveItem(list,incr,num); + result:=num; end; +end; - // Fill action group list and disable chain controls - function FillGroupList{(Dialog:hwnd)}:integer; - var - CurGroup:pHKRecord; - i:integer; - list:HWND; - lvi:TLVITEMW; - begin - SendDlgItemMessage(Dialog,IDC_ACTION_LIST,LVM_DELETEALLITEMS,0,0); - CheckActionList(-1); - list:=GetDlgItem(Dialog,IDC_ACTION_GROUP); +// enable/disable navigation chain buttons +procedure CheckMacroListDirectionButtons(Dialog:HWND); +var + wnd:HWND; + dir:integer; + okup,okdown:boolean; +begin + wnd:=MacroListWindow; + dir:=LV_CheckDirection(wnd); + okup :=odd(loword(dir)); + okdown:=(loword(dir) and 2)<>0; + + EnableWindow(GetDlgItem(Dialog,IDC_GROUP_UP ),okup); + EnableWindow(GetDlgItem(Dialog,IDC_GROUP_DOWN),okdown); + SendMessage(wnd,LVM_ENSUREVISIBLE,hiword(dir)-1,0); +end; - SendMessage(list,LVM_DELETEALLITEMS,0,0); - CurGroup:=@NewGroupList^; - result:=-1; +procedure CheckMacroList(Dialog:HWND); +var + wnd:HWND; + b:boolean; +begin + wnd:=MacroListWindow; + + b:=SendMessage(wnd,LVM_GETITEMCOUNT,0,0)>0; + if not b then + CheckActListButtons(Dialog); + + EnableWindow(wnd,b); + EnableWindow(GetDlgItem(Dialog,IDC_ACTION_NEW ),b); + EnableWindow(GetDlgItem(Dialog,IDC_GROUP_DELETE),b); + EnableWindow(GetDlgItem(Dialog,IDC_GROUP_EXPORT),b); + + CheckMacroListDirectionButtons(Dialog); +end; + +// Fill action group list and disable chain controls +function FillMacroList(Dialog:HWND):integer; +var + CurMacro:pMacroRecord; + i:integer; + list:HWND; + lvi:TLVITEMW; +begin + SendDlgItemMessage(Dialog,IDC_ACTION_LIST,LVM_DELETEALLITEMS,0,0); + CheckActListButtons(Dialog); + + list:=MacroListWindow; + + SendMessage(list,LVM_DELETEALLITEMS,0,0); + result:=-1; + if EditMacroList.Count>0 then + begin + CurMacro:=EditMacroList[0]; lvi.mask:=LVIF_TEXT+LVIF_PARAM; lvi.iSubItem:=0; - for i:=0 to NewMaxGroups-1 do + for i:=0 to EditMacroList.Count-1 do begin - if (CurGroup^.flags and ACF_ASSIGNED)<>0 then + if (CurMacro^.flags and ACF_ASSIGNED)<>0 then begin lvi.iItem :=i; + lvi.lParam:=i; - if CurGroup^.descr=nil then - lvi.pszText:=NoDescription - else - lvi.pszText:=CurGroup^.descr; + if (CurMacro^.flags and ACF_FIRSTRUN)<>0 then + lvi.lParam:=lvi.lParam or ACF_FIRSTRUN; + + lvi.pszText:=@(CurMacro^.descr); SendMessageW(list,LVM_INSERTITEMW,0,tlparam(@lvi)); inc(result); end; - inc(CurGroup); + inc(CurMacro); end; - - EnableWindow(GetDlgItem(Dialog,IDC_ACTION_GROUP ),result>=0); - EnableWindow(GetDlgItem(Dialog,IDC_ACTION_LIST ),result>=0); - EnableWindow(GetDlgItem(Dialog,IDC_ACTION_NEW ),result>=0); - EnableWindow(GetDlgItem(Dialog,IDC_GROUP_DELETE ),result>=0); - if result<0 then - begin - EnableWindow(GetDlgItem(Dialog,IDC_GROUP_TEST ),false); - EnableWindow(GetDlgItem(Dialog,IDC_ACTION_HELP ),false); - EnableWindow(GetDlgItem(Dialog,IDC_ACTION_DELETE),false); - EnableWindow(GetDlgItem(Dialog,IDC_ACTION_UP ),false); - EnableWindow(GetDlgItem(Dialog,IDC_ACTION_DOWN ),false); - EnableWindow(GetDlgItem(Dialog,IDC_STAT_GROUPS ),false); - EnableWindow(GetDlgItem(Dialog,IDC_ACTION_TYPE ),false); - end - else - result:=0; - SendMessage(list,CB_SETCURSEL,0,0); - SendMessage(list,LVM_SETCOLUMNWIDTH,0,LVSCW_AUTOSIZE_USEHEADER); - - ListView_SetItemState(list,0, - LVIS_FOCUSED or LVIS_SELECTED, - LVIS_FOCUSED or LVIS_SELECTED); end; - procedure SHMath(show:boolean); - var - wnd:HWND; - begin - EnableWindow(GetDlgItem(Dialog,IDC_ADV_ASINT),not show); - EnableWindow(GetDlgItem(Dialog,IDC_ADV_VARS ),not show); + CheckMacroList(Dialog); +//?? SendMessage(list,CB_SETCURSEL,0,0); + SendMessage(list,LVM_SETCOLUMNWIDTH,0,LVSCW_AUTOSIZE_USEHEADER); - wnd:=GetDlgItem(Dialog,IDC_ADV_OPER); - EnableWindow(wnd,show); - EnableWindow(GetDlgItem(Dialog,IDC_ADV_VAL1), - show and (CB_GetData(wnd)<>lresult(aeNot)));//(SendMessage(wnd,CB_GETCURSEL,0,0)<>0)); - end; + ListView_SetItemState(list,0, + LVIS_FOCUSED or LVIS_SELECTED, + LVIS_FOCUSED or LVIS_SELECTED); +end; - procedure SetMBRadioIcon(h:THANDLE;id:dword;icon:uint_ptr); - begin - SendDlgItemMessage(Dialog,id,BM_SETIMAGE,IMAGE_ICON, - LoadImage(h,MAKEINTRESOURCE(icon),IMAGE_ICON,16,16,0{LR_SHARED})); - // SendDlgItemMessage(Dialog,id,BM_SETIMAGE,IMAGE_ICON,LoadIcon(0,icon)); - end; +//----- Other stuff ----- - procedure SetMBRadioIcons; - var - h:THANDLE; - begin - h:=LoadLibrary('user32.dll'); - // SetMBRadioIcon(IDC_MSGI_NONE,IDI_); //? - SetMBRadioIcon(h,IDC_MSGI_ERROR,103{IDI_HAND}); - SetMBRadioIcon(h,IDC_MSGI_QUEST,102{IDI_QUESTION}); - SetMBRadioIcon(h,IDC_MSGI_WARN ,101{IDI_EXCLAMATION}); - SetMBRadioIcon(h,IDC_MSGI_INFO ,104{IDI_ASTERISK}); - FreeLibrary(h); - end; +procedure SetButtonIcons2(Dialog:HWND); +var + ti:TTOOLINFOW; + hwndTooltip:HWND; +begin + hwndTooltip:=CreateWindowW(TOOLTIPS_CLASS,nil,TTS_ALWAYSTIP, + integer(CW_USEDEFAULT),integer(CW_USEDEFAULT), + integer(CW_USEDEFAULT),integer(CW_USEDEFAULT), + Dialog,0,hInstance,nil); - procedure FillFileName(idc:integer); - var - pw,ppw:pWideChar; - begin - mGetMem(pw,1024*SizeOf(WideChar)); - ppw:=GetDlgText(Dialog,idc); - if ShowDlgW(pw,ppw) then - SetDlgItemTextW(Dialog,idc,pw); - mFreeMem(ppw); - mFreeMem(pw); - end; + FillChar(ti,SizeOf(ti),0); + ti.cbSize :=sizeof(TOOLINFO); + ti.uFlags :=TTF_IDISHWND or TTF_SUBCLASS; + ti.hwnd :=Dialog; + ti.hinst :=hInstance; + + ti.uId :=GetDlgItem(Dialog,IDC_ACTION_HELP); + ti.lpszText:=TranslateW('Help'); + SendMessage(ti.uId,BM_SETIMAGE,IMAGE_ICON, + CallService(MS_SKIN_LOADICON,SKINICON_OTHER_HELP,0)); + SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); + + ti.uId :=GetDlgItem(Dialog,IDC_ACTION_NEW); + ti.lpszText:=TranslateW('New'); + OptSetButtonIcon(ti.uId,ACI_NEW); + SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); +{ + hNew:=GetDlgItem(Dialog,IDC_NEW); + SendMessage (hNew,BUTTONADDTOOLTIP,TWPARAM(TranslateW('New')),BATF_UNICODE); + OptSetButtonIcon(hNew,ACI_NEW); +} + + ti.uId :=GetDlgItem(Dialog,IDC_GROUP_NEW); + OptSetButtonIcon(ti.uId,ACI_NEW); + SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); + + ti.uId :=GetDlgItem(Dialog,IDC_ACTION_UP); + ti.lpszText:=TranslateW('Up'); + OptSetButtonIcon(ti.uId,ACI_UP); + SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); + + ti.uId :=GetDlgItem(Dialog,IDC_GROUP_UP); + OptSetButtonIcon(ti.uId,ACI_UP); + SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); + + ti.uId :=GetDlgItem(Dialog,IDC_ACTION_DOWN); + ti.lpszText:=TranslateW('Down'); + OptSetButtonIcon(ti.uId,ACI_DOWN); + SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); + + ti.uId :=GetDlgItem(Dialog,IDC_GROUP_DOWN); + OptSetButtonIcon(ti.uId,ACI_DOWN); + SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); + + ti.uId :=GetDlgItem(Dialog,IDC_ACTION_DELETE); + ti.lpszText:=TranslateW('Delete'); + OptSetButtonIcon(ti.uId,ACI_DELETE); + SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); + + ti.uId :=GetDlgItem(Dialog,IDC_GROUP_DELETE); + OptSetButtonIcon(ti.uId,ACI_DELETE); + SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); +{ + ti.uId :=GetDlgItem(Dialog,IDC_GROUP_RELOAD); + ti.lpszText:=TranslateW('Reload'); + OptSetButtonIcon(ti.uId,ACI_RELOAD); + SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); +} + ti.uId :=GetDlgItem(Dialog,IDC_GROUP_TEST); + ti.lpszText:=TranslateW('Test'); + OptSetButtonIcon(ti.uId,ACI_TEST); + SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); +{!! + ti.uId :=GetDlgItem(Dialog,IDC_GROUP_IMPORT); + ti.lpszText:=TranslateW('Import'); + OptSetButtonIcon(ti.uId,ACI_IMPORT); + SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); + + ti.uId :=GetDlgItem(Dialog,IDC_GROUP_EXPORT); + ti.lpszText:=TranslateW('Export'); + OptSetButtonIcon(ti.uId,ACI_EXPORT); + SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti)); +} +end; +function DlgProcOpt2(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; var - wnd,wnd1,wnd2:HWND; - i,j:int_ptr; + wnd:HWND; + p:pActModule; + i,j,num:int_ptr; lvflag:integer; - pc:pAnsiChar; li:LV_ITEMW; lv:LV_COLUMNW; - b:boolean; - ico:HICON; begin result:=0; case hMessage of WM_DESTROY: begin - ApiCard.Free; SetCancel; - mFreeMem(wstruct); - mFreeMem(lstruct); end; WM_INITDIALOG: begin - ApiCard:=CreateServiceCard(Dialog); - wstruct:=nil; - lstruct:=nil; SetStart; DontReact :=true; - SHWindows; + // variant - put after all dialogs adds (to translate them too) TranslateDialogDefault(Dialog); + // For some actions + MacroListWindow :=GetDlgItem(Dialog,IDC_MACRO_LIST); + ActionListWindow:=GetDlgItem(Dialog,IDC_ACTION_LIST); + SetButtonIcons2(Dialog); - wnd:=GetDlgItem(Dialog,IDC_ACTION_LIST); + wnd:=ActionListWindow; SendMessage(wnd,LVM_SETEXTENDEDLISTVIEWSTYLE,LVS_EX_CHECKBOXES,LVS_EX_CHECKBOXES); SendMessage(wnd,LVM_SETUNICODEFORMAT,1,0); - zeromemory(@lv,sizeof(lv)); + FillChar(lv,SizeOf(lv),0); lv.mask:=LVCF_WIDTH; lv.cx :=110; SendMessageW(wnd,LVM_INSERTCOLUMNW ,0,tlparam(@lv)); SendMessageW(wnd,LVM_SETCOLUMNWIDTH,0,LVSCW_AUTOSIZE_USEHEADER); - MakeResultTypeList(GetDlgItem(Dialog,IDC_SRV_RESULT)); - MakeParamTypeList (GetDlgItem(Dialog,IDC_FLAG_WPAR)); - MakeParamTypeList (GetDlgItem(Dialog,IDC_FLAG_LPAR)); - MakeMathOperList (GetDlgItem(Dialog,IDC_ADV_OPER)); - MakeFileEncList (GetDlgItem(Dialog,IDC_FILE_ENC)); - MakeDataTypeList (GetDlgItem(Dialog,IDC_RW_DATATYPE)); - - // service list for RunService - ApiCard.FillList(GetDlgItem(Dialog,IDC_EDIT_SERVICE)); - // contact list for ContactMessage - FillContactList(GetDlgItem(Dialog,IDC_CONTACTLIST),fCLfilter,fCLformat); // action type combobox FillActTypeList(GetDlgItem(Dialog,IDC_ACTION_TYPE)); - - if isVarsInstalled then - begin - ico:=CallService(MS_VARS_GETSKINITEM,0,VSI_HELPICON); - SendDlgItemMessage(Dialog,IDC_HLP_FVARS,BM_SETIMAGE,IMAGE_ICON,ico); - SendDlgItemMessage(Dialog,IDC_HLP_VARS ,BM_SETIMAGE,IMAGE_ICON,ico); - SendDlgItemMessage(Dialog,IDC_ADV_HVARS,BM_SETIMAGE,IMAGE_ICON,ico); - end; - +{!! + // XML import/export service if ServiceExists(MS_SYSTEM_GET_XI)=0 then begin EnableWindow(GetDlgItem(Dialog,IDC_GROUP_EXPORT),false); EnableWindow(GetDlgItem(Dialog,IDC_GROUP_IMPORT),false); end; - +} OldActTableProc :=pointer(SetWindowLongPtrW(wnd,GWL_WNDPROC,long_ptr(@NewActTableProc))); - OldGroupTableProc:=pointer(SetWindowLongPtrW(GetDlgItem(Dialog,IDC_ACTION_GROUP), + OldGroupTableProc:=pointer(SetWindowLongPtrW(MacroListWindow, GWL_WNDPROC,long_ptr(@NewGroupTableProc))); + ClearDialogData; + ResetDialogs; + // fill group list - wnd:=GetDlgItem(Dialog,IDC_ACTION_GROUP); + wnd:=MacroListWindow; SendMessage(wnd,LVM_SETUNICODEFORMAT,1,0); lv.mask:=LVCF_WIDTH; lv.cx :=110; SendMessageW(wnd,LVM_INSERTCOLUMNW,0,tlparam(@lv)); - FillGroupList{(Dialog)}; - FillChainList(Dialog); - - SetMBRadioIcons; + FillMacroList(Dialog); + ChangeListNotify(1); // fill current group - MakeActionList(@NewGroupList^); - ChMask:=0; - CheckGrpList(-1); + FillActionList(Dialog,EditMacroList[0]); + ChangeListNotify(2); + EventMask:=0; DontReact:=false; end; WM_COMMAND: begin if DontReact then exit; case wParam shr 16 of - CBN_EDITCHANGE: begin - ChMask:=ChMask or ACTM_ACT or ACTM_ACTS; - SetChanged(Dialog,etACT); - end; +{ EN_CHANGE: begin // check for group renaming if loword(wParam)<>IDC_EDIT_FORMAT then begin - ChMask:=ChMask or ACTM_ACT or ACTM_ACTS; SetChanged(Dialog,etACT); end; end; +} CBN_SELCHANGE: begin - ChMask:=ChMask or ACTM_ACT or ACTM_ACTS; - SetChanged(Dialog,etACT); case loword(wParam) of - IDC_SRV_RESULT: begin - i:=CB_GetData(lParam); - case i of - sresHex,sresInt,sresStruct: begin - SHControl(IDC_RES_FREEMEM,SW_HIDE); - SHControl(IDC_RES_UNICODE,SW_HIDE); - if i=sresInt then - SHControl(IDC_RES_SIGNED,SW_SHOW) - else - SHControl(IDC_RES_SIGNED,SW_HIDE); - end; - sresString: begin - SHControl(IDC_RES_FREEMEM,SW_SHOW); - SHControl(IDC_RES_UNICODE,SW_SHOW); - SHControl(IDC_RES_SIGNED ,SW_HIDE); - end; - end; - end; - - IDC_ADV_OPER: begin - EnableWindow(GetDlgItem(Dialog,IDC_ADV_VAL1), - (CB_GetData(lParam)<>lresult(aeNot))); -// SendMessage(lParam,CB_GETCURSEL,0,0)<>0); - end; - - IDC_RW_DATATYPE: begin - if CB_GetData(GetDlgItem(Dialog,IDC_RW_DATATYPE))>2 then - begin - SHControl(IDC_RW_TEXT ,SW_SHOW); - SHControl(IDC_RW_VALUE,SW_HIDE); - end - else - begin - SHControl(IDC_RW_TEXT ,SW_HIDE); - SHControl(IDC_RW_VALUE,SW_SHOW); - end; - end; - IDC_ACTION_TYPE: begin - i:=SendMessage(lParam,CB_GETCURSEL,0,0); - SHWindows(ActIds[i].code); - ChangeActionName(-1,i+1); - case ActIds[i].code of - ACT_CONTACT: EnableWindow(GetDlgItem(Dialog,IDC_CONTACTLIST),true); - ACT_RW: begin - EnableWindow(GetDlgItem(Dialog,IDC_CONTACTLIST), - (IsDlgButtonChecked(Dialog,IDC_RW_MANUAL)=BST_CHECKED)); - - if CB_GetData(GetDlgItem(Dialog,IDC_RW_DATATYPE))>2 then - begin - SHControl(IDC_RW_TEXT ,SW_SHOW); - SHControl(IDC_RW_VALUE,SW_HIDE); - end - else - begin - SHControl(IDC_RW_TEXT ,SW_HIDE); - SHControl(IDC_RW_VALUE,SW_SHOW); - end; - - end; - ACT_ADVANCE: FillSubList(Dialog); - end; - end; -{ - IDC_EDIT_WPAR,IDC_EDIT_LPAR: begin - SendMessage(lParam,CB_GETLBTEXT, - SendMessage(lParam,CB_GETCURSEL,0,0),TLPARAM(@buf)); - if loword(wParam)=IDC_EDIT_WPAR then - FixParam(buf,IDC_EDIT_WPAR,IDC_FLAG_WPAR) - else - FixParam(buf,IDC_EDIT_LPAR,IDC_FLAG_LPAR) - end; -} - IDC_FLAG_WPAR,IDC_FLAG_LPAR: begin - if loword(wParam)=IDC_FLAG_WPAR then - begin - wnd :=GetDlgItem(Dialog,IDC_EDIT_WPAR); - wnd1:=GetDlgItem(Dialog,IDC_WSTRUCT); - wnd2:=GetDlgItem(Dialog,IDC_SRV_WPAR); - end - else - begin - wnd :=GetDlgItem(Dialog,IDC_EDIT_LPAR); - wnd1:=GetDlgItem(Dialog,IDC_LSTRUCT); - wnd2:=GetDlgItem(Dialog,IDC_SRV_LPAR); - end; - i:=CB_GetData(GetDlgItem(Dialog,loword(wParam))); + ClearDialogData; + p:=GetLink(CB_GetData(lParam)); + ShowWindow(p^.DlgHandle,SW_SHOW); - if i=ptStruct then - begin - ShowWindow(wnd ,SW_HIDE); - ShowWindow(wnd2,SW_HIDE); - ShowWindow(wnd1,SW_SHOW); - end - else + // Saving prevoius "normal" action type + if p^.Hash>10 then begin - ShowWindow(wnd ,SW_SHOW); - ShowWindow(wnd2,SW_SHOW); - ShowWindow(wnd1,SW_HIDE); - if i in [ptCurrent,ptResult,ptParam] then - EnableWindow(wnd,false) - else - begin - EnableWindow(wnd,true); -{ - flag:=GetWindowLongPtr(wnd,GWL_STYLE); - if i=ptNumber then - flag:=flag or ES_NUMBER - else - flag:=flag and not ES_NUMBER; - SetWindowLongPtr(wnd,GWL_STYLE,flag); -} - end; + SetWindowLongPtrW(lParam,GWLP_USERDATA, + SendMessage(lParam,CB_GETCURSEL,0,0)); + SetChanged(Dialog,etACT); end; end; - IDC_EDIT_SERVICE: ReloadService; end; end; + BN_CLICKED: begin case loword(wParam) of IDC_GROUP_RELOAD, // don't affect to saved (DB) datas - IDC_WSTRUCT, // 'Changed' on process - IDC_LSTRUCT, // 'Changed' on process - IDC_HLP_FVARS, - IDC_HLP_VARS, - IDC_ADV_HVARS, IDC_ACTION_HELP, IDC_GROUP_EXPORT, - IDC_CNT_APPLY, - IDC_CNT_FILTER, IDC_GROUP_TEST: ; IDC_GROUP_UP, IDC_GROUP_DOWN, - IDC_GROUP_NEW : SetChanged(Dialog,etHK); + IDC_GROUP_NEW : SetChanged(Dialog,etMacro); IDC_GROUP_DELETE, // action deleting with subactions IDC_GROUP_IMPORT, @@ -1540,69 +969,28 @@ begin IDC_ACTION_DELETE, IDC_ACTION_UP, IDC_ACTION_DOWN: begin - ChMask:=ChMask or ACTM_ACT or ACTM_ACTS; - SetChanged(Dialog,etHK+etACT); + SetChanged(Dialog,etMacro+etACT); end; else - ChMask:=ChMask or ACTM_ACT or ACTM_ACTS; SetChanged(Dialog,etACT); end; case loword(wParam) of - IDC_SRV_WPAR, - IDC_SRV_LPAR, - IDC_SRV_SRVC, - IDC_PRG_PRG , - IDC_PRG_ARG , - IDC_TXT_FILE, - IDC_TXT_TEXT, - IDC_RW_MVAR , - IDC_RW_SVAR , - IDC_RW_TVAR , - IDC_MSG_TTL , - IDC_MSG_TXT : SetButtonIcon(lParam,checknames[IsDlgButtonChecked(Dialog,loword(wParam))]); - end; - - case loword(wParam) of - IDC_CNT_FILTER, - IDC_CNT_APPLY: begin - if loword(wParam)=IDC_CNT_APPLY then - begin - mFreeMem(fCLformat); - fCLformat:=GetDlgText(Dialog,IDC_EDIT_FORMAT); - DBWriteUnicode(0,DBBranch,'CLformat',fCLformat); - end - else - begin - fCLfilter:=IsDlgButtonChecked(Dialog,IDC_CNT_FILTER)<>BST_UNCHECKED; - DBWriteByte(0,DBBranch,'CLfilter',ord(fCLfilter)); - end; -// Saving and restoring contact after list rebuild - wnd:=GetDlgItem(Dialog,IDC_CONTACTLIST); - i:=SendMessage(wnd,CB_GETITEMDATA,SendMessage(wnd,CB_GETCURSEL,0,0),0); - - FillContactList(wnd,fCLfilter,fCLformat); - - SendMessage(wnd,CB_SETCURSEL,FindContact(wnd,i),0); - end; - IDC_HLP_FVARS, - IDC_HLP_VARS : ShowHelp(hlpVariables); - IDC_ADV_HVARS: ShowHelp(hlpAdvVariables); - +{ IDC_GROUP_EXPORT: begin - if ShowDlgW(xmlfilename,xmlfilename,inoutfilter,false) then + if ShowDlgW(xmlfilename,xmlfilename,TranslateW(inoutfilter),false) then begin - wnd:=GetDlgItem(Dialog,IDC_ACTION_GROUP); + wnd:=MacroListWindow; for i:=0 to ListView_GetItemCount(wnd)-1 do begin if ListView_GetItemState(wnd,i,LVIS_SELECTED)<>0 then begin - with GroupList[LV_GetLParam(wnd,i)] do + with EditMacroList[LV_GetLParam(wnd,i)] do if (flags and ACF_ASSIGNED)<>0 then // must be always true flags:=flags or ACF_EXPORT; end else - with GroupList[i] do + with EditMacroList[i] do if (flags and (ACF_EXPORT or ACF_ASSIGNED))= (ACF_EXPORT or ACF_ASSIGNED) then flags:=flags and not ACF_EXPORT; @@ -1612,357 +1000,190 @@ begin if MessageBoxW(Dialog,TranslateW('Append data to file?'), PluginName,MB_YESNO+MB_ICONWARNING)=IDYES then i:=i or ACIO_APPEND; +//!!!!!!!!!!!!!!! +// we MUST Export EditMacroList, NOT MacroList +// OR +// Use "Apply" code before CallService(MS_ACT_INOUT,i,TLPARAM(@xmlfilename)); -// Export({GetLParam(GetDlgItem(Dialog,IDC_ACTION_GROUP)),}xmlfilename,i); for i:=0 to MaxGroups-1 do - with GroupList[i] do + with EditMacroList[i] do if (flags and (ACF_EXPORT or ACF_ASSIGNED))= (ACF_EXPORT or ACF_ASSIGNED) then flags:=flags and not ACF_EXPORT; end; end; - +} IDC_GROUP_IMPORT: begin - if ShowDlgW(xmlfilename,xmlfilename,inoutfilter) then + if ShowDlgW(xmlfilename,xmlfilename,TranslateW(inoutfilter)) then begin -// if Import(xmlfilename) then - if CallService(MS_ACT_INOUT,0,TLPARAM(@xmlfilename))<>0 then + // "save" selected macro (in edit list only) + BuildActionChain(Dialog); + + if Import(EditMacroList,xmlfilename,0)<>0 then +// if CallService(MS_ACT_INOUT,0,TLPARAM(@xmlfilename))<>0 then begin - ChMask:=ChMask or ACTM_NEW; - SendMessage(Dialog,WM_COMMAND,IDC_GROUP_RELOAD+(BN_CLICKED shl 16), - GetDlgItem(Dialog,IDC_GROUP_RELOAD)); -//(in reload) FillChainList(Dialog); - end; - end; - end; + // copy from WM_INITDIALOG + FillMacroList(Dialog); + ChangeListNotify(1); - IDC_WSTRUCT, IDC_LSTRUCT: begin - if loword(wParam)=IDC_WSTRUCT then - pc:=wstruct - else - pc:=lstruct; -//!!!! - pAnsiChar(j):=EditStructure(pAnsiChar(pc),Dialog); - if j<>0 then - begin - ChMask:=ChMask or ACTM_ACT or ACTM_ACTS; - SetChanged(Dialog,etACT); - mFreeMem(pAnsiChar(pc)); - pc:=pAnsiChar(j); + // fill current group + FillActionList(Dialog,EditMacroList[0]); + ChangeListNotify(2); - if loword(wParam)=IDC_WSTRUCT then - wstruct:=pc - else - lstruct:=pc; + CheckMacroListDirectionButtons(Dialog); + end; end; end; - IDC_PROGRAM: begin - FillFileName(IDC_EDIT_PRGPATH); - end; - IDC_FILE_FILEBTN: begin - FillFileName(IDC_FILE_PATH); - end; - IDC_GROUP_TEST: begin - wnd:=GetDlgItem(Dialog,IDC_ACTION_LIST); li.mask :=LVIF_PARAM; li.iSubItem:=0; - li.iItem :=0; - SendMessageW(wnd,LVM_GETITEMW,0,tlparam(@li)); - j:=SendMessage(wnd,LVM_GETNEXTITEM,-1,LVNI_FOCUSED); - - ActionStarterWait(li.lParam); - // doubling from "reload" button - wnd:=GetDlgItem(Dialog,IDC_ACTION_GROUP); - i:=SendMessage(wnd,LVM_GETNEXTITEM,-1,LVNI_FOCUSED); - NewGroupList :=GroupList; - NewMaxGroups :=MaxGroups; - NewActionList:=ActionList; - NewMaxActions:=MaxActions; - FillGroupList{(Dialog)}; - FillChainList(Dialog); - - Listview_SetItemState(wnd,0,0,LVIS_FOCUSED or LVIS_SELECTED); - Listview_SetItemState(wnd,i, - LVIS_FOCUSED or LVIS_SELECTED, - LVIS_FOCUSED or LVIS_SELECTED); - SendMessage(wnd,LVM_ENSUREVISIBLE,i,0); - - wnd:=GetDlgItem(Dialog,IDC_ACTION_LIST); - Listview_SetItemState(wnd,0,0,LVIS_FOCUSED or LVIS_SELECTED); - Listview_SetItemState(wnd,j, - LVIS_FOCUSED or LVIS_SELECTED, - LVIS_FOCUSED or LVIS_SELECTED); - SendMessage(wnd,LVM_ENSUREVISIBLE,j,0); - + // Get selected macro + li.iItem :=SendMessage(MacroListWindow,LVM_GETNEXTITEM,-1,LVNI_FOCUSED); + // "save" selected macro (in edit list only) + BuildActionChain(Dialog,li.iItem); + // Get lParam = EditMacroList element + SendMessageW(MacroListWindow,LVM_GETITEMW,0,tlparam(@li)); + + ActionStarter(EditMacroList[loword(li.lParam)],nil,ACTP_SAMETHREAD or ACTP_WAIT); end; + IDC_GROUP_NEW: begin - i:=AddGroup(Dialog,NewGroup(NewGroupList,NewMaxGroups)); - if i>=0 then + if AddMacro(Dialog,EditMacroList.NewMacro())>=0 then begin - ChMask:=ChMask or ACTM_NEW or ACTM_SORT; - EnableWindow(GetDlgItem(Dialog,IDC_ACTION_GROUP),true); - EnableWindow(GetDlgItem(Dialog,IDC_GROUP_DELETE),true); - EnableWindow(GetDlgItem(Dialog,IDC_ACTION_NEW ),true); - FillChainList(Dialog); - CheckGrpList(i); + CheckMacroList(Dialog); + ChangeListNotify(1); end; end; IDC_GROUP_DELETE: begin - wnd:=GetDlgItem(Dialog,IDC_ACTION_GROUP); + DontReact:=true; + wnd:=MacroListWindow; for i:=ListView_GetItemCount(wnd)-1 downto 0 do begin if ListView_GetItemState(wnd,i,LVIS_SELECTED)<>0 then begin - ChMask:=ChMask or ACTM_DELETE or ACTM_SORT; - - with NewGroupList^[LV_GetLParam(wnd,i)] do - begin - flags:=0; - mFreeMem(descr); - FreeActions(NewActionList,firstAction); - end; + num:=Loword(LV_GetLParam(wnd,i)); + // mark old to delete on apply (must be first) + with EditMacroList[num]^ do + for j:=0 to ActionCount-1 do + ActionList[j].flags:=ActionList[j].flags or ACF_REPLACED; + // delete new actions + FreeMacro(EditMacroList[num],ACF_INTRODUCED); SendMessage(wnd,LVM_DELETEITEM,i,0); end; end; + Listview_SetItemState(wnd,-1,0,LVIS_FOCUSED or LVIS_SELECTED); + DontReact:=false; SendDlgItemMessage(Dialog,IDC_ACTION_LIST,LVM_DELETEALLITEMS,0,0); - FillChainList(Dialog); Listview_SetItemState(wnd,0,LVIS_FOCUSED or LVIS_SELECTED, LVIS_FOCUSED or LVIS_SELECTED); - CheckGroupList(-1); -{ - i:=SendMessageW(wnd,LVM_GETNEXTITEM,-1,LVNI_FOCUSED); //?? - if i>=0 then - begin - ChMask:=ChMask or ACTM_DELETE; - j:=GetLParam(wnd,i); - - with NewGroupList^[j] do - begin - flags:=0; - mFreeMem(descr); - FreeActions(NewActionList,firstAction); - end; - SendDlgItemMessage(Dialog,IDC_ACTION_LIST,LVM_DELETEALLITEMS,0,0); - -//?? i:=ListView_GetNextItem(wnd,-1,LVNI_FOCUSED); - SendMessage(wnd,LVM_DELETEITEM,i,0); - FillChainList(Dialog); - CheckGroupList(i); - end; -} - end; - IDC_GROUP_RELOAD: begin - ChMask:=ChMask or ACTM_RELOAD; - SetCancel; - NewGroupList :=GroupList; - NewMaxGroups :=MaxGroups; - NewActionList:=ActionList; - NewMaxActions:=MaxActions; - FillGroupList{(Dialog)}; - FillChainList(Dialog); + CheckMacroList(Dialog); + ChangeListNotify(1); end; IDC_ACTION_HELP: begin - ShowHelp(SendDlgItemMessage(Dialog,IDC_ACTION_TYPE,CB_GETCURSEL,0,0)); + SendMessage( + GetLink(CB_GetData(GetDlgItem(Dialog,IDC_ACTION_TYPE)))^.DlgHandle, + WM_HELP,0,0); end; IDC_ACTION_NEW: begin - wnd:=GetDlgItem(Dialog,IDC_ACTION_LIST); + wnd:=ActionListWindow; li.mask :=LVIF_PARAM; i :=SendMessage(wnd,LVM_GETNEXTITEM,-1,LVNI_FOCUSED); li.iItem :=i+1; li.iSubItem:=0; - li.lParam :=NewAction(NewActionList,NewMaxActions); + li.lParam :=0;{NewAction(NewActionList,NewMaxActions);} SendMessageW(wnd,LVM_INSERTITEMW,0,tlparam(@li)); ListView_SetCheckState(wnd,li.iItem,true); if li.iItem=0 then begin ListView_SetItemState(wnd,0,LVIS_FOCUSED or LVIS_SELECTED, LVIS_FOCUSED or LVIS_SELECTED); - SHActButtons(SW_SHOW); + SHActButtons(Dialog,SW_SHOW); + SendDlgItemMessage(Dialog,IDC_ACTION_TYPE,CB_SETCURSEL,0,0); end; - ChangeActionName(li.iItem); - EnableWindow(GetDlgItem(Dialog,IDC_ACTION_LIST ),true); - EnableWindow(GetDlgItem(Dialog,IDC_ACTION_HELP ),true); - EnableWindow(GetDlgItem(Dialog,IDC_GROUP_TEST ),true); - EnableWindow(GetDlgItem(Dialog,IDC_ACTION_DELETE),true); - EnableWindow(GetDlgItem(Dialog,IDC_ACTION_TYPE ),true); - CheckActList(i); - - wnd:=GetDlgItem(Dialog,IDC_ADV_VAL2); - i:=SendMessage(wnd,CB_GETCURSEL,0,0); - FillSubList(Dialog); - SendMessage(wnd,CB_SETCURSEL,i,0); + ChangeActionName(Dialog,li.iItem); + + CheckActListButtons(Dialog); + ChangeListNotify(2); end; IDC_ACTION_DELETE: begin - wnd:=GetDlgItem(Dialog,IDC_ACTION_LIST); + DontReact:=true; + wnd:=ActionListWindow; for i:=ListView_GetItemCount(wnd)-1 downto 0 do begin if ListView_GetItemState(wnd,i,LVIS_SELECTED)<>0 then begin - FreeAction(@NewActionList^[LV_GetLParam(wnd,i)]); + j:=LV_GetLParam(wnd,i); + if j<>0 then + begin + if (tBaseAction(j).flags and ACF_INTRODUCED)<>0 then + tBaseAction(j).Free + else + tBaseAction(j).flags:=tBaseAction(j).flags or ACF_REPLACED; + end; SendMessage(wnd,LVM_DELETEITEM,i,0); end; end; + Listview_SetItemState(wnd,-1,0,LVIS_FOCUSED or LVIS_SELECTED); + DontReact:=false; Listview_SetItemState(wnd,0,LVIS_FOCUSED or LVIS_SELECTED, LVIS_FOCUSED or LVIS_SELECTED); - CheckActionList(0); -{ - wnd:=GetDlgItem(Dialog,IDC_ACTION_LIST); - li.iItem:=SendMessage(wnd,LVM_GETNEXTITEM,-1,LVNI_FOCUSED); //?? - if li.iItem>=0 then - begin - li.mask :=LVIF_PARAM; - li.iSubItem:=0; - SendMessageW(wnd,LVM_GETITEM,0,TLPARAM(@li)); - FreeAction(@NewActionList^[li.lParam]); - - SendMessage(wnd,LVM_DELETEITEM,li.iItem,0); - CheckActionList(li.iItem); - end; -} + CheckActListButtons(Dialog); + ChangeListNotify(2); end; IDC_GROUP_UP: begin - wnd:=GetDlgItem(Dialog,IDC_ACTION_GROUP); -// i:=SendMessage(wnd,LVM_GETNEXTITEM,-1,LVNI_FOCUSED); -// if i>0 then - begin - CheckGrpList(MoveGroup(wnd,-1,-1)); - ChMask:=ChMask or ACTM_SORT; - end; + MoveMacro(MacroListWindow,-1,-1); + CheckMacroListDirectionButtons(Dialog); + EventMask:=EventMask or ACTM_SORT; + ChangeListNotify(1); end; IDC_GROUP_DOWN: begin - wnd:=GetDlgItem(Dialog,IDC_ACTION_GROUP); -// i:=SendMessage(wnd,LVM_GETNEXTITEM,-1,LVNI_FOCUSED); -// if i<(SendMessage(wnd,LVM_GETITEMCOUNT,0,0)-1) then - begin - CheckGrpList(MoveGroup(wnd,-1,1)); - ChMask:=ChMask or ACTM_SORT; - end; + MoveMacro(MacroListWindow,-1,1); + CheckMacroListDirectionButtons(Dialog); + EventMask:=EventMask or ACTM_SORT; + ChangeListNotify(1); end; IDC_ACTION_UP: begin - wnd:=GetDlgItem(Dialog,IDC_ACTION_LIST); -// i:=SendMessage(wnd,LVM_GETNEXTITEM,-1,LVNI_FOCUSED); -// if i>0 then - CheckActList(MoveGroup(wnd,-1,-1)); + MoveMacro(ActionListWindow,-1,-1); + CheckActListDirectionButtons(Dialog); + ChangeListNotify(2); end; IDC_ACTION_DOWN: begin - wnd:=GetDlgItem(Dialog,IDC_ACTION_LIST); -// i:=SendMessage(wnd,LVM_GETNEXTITEM,-1,LVNI_FOCUSED); -// if i<(SendMessage(wnd,LVM_GETITEMCOUNT,0,0)-1) then - CheckActList(MoveGroup(wnd,-1,1)); - end; - - IDC_FILE_WRITE, IDC_FILE_READ, IDC_FILE_APPEND: - EnableWindow(GetDlgItem(Dialog,IDC_EDIT_INSERT), - loword(wParam)<>IDC_FILE_APPEND); - - IDC_RW_DELETE, - IDC_RW_READ, - IDC_RW_WRITE: begin - b:=loword(wParam)<>IDC_RW_DELETE; - EnableWindow(GetDlgItem(Dialog,IDC_RW_DATATYPE),b); - EnableWindow(GetDlgItem(Dialog,IDC_RW_LAST ),b); - EnableWindow(GetDlgItem(Dialog,IDC_RW_VALUE ),b); - EnableWindow(GetDlgItem(Dialog,IDC_RW_TEXT ),b); - end; - - IDC_FLAG_CLIP,IDC_FLAG_FILE,IDC_FLAG_MESSAGE: begin - b:=loword(wParam)=IDC_FLAG_CLIP; -//!! +text read = disabled - EnableWindow(GetDlgItem(Dialog,IDC_CLIP_COPYTO),b); - EnableWindow(GetDlgItem(Dialog,IDC_CLIP_PASTE ),b); - b:=b or ((loword(wParam)=IDC_FLAG_FILE) and - (IsDlgButtonChecked(Dialog,IDC_FILE_READ)<>BST_UNCHECKED)); - EnableWindow(GetDlgItem(Dialog,IDC_EDIT_INSERT),not b); - - b:=loword(wParam)=IDC_FLAG_FILE; - EnableWindow(GetDlgItem(Dialog,IDC_FILE_ENC ),b); - EnableWindow(GetDlgItem(Dialog,IDC_FILE_PATH ),b); - EnableWindow(GetDlgItem(Dialog,IDC_FILE_FILEBTN),b); - EnableWindow(GetDlgItem(Dialog,IDC_FILE_READ ),b); - EnableWindow(GetDlgItem(Dialog,IDC_FILE_WRITE ),b); - EnableWindow(GetDlgItem(Dialog,IDC_FILE_APPEND ),b); - end; - - IDC_FLAG_JUMP: begin - EnableWindow(GetDlgItem(Dialog,IDC_ADV_VAL2),true); - end; - - IDC_FLAG_BREAK,IDC_FLAG_ANOP: - begin - EnableWindow(GetDlgItem(Dialog,IDC_ADV_VAL2),false); - end; - - IDC_FLAG_VARS: begin - if IsDlgButtonChecked(Dialog,IDC_FLAG_VARS)<>BST_UNCHECKED then - begin - SHMath(false); - CheckDlgButton(Dialog,IDC_FLAG_MATH,BST_UNCHECKED); - end - else - begin - EnableWindow(GetDlgItem(Dialog,IDC_ADV_ASINT),false); - EnableWindow(GetDlgItem(Dialog,IDC_ADV_VARS ),false); - end; - end; - IDC_FLAG_MATH: begin - if IsDlgButtonChecked(Dialog,IDC_FLAG_MATH)<>BST_UNCHECKED then - begin - SHMath(true); - CheckDlgButton(Dialog,IDC_FLAG_VARS,BST_UNCHECKED); - end - else - begin - EnableWindow(GetDlgItem(Dialog,IDC_ADV_OPER),false); - EnableWindow(GetDlgItem(Dialog,IDC_ADV_VAL1),false); - end; - end; - - IDC_RW_CURRENT, IDC_RW_RESULT, IDC_RW_PARAM: begin - EnableWindow(GetDlgItem(Dialog,IDC_CONTACTLIST),false); + MoveMacro(ActionListWindow,-1,1); + CheckActListDirectionButtons(Dialog); + ChangeListNotify(2); end; - IDC_RW_MANUAL: EnableWindow(GetDlgItem(Dialog,IDC_CONTACTLIST),true); - IDC_RW_LAST: begin - b :=IsDlgButtonChecked(Dialog,IDC_RW_LAST )=BST_UNCHECKED; - EnableWindow(GetDlgItem(Dialog,IDC_RW_VALUE), b); - EnableWindow(GetDlgItem(Dialog,IDC_RW_TEXT ), b); - end; end; end; end; end; WM_HELP: begin - if (PHELPINFO(lParam)^.iContextType=HELPINFO_WINDOW) then - ShowHelp(SendDlgItemMessage(Dialog,IDC_ACTION_TYPE,CB_GETCURSEL,0,0)); + SendMessage( + GetLink(CB_GetData(GetDlgItem(Dialog,IDC_ACTION_TYPE)))^.DlgHandle, + WM_HELP,0,lParam); + result:=1; end; WM_NOTIFY: begin case integer(PNMHdr(lParam)^.code) of PSN_APPLY: begin - BuildActionChain; - SetSave(Dialog,LV_GetLParam(GetDlgItem(Dialog,IDC_ACTION_GROUP))); + BuildActionChain(Dialog); - if ActionList<>NewActionList then - begin - DestroyActions(ActionList,MaxActions); - ActionList:=NewActionList; - MaxActions:=NewMaxActions; - end; + EventMask:=EventMask or CheckChanges(); + SetSave(Dialog); + SaveMacros; - SaveGroups; - - if ChMask<>0 then //?? + if EventMask<>0 then //?? begin - NotifyEventHooks(hHookChanged,ChMask,0); - ChMask:=0; + NotifyEventHooks(hHookChanged,EventMask,0); + EventMask:=0; end; end; @@ -1976,7 +1197,7 @@ begin LVN_ITEMCHANGED: begin if DontReact then exit; // bug when group moved avoid - if wParam=IDC_ACTION_GROUP then + if wParam=IDC_MACRO_LIST then begin if PNMLISTVIEW(lParam)^.uChanged=LVIF_STATE then begin @@ -1984,60 +1205,64 @@ begin (PNMLISTVIEW(lParam)^.uNewState and LVNI_FOCUSED); if lvflag>0 then // old focus - BuildActionChain(PNMLISTVIEW(lParam)^.iItem) + BuildActionChain(Dialog,PNMLISTVIEW(lParam)^.iItem) else if lvflag<0 then // new focus begin DontReact:=true; ClearDialogData; - MakeActionList(@NewGroupList^[PNMLISTVIEW(lParam)^.lParam]); - CheckGrpList(PNMLISTVIEW(lParam)^.iItem); + ResetDialogs; + FillActionList(Dialog,EditMacroList[Loword(PNMLISTVIEW(lParam)^.lParam)]); + CheckMacroListDirectionButtons(Dialog); + ChangeListNotify(2); DontReact:=false; end else begin +{?? lvflag:=(PNMLISTVIEW(lParam)^.uOldState and LVNI_SELECTED)- (PNMLISTVIEW(lParam)^.uNewState and LVNI_SELECTED); + if lvflag<>0 then - CheckGrpList(PNMLISTVIEW(lParam)^.iItem); + CheckMacroListDirectionButtons(Dialog); +} end; end; end + else if wParam=IDC_ACTION_LIST then begin lvflag:=(PNMLISTVIEW(lParam)^.uOldState and LVNI_FOCUSED)- (PNMLISTVIEW(lParam)^.uNewState and LVNI_FOCUSED); if lvflag>0 then // old focus - SaveAction(PNMLISTVIEW(lParam)^.iItem, - PNMLISTVIEW(lParam)^.lParam) + begin + SaveAction(Dialog, + PNMLISTVIEW(lParam)^.iItem, + tBaseAction(PNMLISTVIEW(lParam)^.lParam)); + end else if lvflag<0 then // new focus begin DontReact:=true; ClearDialogData; - j:=PNMLISTVIEW(lParam)^.lParam; - FillAction(j); - CheckActList(PNMLISTVIEW(lParam)^.iItem); + ResetDialogs; + FillAction(Dialog,tBaseAction(PNMLISTVIEW(lParam)^.lParam)); + CheckActListDirectionButtons(Dialog); DontReact:=false; end else begin // checkboxes +{?? lvflag:=(PNMLISTVIEW(lParam)^.uOldState and LVNI_SELECTED)- (PNMLISTVIEW(lParam)^.uNewState and LVNI_SELECTED); - if lvflag<>0 then - CheckGrpList(PNMLISTVIEW(lParam)^.iItem); + if lvflag<>0 then + CheckMacroListDirectionButtons(Dialog); +} if (PNMLISTVIEW(lParam)^.uOldState or PNMLISTVIEW(lParam)^.uNewState)=$3000 then begin - if PNMLISTVIEW(lParam)^.uOldState=$1000 then - i:=0 - else - i:=ACF_DISABLED; - j:=PNMLISTVIEW(lParam)^.lParam; - NewActionList^[j].flags:=(NewActionList^[j].flags and not ACF_DISABLED) or dword(i); - ChMask:=ChMask or ACTM_ACT or ACTM_ACTS; SetChanged(Dialog,etACT); end; end; @@ -2046,26 +1271,26 @@ begin LVN_ENDLABELEDITW: begin if DontReact then exit; - if wParam=IDC_ACTION_GROUP then + + if wParam=IDC_MACRO_LIST then begin with PLVDISPINFOW(lParam)^ do begin if item.pszText<>nil then begin - ChMask:=ChMask or ACTM_RENAME; - SetChanged(Dialog,etHK); + EventMask:=EventMask or ACTM_RENAME; + SetChanged(Dialog,etMacro); item.mask:=LVIF_TEXT; if pWideChar(item.pszText)^=#0 then pWideChar(item.pszText):=NoDescription; SendMessageW(hdr.hWndFrom,LVM_SETITEMW,0,tlparam(@item)); - with NewGroupList^[item.lParam] do + with EditMacroList[loword(item.lParam)]^ do begin - mFreeMem(descr); - StrDupW(descr,item.pszText); + StrCopyW(descr,item.pszText,MacroNameLen-1); end; + ChangeListNotify(1); - FillChainList(Dialog); result:=1; end; end; @@ -2076,12 +1301,11 @@ begin begin if item.pszText<>nil then begin - ChMask:=ChMask or ACTM_ACT or ACTM_ACTS; SetChanged(Dialog,etACT); - ChangeActionName(item.iItem,0,pWideChar(item.pszText)); + ChangeActionName(Dialog,item.iItem,pWideChar(item.pszText)); + ChangeListNotify(2); result:=1; end; -//?? end; end; end; diff --git a/plugins/Actman/i_options.inc b/plugins/Actman/i_options.inc index 26dd8e1f08..fbbf6c558c 100644 --- a/plugins/Actman/i_options.inc +++ b/plugins/Actman/i_options.inc @@ -1,459 +1,475 @@ {Save/load options} const - opt_group = 'Group'; - opt_actions = 'Action'; - opt_numacts = 'numactions'; - opt_numhk = 'numgroups'; - opt_firstAction = 'firstaction'; - - opt_cproto = 'cproto'; - opt_cuid = 'cuid'; - opt_ischat = 'ischat'; + opt_group = 'Group'; + opt_actions = 'Action'; + opt_numacts = 'numactions'; + opt_nummacro = 'numgroups'; opt_descr = 'descr'; opt_id = 'id'; + opt_uid = 'uid'; opt_flags = 'flags'; - opt_flags2 = 'flags2'; - opt_time = 'time'; - opt_show = 'show'; - opt_action = 'action'; - opt_value = 'value'; - opt_file = 'file'; - - opt_next = 'next'; - opt_type = 'type'; - opt_contact = 'contact'; - opt_text = 'text'; - opt_prg = 'program'; - opt_args = 'arguments'; - opt_service = 'service'; - opt_wparam = 'wparam'; - opt_wlparam = 'wparamlen'; - opt_llparam = 'lparamlen'; - opt_lparam = 'lparam'; - opt_chain = 'chain'; - opt_cond = 'condition'; - opt_count = 'count'; - opt_module = 'module'; - opt_setting = 'setting'; - opt_oper = 'operation'; - opt_mathval = 'mathval'; - opt_operval = 'operval'; - opt_varval = 'varval'; - opt_msgtitle = 'msgtitle'; - opt_msgtext = 'msgtext'; - opt_boxopts = 'boxopts'; - //----- Save settings ----- -procedure SaveNumValue(setting:pAnsiChar;value:uint_ptr;isvar:boolean); -begin - if isvar then - DBWriteUnicode(0,DBBranch,setting,pWideChar(value)) - else - DBWriteDWord (0,DBBranch,setting,value); -end; - -function SaveActions(section:pAnsiChar;first:integer):integer; +procedure SaveActions(Macro:pMacroRecord;section:pAnsiChar); var p,p1:PAnsiChar; - act:pHKAction; i:integer; begin - result:=0; + p:=StrEnd(section); + StrCopy(p,opt_numacts); DBWriteWord(0,DBBranch,section,Macro^.ActionCount); + // in: section = "Group#/" - p1:=StrCopyE(StrEnd(section),opt_actions); // "Group#/Action" + p1:=StrCopyE(p,opt_actions); // "Group#/Action" DBDeleteGroup(0,DBBranch,section); - i:=1; - while first<>0 do + + for i:=0 to Macro^.ActionCount-1 do begin - act:=@ActionList[first]; - p:=StrEnd(IntToStr(p1,i)); //!!! + p:=StrEnd(IntToStr(p1,i)); p^:='/'; inc(p); // "Group#/Action#/" - StrCopy(p,opt_flags ); DBWriteDWord(0,DBBranch,section,act^.flags); - StrCopy(p,opt_flags2); DBWriteDWord(0,DBBranch,section,act^.flags2); - StrCopy(p,opt_type ); DBWriteByte (0,DBBranch,section,act^.actionType); - if act^.descr<>nil then - begin - StrCopy(p,opt_descr); DBWriteUnicode(0,DBBranch,section,act^.descr); - end; - - case act^.actionType of - ACT_CONTACT: begin - p^:=#0; - SaveContact(act^.contact,DBBranch,section); - end; - - ACT_SERVICE: begin - StrCopy(p,opt_service); DBWriteString(0,DBBranch,section,act^.service); - - if (act^.flags and (ACF_WCURRENT or ACF_WRESULT or ACF_WPARAM))=0 then - begin - StrCopy(p,opt_wparam); - if (act^.flags and ACF_WPARNUM)<>0 then - SaveNumValue(section,act^.wparam,(act^.flags2 and ACF2_SRV_WPAR)<>0) -// DBWriteDWord(0,DBBranch,section,act^.wparam) - else if act^.wparam<>0 then - begin - if (act^.flags and ACF_WSTRUCT)<>0 then - DBWriteUTF8(0,DBBranch,section,pAnsiChar(act^.wparam)) - else if (act^.flags and ACF_WUNICODE)<>0 then - DBWriteUnicode(0,DBBranch,section,pWideChar(act^.wparam)) - else - DBWriteString(0,DBBranch,section,PAnsiChar(act^.wparam)); - end; - end; - - if (act^.flags and (ACF_LCURRENT or ACF_LRESULT or ACF_LPARAM))=0 then - begin - StrCopy(p,opt_lparam); - if (act^.flags and ACF_LPARNUM)<>0 then - SaveNumValue(section,act^.lparam,(act^.flags2 and ACF2_SRV_LPAR)<>0) -// DBWriteDWord(0,DBBranch,section,act^.lparam) - else if act^.lparam<>0 then - begin - if (act^.flags and ACF_LSTRUCT)<>0 then - DBWriteUTF8(0,DBBranch,section,pAnsiChar(act^.lparam)) - else if (act^.flags and ACF_LUNICODE)<>0 then - DBWriteUnicode(0,DBBranch,section,pWideChar(act^.lparam)) - else - DBWriteString(0,DBBranch,section,PAnsiChar(act^.lparam)); - end; - end; - - end; - - ACT_PROGRAM: begin - StrCopy(p,opt_prg ); DBWriteUnicode(0,DBBranch,section,act^.prgname); - StrCopy(p,opt_args); DBWriteUnicode(0,DBBranch,section,act^.args); - StrCopy(p,opt_time); DBWriteDWord (0,DBBranch,section,act^.time); - StrCopy(p,opt_show); DBWriteDWord (0,DBBranch,section,act^.show); - end; - - ACT_TEXT: begin - if (act^.flags and ACF_CLIPBRD)=0 then - begin - StrCopy(p,opt_text); DBWriteUnicode(0,DBBranch,section,act^.text); - if (act^.flags and ACF_FILE)<>0 then - begin - StrCopy(p,opt_file); DBWriteUnicode(0,DBBranch,section,act^.tfile); - end; - end; - end; - - ACT_ADVANCE: begin - StrCopy(p,opt_cond ); DBWriteByte (0,DBBranch,section,act^.condition); - StrCopy(p,opt_value ); DBWriteDWord (0,DBBranch,section,act^.value); - StrCopy(p,opt_action ); DBWriteByte (0,DBBranch,section,act^.action); - StrCopy(p,opt_operval); DBWriteUnicode(0,DBBranch,section,act^.operval); - StrCopy(p,opt_oper ); DBWriteByte (0,DBBranch,section,act^.oper); - StrCopy(p,opt_mathval); DBWriteDWord (0,DBBranch,section,act^.mathval); - StrCopy(p,opt_varval ); DBWriteUnicode(0,DBBranch,section,act^.varval); - end; - - ACT_CHAIN: begin - StrCopy(p,opt_text); DBWriteDWord(0,DBBranch,section,act^.id); - end; - - ACT_RW: begin - if (act^.flags and ACF_NOCNTCT)=0 then - begin - p^:=#0; - SaveContact(act^.dbcontact,DBBranch,section); - end; - StrCopy(p,opt_module ); DBWriteString(0,DBBranch,section,act^.dbmodule); - StrCopy(p,opt_setting); DBWriteString(0,DBBranch,section,act^.dbsetting); - StrCopy(p,opt_value ); - if (act^.flags and ACF_DBUTEXT)=0 then - begin - SaveNumValue(section,act^.dbvalue,(act^.flags2 and ACF2_RW_TVAR)<>0); -// DBWriteDWord(0,DBBranch,section,act^.dbvalue) - end - else - DBWriteUnicode(0,DBBranch,section,pWideChar(act^.dbvalue)); - end; - - ACT_MESSAGE: begin - StrCopy(p,opt_msgtitle); DBWriteUnicode(0,DBBranch,section,act^.msgtitle); - StrCopy(p,opt_msgtext ); DBWriteUnicode(0,DBBranch,section,act^.msgtext); - StrCopy(p,opt_boxopts ); DBWriteByte (0,DBBranch,section,act^.boxopts); //!! - end; - - end; - inc(result); - inc(i); - first:=ActionList^[first].next; +//?? StrCopy(p,opt_uid); DBWriteDWord(0,DBBranch,section,Macro^.ActionList[i].uid); + p^:=#0; + Macro^.ActionList[i].Save(section,0); end; + end; -procedure SaveGroups; +procedure SaveMacros; var - HK:pHKRecord; - NumHK:integer; - i,num:integer; + Macro:pMacroRecord; + OldNumMacros,NumMacros:integer; + i:integer; section:array [0..127] of AnsiChar; p,p1:PAnsiChar; - Actions:integer; begin // even if crap in settings, skip on read -// DBDeleteGroup(0,DBBranch,opt_group); - HK:=@GroupList^; - i:=MaxGroups; - NumHK:=0; - Actions:=1; - DBWriteUnicode(0,DBBranch,'CLformat',fCLformat); - DBWriteByte (0,DBBranch,'CLfilter',ord(fCLfilter)); + DBWriteByte(0,DBBranch,'version' ,3); + + OldNumMacros:=DBReadWord(0,DBBranch,opt_nummacro,0); + + Macro:=MacroList[0]; + i:=MacroList.Count; + NumMacros:=0; p1:=StrCopyE(section,opt_group); while i>0 do begin - with HK^ do + with Macro^ do begin if (flags and (ACF_ASSIGNED or ACF_VOLATILE))=ACF_ASSIGNED then begin - p:=StrEnd(IntToStr(p1,NumHK)); + p:=StrEnd(IntToStr(p1,NumMacros)); p^:='/'; inc(p); StrCopy(p,opt_id ); DBWriteDWord(0,DBBranch,section,id); StrCopy(p,opt_flags); DBWriteDWord(0,DBBranch,section,flags); - StrCopy(p,opt_descr); - if descr<>nil then - DBWriteUnicode (0,DBBranch,section,descr) - else - DBDeleteSetting(0,DBBranch,section); + StrCopy(p,opt_descr); DBWriteUnicode (0,DBBranch,section,descr); p^:=#0; - //?? - num:=SaveActions(section,firstAction); - StrCopy(p,opt_numacts); DBWriteWord(0,DBBranch,section,num); - inc(Actions,num); - inc(NumHK); + SaveActions(Macro,section); + + inc(NumMacros); end; end; - inc(HK); + inc(Macro); dec(i); end; - DBWriteWord(0,DBBranch,opt_numhk ,NumHK); - DBWriteWord(0,DBBranch,opt_numacts,Actions-1); + DBWriteWord(0,DBBranch,opt_nummacro,NumMacros); + + // deleting old unused macro settings + while OldNumMacros>NumMacros do + begin + dec(OldNumMacros); + IntToStr(p1,OldNumMacros); + DBDeleteGroup(0,DBBranch,section); + end; end; -//----- Load settings ----- +//===== Load settings ===== + +//----- V2 settings processing ----- + +const + ACT_CONTACT = 1; + ACT_SERVICE = 2; + ACT_PROGRAM = 3; + ACT_TEXT = 4; + ACT_ADVANCE = 5; + ACT_CHAIN = 6; + ACT_RW = 7; + ACT_MESSAGE = 8; + +// action flags +const + ACF_MASK = $00FFFFFF; -function LoadNumValue(setting:pAnsiChar;isvar:boolean):uint_ptr; + ACF_OLD_CLIPBRD = $00000002; // Clipboard operations, not window + ACF_OLD_FILE = $00000010; // File operations + ACF_OLD_FWRITE = $00000020; // read/write file + ACF_OLD_FAPPEND = $00000040; // append file + +const + OldVersion = 'Your Actman settings are for old version. If you are ready to upgrade settings, ' + + 'press OK. Else press Cancel and change manually Actman plugin back to old version ' + + 'or make settings backup. To keep previously exported macros please import them back ' + + 'before conversion.'; + Notes = 'Please, don''t use macro test for non-saved macros. If you had ''Advanced'' or file ' + + 'writing actions previously, check them - their logic was changed.'; + ConvResult = 'Actman settings converted to new version'; + +procedure CheckActionList(Macro:pMacroRecord;num:integer); +var + tmplist:pActionList; begin - if isvar then - result:=uint_ptr(DBReadUnicode(0,DBBranch,setting,nil)) - else - result:=DBReadDWord(0,DBBranch,setting); + if num=Macro^.ActionCount then + begin + GetMem(tmplist,SizeOf(tBaseAction)*(num+1)); + move(Macro^.ActionList^,tmplist^,Macro^.ActionCount*SizeOf(tBaseAction)); + FreeMem(Macro^.ActionList); + Macro^.ActionList:=tmplist; + Inc(Macro^.ActionCount); + end; end; -function LoadActions(section:pAnsiChar;count:integer):integer; +function LoadActionsV2(Macro:pMacroRecord;section:pAnsiChar):boolean; stdcall; var - p,p1:PAnsiChar; - act:tHKAction; - i,num,oldnum:integer; + buf:array [0..31] of WideChar; + p,p1,pc:PAnsiChar; + action:tBaseAction; + actm:pActModule; + flags2,actionType:dword; + code,i,num,count:integer; + cond,act:byte; begin - result:=0; - p1:=StrCopyE(StrEnd(section),opt_actions); // "Group#/Action" + result:=false; + p:=StrEnd(section); + StrCopy(p,opt_numacts); Macro^.ActionCount:=DBReadWord(0,DBBranch,section); - oldnum:=0; - for i:=1 to count do + if Macro^.ActionCount>0 then begin - p:=StrEnd(IntToStr(p1,i)); - p^:='/'; inc(p); // "Group#/Action#/" - FillChar(act,SizeOf(act),0); + GetMem(Macro^.ActionList,SizeOf(tBaseAction)*Macro^.ActionCount); + p1:=StrCopyE(p,opt_actions); // "Group#/Action" - StrCopy(p,opt_flags ); act.flags :=DBReadDWord (0,DBBranch,section,0); - if (act.flags and ACF_ASSIGNED)<>0 then + num:=0; + count:=Macro^.ActionCount; + for i:=1 to count do begin - StrCopy(p,opt_flags2); act.flags2 :=DBReadDWord (0,DBBranch,section,0); - StrCopy(p,opt_descr ); act.descr :=DBReadUnicode(0,DBBranch,section,nil); - StrCopy(p,opt_type ); act.actionType:=DBReadByte (0,DBBranch,section,ACT_CONTACT); + p:=StrEnd(IntToStr(p1,i)); + p^:='/'; inc(p); // "Group#/Action#/" + + StrCopy(p,'type' ); actionType:=DBReadByte (0,DBBranch,section,ACT_CONTACT); + case actionType of + ACT_CONTACT: pc:='Contact'; + ACT_SERVICE: pc:='Service'; + ACT_PROGRAM: pc:='Program'; + ACT_TEXT: pc:=nil; + ACT_ADVANCE: pc:=nil; + ACT_CHAIN: pc:='Chain'; + ACT_RW: pc:='Database'; + ACT_MESSAGE: pc:='MessageBox'; + else + pc:=nil; + end; + if pc<>nil then + begin + actm :=GetLinkByName(pc); + action:=actm.Create; + end + else + begin + action:=nil; + end; - case act.actionType of + p^:=#0; + case actionType of ACT_CONTACT: begin - p^:=#0; - act.contact:=LoadContact(DBBranch,section); + action.Load(section,0); end; ACT_SERVICE: begin - StrCopy(p,opt_service); - act.service:=DBReadString(0,DBBranch,section,nil); - - if (act.flags and (ACF_WCURRENT or ACF_WRESULT or ACF_WPARAM))=0 then - begin - StrCopy(p,opt_wparam); - if (act.flags and ACF_WPARNUM)<>0 then - act.wparam:=LoadNumValue(section,(act.flags2 and ACF2_SRV_WPAR)<>0) - else if (act.flags and ACF_WSTRUCT)<>0 then - act.wparam:=wparam(DBReadUTF8(0,DBBranch,section,nil)) - else if (act.flags and ACF_WUNICODE)<>0 then - act.wparam:=wparam(DBReadUnicode(0,DBBranch,section,nil)) - else - act.wparam:=wparam(DBReadString (0,DBBranch,section,nil)); - end; - - if (act.flags and (ACF_LCURRENT or ACF_LRESULT or ACF_LPARAM))=0 then - begin - StrCopy(p,opt_lparam); - if (act.flags and ACF_LPARNUM)<>0 then - act.lparam:=LoadNumValue(section,(act.flags2 and ACF2_SRV_LPAR)<>0) - // act.lparam:=DBReadDWord(0,DBBranch,section,0) - else if (act.flags and ACF_LSTRUCT)<>0 then - act.lparam:=lparam(DBReadUTF8(0,DBBranch,section,nil)) - else if (act.flags and ACF_LUNICODE)<>0 then - act.lparam:=lparam(DBReadUnicode(0,DBBranch,section,nil)) - else - act.lparam:=lparam(DBReadString(0,DBBranch,section,nil)); - end; - + action.Load(section,100); end; ACT_PROGRAM: begin - StrCopy(p,opt_prg ); act.prgname:=DBReadUnicode(0,DBBranch,section,nil); - StrCopy(p,opt_args); act.args :=DBReadUnicode(0,DBBranch,section,nil); - StrCopy(p,opt_time); act.time :=DBReadDWord (0,DBBranch,section,0); - StrCopy(p,opt_show); act.show :=DBReadDWord (0,DBBranch,section,SW_SHOW); + action.Load(section,100); end; ACT_TEXT: begin - if (act.flags and ACF_CLIPBRD)=0 then + StrCopy(p,opt_flags); flags2:=DBReadDWord(0,DBBranch,section,0); + p^:=#0; + if ((flags2 and ACF_OLD_CLIPBRD)=0) then begin - StrCopy(p,opt_text); act.text:=DBReadUnicode(0,DBBranch,section,nil); - if (act.flags and ACF_FILE)<>0 then + if ((flags2 and ACF_OLD_FILE)=0) or ((flags2 and (ACF_OLD_FWRITE or ACF_OLD_FAPPEND)<>0)) then begin - StrCopy(p,opt_file); act.tfile:=DBReadUnicode(0,DBBranch,section,nil); + actm :=GetLinkByName('Text'); + action:=actm.Create; + + action.Load(section,100); + + CheckActionList(Macro,num); + Macro^.ActionList^[num]:=action; + inc(num); end; end; + + actm :=GetLinkByName('In/Out'); + action:=actm.Create; + + action.Load(section,100); end; ACT_ADVANCE: begin - StrCopy(p,opt_cond ); act.condition:=DBReadByte (0,DBBranch,section); - StrCopy(p,opt_value ); act.value :=DBReadDWord (0,DBBranch,section); - StrCopy(p,opt_action ); act.action :=DBReadByte (0,DBBranch,section); - StrCopy(p,opt_oper ); act.oper :=DBReadByte (0,DBBranch,section); - StrCopy(p,opt_mathval); act.mathval :=DBReadDWord (0,DBBranch,section); - StrCopy(p,opt_operval); act.operval :=DBReadUnicode(0,DBBranch,section); - StrCopy(p,opt_varval ); act.varval :=DBReadUnicode(0,DBBranch,section); + StrCopy(p,'condition' ); cond:=DBReadByte(0,DBBranch,section); + StrCopy(p,'action'); act :=DBReadByte(0,DBBranch,section); + p^:=#0; + // get code of my list + code:=0; + if (cond and $0F)=0 then + begin + if act<>0 then code:=4; // action and jump + if (act and $F0)=0 then code:=6; // no action + if (act and $0F)=0 then code:=5; // no jump + end + else // with condition + begin + if act<>0 then code:=1; // action and jump + if (act and $F0)=0 then code:=2; // no action + if (act and $0F)=0 then code:=3; // no jump + end; + case code of + 1: begin // conditional action and jump + actm :=GetLinkByName('Jump'); // reversed condition jump to tmplabel + action:=actm.Create; + action.Load(section,102+i); + CheckActionList(Macro,num); + Macro^.ActionList^[num]:=action; + inc(num); + + actm :=GetLinkByName('Text'); // action + action:=actm.Create; + action.Load(section,101); + CheckActionList(Macro,num); + Macro^.ActionList^[num]:=action; + inc(num); + + actm :=GetLinkByName('Jump'); // jump to label (no condition) + action:=actm.Create; + action.Load(section,101); + CheckActionList(Macro,num); + Macro^.ActionList^[num]:=action; + inc(num); + + actm :=GetLinkByName('Notes'); // tmplabel + action:=actm.Create; + mFreeMem(action.ActionDescr); // created by constructor + buf[0]:='$'; buf[1]:='$'; + IntToStr(PWideChar(@buf[2]),i); + StrDupW(action.ActionDescr,buf); + end; + 2,6: begin // conditional and unconditional jump + actm :=GetLinkByName('Jump'); + action:=actm.Create; + + action.Load(section,100); + end; + 3: begin // conditional action + actm :=GetLinkByName('Jump'); + action:=actm.Create; + action.Load(section,101+num); + CheckActionList(Macro,num); + Macro^.ActionList^[num]:=action; + inc(num); + + actm :=GetLinkByName('Text'); + action:=actm.Create; + action.Load(section,101); + CheckActionList(Macro,num); + Macro^.ActionList^[num]:=action; + inc(num); + + actm :=GetLinkByName('Notes'); + action:=actm.Create; + mFreeMem(action.ActionDescr); // created by constructor + buf[0]:='$'; buf[1]:='$'; + StrDupW(action.ActionDescr,IntToStr(PWideChar(@buf[2]),num)); + end; + 4: begin // action + unconditional jump + actm :=GetLinkByName('Text'); + action:=actm.Create; + action.Load(section,101); + CheckActionList(Macro,num); + Macro^.ActionList^[num]:=action; + inc(num); + + actm :=GetLinkByName('Jump'); + action:=actm.Create; + + action.Load(section,100); + end; + 5: begin // direct text action + actm :=GetLinkByName('Text'); + action:=actm.Create; + + action.Load(section,101); + end; + end; end; ACT_CHAIN: begin - StrCopy(p,opt_text); act.id:=DBReadDWord(0,DBBranch,section); + action.Load(section,100); end; ACT_RW: begin - if (act.flags and ACF_NOCNTCT)=0 then - begin - p^:=#0; - act.dbcontact:=LoadContact(DBBranch,section); - end; - StrCopy(p,opt_module ); act.dbmodule :=DBReadString(0,DBBranch,section); - StrCopy(p,opt_setting); act.dbsetting:=DBReadString(0,DBBranch,section); - StrCopy(p,opt_value ); - - if (act.flags and ACF_DBUTEXT)=0 then - act.dbvalue:=LoadNumValue(section,(act.flags2 and ACF2_RW_TVAR)<>0) - else - act.dbvalue:=uint_ptr(DBReadUnicode(0,DBBranch,section)); + action.Load(section,100); end; ACT_MESSAGE: begin - StrCopy(p,opt_msgtitle); act.msgtitle:=DBReadUnicode(0,DBBranch,section); - StrCopy(p,opt_msgtext ); act.msgtext :=DBReadUnicode(0,DBBranch,section); - StrCopy(p,opt_boxopts ); act.boxopts :=DBReadByte (0,DBBranch,section); + action.Load(section,0); + + StrCopy(p,'flags2'); flags2:=DBReadDWord(0,DBBranch,section,0); + action.flags:=(action.flags and not ACF_MASK) or flags2; end; end; - num:=NewAction(ActionList,MaxActions); - move(act,ActionList^[num],SizeOf(tHKAction)); - if i=1 then - result:=num - else - ActionList^[oldnum].next:=num; - oldnum:=num; + + if action<>nil then + begin + CheckActionList(Macro,num); + Macro^.ActionList^[num]:=action; + inc(num); + end; end; end; end; -procedure LoadGroups; +//----- V3 settings processing ----- + +function LoadActions(Macro:pMacroRecord;section:pAnsiChar):integer; stdcall; var - HK:pHKRecord; - i,num:cardinal; p,p1:PAnsiChar; - section:array [0..127] of AnsiChar; - NumGroups,NumActions:cardinal; + actm:pActModule; + action:tBaseAction; + tmp:pActionList; + uid:dword; + i,num:integer; begin -{ remove doubling - no need? (called just once) - if MaxGroups>0 then + result:=0; + p:=StrEnd(section); + StrCopy(p,opt_numacts); Macro^.ActionCount:=DBReadWord(0,DBBranch,section); + if Macro^.ActionCount>0 then begin - while MaxGroups>0 do + GetMem(Macro^.ActionList,SizeOf(tBaseAction)*Macro^.ActionCount); + p1:=StrCopyE(p,opt_actions); // "Group#/Action" + + num:=0; + for i:=0 to Macro^.ActionCount-1 do begin - FreeGroup(MaxGroups); - dec(MaxGroups); + p:=StrEnd(IntToStr(p1,i)); + p^:='/'; inc(p); // "Group#/Action#/" + + // get uid + StrCopy(p,opt_uid); uid:=DBReadDWord(0,DBBranch,section,0); + if uid<>0 then + begin + p^:=#0; + // call proper constructor + actm:=GetLink(uid); + if actm=nil then + continue; + + action:=actm.Create; + // call proper loader + action.Load(section,0); + + Macro^.ActionList^[num]:=action; + inc(num); + end; end; - FreeMem(GroupList); - end; -} - NumGroups:=DBReadWord(0,DBBranch,opt_numhk,HKListPage); - if NumGroups0 then - begin - act:=@ActionList[1]; - while MaxActions>0 do + if Macro^.ActionCount<>num then begin - FreeAction(act); - inc(act); - dec(MaxActions); + GetMem(tmp,SizeOf(tBaseAction)*num); + move(Macro^.ActionList^,tmp^,SizeOf(tBaseAction)*num); + Macro^.ActionCount:=num; + FreeMem(Macro^.ActionList); + Macro^.ActionList:=tmp; end; - FreeMem(ActionList); end; -} - NumActions:=DBReadWord(0,DBBranch,opt_numacts,ActListPage); - if NumActions0 then begin - p:=StrEnd(IntToStr(p1,i)); - p^:='/'; inc(p); + // V2 counts actions from 1, not 0 + v2:=DBReadDWord(0,DBBranch,'Group0/Action0/flags',$FFFFFFFF)=$FFFFFFFF; - StrCopy(p,opt_flags); - with HK^ do + if v2 then begin - flags:=DBReadDWord(0,DBBranch,section,0{integer(ACF_ASSIGNED or ACF_DISABLED)}); - if (flags and ACF_ASSIGNED)<>0 then // not needed in normal cases + if MessageBoxW(0,TranslateW(OldVersion),'Actman',MB_OKCANCEL or MB_ICONWARNING)<>IDOK then begin - StrCopy(p,opt_id ); id :=DBReadDWord (0,DBBranch,section); - StrCopy(p,opt_descr); descr:=DBReadUnicode(0,DBBranch,section,nil); - if descr=nil then - StrDupW(descr,TranslateW('No description')); + MacroList:=tMacroList.Create(0); + exit; + end; + end; + end; - StrCopy(p,opt_numacts); num:=DBReadWord(0,DBBranch,section); - p^:=#0; - firstAction:=LoadActions(section,num); + // Allocate macro list + MacroList:=tMacroList.Create(NumMacros); + + // read macro list settings + if NumMacros>0 then //?? really, not so necessary + begin + Macro:=MacroList[0]; + i:=0; + p1:=StrCopyE(section,opt_group); + while i0 then //?? not needed in normal cases + begin + StrCopy(p,opt_id ); id :=DBReadDWord (0,DBBranch,section); + StrCopy(p,opt_descr); tmp:=DBReadUnicode(0,DBBranch,section,NoDescription); + StrCopyW(descr,tmp,MacroNameLen-1); + mFreeMem(tmp); + p^:=#0; + if v2 then + LoadActionsV2(Macro,section) + else + LoadActions(Macro,section); + end; end; + inc(Macro); + inc(i); + end; + + if v2 then + begin + DBDeleteSetting(0,DBBranch,opt_numacts); + SaveMacros; + MessageBoxW(0,TranslateW(Notes),TranslateW(ConvResult),MB_ICONINFORMATION); end; - inc(HK); - inc(i); end; - fCLfilter:=DBReadByte (0,DBBranch,'CLfilter',0)<>0; - fCLformat:=DBReadUnicode(0,DBBranch,'CLformat'); + end; diff --git a/plugins/Actman/i_services.inc b/plugins/Actman/i_services.inc index d835c9225a..2954fa4b15 100644 --- a/plugins/Actman/i_services.inc +++ b/plugins/Actman/i_services.inc @@ -1,5 +1,27 @@ {Basic ActMan services} +function ActSelect(wParam:WPARAM;lParam:LPARAM):int_ptr;cdecl; +begin + if odd(wParam) then + result:=int_ptr(MacroList.GetMacro(lParam)) + else + result:=int_ptr(MacroList.GetMacro(pWideChar(lParam))); + + if result<>0 then + with pMacroRecord(result)^ do + begin + if (wParam and 4)<>0 then + result:=ord((flags and ACF_SELECTED)<>0) + else + begin + if (wParam and 2)<>0 then + flags:=flags and not ACF_SELECTED + else + flags:=flags or ACF_SELECTED; + end; + end; +end; + function ActFreeList(wParam:WPARAM;lParam:LPARAM):int_ptr;cdecl; begin result:=0; @@ -9,12 +31,12 @@ end; function ActGetList(wParam:WPARAM;lParam:LPARAM):int_ptr;cdecl; var pc:^tChain; - p:pHKRecord; + p:pMacroRecord; i,cnt:integer; begin - p:=@GroupList[0]; + p:=MacroList[0]; cnt:=0; - for i:=0 to MaxGroups-1 do + for i:=0 to MacroList.Count-1 do begin if (p^.flags and (ACF_ASSIGNED or ACF_VOLATILE))=ACF_ASSIGNED then inc(cnt); inc(p); @@ -25,12 +47,11 @@ begin begin mGetMem(pc,cnt*SizeOf(tChain)+4); puint_ptr(lParam)^:=uint_ptr(pc); -// {$IFDEF WIN64}pqword{$ELSE}pdword{$ENDIF}(lParam)^:=uint_ptr(pc); pdword(pc)^:=SizeOf(tChain); inc(PByte(pc),4); - p:=@GroupList[0]; - for i:=0 to MaxGroups-1 do + p:=MacroList[0]; + for i:=0 to MacroList.Count-1 do begin if (p^.flags and (ACF_ASSIGNED or ACF_VOLATILE))=ACF_ASSIGNED then begin @@ -44,88 +65,253 @@ begin end else puint_ptr(lParam)^:=0; -// {$IFDEF WIN64}pqword{$ELSE}pdword{$ENDIF}(lParam)^:=0; end; -function ActRun(wParam:WPARAM;lParam:LPARAM):int_ptr;cdecl; +//====================== Execute code ======================= + +{$IFDEF DEBUG} +procedure ActmanMacroDebug(txt:pWideChar); +begin + OutputDebugStringW(txt); +end; +{$ENDIF} + +procedure DoAction(Macro:pMacroRecord;var WorkData:tWorkData); var - i:integer; - p:pHKRecord; + res:LRESULT; + i,cnt:integer; +{$IFDEF DEBUG} + buf:array [0..1023] of WideChar; + buf1,buf2:array [0..31] of WideChar; + p:pWideChar; +{$ENDIF} begin - result:=-1; - p:=@GroupList[0]; - for i:=0 to MaxGroups-1 do + cnt:=Macro^.ActionCount; + if cnt<>0 then begin - if ((p^.flags and ACF_ASSIGNED)<>0) and (p^.id=dword(wParam)) then +//!! act:=CloneActions(action); + i:=0; + WorkData.ActionList :=Macro^.ActionList; + WorkData.ActionCount:=Macro^.ActionCount; + while i0 then // res = next action number+1 + begin + i:=res-1; + continue; + end; + end; + inc(i); end; - inc(p); +//!! FreeActionsContinued(act_org); end; - if result>0 then - result:=ActionStarter(result,lParam,p); end; -function ActRunGroup(wParam:WPARAM;lParam:LPARAM):int_ptr;cdecl; +type + pActStartData = ^tActStartData; + tActStartData = record + macro :pMacroRecord; + event :THANDLE; + WorkData:tWorkData; + flags :dword; + end; + +procedure ThDoAction(arg:pActStartData); cdecl; var i:integer; - p:pHKRecord; begin - result:=-1; - p:=@GroupList[0]; - for i:=0 to MaxGroups-1 do + if (arg^.flags and ACTP_NOTIFY)<>0 then begin - if ((p^.flags and ACF_ASSIGNED)<>0) and (StrCmpW(p^.descr,pWideChar(wParam))=0) then - begin - result:=p^.firstAction; - break; - end; - inc(p); + NotifyEventHooks(hevaction,arg^.macro.id,0); // started + arg^.macro.flags:=arg^.macro.flags or ACF_USEDNOW; + end; + + DoAction(arg^.macro,arg^.WorkData); + + if (arg^.flags and ACTP_NOTIFY)<>0 then + begin + arg^.macro.flags:=arg^.macro.flags and not ACF_USEDNOW; + NotifyEventHooks(hevaction,arg^.macro.id,1); // finished + end; + + if arg^.event<>0 then // service, waiting + SetEvent(arg^.event) + else if (arg^.flags and ACTP_SAMETHREAD)=0 then // no waiting + begin + ClearResult(arg^.WorkData); // free last result memory if needs + // Free Storage + for i:=0 to 9 do + ClearResult(arg^.WorkData,i); + mFreeMem(arg); // free ActStartData (no time to free after) end; - if result>0 then - result:=ActionStarter(result,lParam,p); end; -function ActRunParam(wParam:WPARAM;lParam:LPARAM):int_ptr;cdecl; +function ActionStarter(macro:pMacroRecord;wd:pWorkData;flags:dword):LPARAM; var + tmp:pActStartData; i:integer; - p:pHKRecord; begin - result:=-1; - p:=@GroupList[0]; - - if (pAct_Param(lParam)^.flags and ACTP_BYNAME)=0 then + mGetMem (tmp ,SizeOf(tActStartData)); + FillChar(tmp^,SizeOf(tActStartData),0); + + if wd<>nil then begin - for i:=0 to MaxGroups-1 do - begin - if ((p^.flags and ACF_ASSIGNED)<>0) and (p^.id=pAct_Param(lParam)^.Id) then - begin - result:=p^.firstAction; - break; + tmp^.WorkData.ResultType:=wd^.ResultType; + case wd^.ResultType of + rtInt : tmp^.WorkData.LastResult:=wd^.LastResult; + rtWide: StrDupW(pWideChar(tmp^.WorkData.LastResult),pWideChar(wd^.LastResult)); + rtAnsi: begin + AnsiToWide(pAnsiChar(wd^.LastResult),pWideChar(tmp^.WorkData.LastResult)); + tmp^.WorkData.ResultType:=rtWide; + end; + rtUTF8: begin + UTF8ToWide(pAnsiChar(wd^.LastResult),pWideChar(tmp^.WorkData.LastResult)); + tmp^.WorkData.ResultType:=rtWide; end; - inc(p); end; + tmp^.WorkData.Parameter:=wd^.Parameter; end else + tmp^.WorkData.ResultType:=rtInt; + + tmp^.macro :=macro; + tmp^.flags :=flags; + + if (flags and ACTP_SAMETHREAD)<>0 then // with waiting, macro or service begin - for i:=0 to MaxGroups-1 do + tmp^.event:=0; + ThDoAction(tmp); + // keep text result (for macro from macro) + if (flags and ACTP_KEEPRESULT)<>0 then begin - if ((p^.flags and ACF_ASSIGNED)<>0) and - (StrCmpW(p^.descr,pWideChar(pAct_Param(lParam)^.Id))=0) then - begin - result:=p^.firstAction; - break; - end; - inc(p); - end; - end; + wd^.ResultType:=tmp^.WorkData.ResultType; + if wd^.ResultType=rtInt then + wd^.LastResult:=tmp^.WorkData.LastResult + else + StrDupW(pWideChar(wd^.LastResult),pWideChar(tmp^.WorkData.LastResult)); + result:=0; + end + else if tmp^.WorkData.ResultType=rtInt then + result:=tmp^.WorkData.LastResult + // result no needs or macro from service + else + result:=StrToInt(pWideChar(tmp^.WorkData.LastResult)); + end - if result>0 then + else if (flags and ACTP_WAIT)<>0 then // with waiting, service begin - if (pAct_Param(lParam)^.flags and ACTP_WAIT)=0 then - result:=ActionStarter (result,pAct_Param(lParam)^.wParam,p,pAct_Param(lParam)^.lParam) + tmp^.event:=CreateEvent(nil,FALSE,FALSE,nil); + {CloseHandle}(mir_forkthread(@ThDoAction,tmp)); + //!!!!!!!!! movetmp structure (event handle) to array, not stack? + WaitForSingleObjectEx(tmp^.event,INFINITE,true); + CloseHandle(tmp^.event); + if tmp^.WorkData.ResultType=rtWide then + result:=StrToInt(pWideChar(tmp^.WorkData.LastResult)) else - result:=ActionStarterWait(result,pAct_Param(lParam)^.wParam,p,pAct_Param(lParam)^.lParam); + result:=tmp^.WorkData.LastResult; + end + + else // no waiting, service or macro + begin + tmp^.event:=0; + {CloseHandle}(mir_forkthread(@ThDoAction,tmp)); + result:=0; + exit; + end; + + ClearResult(tmp^.WorkData); // free last result memory if needs + // Free Storage + for i:=0 to 9 do + ClearResult(tmp^.WorkData,i); + mFreeMem(tmp); // free ActStartData (no time to free after) +end; + +//----- execute services ----- + +function ActRun(wParam:WPARAM;lParam:LPARAM):int_ptr;cdecl; +var + p:pMacroRecord; + w:tWorkData; +begin + result:=-1; + p:=MacroList.GetMacro(wParam); + if p<>nil then + begin + FillChar(w,SizeOf(w),0); + w.ResultType:=rtInt; + w.Parameter:=lParam; + result:=ActionStarter(p,@w,ACTP_SAMETHREAD); + end; +end; + +function ActRunGroup(wParam:WPARAM;lParam:LPARAM):int_ptr;cdecl; +var + p:pMacroRecord; + w:tWorkData; +begin + result:=-1; + p:=MacroList.GetMacro(pWideChar(wParam)); + if p<>nil then + begin + FillChar(w,SizeOf(w),0); + w.ResultType:=rtInt; + w.Parameter:=lParam; + result:=ActionStarter(p,@w,ACTP_SAMETHREAD); + end; +end; + +function ActRunParam(wParam:WPARAM;lParam:LPARAM):int_ptr;cdecl; +var + p:pMacroRecord; + w:tWorkData; +begin + result:=-1; + if (pAct_Param(lParam)^.flags and ACTP_BYNAME)=0 then + p:=MacroList.GetMacro(pAct_Param(lParam)^.Id) + else + p:=MacroList.GetMacro(pWideChar(pAct_Param(lParam)^.Id)); + + if p<>nil then + begin + FillChar(w,SizeOf(w),0); + w.Parameter :=pAct_Param(lParam)^.wParam; + w.LastResult:=pAct_Param(lParam)^.lParam; + w.ResultType:=pAct_Param(lParam)^.lPType; + result:=ActionStarter(p,@w,pAct_Param(lParam)^.flags); + if (pAct_Param(lParam)^.flags and (ACTP_KEEPRESULT or ACTP_SAMETHREAD))= + (ACTP_KEEPRESULT or ACTP_SAMETHREAD) then + begin + pAct_Param(lParam)^.lParam:=w.LastResult; + pAct_Param(lParam)^.lPType:=w.ResultType; + end; end; end; diff --git a/plugins/Actman/i_vars.inc b/plugins/Actman/i_vars.inc deleted file mode 100644 index 4ca6764191..0000000000 --- a/plugins/Actman/i_vars.inc +++ /dev/null @@ -1,31 +0,0 @@ -{variables} -type - pHKList = ^tHKList; - tHKList = array [0..1023] of tHKRecord; - pActList = ^tActList; - tActList = array [0..1023] of tHKAction; -const - StructDelim = #7; -const - HKListPage = 8; - ActListPage = 16; -var - MaxGroups :cardinal=0; // current array size - MaxActions:cardinal=0; // current array size -var - GroupList :pHKList =nil; - ActionList:pActList=nil; -var - NoDescription:PWideChar; -var - NewGroupList :pHKList = nil; - NewActionList:pActList = nil; - NewMaxGroups :cardinal; - NewMaxActions:cardinal; -var - xmlfilename:array [0..511] of WideChar; -var - fCLfilter:boolean = true; - fCLformat:pWideChar = nil; -var - ApiCard:tmApiCard; \ No newline at end of file diff --git a/plugins/Actman/i_visual.inc b/plugins/Actman/i_visual.inc deleted file mode 100644 index ab32488165..0000000000 --- a/plugins/Actman/i_visual.inc +++ /dev/null @@ -1,1073 +0,0 @@ -{Dialog visual part, depends of Dialog window} - procedure SHControl(ctrl,mode:dword); - begin - ShowWindow(GetDlgItem(Dialog,ctrl),mode); - end; - - procedure SetupControls(group,mode:dword); - begin - case group of - ACT_CONTACT: begin - SHControl(IDC_STAT_CONTACT,mode); - SHControl(IDC_CONTACTLIST ,mode); - SHControl(IDC_CNT_KEEP ,mode); - SHControl(IDC_CNT_FILTER ,mode); - SHControl(IDC_STAT_FORMAT ,mode); - SHControl(IDC_EDIT_FORMAT ,mode); - SHControl(IDC_CNT_APPLY ,mode); - SHControl(IDC_STAT_FHELP ,mode); - end; - ACT_SERVICE: begin - SHControl(IDC_STAT_WPAR ,mode); - SHControl(IDC_STAT_LPAR ,mode); - SHControl(IDC_STAT_WPAR1 ,mode); - SHControl(IDC_STAT_LPAR1 ,mode); - SHControl(IDC_STAT_SERVICE,mode); - SHControl(IDC_EDIT_SERVICE,mode); - SHControl(IDC_SRV_SRVC ,mode); - SHControl(IDC_FLAG_WPAR ,mode); - SHControl(IDC_FLAG_LPAR ,mode); - - SHControl(IDC_RES_GROUP ,mode); - SHControl(IDC_RES_POPUP ,mode); - SHControl(IDC_RES_MESSAGE ,mode); - SHControl(IDC_RES_INSERT ,mode); - - SHControl(IDC_SRV_RESULT ,mode); - SHControl(IDC_SRV_RESSTAT ,mode); - - if mode=SW_SHOW then - begin -//!! Check parameter type - if CB_GetData(GetDlgItem(Dialog,IDC_FLAG_WPAR))=ptStruct then -// if SendDlgItemMessage(Dialog,IDC_FLAG_WPAR,CB_GETCURSEL,0,0)=ptStruct then - begin - SHControl(IDC_WSTRUCT ,SW_SHOW); - SHControl(IDC_EDIT_WPAR,SW_HIDE); - SHControl(IDC_SRV_WPAR ,SW_HIDE); - end - else - begin - SHControl(IDC_WSTRUCT ,SW_HIDE); - SHControl(IDC_EDIT_WPAR,SW_SHOW); - SHControl(IDC_SRV_WPAR ,SW_SHOW); - end; - if CB_GetData(GetDlgItem(Dialog,IDC_FLAG_LPAR))=ptStruct then -// if SendDlgItemMessage(Dialog,IDC_FLAG_LPAR,CB_GETCURSEL,0,0)=ptStruct then - begin - SHControl(IDC_LSTRUCT ,SW_SHOW); - SHControl(IDC_EDIT_LPAR,SW_HIDE); - SHControl(IDC_SRV_LPAR ,SW_HIDE); - end - else - begin - SHControl(IDC_LSTRUCT ,SW_HIDE); - SHControl(IDC_EDIT_LPAR,SW_SHOW); - SHControl(IDC_SRV_LPAR ,SW_SHOW); - end; - - case CB_GetData(GetDlgItem(Dialog,IDC_SRV_RESULT)) of - sresHex: ; - sresInt: SHControl(IDC_RES_SIGNED,SW_SHOW); - sresString: begin - SHControl(IDC_RES_UNICODE,SW_SHOW); - SHControl(IDC_RES_FREEMEM,SW_SHOW); - end; - sresStruct: ; - end; - - end - else - begin - SHControl(IDC_WSTRUCT ,SW_HIDE); - SHControl(IDC_LSTRUCT ,SW_HIDE); - SHControl(IDC_SRV_WPAR ,SW_HIDE); - SHControl(IDC_SRV_LPAR ,SW_HIDE); - SHControl(IDC_EDIT_WPAR ,SW_HIDE); - SHControl(IDC_EDIT_LPAR ,SW_HIDE); - SHControl(IDC_RES_FREEMEM,SW_HIDE); - SHControl(IDC_RES_UNICODE,SW_HIDE); - SHControl(IDC_RES_SIGNED ,SW_HIDE); - end; - end; - ACT_PROGRAM: begin - SHControl(IDC_PROCESS_GROUP,mode); - SHControl(IDC_PROGRAM ,mode); - SHControl(IDC_EDIT_PROCTIME,mode); - SHControl(IDC_EDIT_PRGPATH ,mode); - SHControl(IDC_PRG_PRG ,mode); - SHControl(IDC_EDIT_PRGARGS ,mode); - SHControl(IDC_PRG_ARG ,mode); - SHControl(IDC_STAT_PROCTIME,mode); - SHControl(IDC_STAT_PRGPATH ,mode); - SHControl(IDC_STAT_PRGARGS ,mode); - - SHControl(IDC_PRSTART_GROUP,mode); - SHControl(IDC_FLAG_NORMAL ,mode); - SHControl(IDC_FLAG_HIDDEN ,mode); - SHControl(IDC_FLAG_MAXIMIZE,mode); - SHControl(IDC_FLAG_MINIMIZE,mode); - - SHControl(IDC_FLAG_CURPATH,mode); - SHControl(IDC_FLAG_CONTINUE,mode); - SHControl(IDC_FLAG_PARALLEL,mode); - - if mode=SW_SHOW then - begin - if isVarsInstalled then - SHControl(IDC_HLP_FVARS,SW_SHOW); - end - else - SHControl(IDC_HLP_FVARS,SW_HIDE); - end; - ACT_TEXT: begin - SHControl(IDC_FLAG_CLIP ,mode); - SHControl(IDC_FLAG_MESSAGE,mode); - SHControl(IDC_CLIP_COPYTO ,mode); - SHControl(IDC_CLIP_PASTE ,mode); - SHControl(IDC_CLIP_GROUP ,mode); - SHControl(IDC_FILE_ENC ,mode); - - SHControl(IDC_FLAG_FILE ,mode); - SHControl(IDC_FILE_PATH ,mode); - SHControl(IDC_TXT_FILE ,mode); - SHControl(IDC_FILE_FILEBTN,mode); - SHControl(IDC_FILE_READ ,mode); - SHControl(IDC_FILE_WRITE ,mode); - SHControl(IDC_FILE_APPEND ,mode); - SHControl(IDC_FILE_GROUP ,mode); - - SHControl(IDC_TXT_TEXT ,mode); - SHControl(IDC_EDIT_INSERT ,mode); - SHControl(IDC_STAT_INSERT ,mode); - - if mode=SW_SHOW then - begin - if isVarsInstalled then - SHControl(IDC_HLP_VARS,SW_SHOW); - end - else - SHControl(IDC_HLP_VARS,SW_HIDE); - end; - ACT_ADVANCE: begin - SHControl(IDC_CONDITION,mode); - SHControl(IDC_FLAG_GT ,mode); - SHControl(IDC_FLAG_LT ,mode); - SHControl(IDC_FLAG_EQ ,mode); - SHControl(IDC_FLAG_NOP ,mode); - SHControl(IDC_FLAG_NOT ,mode); - SHControl(IDC_ADV_VALUE,mode); - SHControl(IDC_STAT_VAL ,mode); - SHControl(IDC_ADV_ASINT,mode); - - SHControl(IDC_OPERATION ,mode); - SHControl(IDC_FLAG_BREAK,mode); - SHControl(IDC_FLAG_JUMP ,mode); - SHControl(IDC_FLAG_ANOP ,mode); - - SHControl(IDC_FLAG_MATH,mode); - SHControl(IDC_ADV_OPER ,mode); - SHControl(IDC_ADV_VAL2 ,mode); - SHControl(IDC_ADV_VAL1 ,mode); - - if mode=SW_SHOW then - begin - if isVarsInstalled then - SHControl(IDC_ADV_HVARS,SW_SHOW); - end - else - SHControl(IDC_ADV_HVARS,SW_HIDE); - SHControl(IDC_FLAG_VARS,mode); - SHControl(IDC_ADV_VARS ,mode); - end; - ACT_CHAIN: begin - SHControl(IDC_STAT_GROUPS,mode); - SHControl(IDC_GROUP_LIST ,mode); - end; - ACT_RW: begin - SHControl(IDC_STAT_CONTACT,mode); - SHControl(IDC_CONTACTLIST ,mode); - - SHControl(IDC_RW_OPER ,mode); - SHControl(IDC_RW_VAL ,mode); - SHControl(IDC_RW_READ ,mode); - SHControl(IDC_RW_WRITE ,mode); - SHControl(IDC_RW_DELETE ,mode); - SHControl(IDC_RW_STATM ,mode); - SHControl(IDC_RW_MODULE ,mode); - SHControl(IDC_RW_STATS ,mode); - SHControl(IDC_RW_SETTING,mode); - SHControl(IDC_RW_TVAR ,mode); - - if mode=SW_SHOW then - begin - if CB_GetData(GetDlgItem(Dialog,IDC_RW_DATATYPE))>2 then - begin - SHControl(IDC_RW_VALUE,SW_HIDE); - SHControl(IDC_RW_TEXT ,SW_SHOW); - end - else - begin - SHControl(IDC_RW_VALUE,SW_SHOW); - SHControl(IDC_RW_TEXT ,SW_HIDE); - end - end - else - begin - SHControl(IDC_RW_VALUE,SW_HIDE); - SHControl(IDC_RW_TEXT ,SW_HIDE); - end; - SHControl(IDC_RW_DATATYPE,mode); - - SHControl(IDC_RW_CURRENT,mode); - SHControl(IDC_RW_PARAM ,mode); - SHControl(IDC_RW_RESULT ,mode); - SHControl(IDC_RW_MANUAL ,mode); - SHControl(IDC_RW_LAST ,mode); - - SHControl(IDC_RW_MVAR ,mode); - SHControl(IDC_RW_SVAR ,mode); - end; - ACT_MESSAGE: begin - SHControl(IDC_MSG_KEEP ,mode); - SHControl(IDC_MSG_STAT1 ,mode); - SHControl(IDC_MSG_STAT2 ,mode); - SHControl(IDC_MSG_TITLE ,mode); - SHControl(IDC_MSG_TEXT ,mode); - SHControl(IDC_MSG_BTNS ,mode); - SHControl(IDC_MSGB_ARI ,mode); - SHControl(IDC_MSGB_OK ,mode); - SHControl(IDC_MSGB_OC ,mode); - SHControl(IDC_MSGB_RC ,mode); - SHControl(IDC_MSGB_YN ,mode); - SHControl(IDC_MSGB_YNC ,mode); - SHControl(IDC_MSG_ICONS ,mode); - SHControl(IDC_MSGI_NONE ,mode); - SHControl(IDC_MSGI_WARN ,mode); - SHControl(IDC_MSGI_INFO ,mode); - SHControl(IDC_MSGI_QUEST,mode); - SHControl(IDC_MSGI_ERROR,mode); - - SHControl(IDC_MSG_TTL ,mode); - SHControl(IDC_MSG_TXT ,mode); - end; - end; - end; - - procedure SetButtonOnOff(ctrl,state:dword); - begin - CheckDlgButton(Dialog,ctrl,state); - case ctrl of - IDC_SRV_WPAR, - IDC_SRV_LPAR, - IDC_SRV_SRVC, - IDC_PRG_PRG , - IDC_PRG_ARG , - IDC_TXT_FILE, - IDC_TXT_TEXT, - IDC_RW_MVAR , - IDC_RW_SVAR , - IDC_RW_TVAR , - IDC_MSG_TTL , - IDC_MSG_TXT : SetButtonIcon(GetDlgItem(Dialog,ctrl),checknames[state]); - end; - end; - - procedure ButtonOff(ctrl:dword); {$IFDEF MSWINDOWS}inline;{$ENDIF} - begin - SetButtonOnOff(ctrl,BST_UNCHECKED); - end; - - procedure ButtonOn(ctrl:dword); {$IFDEF MSWINDOWS}inline;{$ENDIF} - begin - SetButtonOnOff(ctrl,BST_CHECKED); - end; - - procedure TextClear(ctrl:dword); - begin - SetDlgItemTextW(Dialog,ctrl,nil); - end; - - function FixParam(buf:PAnsiChar;flag:integer):integer; - begin - if lstrcmpia(buf,Translate('hContact' ))=0 then result:=ptCurrent - else if lstrcmpia(buf,Translate('parameter'))=0 then result:=ptParam - else if lstrcmpia(buf,Translate('result' ))=0 then result:=ptResult - else if lstrcmpia(buf,Translate('structure'))=0 then result:=ptStruct - else - begin - if (buf[0] in ['0'..'9']) or ((buf[0]='-') and (buf[1] in ['0'..'9'])) or - ((buf[0]='$') and (buf[1] in sHexNum)) then - result:=ptNumber - else - result:=ptString; - end; - - CB_SelectData(Dialog,flag,result); -// SendDlgItemMessage(Dialog,flag,CB_SETCURSEL,result,0); - SendMessage(Dialog,WM_COMMAND,(CBN_SELCHANGE shl 16) or flag,GetDlgItem(Dialog,flag)); - end; - - procedure ReloadService; - var - pc:pAnsiChar; - buf,buf1:array [0..MaxDescrLen] of AnsiChar; - wnd:hwnd; - i:integer; -// bufw:array [0..MaxDescrLen] of WideChar; - begin - wnd:=GetDlgItem(Dialog,IDC_EDIT_SERVICE); - SendMessageA(wnd,CB_GETLBTEXT,SendMessage(wnd,CB_GETCURSEL,0,0),tlparam(@buf)); - ApiCard.Service:=@buf; - - pc:=ApiCard.FillParams(GetDlgItem(Dialog,IDC_EDIT_WPAR),true); - if pc<>nil then - begin - if GetDlgItemTextA(Dialog,IDC_EDIT_WPAR,buf1,SizeOf(buf1))>0 then - case FixParam(@buf1,IDC_FLAG_WPAR) of - ptStruct: begin - mFreeMem(wstruct); - StrDup(wstruct,StrScan(pc,'|')+1); -// AnsiToWide(StrScan(pc,'|')+1,wstruct,MirandaCP); - end; - end; - mFreeMem(pc); - end; - - pc:=ApiCard.FillParams(GetDlgItem(Dialog,IDC_EDIT_LPAR),false); - if pc<>nil then - begin - if GetDlgItemTextA(Dialog,IDC_EDIT_LPAR,buf1,SizeOf(buf1))>0 then - case FixParam(@buf1,IDC_FLAG_LPAR) of - ptStruct: begin - mFreeMem(lstruct); - StrDup(lstruct,StrScan(pc,'|')+1); -// AnsiToWide(StrScan(pc,'|')+1,lstruct,MirandaCP); - end; - end; - mFreeMem(pc); - end; - - pc:=ApiCard.ResultType; - i:=sresInt; - if pc<>nil then - begin - if lstrcmpia(pc,'struct')=0 then i:=sresStruct - else if lstrcmpia(pc,'hex' )=0 then i:=sresHex - else if lstrcmpia(pc,'int')=0 then - begin - i:=sresInt; - ButtonOff(IDC_RES_SIGNED); - end - else if lstrcmpia(pc,'signed')=0 then - begin - i:=sresInt; - ButtonOn(IDC_RES_SIGNED); - end - else if lstrcmpia(pc,'str')=0 then - begin - i:=sresString; - ButtonOff(IDC_RES_UNICODE); - end - else if lstrcmpia(pc,'wide')=0 then - begin - i:=sresString; - ButtonOn(IDC_RES_UNICODE); - end; - mFreeMem(pc); - end; - CB_SelectData(Dialog,IDC_SRV_RESULT,i); - -// ApiCard.Show; - end; - - procedure SelectActionType(group:dword); - var - i:integer; - begin - for i:=0 to ACT_MAXTYPE-1 do - if ActIds[i].code=group then break; - SendDlgItemMessage(Dialog,IDC_ACTION_TYPE,CB_SETCURSEL,i,0); - end; - - procedure ClearControls(group:dword); - begin -//! SelectActionType(group); - case group of - ACT_CONTACT: begin - EnableWindow(GetDlgItem(Dialog,IDC_CONTACTLIST),true); - SendDlgItemMessage(Dialog,IDC_CONTACTLIST,CB_SETCURSEL,0,0); - ButtonOff(IDC_CNT_KEEP); - ButtonOff(IDC_CNT_FILTER); - TextClear(IDC_EDIT_FORMAT); - end; - ACT_SERVICE: begin - TextClear(IDC_EDIT_SERVICE); - TextClear(IDC_EDIT_WPAR); - TextClear(IDC_EDIT_LPAR); - EnableWindow(GetDlgItem(Dialog,IDC_EDIT_WPAR),true); - EnableWindow(GetDlgItem(Dialog,IDC_EDIT_LPAR),true); -// SendDlgItemMessage(Dialog,IDC_FLAG_WPAR,CB_SETCURSEL,0,0); -// SendDlgItemMessage(Dialog,IDC_FLAG_LPAR,CB_SETCURSEL,0,0); - CB_SelectData(GetDlgItem(Dialog,IDC_FLAG_WPAR),ptNumber); - CB_SelectData(GetDlgItem(Dialog,IDC_FLAG_LPAR),ptNumber); - - CB_SelectData(GetDlgItem(Dialog,IDC_SRV_RESULT),sresInt); - - SendMessage(GetDlgItem(Dialog,IDC_EDIT_WPAR),CB_RESETCONTENT,0,0); - SendMessage(GetDlgItem(Dialog,IDC_EDIT_LPAR),CB_RESETCONTENT,0,0); - - ButtonOff(IDC_RES_POPUP); - ButtonOff(IDC_RES_MESSAGE); - ButtonOff(IDC_RES_INSERT); - - ButtonOff(IDC_RES_FREEMEM); - ButtonOff(IDC_RES_UNICODE); - ButtonOff(IDC_RES_SIGNED); - - ButtonOff(IDC_SRV_WPAR); - ButtonOff(IDC_SRV_LPAR); - ButtonOff(IDC_SRV_SRVC); - end; - ACT_PROGRAM: begin - TextClear(IDC_EDIT_PROCTIME); - TextClear(IDC_EDIT_PRGPATH); - TextClear(IDC_EDIT_PRGARGS); - - ButtonOff(IDC_FLAG_NORMAL); - ButtonOff(IDC_FLAG_HIDDEN); - ButtonOff(IDC_FLAG_MINIMIZE); - ButtonOff(IDC_FLAG_MAXIMIZE); - - ButtonOff(IDC_FLAG_CURPATH); - ButtonOff(IDC_FLAG_CONTINUE); - ButtonOff(IDC_FLAG_PARALLEL); - - ButtonOff(IDC_PRG_PRG); - ButtonOff(IDC_PRG_ARG); - end; - ACT_TEXT: begin - ButtonOff(IDC_FLAG_CLIP); - ButtonOff(IDC_FLAG_MESSAGE); - ButtonOff(IDC_CLIP_COPYTO); - ButtonOff(IDC_CLIP_PASTE); - - ButtonOff(IDC_FLAG_FILE); - TextClear(IDC_FILE_PATH); - ButtonOff(IDC_FILE_READ); - ButtonOff(IDC_FILE_WRITE); - ButtonOff(IDC_FILE_APPEND); - - EnableWindow(GetDlgItem(Dialog,IDC_EDIT_INSERT ),false); - EnableWindow(GetDlgItem(Dialog,IDC_CLIP_COPYTO ),false); - EnableWindow(GetDlgItem(Dialog,IDC_CLIP_PASTE ),false); - - EnableWindow(GetDlgItem(Dialog,IDC_FILE_ENC ),false); - EnableWindow(GetDlgItem(Dialog,IDC_FILE_PATH ),false); - EnableWindow(GetDlgItem(Dialog,IDC_FILE_FILEBTN),false); - EnableWindow(GetDlgItem(Dialog,IDC_FILE_READ ),false); - EnableWindow(GetDlgItem(Dialog,IDC_FILE_WRITE ),false); - EnableWindow(GetDlgItem(Dialog,IDC_FILE_APPEND ),false); - - TextClear(IDC_EDIT_INSERT); - - ButtonOff(IDC_TXT_FILE); - ButtonOff(IDC_TXT_TEXT); - end; - ACT_ADVANCE: begin - ButtonOff(IDC_FLAG_GT); - ButtonOff(IDC_FLAG_LT); - ButtonOff(IDC_FLAG_EQ); - ButtonOff(IDC_FLAG_NOP); - ButtonOff(IDC_FLAG_NOT); - TextClear(IDC_ADV_VALUE); - - ButtonOff(IDC_FLAG_BREAK); - ButtonOff(IDC_FLAG_JUMP); - ButtonOff(IDC_FLAG_ANOP); - EnableWindow(GetDlgItem(Dialog,IDC_ADV_VAL2),false); - - ButtonOff(IDC_FLAG_MATH); - SendDlgItemMessage(Dialog,IDC_ADV_OPER,CB_SETCURSEL,0,0); - TextClear(IDC_ADV_VAL1); - ButtonOff(IDC_ADV_ASINT); - - EnableWindow(GetDlgItem(Dialog,IDC_ADV_OPER),false); - EnableWindow(GetDlgItem(Dialog,IDC_ADV_VAL1),false); - EnableWindow(GetDlgItem(Dialog,IDC_ADV_VARS),false); - - ButtonOff(IDC_FLAG_VARS); - TextClear(IDC_ADV_VARS); - end; - ACT_CHAIN: begin -// FillChainList(Dialog); - SendDlgItemMessage(Dialog,IDC_GROUP_LIST,CB_SETCURSEL,0,0); - end; - ACT_RW: begin - ButtonOff(IDC_RW_READ); - ButtonOff(IDC_RW_WRITE); - ButtonOff(IDC_RW_DELETE); - SendDlgItemMessage(Dialog,IDC_CONTACTLIST,CB_SETCURSEL,0,0); - EnableWindow(GetDlgItem(Dialog,IDC_CONTACTLIST),true); - TextClear(IDC_CONTACTLIST); - TextClear(IDC_RW_MODULE); - TextClear(IDC_RW_SETTING); - TextClear(IDC_RW_VALUE); - TextClear(IDC_RW_TEXT); - - ButtonOff(IDC_RW_CURRENT); - ButtonOff(IDC_RW_PARAM); - ButtonOff(IDC_RW_RESULT); - ButtonOff(IDC_RW_MANUAL); - ButtonOff(IDC_RW_LAST); - - ButtonOff(IDC_RW_MVAR); - ButtonOff(IDC_RW_SVAR); - ButtonOff(IDC_RW_TVAR); - end; - ACT_MESSAGE: begin - TextClear(IDC_MSG_TITLE); - TextClear(IDC_MSG_TEXT); - ButtonOff(IDC_MSG_KEEP); - ButtonOff(IDC_MSGB_OK); - ButtonOff(IDC_MSGB_OC); - ButtonOff(IDC_MSGB_ARI); - ButtonOff(IDC_MSGB_YNC); - ButtonOff(IDC_MSGB_YN); - ButtonOff(IDC_MSGB_RC); - ButtonOff(IDC_MSGI_NONE); - ButtonOff(IDC_MSGI_ERROR); - ButtonOff(IDC_MSGI_QUEST); - ButtonOff(IDC_MSGI_WARN); - ButtonOff(IDC_MSGI_INFO); - - ButtonOff(IDC_MSG_TTL); - ButtonOff(IDC_MSG_TXT); - end; - end; - end; - - procedure ClearDialogData; - begin - ClearControls(ACT_CONTACT); - ClearControls(ACT_SERVICE); - ClearControls(ACT_PROGRAM); - ClearControls(ACT_TEXT); - ClearControls(ACT_ADVANCE); - ClearControls(ACT_CHAIN); - ClearControls(ACT_RW); - ClearControls(ACT_MESSAGE); - mFreeMem(wstruct); - mFreeMem(lstruct); - end; - - procedure SHWindows(exclude:dword=0); - begin - SetupControls(ACT_CONTACT,SW_HIDE); - SetupControls(ACT_SERVICE,SW_HIDE); - SetupControls(ACT_PROGRAM,SW_HIDE); - SetupControls(ACT_TEXT ,SW_HIDE); - SetupControls(ACT_ADVANCE,SW_HIDE); - SetupControls(ACT_CHAIN ,SW_HIDE); - SetupControls(ACT_RW ,SW_HIDE); - SetupControls(ACT_MESSAGE,SW_HIDE); -{ - if exclude<>ACT_CONTACT then SetupControls(ACT_CONTACT,SW_HIDE); - if exclude<>ACT_SERVICE then SetupControls(ACT_SERVICE,SW_HIDE); - if exclude<>ACT_PROGRAM then SetupControls(ACT_PROGRAM,SW_HIDE); - if exclude<>ACT_TEXT then SetupControls(ACT_TEXT ,SW_HIDE); - if exclude<>ACT_ADVANCE then SetupControls(ACT_ADVANCE,SW_HIDE); - if exclude<>ACT_CHAIN then SetupControls(ACT_CHAIN ,SW_HIDE); - if exclude<>ACT_RW then SetupControls(ACT_RW ,SW_HIDE); -} - case exclude of - ACT_CONTACT, - ACT_SERVICE, - ACT_PROGRAM, - ACT_TEXT , - ACT_ADVANCE, - ACT_CHAIN , - ACT_RW , - ACT_MESSAGE: begin - SetupControls(exclude,SW_SHOW); - end; - end; - end; - - procedure SHActButtons(mode:integer); - begin - ShowWindow(GetDlgItem(Dialog,IDC_STAT_ACTION),mode); - ShowWindow(GetDlgItem(Dialog,IDC_ACTION_TYPE),mode); - end; - - procedure InitDef(exclude:dword=0); - begin - if exclude<>ACT_CONTACT then - begin - ButtonOn(IDC_CNT_FILTER); - // do nothing - end; - if exclude<>ACT_SERVICE then - begin - CB_SelectData(Dialog,IDC_SRV_RESULT,sresInt); - end; - if exclude<>ACT_PROGRAM then - begin - ButtonOn(IDC_FLAG_PARALLEL); - ButtonOn(IDC_FLAG_NORMAL); - SetDlgItemInt(Dialog,IDC_EDIT_PROCTIME,0,false); - end; - if exclude<>ACT_TEXT then - begin - ButtonOn(IDC_FLAG_CLIP); - EnableWindow(GetDlgItem(Dialog,IDC_CLIP_COPYTO),true); - EnableWindow(GetDlgItem(Dialog,IDC_CLIP_PASTE ),true); - ButtonOn(IDC_CLIP_COPYTO); - - ButtonOn(IDC_FILE_READ); - // do nothing - end; - if exclude<>ACT_ADVANCE then - begin - ButtonOn(IDC_FLAG_NOP); - ButtonOn(IDC_FLAG_ANOP); - SetDlgItemInt(Dialog,IDC_ADV_VALUE,0,false); - SetDlgItemInt(Dialog,IDC_ADV_VAL1 ,0,false); - EnableWindow(GetDlgItem(Dialog,IDC_ADV_VAL1),false); - EnableWindow(GetDlgItem(Dialog,IDC_ADV_VAL2),false); - EnableWindow(GetDlgItem(Dialog,IDC_ADV_OPER),false); -// SendDlgItemMessage(Dialog,IDC_ADV_OPER,CB_SETCURSEL,0,0); - CB_SelectData(Dialog,IDC_ADV_OPER,ORD(aeNot)); - end; - if exclude<>ACT_CHAIN then - begin -// FillChainList(Dialog); - SendDlgItemMessage(Dialog,IDC_GROUP_LIST,CB_SETCURSEL,0,0); - end; - if exclude<>ACT_RW then - begin - ButtonOn(IDC_RW_READ); - SetDlgItemInt(Dialog,IDC_RW_VALUE,0,false); - ButtonOn(IDC_RW_MANUAL); - EnableWindow(GetDlgItem(Dialog,IDC_RW_VALUE),true); - EnableWindow(GetDlgItem(Dialog,IDC_RW_TEXT ),true); - end; - if exclude<>ACT_MESSAGE then - begin - ButtonOn(IDC_MSGB_OK); - ButtonOn(IDC_MSGI_NONE); - end; - end; - - // set buttons by options - procedure FillAction(CurAction:integer); - var - i:integer; - bb:boolean; - wnd:HWND; - begin - with NewActionList^[CurAction] do - begin - if (flags and ACF_ASSIGNED)=0 then - exit; - if actionType=0 then - actionType:=ACT_CONTACT; - - InitDef(actionType); - SelectActionType(actionType); - case actionType of - - ACT_CONTACT: begin - if (flags and ACF_KEEPONLY)<>0 then - ButtonOn(IDC_CNT_KEEP); - if fCLfilter then - ButtonOn(IDC_CNT_FILTER); - SetDlgItemTextW(Dialog,IDC_EDIT_FORMAT,fCLformat); - - SendDlgItemMessage(Dialog,IDC_CONTACTLIST,CB_SETCURSEL, - FindContact(GetDlgItem(Dialog,IDC_CONTACTLIST),contact),0); - end; - - ACT_SERVICE: begin - if SendDlgItemMessageA(Dialog,IDC_EDIT_SERVICE,CB_SELECTSTRING,twparam(-1),tlparam(service))<>CB_ERR then - ReloadService - else - SetDlgItemTextA(Dialog,IDC_EDIT_SERVICE,service); - - if (flags2 and ACF2_SRV_WPAR)<>0 then ButtonOn(IDC_SRV_WPAR); - if (flags2 and ACF2_SRV_LPAR)<>0 then ButtonOn(IDC_SRV_LPAR); - if (flags2 and ACF2_SRV_SRVC)<>0 then ButtonOn(IDC_SRV_SRVC); - - if (flags and ACF_MESSAGE)<>0 then ButtonOn(IDC_RES_MESSAGE); - if (flags and ACF_POPUP )<>0 then ButtonOn(IDC_RES_POPUP); - if (flags and ACF_INSERT )<>0 then ButtonOn(IDC_RES_INSERT); - - if (flags and ACF_HEX)<>0 then - i:=sresHex - else if (flags and ACF_STRUCT)<>0 then - i:=sresStruct - else if (flags and ACF_STRING)<>0 then - begin - i:=sresString; - if (flags and ACF_UNICODE )<>0 then ButtonOn(IDC_RES_UNICODE); - if (flags2 and ACF2_FREEMEM)<>0 then ButtonOn(IDC_RES_FREEMEM); - end - else - begin - i:=sresInt; - if (flags and ACF_SIGNED)<>0 then - ButtonOn(IDC_RES_SIGNED); - end; - CB_SelectData(Dialog,IDC_SRV_RESULT,i); - - if (flags and ACF_WPARAM)<>0 then - begin - EnableWindow(GetDlgItem(Dialog,IDC_EDIT_WPAR),false); - i:=ptParam; - end - else if (flags and ACF_WRESULT)<>0 then - begin - EnableWindow(GetDlgItem(Dialog,IDC_EDIT_WPAR),false); - i:=ptResult; - end - else if (flags and ACF_WPARNUM)<>0 then - begin - if (flags and ACF_WCURRENT)<>0 then - begin - EnableWindow(GetDlgItem(Dialog,IDC_EDIT_WPAR),false); - i:=ptCurrent - end - else - begin - i:=ptNumber; - SetNumValue(GetDlgItem(Dialog,IDC_EDIT_WPAR),wparam, - (flags2 and ACF2_SRV_WPAR)<>0, - (flags2 and ACF2_SRV_WHEX)<>0); -// SetDlgItemInt(Dialog,IDC_EDIT_WPAR,wparam,true) - end; - end - else if (flags and ACF_WSTRUCT)<>0 then - begin - i:=ptStruct; - SHControl(IDC_EDIT_WPAR,SW_HIDE); - SHControl(IDC_WSTRUCT ,SW_SHOW); - mFreeMem(wstruct); - StrDup(wstruct,PAnsiChar(wparam)); - end - else if (flags and ACF_WUNICODE)<>0 then - begin - i:=ptUnicode; - SetDlgItemTextW(Dialog,IDC_EDIT_WPAR,pWideChar(wparam)); - end - else - begin - i:=ptString; - SetDlgItemTextA(Dialog,IDC_EDIT_WPAR,PAnsiChar(wparam)); - end; - CB_SelectData(GetDlgItem(Dialog,IDC_FLAG_WPAR),i); - SendDlgItemMessage(Dialog,IDC_FLAG_WPAR,CB_SETCURSEL,i,0); - - if (flags and ACF_LPARAM)<>0 then - begin - EnableWindow(GetDlgItem(Dialog,IDC_EDIT_LPAR),false); - i:=ptParam; - end - else if (flags and ACF_LRESULT)<>0 then - begin - EnableWindow(GetDlgItem(Dialog,IDC_EDIT_LPAR),false); - i:=ptResult; - end - else if (flags and ACF_LPARNUM)<>0 then - begin - if (flags and ACF_LCURRENT)<>0 then - begin - EnableWindow(GetDlgItem(Dialog,IDC_EDIT_LPAR),false); - i:=ptCurrent; - end - else - begin - i:=ptNumber; - SetNumValue(GetDlgItem(Dialog,IDC_EDIT_LPAR),lparam, - (flags2 and ACF2_SRV_LPAR)<>0, - (flags2 and ACF2_SRV_LHEX)<>0); -// SetDlgItemInt(Dialog,IDC_EDIT_LPAR,lparam,true) - end; - end - else if (flags and ACF_LSTRUCT)<>0 then - begin - i:=ptStruct; - SHControl(IDC_EDIT_LPAR,SW_HIDE); - SHControl(IDC_LSTRUCT ,SW_SHOW); - mFreeMem(lstruct); - StrDup(lstruct,PAnsiChar(lparam)); - end - else if (flags and ACF_LUNICODE)<>0 then - begin - i:=ptUnicode; - SetDlgItemTextW(Dialog,IDC_EDIT_LPAR,pWideChar(lparam)); - end - else - begin - i:=ptString; - SetDlgItemTextA(Dialog,IDC_EDIT_LPAR,PAnsiChar(lparam)); - end; - CB_SelectData(GetDlgItem(Dialog,IDC_FLAG_LPAR),i); - - end; - - ACT_PROGRAM: begin - if (flags2 and ACF2_PRG_PRG)<>0 then - ButtonOn(IDC_PRG_PRG); - if (flags2 and ACF2_PRG_ARG)<>0 then - ButtonOn(IDC_PRG_ARG); - - SetDlgItemTextW(Dialog,IDC_EDIT_PRGPATH ,prgname); - SetDlgItemTextW(Dialog,IDC_EDIT_PRGARGS ,args); - SetDlgItemInt (Dialog,IDC_EDIT_PROCTIME,time,false); - case show of - SW_HIDE : ButtonOn(IDC_FLAG_HIDDEN); - SW_SHOWMINIMIZED: ButtonOn(IDC_FLAG_MINIMIZE); - SW_SHOWMAXIMIZED: ButtonOn(IDC_FLAG_MAXIMIZE); - else - {SW_SHOWNORMAL :} ButtonOn(IDC_FLAG_NORMAL); - end; - if (flags and ACF_CURPATH)<>0 then - ButtonOn(IDC_FLAG_CURPATH); - if (flags and ACF_PRTHREAD)<>0 then - ButtonOn(IDC_FLAG_PARALLEL) - else - ButtonOn(IDC_FLAG_CONTINUE); - - end; - - ACT_TEXT: begin - if (flags and ACF_CLIPBRD)<>0 then - begin - ButtonOn(IDC_FLAG_CLIP); - EnableWindow(GetDlgItem(Dialog,IDC_CLIP_COPYTO),true); - EnableWindow(GetDlgItem(Dialog,IDC_CLIP_PASTE ),true); - if (flags and ACF_COPYTO)<>0 then - ButtonOn(IDC_CLIP_COPYTO) - else - ButtonOn(IDC_CLIP_PASTE); -// for switches - ButtonOn(IDC_FILE_READ); - end - - else - begin - if (flags and (ACF_FILE or ACF_FAPPEND or ACF_FWRITE))<>ACF_FILE then - EnableWindow(GetDlgItem(Dialog,IDC_EDIT_INSERT),true); - SetDlgItemTextW(Dialog,IDC_EDIT_INSERT,text); -// for switches - ButtonOn(IDC_CLIP_COPYTO); - - if (flags2 and ACF2_TXT_TEXT)<>0 then - ButtonOn(IDC_TXT_TEXT); - - if (flags and ACF_FILE)<>0 then - begin - if (flags2 and ACF2_TXT_FILE)<>0 then - ButtonOn(IDC_TXT_FILE); - ButtonOn(IDC_FLAG_FILE); - EnableWindow(GetDlgItem(Dialog,IDC_FILE_PATH ),true); - EnableWindow(GetDlgItem(Dialog,IDC_FILE_FILEBTN),true); - EnableWindow(GetDlgItem(Dialog,IDC_FILE_READ ),true); - EnableWindow(GetDlgItem(Dialog,IDC_FILE_WRITE ),true); - EnableWindow(GetDlgItem(Dialog,IDC_FILE_APPEND ),true); - - wnd:=GetDlgItem(Dialog,IDC_FILE_ENC); - EnableWindow(wnd,true); - if (flags and ACF_ANSI)<>0 then - CB_SelectData(wnd,0) - else if (flags and ACF_UTF8)<>0 then - begin - if (flags and ACF_SIGN)<>0 then - CB_SelectData(wnd,2) - else - CB_SelectData(wnd,1); - end - else if (flags and ACF_SIGN)<>0 then - CB_SelectData(wnd,4) - else - CB_SelectData(wnd,3); - - if (flags and ACF_FAPPEND)<>0 then ButtonOn(IDC_FILE_APPEND) - else if (flags and ACF_FWRITE )<>0 then ButtonOn(IDC_FILE_WRITE) - else ButtonOn(IDC_FILE_READ); - SetDlgItemTextW(Dialog,IDC_FILE_PATH,tfile); - end - else - begin - ButtonOn(IDC_FLAG_MESSAGE); -// for switches - ButtonOn(IDC_FILE_READ); - end; - end; - - end; - - ACT_ADVANCE: begin - FillSubList(Dialog); -// SendDlgItemMessage(Dialog,IDC_ADV_VAL2,CB_SETCURSEL,0,0); - - case condition and not ADV_COND_NOT of - ADV_COND_GT: ButtonOn(IDC_FLAG_GT); - ADV_COND_LT: ButtonOn(IDC_FLAG_LT); - ADV_COND_EQ: ButtonOn(IDC_FLAG_EQ); - else // ADV_COND_NOP - ButtonOn(IDC_FLAG_NOP); - end; - SetDlgItemInt(Dialog,IDC_ADV_VALUE,value,false); - if (condition and ADV_COND_NOT)<>0 then - ButtonOn(IDC_FLAG_NOT); - - SetDlgItemInt(Dialog,IDC_ADV_VAL1,mathval,true); - case action and ADV_ACTION of - ADV_ACT_MATH: begin - ButtonOn(IDC_FLAG_MATH); - CB_SelectData(GetDlgItem(Dialog,IDC_ADV_OPER),oper); -// SendDlgItemMessage(Dialog,IDC_ADV_OPER,CB_SETCURSEL,oper,0); - EnableWindow(GetDlgItem(Dialog,IDC_ADV_VAL1),true); - EnableWindow(GetDlgItem(Dialog,IDC_ADV_OPER),true); - end; - ADV_ACT_VARS: begin - ButtonOn(IDC_FLAG_VARS); - if (flags and ACF_VARASINT)<>0 then - ButtonOn(IDC_ADV_ASINT); - EnableWindow(GetDlgItem(Dialog,IDC_ADV_VARS),true); - SetDlgItemTextW(Dialog,IDC_ADV_VARS,varval); - end; - end; - bb:=false; - case action and ADV_ACT_POST of - ADV_ACT_BREAK: ButtonOn(IDC_FLAG_BREAK); - ADV_ACT_JUMP : begin - SendDlgItemMessageW(Dialog,IDC_ADV_VAL2,CB_SELECTSTRING,twparam(-1),tlparam(operval)); - ButtonOn(IDC_FLAG_JUMP); - bb:=true; - end; - else // ADV_ACT_NOP - ButtonOn(IDC_FLAG_ANOP); - end; - EnableWindow(GetDlgItem(Dialog,IDC_ADV_VAL2),bb); - end; - - ACT_CHAIN: begin -// FillChainList(Dialog); - if (flags and ACF_BYNAME)<>0 then - SendDlgItemMessageW(Dialog,IDC_GROUP_LIST,CB_SELECTSTRING,twparam(-1),tlparam(actname)) - else - SendDlgItemMessageW(Dialog,IDC_GROUP_LIST,CB_SELECTSTRING,twparam(-1),tlparam(GetGroupName(id))); - end; - - ACT_RW: begin - if (flags and ACF_DBDELETE)<>0 then ButtonOn(IDC_RW_DELETE) - else if (flags and ACF_DBWRITE )= 0 then ButtonOn(IDC_RW_READ) - else ButtonOn(IDC_RW_WRITE); - - bb:=false; - if (flags and ACF_CURRENT)<>0 then - begin - ButtonOn(IDC_RW_CURRENT); - EnableWindow(GetDlgItem(Dialog,IDC_CONTACTLIST),false); - end - else if (flags and ACF_PARAM)<>0 then - begin - ButtonOn(IDC_RW_PARAM); - EnableWindow(GetDlgItem(Dialog,IDC_CONTACTLIST),false); - end - else if (flags and ACF_RESULT)<>0 then - begin - ButtonOn(IDC_RW_RESULT); - EnableWindow(GetDlgItem(Dialog,IDC_CONTACTLIST),false); - end - else - begin - ButtonOn(IDC_RW_MANUAL); - bb:=true; - EnableWindow(GetDlgItem(Dialog,IDC_CONTACTLIST),true); - SendDlgItemMessage(Dialog,IDC_CONTACTLIST,CB_SETCURSEL, - FindContact(GetDlgItem(Dialog,IDC_CONTACTLIST),dbcontact),0); - end; - EnableWindow(GetDlgItem(Dialog,IDC_CONTACTLIST),bb); - - if (flags and ACF_LAST)<>0 then - begin - ButtonOn(IDC_RW_LAST); - bb:=false; - end - else - bb:=true; - if (flags and ACF_DBDELETE)<>0 then - bb:=false; - - EnableWindow(GetDlgItem(Dialog,IDC_RW_VALUE),bb); - EnableWindow(GetDlgItem(Dialog,IDC_RW_TEXT ),bb); - - SetDlgItemTextA(Dialog,IDC_RW_MODULE ,dbmodule); - SetDlgItemTextA(Dialog,IDC_RW_SETTING,dbsetting); - if (flags2 and ACF2_RW_MVAR)<>0 then ButtonOn(IDC_RW_MVAR); - if (flags2 and ACF2_RW_SVAR)<>0 then ButtonOn(IDC_RW_SVAR); - if (flags2 and ACF2_RW_TVAR)<>0 then ButtonOn(IDC_RW_TVAR); - - - wnd:=GetDlgItem(Dialog,IDC_RW_DATATYPE); - if ((flags and ACF_DBANSI )=ACF_DBANSI) or - ((flags and ACF_DBUTEXT)=ACF_DBUTEXT) then - begin - SHControl(IDC_RW_TEXT ,SW_SHOW); - SHControl(IDC_RW_VALUE,SW_HIDE); - if (flags and ACF_DBANSI)=ACF_DBANSI then - CB_SelectData(wnd,3) - else - CB_SelectData(wnd,4); - SetDlgItemTextW(Dialog,IDC_RW_TEXT,pWideChar(dbvalue)); - end - else - begin - if (flags and ACF_DBBYTE)=ACF_DBBYTE then - CB_SelectData(wnd,0) - else if (flags and ACF_DBWORD)=ACF_DBWORD then - CB_SelectData(wnd,1) - else - CB_SelectData(wnd,2); - SHControl(IDC_RW_TEXT ,SW_HIDE); - SHControl(IDC_RW_VALUE,SW_SHOW); - - SetNumValue(GetDlgItem(Dialog,IDC_RW_VALUE),dbvalue, - (flags2 and ACF2_RW_TVAR)<>0, - (flags2 and ACF2_RW_HEX )<>0); - end; - - end; - - ACT_MESSAGE: begin - SetDlgItemTextW(Dialog,IDC_MSG_TITLE,msgtitle); - SetDlgItemTextW(Dialog,IDC_MSG_TEXT ,msgtext); - if (flags2 and ACF2_MSG_TTL)<>0 then ButtonOn(IDC_MSG_TTL); - if (flags2 and ACF2_MSG_TXT)<>0 then ButtonOn(IDC_MSG_TXT); - if (flags and ACF_MSG_KEEP)<>0 then ButtonOn(IDC_MSG_KEEP); - - case boxopts and $0F of - 1: ButtonOn(IDC_MSGB_OC); - 2: ButtonOn(IDC_MSGB_ARI); - 3: ButtonOn(IDC_MSGB_YNC); - 4: ButtonOn(IDC_MSGB_YN); - 5: ButtonOn(IDC_MSGB_RC); - else - ButtonOn(IDC_MSGB_OK); - end; - case boxopts and $F0 of - $10: ButtonOn(IDC_MSGI_ERROR); - $20: ButtonOn(IDC_MSGI_QUEST); - $30: ButtonOn(IDC_MSGI_WARN); - $40: ButtonOn(IDC_MSGI_INFO); - else - ButtonOn(IDC_MSGI_NONE); - end; - end; - end; - SHWindows(actionType); - end; - end; diff --git a/plugins/Actman/iac_.pas b/plugins/Actman/iac_.pas new file mode 100644 index 0000000000..5a47ba96a1 --- /dev/null +++ b/plugins/Actman/iac_.pas @@ -0,0 +1,155 @@ +unit iac_; + +interface + +implementation + +uses windows, iac_global, mirutils; + + +type + = class(tBaseAction) + + constructor Create(uid:dword); + destructor Destroy; override; + function Clone:tBaseAction; override; + function DoAction(var WorkData:tWorkData):LRESULT; override; + procedure Save(node:pointer;fmt:integer); override; + procedure Load(node:pointer;fmt:integer); override; + end; + +//----- Support functions ----- + +//----- Object realization ----- + +constructor .Create(uid:dword); +begin + inherited Create(uid); +end; + +destructor .Destroy; +begin + + inherited Destroy; +end; + +function .Clone:tBaseAction; +begin + result:=.Create(0); + Duplicate(result); + +end; + +function .DoAction(var WorkData:tWorkData):LRESULT; +begin + result:=0; +end; + +procedure .Load(node:pointer;fmt:integer); +var + section: array [0..127] of AnsiChar; + pc:pAnsiChar; +begin + inherited Load(node,fmt); + case fmt of + 0: begin + pc:=StrCopyE(section,pAnsiChar(node)); + end; +{ + 1: begin + end; +} + end; +end; + +procedure .Save(node:pointer;fmt:integer); +var + section: array [0..127] of AnsiChar; + pc:pAnsiChar; +begin + inherited Save(node,fmt); + case fmt of + 0: begin + pc:=StrCopyE(section,pAnsiChar(node)); + end; +{ + 1: begin + end; +} + end; +end; + +//----- Dialog realization ----- + +procedure ClearFields(Dialog:HWND); +begin +end; + +function DlgProc(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; +begin + result:=0; + + case hMessage of + WM_INITDIALOG: begin + TranslateDialogDefault(Dialog); + end; + + WM_ACT_SETVALUE: begin + ClearFields(Dialog); + with (lParam) do + begin + end; + end; + + WM_ACT_RESET: begin + ClearFields(Dialog); + end; + + WM_ACT_SAVE: begin + with (lParam) do + begin + end; + end; + + WM_COMMAND: begin + case wParam shr 16 of + end; + end; + + WM_HELP: begin + result:=1; + end; + + end; +end; + +//----- Export/interface functions ----- + +var + vc:tActModule; + +function CreateAction:tBaseAction; +begin + result:=.Create(vc.Hash); +end; + +function CreateDialog(parent:HWND):HWND; +begin + result:=CreateDialogW(hInstance,,parent,@DlgProc); +end; + +procedure Init; +begin + vc.Next :=ModuleLink; + + vc.Name :=; + vc.Dialog :=@CreateDialog; + vc.Create :=@CreateAction; + vc.Icon :=; + + ModuleLink :=@vc; +end; + +begin + Init; +end. diff --git a/plugins/Actman/iac_call.pas b/plugins/Actman/iac_call.pas new file mode 100644 index 0000000000..f5235e2f2e --- /dev/null +++ b/plugins/Actman/iac_call.pas @@ -0,0 +1,948 @@ +unit iac_call; + +interface + +implementation + +uses + windows, messages, commctrl, + sparam, + common, wrapper, memini, + iac_global, global, + m_api, dbsettings, mirutils; + +{$include i_cnst_call.inc} +{$resource iac_call.res} + +const + MaxArgCount = 8; + MaxArgNameLen = 32; + +const + API_FUNCTION_FILE:pAnsiChar = 'plugins\services.ini'; + namespace = 'Function'; + +const + opt_dllname = 'dllname'; + opt_funcname = 'funcname'; + opt_argcount = 'argcount'; + opt_argf = 'argtype'; + opt_argn = 'argname'; + opt_argv = 'argvalue'; + +type + tCallAction = class(tBaseAction) + private + dllname:pAnsiChar; + funcname:pAnsiChar; + + argcount:integer; + argf:array [0..MaxArgCount-1] of dword; + argv:array [0..MaxArgCount-1] of uint_ptr; + argn:array [0..MaxArgCount-1,0..MaxArgNameLen-1] of AnsiChar; + public + constructor Create(uid:dword); + destructor Destroy; override; +// function Clone:tBaseAction; override; + function DoAction(var WorkData:tWorkData):LRESULT; override; + procedure Save(node:pointer;fmt:integer); override; + procedure Load(node:pointer;fmt:integer); override; + end; + +var + storage:pointer; + +const + ACF_CDECL = $00000001; + ACF_CACHE_NOW = $00000002; + ACF_CACHE_MACRO = $00000004; + +type + sp0 = function:int_ptr; stdcall; + sp1 = function(arg1:int_ptr):int_ptr; stdcall; + sp2 = function(arg1,arg2:uint_ptr):int_ptr; stdcall; + sp3 = function(arg1,arg2,arg3:uint_ptr):int_ptr; stdcall; + sp4 = function(arg1,arg2,arg3,arg4:uint_ptr):int_ptr; stdcall; + sp5 = function(arg1,arg2,arg3,arg4,arg5:uint_ptr):int_ptr; stdcall; + sp6 = function(arg1,arg2,arg3,arg4,arg5,arg6:uint_ptr):int_ptr; stdcall; + sp7 = function(arg1,arg2,arg3,arg4,arg5,arg6,arg7:uint_ptr):int_ptr; stdcall; + sp8 = function(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8:uint_ptr):int_ptr; stdcall; + + cp0 = function:int_ptr; cdecl; + cp1 = function(arg1:uint_ptr):int_ptr; cdecl; + cp2 = function(arg1,arg2:uint_ptr):int_ptr; cdecl; + cp3 = function(arg1,arg2,arg3:uint_ptr):int_ptr; cdecl; + cp4 = function(arg1,arg2,arg3,arg4:uint_ptr):int_ptr; cdecl; + cp5 = function(arg1,arg2,arg3,arg4,arg5:uint_ptr):int_ptr; cdecl; + cp6 = function(arg1,arg2,arg3,arg4,arg5,arg6:uint_ptr):int_ptr; cdecl; + cp7 = function(arg1,arg2,arg3,arg4,arg5,arg6,arg7:uint_ptr):int_ptr; cdecl; + cp8 = function(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8:uint_ptr):int_ptr; cdecl; + +//----- Support functions ----- + +//----- Object realization ----- + +constructor tCallAction.Create(uid:dword); +begin + inherited Create(uid); + + argcount:=0; + dllname :=nil; + funcname:=nil; +end; + +destructor tCallAction.Destroy; +begin + mFreeMem(dllname); + mFreeMem(funcname); + + inherited Destroy; +end; +{ +function tCallAction.Clone:tBaseAction; +begin + result:=.Create(0); + Duplicate(result); + +end; +} +function tCallAction.DoAction(var WorkData:tWorkData):LRESULT; +var + hDLL:THANDLE; + pp:pointer; + res:LRESULT; + largv:array [0..MaxArgCount-1] of uint_ptr; + i:integer; + loaded:bool; +begin + result:=0; + if (dllname =nil) or (dllname^ =#0) or + (funcname=nil) or (funcname^=#0) then + begin + // clear last result? + exit; + end; + + loaded:=false; + hDLL:=GetModuleHandleA(dllname); + if hDLL=0 then + begin + loaded:=true; + hDLL:=LoadLibraryA(dllname); + end; +// hDLL:=GetDllHandle(dllname); + if hDLL<>0 then + begin + pp:=GetProcAddress(hDLL,funcname); + if pp<>nil then + begin + // prepare arguments? + for i:=0 to argcount-1 do + begin + largv[i]:=argv[i]; +//!! PreProcess(argf[i],LPARAM(largv[i]),WorkData); + end; + // call function + case argcount of + 0: begin + if (flags and ACF_CDECL)<>0 then + res:=cp0(pp) + else + res:=sp0(pp); + end; + 1: begin + if (flags and ACF_CDECL)<>0 then + res:=cp1(pp)(largv[0]) + else + res:=sp1(pp)(largv[0]); + end; + 2: begin + if (flags and ACF_CDECL)<>0 then + res:=cp2(pp)(largv[0],largv[1]) + else + res:=sp2(pp)(largv[0],largv[1]); + end; + 3: begin + if (flags and ACF_CDECL)<>0 then + res:=cp3(pp)(largv[0],largv[1],largv[2]) + else + res:=sp3(pp)(largv[0],largv[1],largv[2]); + end; + 4: begin + if (flags and ACF_CDECL)<>0 then + res:=cp4(pp)(largv[0],largv[1],largv[2],largv[3]) + else + res:=sp4(pp)(largv[0],largv[1],largv[2],largv[3]); + end; + 5: begin + if (flags and ACF_CDECL)<>0 then + res:=cp5(pp)(largv[0],largv[1],largv[2],largv[3],largv[4]) + else + res:=sp5(pp)(largv[0],largv[1],largv[2],largv[3],largv[4]); + end; + 6: begin + if (flags and ACF_CDECL)<>0 then + res:=cp6(pp)(largv[0],largv[1],largv[2],largv[3],largv[4],largv[5]) + else + res:=sp6(pp)(largv[0],largv[1],largv[2],largv[3],largv[4],largv[5]); + end; + 7: begin + if (flags and ACF_CDECL)<>0 then + res:=cp7(pp)(largv[0],largv[1],largv[2],largv[3],largv[4],largv[5],largv[6]) + else + res:=sp7(pp)(largv[0],largv[1],largv[2],largv[3],largv[4],largv[5],largv[6]); + end; + 8: begin + if (flags and ACF_CDECL)<>0 then + res:=cp8(pp)(largv[0],largv[1],largv[2],largv[3],largv[4],largv[5],largv[6],largv[7]) + else + res:=sp8(pp)(largv[0],largv[1],largv[2],largv[3],largv[4],largv[5],largv[6],largv[7]); + end; + end; + + ClearResult(WorkData); + // result type processing + if (flags and (ACF_RSTRING or ACF_UNICODE))<>0 then + begin + if (flags and ACF_RUNICODE)=0 then + AnsiToWide(pAnsiChar(res),pWideChar(WorkData.LastResult),MirandaCP) + else + StrDupW(pWideChar(WorkData.LastResult),pWideChar(res)); + WorkData.ResultType:=rtWide; + + if (flags and ACF_RFREEMEM)<>0 then + mFreeMem(pAnsiChar(res)); //?? Miranda MM?? + end + else if (flags and ACF_RSTRUCT)=0 then + begin + WorkData.ResultType:=rtInt +{!!!! + end + else if (flags and ACF_RSTRUCT)<>0 then + begin + PostProcess(flags ,lwparam,WorkData); + PostProcess(flags2,llparam,WorkData); +} + end; + + end; +// FreeDllHandle(hDLL); + if loaded then + FreeLibrary(hDLL); + end; + +end; + +procedure LoadParam(section:PAnsiChar;flags:dword; var param:pointer); +begin + if (flags and (ACF_CURRENT or ACF_RESULT or ACF_PARAM))=0 then + begin + if (flags and ACF_STRUCT)<>0 then + param:=DBReadUTF8(0,DBBranch,section,nil) + else + param:=DBReadUnicode(0,DBBranch,section,nil); + end; +end; + +procedure tCallAction.Load(node:pointer;fmt:integer); +var + section: array [0..127] of AnsiChar; + pc,p,pd,ppd:pAnsiChar; + i:integer; +begin + inherited Load(node,fmt); + case fmt of + 0: begin + pc:=StrCopyE(section,pAnsiChar(node)); + StrCopy(pc,opt_dllname ); dllname :=DBReadString(0,DBBranch,section); + StrCopy(pc,opt_funcname); funcname:=DBReadString(0,DBBranch,section); + StrCopy(pc,opt_argcount); argcount:=DBReadByte (0,DBBranch,section); + if argcount>0 then + begin + pd:=nil; + for i:=0 to argcount-1 do + begin + IntToStr(StrCopyE(pc,opt_argf),i); argf[i]:=DBReadDWord (0,DBBranch,section); + IntToStr(StrCopyE(pc,opt_argn),i); p :=DBReadString(0,DBBranch,section); + if (p=nil) or (p^=#0) then + begin + if pd=nil then + pd:=Translate('Argument'); + ppd:=StrCopyE(argn[i],pd); ppd^:=' '; inc(ppd); + IntToStr(ppd,i+1); + end + else + StrCopy(argn[i],p); + mFreeMem(p); + IntToStr(StrCopyE(pc,opt_argv),i); LoadParam(section,argf[i],pointer(argv[i])); + end; + end; + end; +{ + 1: begin + end; +} + end; +end; + +procedure SaveParam(section:PAnsiChar;flags:dword; param:pointer); +begin + if (flags and (ACF_CURRENT or ACF_RESULT or ACF_PARAM))=0 then + begin + if pointer(param)<>nil then + begin + if (flags and ACF_STRUCT)<>0 then + DBWriteUTF8(0,DBBranch,section,param) + else + DBWriteUnicode(0,DBBranch,section,param); + end; + end; +end; + +procedure tCallAction.Save(node:pointer;fmt:integer); +var + section: array [0..127] of AnsiChar; + pc:pAnsiChar; + i:integer; +begin + inherited Save(node,fmt); + case fmt of + 0: begin + pc:=StrCopyE(section,pAnsiChar(node)); + StrCopy(pc,opt_dllname ); DBWriteString(0,DBBranch,section,dllname); + StrCopy(pc,opt_funcname); DBWriteString(0,DBBranch,section,funcname); + StrCopy(pc,opt_argcount); DBWriteByte (0,DBBranch,section,argcount); + if argcount>0 then + begin + for i:=0 to argcount-1 do + begin + IntToStr(StrCopyE(pc,opt_argf),i); DBWriteDWord (0,DBBranch,section,argf[i]); + IntToStr(StrCopyE(pc,opt_argn),i); DBWriteString(0,DBBranch,section,argn[i]); + IntToStr(StrCopyE(pc,opt_argv),i); SaveParam(section,argf[i],pointer(argv[i])); + end; + end; + end; +{ + 1: begin + end; +} + end; +end; + +//----- Dialog realization ----- + +{ + IDC_ARGNUM userdata = current item (argument number) + IDC_ARGCOUNT userdata = arguments buffer + Dialog userdata = parameter control +} + +type + peditvalues = ^teditvalues; + teditvalues = record + argf:array [0..MaxArgCount-1] of dword; + argv:array [0..MaxArgCount-1] of uint_ptr; + argn:array [0..MaxArgCount-1,0..MaxArgNameLen-1] of AnsiChar; + end; + +function GetArgumentWindow(Dialog:HWND):HWND; +begin + result:=GetWindowLongPtrW(GetDlgItem(Dialog,IDC_CLOSE_ARG),GWLP_USERDATA); +end; + +function GetResultWindow(Dialog:HWND):HWND; +begin + result:=GetWindowLongPtrW(GetDlgItem(Dialog,IDC_CLOSE_RES),GWLP_USERDATA); +end; + +function GetEditValues(Dialog:HWND):pointer; +begin + result:=pointer(GetWindowLongPtrW(GetDlgItem(Dialog,IDC_ARGCOUNT),GWLP_USERDATA)); +end; + +function ChangeArgNumber(Dialog:HWND;cnt:integer=-1):integer; +var + wnd,wnd1:HWND; + tr:bool; + pe:peditvalues; + i:integer; +begin + if cnt<0 then + cnt:=GetDlgItemInt(Dialog,IDC_ARGCOUNT,tr,false) +// cnt:=CB_GetData(GetDlgItem(Dialog,IDC_ARGCOUNT)) + else + SendMessage(GetDlgItem(Dialog,IDC_ARGCOUNT),CB_SETCURSEL,cnt,0); + + wnd :=GetArgumentWindow(Dialog); + wnd1:=GetDlgItem(Dialog,IDC_ARGNUM); + SendMessage(wnd1,CB_RESETCONTENT,0,0); + if cnt=0 then + begin + ShowWindow(wnd ,SW_HIDE); + ShowWindow(wnd1,SW_HIDE); + end + else + begin + if IsDlgButtonChecked(Dialog,IDC_CLOSE_ARG)<>BST_UNCHECKED then + begin + ShowWindow(wnd ,SW_SHOW); + ShowWindow(wnd1,SW_SHOW); + end; + pe:=GetEditValues(Dialog); + + for i:=0 to cnt-1 do + begin + InsertString(wnd1,i,@pe^.argn[i]); + end; + SendMessage(wnd1,CB_SETCURSEL,0,0); + end; + result:=cnt; +end; + +procedure FillTemplates(fwnd:HWND); +var + p,pp,pz:pAnsiChar; + lptr:pointer; + i:integer; +begin + SendMessage(fwnd,CB_RESETCONTENT,0,0); + + p:=GetSectionList(storage,namespace); + pp:=p; + i:=0; + while p^<>#0 do + begin + lptr:=SearchSection(storage,p,namespace); + pz:=StrScan(p,'$'); + if pz=nil then + pz:=p-1; + // add function if not found + if SendMessageA(fwnd,CB_FINDSTRINGEXACT,-1,LParam(pz+1))=CB_ERR then + CB_AddStrData(fwnd,pz+1,int_ptr(lptr){not so required}, i); + + while p^<>#0 do inc(p); inc(p); + inc(i); + end; + FreeSectionList(pp); + if i>0 then + begin + SendMessage(fwnd,CB_SETCURSEL,0,0); + end; +end; + +procedure SearchDllByFName(flist,dlist:HWND;idx:integer=-1); +var + pc,p,pp,pz:pAnsiChar; + lptr:pointer; + buf:array [0..31] of AnsiChar; + buf1:array [0..63] of AnsiChar; + i:integer; +begin + if idx<0 then + pc:=GetDlgText(flist,true) + else + begin + pc:=@buf1; + SendMessageA(flist,CB_GETLBTEXT,idx,LParam(@buf1)); + end; + + SendMessage(dlist,CB_RESETCONTENT,0,0); + + p:=GetSectionList(storage,namespace); + pp:=p; + i:=0; + while p^<>#0 do + begin + lptr:=SearchSection(storage,p,namespace); + pz:=StrScan(p,'$'); + if (pz<>nil) and (StrCmp(pz+1,pc)=0) then + begin + // add dll name + StrCopy(buf,p,pz-p); + CB_AddStrData(dlist,buf,int_ptr(lptr), i); + inc(i); + end; + + while p^<>#0 do inc(p); inc(p); + end; + FreeSectionList(pp); + if idx<0 then + mFreeMem(pc); + + if i>0 then + SendMessage(dlist,CB_SETCURSEL,0,0); +end; + +procedure FillByTemplate(Dialog:HWND); +var + buf:array [0..15] of AnsiChar; + fwnd,dwnd:HWND; + sect:pointer; + pe:peditvalues; + pc,pd,ppd:pAnsiChar; + sel,cnt,i:integer; +begin + fwnd:=GetDlgItem(Dialog,IDC_LIST_FUNC); + dwnd:=GetDlgItem(Dialog,IDC_LIST_DLL); + // right now, without manual typing, by selecting only + sect:=nil; + sel:=SendMessage(dwnd,CB_GETCURSEL,0,0); + if sel=CB_ERR then + begin + sel:=SendMessage(fwnd,CB_GETCURSEL,0,0); + if sel<>CB_ERR then + sect:=pointer(CB_GetData(fwnd,sel)); + end + else + sect:=pointer(CB_GetData(dwnd,sel)); + if sect=nil then + exit; + +// ClearFields if templated found + if StrCmp(GetParamSectionStr(sect,'calltype',nil),'cdecl')=0 then + begin + CheckDlgButton(Dialog,IDC_CDECL,BST_CHECKED); + CheckDlgButton(Dialog,IDC_STDCALL,BST_UNCHECKED); + end + else + begin + CheckDlgButton(Dialog,IDC_CDECL,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_STDCALL,BST_CHECKED); + end; + + cnt:=GetParamSectionInt(sect,'argcount'); + pe:=GetEditValues(Dialog); + pd:=nil; + for i:=0 to cnt-1 do + begin + IntToStr(StrCopyE(buf,opt_argn),i+1); pc:=GetParamSectionStr(sect,buf); + if (pc=nil) or (pc^=#0) then + begin + if pd=nil then + pd:=Translate('Argument'); + ppd:=StrCopyE(pe^.argn[i],pd); ppd^:=' '; inc(ppd); + IntToStr(ppd,i+1); + end + else + StrCopy(pe^.argn[i],pc); + + IntToStr(StrCopyE(buf,opt_argv),i+1); + + mFreeMem(pe^.argv[i]); + StrDup(pAnsiChar(pe^.argv[i]),GetParamSectionStr(sect,buf,'')); + pe^.argf[i]:=ACF_TEMPLATE; + end; + ChangeArgNumber(Dialog,cnt); + FillParam(GetArgumentWindow(Dialog),pointer(pe^.argv[0])); + +end; + +function FillDllName(Dialog:HWND;idc:integer):boolean; +var + pw:array [0..1023] of WideChar; + ppw:pWideChar; +begin +// mGetMem(pw,1024*SizeOf(WideChar)); + ppw:=GetDlgText(Dialog,idc); + result:=ShowDlgW(pw,ppw); + if result then + begin + SetDlgItemTextW(Dialog,idc,pw); + end; + mFreeMem(ppw); +// mFreeMem(pw); +end; + +procedure ShowHideBlock(Dialog:HWND;showarg:boolean); +var + wnd,wnd1:HWND; + rc:TRECT; + pt:TPOINT; + tr:bool; + arg,res:integer; +begin + wnd1:=GetArgumentWindow(Dialog); + if showarg then + begin + arg:=SW_SHOW; + res:=SW_HIDE; + wnd:=wnd1; + end + else + begin + arg:=SW_HIDE; + res:=SW_SHOW; + wnd:=GetDlgItem(Dialog,IDC_CLOSE_ARG); + end; + + GetWindowRect(wnd,rc); + pt.x:=rc.left; + pt.y:=rc.bottom; + ScreenToClient(Dialog,pt); + SetWindowPos(GetDlgItem(Dialog,IDC_CLOSE_RES), + HWND_TOP,1,pt.y+2,0,0,SWP_NOZORDER or SWP_NOSIZE); + + ShowWindow(GetResultWindow(Dialog),res); + + + ShowWindow(GetDlgItem(Dialog,IDC_ARGSTAT ),arg); + ShowWindow(GetDlgItem(Dialog,IDC_ARGCOUNT),arg); + + if GetDlgItemInt(Dialog,IDC_ARGCOUNT,tr,false)=0 then +// if CB_GetData(GetDlgItem(Dialog,IDC_ARGCOUNT))=0 then + arg:=SW_HIDE; + + ShowWindow(GetDlgItem(Dialog,IDC_ARGNUM),arg); + ShowWindow(wnd1,arg); +end; + +procedure MakeDLLCacheList(wnd:HWND); +begin + SendMessage(wnd,CB_RESETCONTENT,0,0); + InsertString(wnd,0,'Keep to end'); + InsertString(wnd,1,'Close immediately'); + InsertString(wnd,2,'Close for macro'); + SendMessage(wnd,CB_SETCURSEL,0,0); +end; + +procedure ClearFields(Dialog:HWND); +begin + CheckDlgButton(Dialog,IDC_CDECL ,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_STDCALL,BST_UNCHECKED); +{!! + CheckDlgButton(Dialog,IDC_DLL_IMM ,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_DLL_MACRO,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_DLL_END ,BST_UNCHECKED); +} + ClearParamFields (GetArgumentWindow(Dialog)); + ClearResultFields(GetResultWindow (Dialog)); + + ShowHideBlock(Dialog,true); +end; + +function DlgProc(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; +var + wnd,wnd1:HWND; + buf:array [0..63] of AnsiChar; + pc:pAnsiChar; + pe:peditvalues; + rc:TRECT; + pt:TPOINT; + tr:bool; + i:integer; +begin + result:=0; + + case hMessage of + WM_DESTROY: begin + pe:=GetEditValues(Dialog); + for i:=0 to MaxArgCount-1 do + begin + //?? depends of copying from edit to action + ClearParam(pe.argf[i],pe.argv[i]); + end; + mFreeMem(pe); + + CloseStorage(storage); + end; + + WM_INITDIALOG: begin + //insert additional dialogs + CheckDlgButton(Dialog,IDC_CLOSE_ARG,BST_CHECKED); + wnd1:=GetDlgItem(Dialog,IDC_CLOSE_ARG); + EnableWindow(wnd1,false); + wnd:=GetDlgItem(Dialog,IDC_ARGNUM); // count offset from + GetWindowRect(wnd,rc); + pt.x:=rc.left; + pt.y:=rc.bottom; + ScreenToClient(Dialog,pt); + GetClientRect(wnd1,rc); + SetWindowLongPtrW(wnd1,GWLP_USERDATA,CreateParamBlock(Dialog,0,pt.y+2,rc.right)); + + CheckDlgButton(Dialog,IDC_CLOSE_RES,BST_UNCHECKED); + wnd:=GetDlgItem(Dialog,IDC_CLOSE_RES); // count offset from initial pos + GetWindowRect(wnd,rc); + EnableWindow(wnd,true); + pt.x:=rc.left; + pt.y:=rc.bottom; + ScreenToClient(Dialog,pt); + wnd1:=CreateResultBlock(Dialog,0,pt.y+2,rc.right-rc.left,ACF_NOVISUAL); + SetWindowLongPtrW(wnd,GWLP_USERDATA,wnd1); + ShowWindow(wnd1,SW_HIDE); + + mGetMem(pe,SizeOf(teditvalues)); + FillChar(pe^,SizeOf(teditvalues),0); + SetWindowLongPtrW(GetDlgItem(Dialog,IDC_ARGCOUNT),GWLP_USERDATA,uint_ptr(pe)); + + // function argument amount list + wnd1:=GetDlgItem(Dialog,IDC_ARGCOUNT); + SendMessage(wnd1,CB_RESETCONTENT,0,0); + for i:=0 to MaxArgCount do + begin + InsertString(wnd1,i,IntToStr(buf,i)); + end; + SendMessage(wnd1,CB_SETCURSEL,0,0); + + // function templates + storage:=OpenStorage(API_FUNCTION_FILE); + if storage<>nil then + begin + wnd :=GetDlgItem(Dialog,IDC_LIST_FUNC); + FillTemplates(wnd) + end; + + MakeDLLCacheList(GetDlgItem(Dialog,IDC_DLL_CACHE)); + + TranslateDialogDefault(Dialog); + end; + + WM_ACT_SETVALUE: begin + ClearFields(Dialog); + + with tCallAction(lParam) do + begin + + // set function + SetDlgItemTextA(Dialog,IDC_LIST_FUNC,funcname); + // sset dll name (semi-auto) + SetDlgItemTextA(Dialog,IDC_LIST_DLL ,dllname); + // set call type (auto) + if (flags and ACF_CDECL)<>0 then + CheckDlgButton(Dialog,IDC_CDECL ,BST_CHECKED) + else + CheckDlgButton(Dialog,IDC_STDCALL,BST_CHECKED); +{!! + // set dll cache option + if (flags and ACF_CACHE_NOW)<>0 then + CheckDlgButton(Dialog,IDC_DLL_IMM,BST_CHECKED) + else if (flags and ACF_CACHE_MACRO)<>0 then + CheckDlgButton(Dialog,IDC_DLL_MACRO,BST_CHECKED) + else + CheckDlgButton(Dialog,IDC_DLL_END,BST_CHECKED); +} + if (flags and ACF_CACHE_NOW)<>0 then + i:=1 + else if (flags and ACF_CACHE_MACRO)<>0 then + i:=2 + else + i:=0; + SendMessage(GetDlgItem(Dialog,IDC_DLL_CACHE),CB_SETCURSEL,i,0); + + // set argument amount + // (auto) + ChangeArgNumber(Dialog,argcount); + if argcount>0 then + begin + // copy action values to edit values + pe:=GetEditValues(Dialog); + // need to clear ALL params before? or keep as is? + // depends of enabled or disabled arg amount combo + for i:=0 to argcount-1 do + begin + StrCopy(pe^.argn[i],argn[i]); + pe^.argf[i]:=DuplicateParam(argf[i],argv[i],pe^.argv[i]); + end; + + wnd1:=GetDlgItem(Dialog,IDC_ARGNUM); + SendMessage(wnd1,CB_RESETCONTENT,0,0); + + for i:=0 to argcount-1 do + begin + InsertString(wnd1,i,@pe^.argn[i]); + end; + SendMessage(wnd1,CB_SETCURSEL,0,0); + + SetParamValue (GetArgumentWindow(Dialog),argf[0],pointer(argv[0])); + SetResultValue(GetResultWindow (Dialog),flags); + end; + + end; + end; + + WM_ACT_RESET: begin + ClearFields(Dialog); + SetDlgItemTextW(Dialog,IDC_LIST_FUNC,nil); + SetDlgItemTextW(Dialog,IDC_LIST_DLL ,nil); + SendMessage(GetDlgItem(Dialog,IDC_LIST_DLL),CB_RESETCONTENT,0,0); + CheckDlgButton(Dialog,IDC_STDCALL,BST_CHECKED); +//!! CheckDlgButton(Dialog,IDC_DLL_END,BST_CHECKED); + SendMessage(GetDlgItem(Dialog,IDC_DLL_CACHE),CB_SETCURSEL,0,0); + + ChangeArgNumber(Dialog,0); + + pe:=GetEditValues(Dialog); + + pc:=StrCopyE(buf,Translate('Argument')); pc^:=' '; inc(pc); + for i:=0 to MaxArgCount-1 do + begin + IntToStr(pc,i+1); + StrCopy(pe^.argn[i],buf); + ClearParam(pe.argf[i],pe.argv[i]); + end; + + end; + + WM_ACT_SAVE: begin + with tCallAction(lParam) do + begin + argcount:=GetDlgItemInt(Dialog,IDC_ARGCOUNT,tr,false); + if argcount>0 then + begin + pe:=GetEditValues(Dialog); + // save current argument + i:=GetWindowLongPtrW(GetDlgItem(Dialog,IDC_ARGNUM),GWLP_USERDATA); // current saved +// i:=CB_GetData(GetDlgItem(Dialog,IDC_ARGNUM)); // current from data + GetParamValue(GetArgumentWindow(Dialog),pe^.argf[i],pointer(pe^.argv[i])); + + // copy edit values to action values + for i:=0 to argcount-1 do + begin + StrCopy(argn[i],pe^.argn[i]); + argf[i]:=DuplicateParam(pe^.argf[i],pe^.argv[i],argv[i]); + end; + end; + + flags:=flags or GetResultValue(GetResultWindow(Dialog)); + if IsDlgButtonChecked(Dialog,IDC_CDECL)<>BST_UNCHECKED then + flags:=flags or ACF_CDECL; +{!! + if IsDlgButtonChecked(Dialog,IDC_DLL_IMM)<>BST_UNCHECKED then + flags:=flags or ACF_CACHE_NOW + else if IsDlgButtonChecked(Dialog,IDC_DLL_MACRO)<>BST_UNCHECKED then + flags:=flags or ACF_CACHE_MACRO; +} + case SendMessage(GetDlgItem(Dialog,IDC_DLL_CACHE),CB_GETCURSEL,0,0) of + 1: flags:=flags or ACF_CACHE_NOW; + 2: flags:=flags or ACF_CACHE_MACRO; + end; + + funcname:=GetDlgText(Dialog,IDC_LIST_FUNC,true); + dllname :=GetDlgText(Dialog,IDC_LIST_DLL ,true); + + end; + end; + + WM_COMMAND: begin + case wParam shr 16 of + + BN_CLICKED: begin + case loword(wParam) of + IDC_DLL: begin + if not FillDllName(Dialog,IDC_LIST_DLL) then + exit; + end; + + IDC_CLOSE_RES: begin + // close buttons + EnableWindow(lParam,false); + EnableWindow(GetDlgItem(Dialog,IDC_CLOSE_ARG),true); + CheckDlgButton(Dialog,IDC_CLOSE_ARG,BST_UNCHECKED); + + ShowHideBlock(Dialog,false); + exit; + end; + + IDC_CLOSE_ARG: begin + // close buttons + EnableWindow(lParam,false); + EnableWindow(GetDlgItem(Dialog,IDC_CLOSE_RES),true); + CheckDlgButton(Dialog,IDC_CLOSE_RES,BST_UNCHECKED); + + ShowHideBlock(Dialog,true); + exit; + end; + end; + SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0); + end; + + CBN_EDITCHANGE, + EN_CHANGE: begin + SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0); + + if loword(wParam)=IDC_LIST_FUNC then + begin + wnd :=GetDlgItem(Dialog,IDC_LIST_FUNC); + wnd1:=GetDlgItem(Dialog,IDC_LIST_DLL); + SearchDllByFName(wnd,wnd1); + end; + end; + + CBN_SELCHANGE: begin + case loword(wParam) of + IDC_LIST_FUNC: begin + // search in templates + SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0); + + wnd :=GetDlgItem(Dialog,IDC_LIST_FUNC); + wnd1:=GetDlgItem(Dialog,IDC_LIST_DLL); + // search this name as part in all ini templates, + // fill IDC_LIST_DLL combobox + SearchDllByFName(wnd,wnd1,SendMessage(wnd,CB_GETCURSEL,0,0)); + FillByTemplate(Dialog); + end; + + IDC_LIST_DLL: begin + SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0); + FillByTemplate(Dialog); + end; + + IDC_ARGNUM: begin + pe:=GetEditValues(Dialog); + + wnd:=GetArgumentWindow(Dialog); + // 1 - save old argument value (save as for dialogs?) + i:=GetWindowLongPtrW(lParam,GWLP_USERDATA); + GetParamValue(wnd,pe^.argf[i],pointer(pe^.argv[i])); + // 2 - set new argument value + i:=CB_GetData(lParam); + SetParamValue(wnd,pe^.argf[i],pointer(pe^.argv[i])); + + SetWindowLongPtrW(lParam,GWLP_USERDATA,i); + end; + + IDC_ARGCOUNT: begin + ChangeArgNumber(Dialog); + SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0); + end; + end; + end; + end; + end; + + WM_HELP: begin + result:=1; + end; + + end; +end; + +//----- Export/interface functions ----- + +var + vc:tActModule; + +function CreateAction:tBaseAction; +begin + result:=tCallAction.Create(vc.Hash); +end; + +function CreateDialog(parent:HWND):HWND; +begin + result:=CreateDialogW(hInstance,'IDD_ACTCALL',parent,@DlgProc); +end; + +procedure Init; +begin + vc.Next :=ModuleLink; + + vc.Name :='Function call'; + vc.Dialog :=@CreateDialog; + vc.Create :=@CreateAction; + vc.Icon :='IDI_CALL'; + + ModuleLink :=@vc; +end; + +begin + Init; +end. diff --git a/plugins/Actman/iac_call.rc b/plugins/Actman/iac_call.rc new file mode 100644 index 0000000000..f32f7bc303 --- /dev/null +++ b/plugins/Actman/iac_call.rc @@ -0,0 +1,38 @@ +#include "i_cnst_call.inc" + +LANGUAGE 0,0 + +IDD_ACTCALL DIALOGEX 0, 0, 168, 200, 0 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0 +{ + RTEXT "Function name", -1, 1, 0, 166, 12, SS_CENTERIMAGE + COMBOBOX IDC_LIST_FUNC , 1, 12, 166, 128, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL + RTEXT "DLL name" , -1, 1, 26, 166, 12, SS_CENTERIMAGE + COMBOBOX IDC_LIST_DLL , 1, 38, 148, 48, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL + PUSHBUTTON "...", IDC_DLL , 151, 38, 16, 12 + + GROUPBOX "Call type" , -1, 1, 52, 166, 22, WS_GROUP + AUTORADIOBUTTON "cdecl" , IDC_CDECL , 4, 61, 52, 11 + AUTORADIOBUTTON "stdcall" , IDC_STDCALL , 57, 61, 52, 11 + + AUTOCHECKBOX "Arguments", IDC_CLOSE_ARG, 1, 78, 166, 11, BS_PUSHLIKE + AUTOCHECKBOX "Result" , IDC_CLOSE_RES, 1, 91, 166, 11, BS_PUSHLIKE + + RTEXT "Number of arguments", IDC_ARGSTAT, 1, 90, 132, 12, SS_CENTERIMAGE + COMBOBOX IDC_ARGCOUNT , 137, 89, 30, 76, CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_VSCROLL + // argument list fills by amount of it? + COMBOBOX IDC_ARGNUM , 1, 104, 166, 76, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL + + RTEXT "DLL Handle Cache", -1, 1, 173, 166, 12, SS_CENTERIMAGE + COMBOBOX IDC_DLL_CACHE , 1, 185, 166, 76, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL +/* + GROUPBOX "DLL Handle Cache" , -1, 1, 156, 166, 44, WS_GROUP + AUTORADIOBUTTON "Close immediately", IDC_DLL_IMM , 4, 165, 162, 11 + AUTORADIOBUTTON "Close for macro" , IDC_DLL_MACRO, 4, 176, 162, 11 + AUTORADIOBUTTON "Keep to end" , IDC_DLL_END , 4, 187, 162, 11 +*/ +} + +IDI_CALL ICON "ico\call.ico" diff --git a/plugins/Actman/iac_call.res b/plugins/Actman/iac_call.res new file mode 100644 index 0000000000..bda9bc40b1 Binary files /dev/null and b/plugins/Actman/iac_call.res differ diff --git a/plugins/Actman/iac_chain.pas b/plugins/Actman/iac_chain.pas new file mode 100644 index 0000000000..48b187259f --- /dev/null +++ b/plugins/Actman/iac_chain.pas @@ -0,0 +1,384 @@ +unit iac_chain; + +interface + +implementation + +uses + windows, messages, commctrl, + global, iac_global, mirutils, m_api, inouttext, + dlgshare,lowlevelc,common,dbsettings, wrapper; + +{$include i_cnst_chain.inc} +{$resource iac_chain.res} + +const + ACF_BYNAME = $00000001; // Address action link by name, not Id + ACF_NOWAIT = $00000002; // Don't wait execution result, continue + ACF_KEEPOLD = $00000004; // Don't change LastResult value + ACF_SAMETHREAD = $00000008; // Execute in same thread with waiting +const + ioNoWait = 'nowait'; + ioKeepOld = 'keepold'; + ioSameThread = 'samethread'; +const + opt_chain = 'chain'; + opt_actname = 'actname'; +const + NoChainText:PWideChar = 'not defined'; + +type + tChainAction = class(tBaseAction) + private + id :dword; + actname:pWideChar; + public + constructor Create(uid:dword); + destructor Destroy; override; +// function Clone:tBaseAction; override; + function DoAction(var WorkData:tWorkData):LRESULT; override; + procedure Save(node:pointer;fmt:integer); override; + procedure Load(node:pointer;fmt:integer); override; + end; + +//----- Support functions ----- + +//----- Object realization ----- + +constructor tChainAction.Create(uid:dword); +begin + inherited Create(uid); + + id :=0; + actname:=nil; +end; + +destructor tChainAction.Destroy; +begin + if (flags and ACF_BYNAME)<>0 then + mFreeMem(actname); + + inherited Destroy; +end; +{ +function tChainAction.Clone:tBaseAction; +begin + result:=tChainAction.Create(0); + Duplicate(result); + + tChainAction(result).id:=id; + StrDupW(tChainAction(result).actname,actname); +end; +} +function tChainAction.DoAction(var WorkData:tWorkData):LRESULT; +var + params:tAct_Param; + res:int_ptr; +begin + result:=0; + + if (flags and ACF_BYNAME)<>0 then + begin + params.flags:=ACTP_BYNAME; + params.Id :=uint_ptr(actname); + end + else + begin + params.flags:=0; + params.Id :=id; + end; + if (flags and ACF_SAMETHREAD)<>0 then + params.flags:=params.flags or ACTP_SAMETHREAD + else if (flags and ACF_NOWAIT)=0 then + params.flags:=params.flags or ACTP_WAIT; + + if (flags and ACF_KEEPOLD)=0 then + params.flags:=params.flags or ACTP_KEEPRESULT; + + params.wParam:=WorkData.Parameter; + params.lParam:=WorkData.LastResult; + res:=CallService(MS_ACT_RUNPARAMS,0,tlparam(@params)); + + if (flags and ACF_KEEPOLD)=0 then + begin + ClearResult(WorkData); + if (flags and ACF_SAMETHREAD)=0 then + begin + WorkData.LastResult:=res; + WorkData.ResultType:=rtInt; + end + else + begin + WorkData.LastResult:=params.lParam; + WorkData.ResultType:=params.lPType; + end; + end; +end; + +procedure tChainAction.Load(node:pointer;fmt:integer); +var + section: array [0..127] of AnsiChar; + pc:pAnsiChar; +begin + inherited Load(node,fmt); + case fmt of + 0: begin + pc:=StrCopyE(section,pAnsiChar(node)); + if (flags and ACF_BYNAME)=0 then + begin + StrCopy(pc,opt_chain); id:=DBReadDWord(0,DBBranch,section); + end + else + begin + StrCopy(pc,opt_actname); actname:=DBReadUnicode(0,DBBranch,section); + end; + end; + + 100: begin + flags:=flags and not ACF_BYNAME; + pc:=StrCopyE(section,pAnsiChar(node)); + StrCopy(pc,'text'); id:=DBReadDWord(0,DBBranch,section); + end; + + 1: begin + with xmlparser do + begin + StrDupW(actname,getText(HXML(node))); + flags:=flags or ACF_BYNAME; + + if StrToInt(getAttrValue(HXML(node),ioNoWait))=1 then + flags:=flags or ACF_NOWAIT; + + if StrToInt(getAttrValue(HXML(node),ioKeepOld))=1 then + flags:=flags or ACF_KEEPOLD; + + if StrToInt(getAttrValue(HXML(node),ioSameThread))=1 then + flags:=flags or ACF_SAMETHREAD; + end; + end; +{ + 2: begin + + UF8ToWide(GetParamSectionStr(node,'name',nil),actname); + flags:=flags or ACF_BYNAME; + + if GetParamSectionInt(node,ioNoWait)=1 then + flags:=flags or ACF_NOWAIT; + + if GetParamSectionInt(node,ioKeepOld)=1 then + flags:=flags or ACF_KEEPOLD; + + if GetParamSectionInt(node,ioSameThread)=1 then + flags:=flags or ACF_SAMETHREAD; + end; +} + end; +end; + +procedure tChainAction.Save(node:pointer;fmt:integer); +var + section: array [0..127] of AnsiChar; + pc:pAnsiChar; +begin + inherited Save(node,fmt); + case fmt of + 0: begin + pc:=StrCopyE(section,pAnsiChar(node)); + if (flags and ACF_BYNAME)=0 then + begin + StrCopy(pc,opt_chain); DBWriteDWord(0,DBBranch,section,id); + end + else + begin + StrCopy(pc,opt_actname); DBWriteUnicode(0,DBBranch,section,actname); + end; + end; +{ + 1: begin + end; +} +{ + 2: begin + end; +} +{ + 3: begin + Out(node,['CallAction',actname, + IFF(flags or ACF_SAMETHREAD,'samethread',''), + IFF(flags or ACF_NOWAIT ,'nowait',''), + IFF(flags or ACF_KEEPOLD ,'keepold','') + ]); + end; +} + 13: begin + tTextExport(node).AddTextW('actionname',actname); + tTextExport(node).AddFlag('samethread',(flags or ACF_SAMETHREAD)<>0); + tTextExport(node).AddFlag('nowait' ,(flags or ACF_NOWAIT )<>0); + tTextExport(node).AddFlag('keepold' ,(flags or ACF_KEEPOLD )<>0); + tTextExport(node).AddNewLine(); + end; + end; +end; + +//----- Dialog realization ----- + +procedure FillChainList(Dialog:HWND); +var + wnd,list:HWND; + i:integer; + + li:LV_ITEMW; + Macro:pMacroRecord; +begin + wnd:=GetDlgItem(Dialog,IDC_MACRO_LIST); + + SendMessage(wnd,CB_RESETCONTENT,0,0); + SendMessage(wnd,CB_SETITEMDATA, + SendMessageW(wnd,CB_ADDSTRING,0,lparam(TranslateW(NoChainText))),0); + + list:=MacroListWindow; + li.mask :=LVIF_PARAM; + li.iSubItem :=0; + for i:=0 to SendMessage(list,LVM_GETITEMCOUNT,0,0)-1 do + begin + li.iItem:=i; + SendMessageW(list,LVM_GETITEMW,0,tlparam(@li)); + Macro:=EditMacroList[loword(li.lParam)]; + SendMessage(wnd,CB_SETITEMDATA, + SendMessageW(wnd,CB_ADDSTRING,0,lparam(@(Macro.descr))),Macro.id); + end; + +end; + +procedure ClearFields(Dialog:HWND); +begin + CheckDlgButton(Dialog,IDC_MACRO_NOWAIT ,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_MACRO_SAMETHREAD,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_MACRO_KEEPOLD ,BST_UNCHECKED); +end; + +function DlgProc(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; +var + tmp:dword; + wnd:HWND; + bb:boolean; +begin + result:=0; + + case hMessage of + WM_INITDIALOG: begin + TranslateDialogDefault(Dialog); + + FillChainList(Dialog); + end; + + WM_ACT_SETVALUE: begin + ClearFields(Dialog); + with tChainAction(lParam) do + begin + if (flags and ACF_BYNAME)<>0 then + SendDlgItemMessageW(Dialog,IDC_MACRO_LIST,CB_SELECTSTRING,twparam(-1),tlparam(actname)) + else + CB_SelectData(Dialog,IDC_MACRO_LIST,id); + if (flags and ACF_KEEPOLD)<>0 then + CheckDlgButton(Dialog,IDC_MACRO_KEEPOLD,BST_CHECKED); + + if (flags and ACF_SAMETHREAD)<>0 then + begin + bb:=false; + CheckDlgButton(Dialog,IDC_MACRO_SAMETHREAD,BST_CHECKED); + end + else + begin + bb:=true; + if (flags and ACF_NOWAIT)<>0 then + CheckDlgButton(Dialog,IDC_MACRO_NOWAIT,BST_CHECKED); + end; + EnableWindow(GetDlgItem(Dialog,IDC_MACRO_NOWAIT),bb); + end; + end; + + WM_ACT_RESET: begin + ClearFields(Dialog); + CheckDlgButton(Dialog,IDC_MACRO_SAMETHREAD,BST_CHECKED); + SendDlgItemMessage(Dialog,IDC_MACRO_LIST,CB_SETCURSEL,0,0); + end; + + WM_ACT_SAVE: begin + with tChainAction(lParam) do + begin + id:=CB_GetData(GetDlgItem(Dialog,IDC_MACRO_LIST)); + + if IsDlgButtonChecked(Dialog,IDC_MACRO_SAMETHREAD)<>BST_UNCHECKED then + flags:=flags or ACF_SAMETHREAD + else if IsDlgButtonChecked(Dialog,IDC_MACRO_NOWAIT)<>BST_UNCHECKED then + flags:=flags or ACF_NOWAIT; + + if IsDlgButtonChecked(Dialog,IDC_MACRO_KEEPOLD)<>BST_UNCHECKED then + flags:=flags or ACF_KEEPOLD; + end; + end; + + WM_ACT_LISTCHANGE: begin + if wParam=1 then + begin + wnd:=GetDlgItem(Dialog,IDC_MACRO_LIST); + tmp:=CB_GetData(wnd); + FillChainList(Dialog); + CB_SelectData(wnd,tmp); + end; + end; + + WM_COMMAND: begin + case wParam shr 16 of + CBN_SELCHANGE: SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0); + BN_CLICKED: begin + if loword(wParam)=IDC_MACRO_SAMETHREAD then + begin + EnableWindow(GetDlgItem(Dialog,IDC_MACRO_NOWAIT), + IsDlgButtonChecked(Dialog,IDC_MACRO_SAMETHREAD)=BST_UNCHECKED); + end; + + SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0); + end; + end; + end; + + WM_HELP: begin + result:=1; + end; + end; +// result:=DefWindowProc(Dialog,hMessage,wParam,lParam); +end; + +//----- Export/interface functions ----- + +var + vc:tActModule; + +function CreateAction:tBaseAction; +begin + result:=tChainAction.Create(vc.Hash); +end; + +function CreateDialog(parent:HWND):HWND; +begin + result:=CreateDialogW(hInstance,'IDD_ACTCHAIN',parent,@DlgProc); +end; + +procedure Init; +begin + vc.Next :=ModuleLink; + + vc.Name :='Chain'; + vc.Dialog :=@CreateDialog; + vc.Create :=@CreateAction; + vc.Icon :='IDI_CHAIN'; + vc.Hash :=0; + + ModuleLink :=@vc; +end; + +begin + Init; +end. diff --git a/plugins/Actman/iac_chain.rc b/plugins/Actman/iac_chain.rc new file mode 100644 index 0000000000..edde6de616 --- /dev/null +++ b/plugins/Actman/iac_chain.rc @@ -0,0 +1,18 @@ +#include "i_cnst_chain.inc" + +LANGUAGE 0,0 + +IDD_ACTCHAIN DIALOGEX 0, 0, 168, 200, 0 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0 +{ + RTEXT "Other Action groups",-1, 0, 2, 160, 10 + COMBOBOX IDC_MACRO_LIST, 1, 13, 166, 128, + CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_VSCROLL + AUTOCHECKBOX "Keep old result" , IDC_MACRO_KEEPOLD , 1, 31, 166, 11 + AUTOCHECKBOX "Same thread" , IDC_MACRO_SAMETHREAD, 1, 44, 166, 11 + AUTOCHECKBOX "Do not wait until the end of execution", IDC_MACRO_NOWAIT , 1, 57, 166, 11 +} + +IDI_CHAIN ICON "ico\chain.ico" diff --git a/plugins/Actman/iac_chain.res b/plugins/Actman/iac_chain.res new file mode 100644 index 0000000000..777e3bc186 Binary files /dev/null and b/plugins/Actman/iac_chain.res differ diff --git a/plugins/Actman/iac_contact.pas b/plugins/Actman/iac_contact.pas new file mode 100644 index 0000000000..55afcfba2f --- /dev/null +++ b/plugins/Actman/iac_contact.pas @@ -0,0 +1,313 @@ +unit iac_contact; + +interface + +implementation + +uses + windows, messages, commctrl, + m_api, global, iac_global, common, + mircontacts, dlgshare, syswin, inouttext, + wrapper, mirutils, dbsettings; + +{$include i_cnst_contact.inc} +{$resource iac_contact.res} + +const + ACF_KEEPONLY = $00000001; // keep contact handle in Last, don't show window + ACF_GETACTIVE = $00000002; // try to get contact from active window + +const + ioKeepOnly = 'keeponly'; + ioWindow = 'window'; + +type + tContactAction = class(tBaseAction) + private + contact:TMCONTACT; + public + constructor Create(uid:dword); +// function Clone:tBaseAction; override; + function DoAction(var WorkData:tWorkData):LRESULT; override; + procedure Save(node:pointer;fmt:integer); override; + procedure Load(node:pointer;fmt:integer); override; + end; + +//----- Support functions ----- + +constructor tContactAction.Create(uid:dword); +begin + inherited Create(uid); + + contact:=0; +end; +{ +function tContactAction.Clone:tBaseAction; +begin + result:=tContactAction.Create(0); + Duplicate(result); + + tContactAction(result).contact:=contact; +end; +} + +//----- Object realization ----- + +function tContactAction.DoAction(var WorkData:tWorkData):LRESULT; +var + wnd:HWND; +begin + ClearResult(WorkData); + + if (flags and ACF_GETACTIVE)<>0 then + begin + wnd:=WaitFocusedWndChild(GetForegroundWindow){GetFocus}; + if wnd<>0 then + contact:=WndToContact(wnd) + else + contact:=0; + end + else if (flags and ACF_KEEPONLY)=0 then + ShowContactDialog(contact); + + WorkData.LastResult:=contact; + WorkData.ResultType:=rtInt; + + result:=0; +end; + +procedure tContactAction.Load(node:pointer;fmt:integer); +begin + inherited Load(node,fmt); + case fmt of + 0: if (flags and ACF_GETACTIVE)=0 then + contact:=LoadContact(DBBranch,node); + + 1: begin + with xmlparser do + begin + contact:=ImportContact(HXML(node)); + if StrToInt(getAttrValue(HXML(node),ioKeepOnly))=1 then + flags:=flags or ACF_KEEPONLY; + if StrToInt(getAttrValue(HXML(node),ioWindow))=1 then + flags:=flags or ACF_GETACTIVE; + end; + end; +{ + 2: begin + contact:=ImportContactINI(node); + + if GetParamSectionInt(node,ioKeepOnly)=1 then + flags:=flags or ACF_KEEPONLY; + if GetParamSectionInt(node,ioWindow)=1 then + flags:=flags or ACF_GETACTIVE; + end; +} + end; +end; + +function ExportContactText(node:tTextExport;hContact:TMCONTACT):integer; +var + proto,uid:pAnsiChar; + cws:TDBVARIANT; + p1:pAnsiChar; + p:pWideChar; +// tmpbuf:array [0..63] of WideChar; + is_chat:boolean; +begin + result:=0; + proto:=GetContactProtoAcc(hContact); + if proto<>nil then + begin + is_chat:=IsChat(hContact); + if is_chat then + begin + p:=DBReadUnicode(hContact,proto,'ChatRoomID'); + node.AddTextW('id',p); + mFreeMem(p); + result:=1; + end + else + begin + uid:=pAnsiChar(CallProtoService(proto,PS_GETCAPS,PFLAG_UNIQUEIDSETTING,0)); + if DBReadSetting(hContact,proto,uid,@cws)=0 then + begin + result:=1; + node.AddDWord('ctype',cws._type); + case cws._type of + DBVT_BYTE : node.AddDWord('id',cws.bVal); + DBVT_WORD : node.AddDWord('id',cws.wVal); + DBVT_DWORD : node.AddDWord('id',cws.dVal); + DBVT_ASCIIZ: begin + node.AddText('id',cws.szVal.A); // ansi to utf + end; + DBVT_UTF8 : begin + node.AddText('id',cws.szVal.A); + end; + DBVT_WCHAR : node.AddTextW('id',cws.szVal.W); + DBVT_BLOB : begin + p1:=mir_base64_encode(cws.pbVal,cws.cpbVal); + node.AddText('id',p1); + mir_free(p1); + end; + end; + end; + DBFreeVariant(@cws); + end; + if result<>0 then + begin + node.AddText('protocol',proto); + node.AddFlag('ischat' ,is_chat); + end; + end; +end; + +procedure tContactAction.Save(node:pointer;fmt:integer); +begin + inherited Save(node,fmt); + case fmt of + 0: if (flags and ACF_GETACTIVE)=0 then + SaveContact(contact,DBBranch,node); +{ + 1: begin + sub:=AddChild(actnode,ioContactWindow,nil); + ExportContact(sub,contact); +// AddAttrInt(sub,ioNumber,0); // contact + if (flags and ACF_KEEPONLY)<>0 then AddAttrInt(sub,ioKeepOnly,1); + end; +} + 13: begin + tTextExport(node).AddFlag('keeponly' ,(flags or ACF_KEEPONLY )<>0); + tTextExport(node).AddFlag('getactive',(flags or ACF_GETACTIVE)<>0); + ExportContactText(tTextExport(node),contact); + end; + end; +end; + +//----- Dialog realization ----- + +procedure ClearFields(Dialog:HWND); +begin + CheckDlgButton(Dialog,IDC_CNT_KEEP,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_CNT_GET ,BST_UNCHECKED); +end; + +function DlgProc(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; +var + wnd:HWND; + bb:boolean; +begin + result:=0; + + case hMessage of + WM_INITDIALOG: begin + TranslateDialogDefault(Dialog); + + wnd:=GetDlgItem(Dialog,IDC_CNT_REFRESH); + OptSetButtonIcon(wnd,ACI_REFRESH); + SendMessage(wnd,BUTTONADDTOOLTIP,TWPARAM(TranslateW('Refresh')),BATF_UNICODE); + OptFillContactList(GetDlgItem(Dialog,IDC_CONTACTLIST)); + end; + + WM_ACT_SETVALUE: begin + ClearFields(Dialog); + + with tContactAction(lParam) do + begin + if (flags and ACF_GETACTIVE)<>0 then + begin + bb:=false; + CheckDlgButton(Dialog,IDC_CNT_GET,BST_CHECKED); + end + else + begin + bb:=true; + if (flags and ACF_KEEPONLY)<>0 then + CheckDlgButton(Dialog,IDC_CNT_KEEP,BST_CHECKED); + + SendDlgItemMessage(Dialog,IDC_CONTACTLIST,CB_SETCURSEL, + FindContact(GetDlgItem(Dialog,IDC_CONTACTLIST),contact),0); + end; + EnableWindow(GetDlgItem(Dialog,IDC_CNT_REFRESH),bb); + EnableWindow(GetDlgItem(Dialog,IDC_CONTACTLIST),bb); + EnableWindow(GetDlgItem(Dialog,IDC_CNT_KEEP ),bb); + end; + end; + + WM_ACT_RESET: begin + ClearFields(Dialog); + EnableWindow(GetDlgItem(Dialog,IDC_CNT_REFRESH),true); + EnableWindow(GetDlgItem(Dialog,IDC_CONTACTLIST),true); + EnableWindow(GetDlgItem(Dialog,IDC_CNT_KEEP ),true); + end; + + WM_ACT_SAVE: begin + with tContactAction(lParam) do + begin + contact:=SendDlgItemMessage(Dialog,IDC_CONTACTLIST,CB_GETITEMDATA, + SendDlgItemMessage(Dialog,IDC_CONTACTLIST,CB_GETCURSEL,0,0),0); + if IsDlgButtonChecked(Dialog,IDC_CNT_KEEP)=BST_CHECKED then + flags:=flags or ACF_KEEPONLY; + end; + end; + + WM_COMMAND: begin + case wParam shr 16 of + CBN_SELCHANGE: SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0); + BN_CLICKED: begin + case loword(wParam) of + IDC_CNT_GET: begin + bb:=IsDlgButtonChecked(Dialog,IDC_CNT_GET)=BST_UNCHECKED; + EnableWindow(GetDlgItem(Dialog,IDC_CNT_REFRESH),bb); + EnableWindow(GetDlgItem(Dialog,IDC_CONTACTLIST),bb); + EnableWindow(GetDlgItem(Dialog,IDC_CNT_KEEP ),bb); + end; + + IDC_CNT_REFRESH: begin + OptFillContactList(GetDlgItem(Dialog,IDC_CONTACTLIST)); + exit; + end; + end; + SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0); + end; + + end; + end; + + WM_HELP: begin + result:=1; + end; + end; +end; + +//----- Export/interface functions ----- + +var + vc:tActModule; + +function CreateAction:tBaseAction; +begin + result:=tContactAction.Create(vc.Hash); +end; + +function CreateDialog(parent:HWND):HWND; +begin + result:=CreateDialogW(hInstance,'IDD_ACTCONTACT',parent,@DlgProc); +end; + +procedure Init; +begin + vc.Next :=ModuleLink; + + vc.Name :='Contact'; + vc.Dialog :=@CreateDialog; + vc.Create :=@CreateAction; + vc.Icon :='IDI_CONTACT'; + vc.Hash :=0; + + ModuleLink :=@vc; +end; + +begin + Init; +end. diff --git a/plugins/Actman/iac_contact.rc b/plugins/Actman/iac_contact.rc new file mode 100644 index 0000000000..65a7d2843e --- /dev/null +++ b/plugins/Actman/iac_contact.rc @@ -0,0 +1,18 @@ +#include "i_cnst_contact.inc" + +LANGUAGE 0,0 + +IDD_ACTCONTACT DIALOGEX 0, 0, 168, 200, 0 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0 +{ + RTEXT "Choose contact", -1 , 0, 2, 160, 10 + CONTROL "Refresh",IDC_CNT_REFRESH,"MButtonClass",WS_TABSTOP,1,12,16,16,$18000000 + COMBOBOX IDC_CONTACTLIST, 19, 14, 148, 128, CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL + AUTOCHECKBOX "Keep handle only", IDC_CNT_KEEP , 1, 31, 160, 11 + + AUTOCHECKBOX "Get from active window", IDC_CNT_GET, 1, 45, 160, 11 +} + +IDI_CONTACT ICON "ico\contact.ico" diff --git a/plugins/Actman/iac_contact.res b/plugins/Actman/iac_contact.res new file mode 100644 index 0000000000..e146eaf451 Binary files /dev/null and b/plugins/Actman/iac_contact.res differ diff --git a/plugins/Actman/iac_database.rc b/plugins/Actman/iac_database.rc new file mode 100644 index 0000000000..cc9f309ebf --- /dev/null +++ b/plugins/Actman/iac_database.rc @@ -0,0 +1,35 @@ +#include "i_cnst_database.inc" + +LANGUAGE 0,0 + +IDD_ACTDATABASE DIALOGEX 0, 0, 168, 200, 0 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0 +{ + RTEXT "Contact type", -1, 1, 0, 160, 8, SS_CENTERIMAGE + COMBOBOX IDC_CONTACTTYPE , 18, 9, 148, 60, CBS_DROPDOWNLIST | WS_VSCROLL + + CONTROL "Refresh",IDC_CNT_REFRESH,"MButtonClass",WS_TABSTOP,1,23,16,16,$18000000 + COMBOBOX IDC_CONTACTLIST, 18, 25, 148, 128, CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL + + RTEXT "Module" , -1, 1, 43, 160, 8, SS_CENTERIMAGE + EDITTEXT IDC_RW_MODULE , 1, 52, 166, 12, ES_AUTOHSCROLL + RTEXT "Setting" , -1, 1, 67, 160, 8, SS_CENTERIMAGE + EDITTEXT IDC_RW_SETTING, 1, 76, 166, 12, ES_AUTOHSCROLL + + GROUPBOX "Operation" , -1, 1, 92, 166, 23, WS_GROUP + AUTORADIOBUTTON "Read" , IDC_RW_READ , 4, 101, 52, 11 + AUTORADIOBUTTON "Write" , IDC_RW_WRITE , 57, 101, 52, 11 + AUTORADIOBUTTON "Delete" , IDC_RW_DELETE , 110, 101, 52, 11 + + GROUPBOX "Value" , -1, 1, 116, 166, 64, WS_GROUP + + COMBOBOX IDC_RW_DATATYPE, 86, 125, 79, 96, CBS_DROPDOWNLIST | WS_VSCROLL + + AUTOCHECKBOX "Last result" , IDC_RW_LAST , 6, 142, 156, 11, BS_RIGHT | BS_LEFTTEXT + EDITTEXT IDC_RW_VALUE, 4, 154, 160, 11, ES_AUTOHSCROLL + AUTOCHECKBOX "Save value" , IDC_RW_SAVE , 6, 166, 156, 11, BS_RIGHT | BS_LEFTTEXT +} + +IDI_DATABASE ICON "ico\rw.ico" diff --git a/plugins/Actman/iac_database.res b/plugins/Actman/iac_database.res new file mode 100644 index 0000000000..b4de95c9e7 Binary files /dev/null and b/plugins/Actman/iac_database.res differ diff --git a/plugins/Actman/iac_dbrw.pas b/plugins/Actman/iac_dbrw.pas new file mode 100644 index 0000000000..7ddbe0b61c --- /dev/null +++ b/plugins/Actman/iac_dbrw.pas @@ -0,0 +1,778 @@ +unit iac_dbrw; + +interface + +implementation + +uses + windows, messages, commctrl, + global, iac_global, + m_api,dbsettings, + common,mirutils,wrapper, + editwrapper,mircontacts,dlgshare; + +{$include i_cnst_database.inc} +{$resource iac_database.res} + +const + opt_module = 'module'; + opt_setting = 'setting'; + opt_value = 'value'; +const + ioOper = 'oper'; + ioDelete = 'delete'; + ioWrite = 'write'; + ioCurrent = 'current'; + ioParam = 'param'; + ioResult = 'result'; + ioModule = 'module'; + ioSetting = 'setting'; + ioContact = 'contact'; + ioFileVariable = 'modvariables'; + ioArgVariable = 'argvariables'; + ioVariables = 'variables'; + ioType = 'type'; + ioByte = 'byte'; + ioWord = 'word'; + ioDword = 'dword'; + ioAnsi = 'ansi'; + ioLast = 'last'; + ioSaveValue = 'savevalue'; + +const + ACF_DBWRITE = $00000001; // write to (not read from) DB + ACF_DBDELETE = $00000002; // delete setting + ACF_DBBYTE = $00000004; // read/write byte (def. dword) + ACF_DBWORD = $00000008; // read/write word (def. dword) + ACF_DBUTEXT = $00000010; // read/write Unicode string + ACF_DBANSI = $00000020; // read/write ANSI string + ACF_PARAM = $00000040; // hContact from parameter + ACF_CURRENT = $00000080; // hContact is 0 (user settings) + ACF_RESULT = $00000100; // hContact is last result value + ACF_LAST = $00000200; // use last result for DB writing + ACF_SAVE = $00000400; // save writing value to Last Result + // dummy + ACF_DBDWORD = 0; + ACF_DBREAD = 0; + ACF_MANUAL = 0; + + ACF_NOCONTACT = ACF_PARAM or ACF_CURRENT or ACF_RESULT; + ACF_VALUETYPE = ACF_DBBYTE or ACF_DBWORD or ACF_DBUTEXT or ACF_DBANSI; + ACF_TEXT = ACF_DBUTEXT or ACF_DBANSI; + ACF_OPERATION = ACF_DBWRITE or ACF_DBDELETE; + + ACF_RW_MODULE = $00001000; // script for module name + ACF_RW_SETTING = $00002000; // script for setting name + ACF_RW_VALUE = $00004000; // script for data value + +const // V2 + ACF_OLD_DBWRITE = $00000001; + ACF_OLD_DBBYTE = $00000002; + ACF_OLD_DBWORD = $00000004; + ACF_OLD_PARAM = $00000008; + ACF_OLD_CURRENT = $00000010; + ACF_OLD_RESULT = $00000020; + ACF_OLD_LAST = $00000040; + ACF_OLD_DBUTEXT = $00000080; + ACF_OLD_DBANSI = $00000082; + ACF_OLD_DBDELETE = $00000100; + ACF_OLD_NOCNTCT = ACF_OLD_PARAM or ACF_OLD_CURRENT or ACF_OLD_RESULT; + + ACF2_RW_MVAR = $00000001; + ACF2_RW_SVAR = $00000002; + ACF2_RW_TVAR = $00000004; + +type + tDataBaseAction = class(tBaseAction) + private + dbcontact:TMCONTACT; + dbmodule :PWideChar; + dbsetting:PWideChar; + dbvalue :PWideChar; // keep all in unicode (str to int translation fast) + public + constructor Create(uid:dword); + destructor Destroy; override; +// function Clone:tBaseAction; override; + function DoAction(var WorkData:tWorkData):LRESULT; override; + procedure Save(node:pointer;fmt:integer); override; + procedure Load(node:pointer;fmt:integer); override; + end; + +//----- Support functions ----- + +//----- Object realization ----- + +constructor tDataBaseACtion.Create(uid:dword); +begin + inherited Create(uid); + + dbcontact:=0; + dbmodule :=nil; + dbsetting:=nil; + dbvalue :=nil; +end; + +destructor tDataBaseAction.Destroy; +begin + mFreeMem(dbmodule); + mFreeMem(dbsetting); + mFreeMem(dbvalue); + + inherited Destroy; +end; +{ +function tDataBaseAction.Clone:tBaseAction; +var + tmp:tDataBaseAction; +begin + result:=tDataBaseAction.Create(0); + Duplicate(result); + + tmp.dbcontact:=dbcontact; + StrDupW(tmp.dbmodule ,dbmodule); + StrDupW(tmp.dbsetting,dbsetting); + + if ((flags and ACF_DBDELETE)=0) and + ((flags and ACF_LAST)=0) then + StrDupW(tmp.dbvalue,dbvalue); + + result:=tmp; +end; +} +function tDataBaseAction.DoAction(var WorkData:tWorkData):LRESULT; +var + sbuf:array [0..31] of WideChar; + bufw:array [0..255] of WideChar; + ambuf,asbuf:array [0..127] of AnsiChar; + ls,tmp:pWideChar; + tmpa,tmpa1:pAnsiChar; + hContact:TMCONTACT; + proto:pAnsiChar; + avalue:uint_ptr; +begin + result:=0; + + if dbmodule=nil then + exit; + if (dbsetting=nil) and ((flags and ACF_DBDELETE)=0) then + exit; + // contact + case (flags and ACF_NOCONTACT) of + ACF_CURRENT: hContact:=0; + ACF_PARAM : hContact:=WorkData.Parameter; + ACF_RESULT : hContact:=WorkData.LastResult; + else + hContact:=dbcontact; + end; + + //--- + // last result for scripts + if WorkData.ResultType=rtWide then + ls:=pWideChar(WorkData.LastResult) + else + begin + ls:=@sbuf; + IntToStr(sbuf,WorkData.LastResult); + end; + + proto:=GetContactProtoAcc(hContact); + // now need to process module + if (flags and ACF_RW_MODULE)<>0 then + begin + tmp:=ParseVarString(dbmodule,hContact,ls); + StrCopyW(bufw,tmp); + mFreeMem(tmp); + end + else + StrCopyW(bufw,dbmodule); + StrReplaceW(@bufw,'',ls); + FastWideToAnsiBuf(bufw,ambuf,SizeOf(ambuf)-1); + StrReplace(ambuf,protostr,proto); + + // now process settings + if dbsetting<>nil then + begin + if (flags and ACF_RW_SETTING)<>0 then + begin + tmp:=ParseVarString(dbsetting,hContact,ls); + StrCopyW(bufw,tmp); + mFreeMem(tmp); + end + else + StrCopyW(bufw,dbsetting); + StrReplaceW(@bufw,'',ls); + FastWideToAnsiBuf(bufw,asbuf,SizeOf(asbuf)-1); + StrReplace(asbuf,protostr,proto); + end + else + asbuf[0]:=#0; + + // Delete data + if (flags and ACF_DBDELETE)<>0 then + begin + if (asbuf[0]='*') or (asbuf[StrLen(asbuf)-1]='*') then + DBDeleteGroup(hContact,ambuf,asbuf) + else if asbuf[0]=#0 then + DBDeleteModule(hContact,ambuf) + else + DBDeleteSetting(hContact,ambuf,asbuf); + end + else + begin + if (flags and ACF_LAST)<>0 then + begin + avalue:=WorkData.LastResult; + if WorkData.ResultType=rtInt then // have number + begin + if (flags and ACF_DBUTEXT)=ACF_DBUTEXT then // need wide text + avalue:=uint_ptr(IntToStr(sbuf,avalue)) + else if (flags and ACF_DBANSI)=ACF_DBANSI then // need ansi text + avalue:=uint_ptr(IntToStr(pAnsiChar(@sbuf),avalue)); + end + // got wide text + else if (flags and ACF_TEXT)=0 then // need number + avalue:=NumToInt(pWideChar(avalue)); +{ + val=LR(wide) (wide,ansi) + val=pointer to static buffer (wide, ansi) + val=number(number) +} + end + else + begin + if (flags and ACF_RW_VALUE)<>0 then + begin + avalue:=uint_ptr(ParseVarString(dbvalue,hContact,ls)); + end + else + avalue:=uint_ptr(dbvalue); + + if (flags and ACF_TEXT)=0 then // need a number + begin + tmp:=pWideChar(avalue); + avalue:=NumToInt(pWideChar(avalue)); + if (flags and ACF_RW_VALUE)<>0 then + mFreeMem(tmp); + end; +{ + val=uint_ptr if need number(number) + val=script result wide(need to free) (wide,ansi) + val=original dbvalue wide (wide,ansi) +} + end; + // Write value + if (flags and ACF_DBWRITE)<>0 then + begin + case (flags and ACF_VALUETYPE) of + ACF_DBBYTE: DBWriteByte(hContact,ambuf,asbuf,avalue); + ACF_DBWORD: DBWriteWord(hContact,ambuf,asbuf,avalue); + ACF_DBANSI: begin + WideToAnsi(pWideChar(avalue),tmpa,MirandaCP); + DBWriteString(hContact,ambuf,asbuf,tmpa); + mFreeMem(tmpa); + end; + ACF_DBUTEXT: begin + DBWriteUnicode(hContact,ambuf,asbuf,pWideChar(avalue)); + end; + else + DBWriteDWord(hContact,ambuf,asbuf,avalue); + end; + + if (flags and ACF_SAVE)<>0 then + begin + ClearResult(WorkData); + case (flags and ACF_VALUETYPE) of + ACF_DBANSI, + ACF_DBUTEXT: begin + StrDupW(pWideChar(WorkData.LastResult),pWideChar(avalue)); + WorkData.ResultType:=rtWide; + end; + else + WorkData.LastResult:=avalue; + WorkData.ResultType:=rtInt; + end; + end; + end + // Read value + else + begin + ClearResult(WorkData); + WorkData.ResultType:=rtInt; + case (flags and ACF_VALUETYPE) of + ACF_DBBYTE: WorkData.LastResult:=DBReadByte(hContact,ambuf,asbuf,avalue); + ACF_DBWORD: WorkData.LastResult:=DBReadWord(hContact,ambuf,asbuf,avalue); + ACF_DBANSI: begin + WideToAnsi(pWideChar(avalue),tmpa1,MirandaCP); + tmpa:=DBReadString(hContact,ambuf,asbuf,tmpa1); + AnsiToWide(tmpa,PWideChar(WorkData.LastResult),MirandaCP); + WorkData.ResultType:=rtWide; + mFreeMem(tmpa1); + mFreeMem(tmpa); + end; + ACF_DBUTEXT: begin + WorkData.LastResult:=uint_ptr(DBReadUnicode(hContact,ambuf,asbuf,pWideChar(avalue))); + WorkData.ResultType:=rtWide; + end + else + WorkData.LastResult:=DBReadDWord(hContact,ambuf,asbuf,avalue); + end; + end; + + if (flags and ACF_RW_VALUE)<>0 then + begin + if (flags and ACF_TEXT)<>0 then + begin + mFreeMem(avalue); + end; + end; + end; +end; + +procedure tDataBaseAction.Load(node:pointer;fmt:integer); +var + section: array [0..127] of AnsiChar; + buf:array [0..31] of WideChar; + pc:pAnsiChar; + tmp:pWideChar; + lflags,flags2:dword; +begin + inherited Load(node,fmt); + case fmt of + 0: begin + if (flags and ACF_NOCONTACT)=0 then + dbcontact:=LoadContact(DBBranch,node); + pc:=StrCopyE(section,pAnsiChar(node)); + StrCopy(pc,opt_module ); dbmodule :=DBReadUnicode(0,DBBranch,section); + StrCopy(pc,opt_setting); dbsetting:=DBReadUnicode(0,DBBranch,section); + if (flags and (ACF_DBDELETE or ACF_LAST))=0 then + begin + StrCopy(pc,opt_value); dbvalue:=DBReadUnicode(0,DBBranch,section); + end; + end; + + 100: begin + if (flags and ACF_OLD_NOCNTCT)=0 then + dbcontact:=LoadContact(DBBranch,node); + pc:=StrCopyE(section,pAnsiChar(node)); + + // auto convert ansi to unicode + StrCopy(pc,opt_module ); dbmodule :=DBReadUnicode(0,DBBranch,section); + StrCopy(pc,opt_setting); dbsetting:=DBReadUnicode(0,DBBranch,section); + + StrCopy(pc,'flags2'); flags2:=DBReadDWord(0,DBBranch,section,0); + + if (flags and (ACF_OLD_DBDELETE or ACF_OLD_LAST))=0 then + begin + StrCopy(pc,opt_value); + if ((flags and ACF_OLD_DBUTEXT)=0) and ((flags2 and ACF2_RW_TVAR)=0) then + StrDupW(dbvalue,IntToStr(buf,DBReadDWord(0,DBBranch,section))) + else + dbvalue:=DBReadUnicode(0,DBBranch,section); + end; + + lflags:=flags; + flags:=flags and not ACF_MASK; + if (lflags and ACF_OLD_DBWRITE )<>0 then flags:=flags or ACF_DBWRITE; + if (lflags and ACF_OLD_DBDELETE)<>0 then flags:=flags or ACF_DBDELETE; + if (lflags and ACF_OLD_PARAM )<>0 then flags:=flags or ACF_PARAM; + if (lflags and ACF_OLD_CURRENT )<>0 then flags:=flags or ACF_CURRENT; + if (lflags and ACF_OLD_RESULT )<>0 then flags:=flags or ACF_RESULT; + if (lflags and ACF_OLD_LAST )<>0 then flags:=flags or ACF_LAST; + if (lflags and ACF_OLD_DBBYTE )=ACF_OLD_DBBYTE then flags:=flags or ACF_DBBYTE; + if (lflags and ACF_OLD_DBWORD )=ACF_OLD_DBWORD then flags:=flags or ACF_DBWORD; + if (lflags and ACF_OLD_DBUTEXT )=ACF_OLD_DBUTEXT then flags:=flags or ACF_DBUTEXT; + if (lflags and ACF_OLD_DBANSI )=ACF_OLD_DBANSI then flags:=(flags or ACF_DBANSI) and not (ACF_DBBYTE or ACF_DBUTEXT); + if (flags2 and ACF2_RW_MVAR)<>0 then flags:=flags or ACF_RW_MODULE; + if (flags2 and ACF2_RW_SVAR)<>0 then flags:=flags or ACF_RW_SETTING; + if (flags2 and ACF2_RW_TVAR)<>0 then flags:=flags or ACF_RW_VALUE; + + end; + + 1: begin + with xmlparser do + begin + tmp:=getAttrValue(HXML(node),ioOper); + if lstrcmpiw(tmp,ioDelete)=0 then flags:=flags or ACF_DBDELETE + else if lstrcmpiw(tmp,ioWrite )=0 then flags:=flags or ACF_DBWRITE; + // else if lstrcmpiw(tmp,ioRead)=0 then ; + tmp:=getAttrValue(HXML(node),ioContact); + if lstrcmpiw(tmp,ioCurrent)=0 then flags:=flags or ACF_CURRENT + else if lstrcmpiw(tmp,ioResult )=0 then flags:=flags or ACF_RESULT + else if lstrcmpiw(tmp,ioParam )=0 then flags:=flags or ACF_PARAM + else if lstrcmpiw(tmp,ioContact)=0 then + begin + dbcontact:=ImportContact(HXML(node)); + end; + + StrDupW(dbmodule ,getAttrValue(HXML(node),ioModule)); + StrDupW(dbsetting,getAttrValue(HXML(node),ioSetting)); + + if StrToInt(getAttrValue(HXML(node),ioFileVariable))=1 then flags:=flags or ACF_RW_MODULE; + if StrToInt(getAttrValue(HXML(node),ioArgVariable ))=1 then flags:=flags or ACF_RW_SETTING; + if StrToInt(getAttrValue(HXML(node),ioVariables ))=1 then flags:=flags or ACF_RW_VALUE; + + tmp:=getAttrValue(HXML(node),ioType); + if lstrcmpiw(tmp,ioByte )=0 then flags:=flags or ACF_DBBYTE + else if lstrcmpiw(tmp,ioWord )=0 then flags:=flags or ACF_DBWORD + else if lstrcmpiw(tmp,ioDword)=0 then + else if lstrcmpiw(tmp,ioAnsi )=0 then flags:=flags or ACF_DBANSI + else flags:=flags or ACF_DBUTEXT; + + if StrToInt(getAttrValue(HXML(node),ioSaveValue))=1 then + flags:=flags or ACF_SAVE; + + if StrToInt(getAttrValue(HXML(node),ioLast))=1 then + flags:=flags or ACF_LAST + else + StrDupW(dbvalue,getText(HXML(node))); + end; + end; +{ + 2: begin + pc:=GetParamSectionStr(node,ioOper); + if lstrcmpi(pc,ioDelete)=0 then flags:=flags or ACF_DBDELETE + else if lstrcmpi(pc,ioWrite )=0 then flags:=flags or ACF_DBWRITE; +// else if lstrcmpiw(tmp,ioRead)=0 then ; + pc:=GetParamSectionStr(node,ioContact); + if lstrcmpi(pc,ioCurrent)=0 then flags:=flags or ACF_CURRENT + else if lstrcmpi(pc,ioResult )=0 then flags:=flags or ACF_RESULT + else if lstrcmpi(pc,ioParam )=0 then flags:=flags or ACF_PARAM + else if lstrcmpi(pc,ioContact)=0 then + begin + dbcontact:=ImportContactINI(node); + end; + + UF8ToWide(GetParamSectionStr(node,ioModule ),dbmodule); + UF8ToWide(GetParamSectionStr(node,ioSetting),dbsetting); + + if GetParamSectionInt(node,ioFileVariable)=1 then flags:=flags or ACF_RW_MODULE; + if GetParamSectionInt(node,ioArgVariable )=1 then flags:=flags or ACF_RW_SETTING; + if GetParamSectionInt(node,ioVariables )=1 then flags:=flags or ACF_RW_VALUE; + + pc:=GetParamSectionStr(node,ioType); + if lstrcmpi(pc,ioByte )=0 then flags:=flags or ACF_DBBYTE + else if lstrcmpi(pc,ioWord )=0 then flags:=flags or ACF_DBWORD + else if lstrcmpi(pc,ioDword)=0 then + else if lstrcmpi(pc,ioAnsi )=0 then flags:=flags or ACF_DBANSI + else flags:=flags or ACF_DBUTEXT; + + if GetParamSectionInt(node,ioLast))=1 then + flags:=flags or ACF_LAST + else + UF8ToWide(GetParamSectionStr(node,'value'),dbvalue); //!! + end; +} + end; +end; + +procedure tDataBaseAction.Save(node:pointer;fmt:integer); +var + section: array [0..127] of AnsiChar; + pc:pAnsiChar; +begin + inherited Save(node,fmt); + case fmt of + 0: begin + if (flags and ACF_NOCONTACT)=0 then + SaveContact(dbcontact,DBBranch,node); + pc:=StrCopyE(section,pAnsiChar(node)); + StrCopy(pc,opt_module ); DBWriteUnicode(0,DBBranch,section,dbmodule); + StrCopy(pc,opt_setting); DBWriteUnicode(0,DBBranch,section,dbsetting); + if ((flags and ACF_DBDELETE)=0) and + ((flags and ACF_LAST)=0) then + begin + StrCopy(pc,opt_value); DBWriteUnicode(0,DBBranch,section,dbvalue); + end; + end; +{ + 1: begin + end; +} + 13: begin + end; + end; +end; + +//----- Dialog realization ----- + +procedure MakeContactTypeList(wnd:HWND); +begin + SendMessage(wnd,CB_RESETCONTENT,0,0); + InsertString(wnd,0,'Own settings'); + InsertString(wnd,1,'Parameter'); + InsertString(wnd,2,'Last result'); + InsertString(wnd,3,'Manual'); + SendMessage(wnd,CB_SETCURSEL,0,0); +end; + +procedure MakeDataTypeList(wnd:HWND); +begin + SendMessage(wnd,CB_RESETCONTENT,0,0); + InsertString(wnd,0,'Byte'); + InsertString(wnd,1,'Word'); + InsertString(wnd,2,'DWord'); + InsertString(wnd,3,'Ansi'); + InsertString(wnd,4,'Unicode'); + SendMessage(wnd,CB_SETCURSEL,0,0); +end; + +procedure ClearFields(Dialog:HWND); +begin + CheckDlgButton(Dialog,IDC_RW_LAST,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_RW_SAVE,BST_UNCHECKED); + + CheckDlgButton(Dialog,IDC_RW_READ ,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_RW_WRITE ,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_RW_DELETE,BST_UNCHECKED); +end; + +function DlgProc(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; +const + NoProcess:boolean=true; +var + wnd:HWND; + i:integer; + bb:boolean; +begin + result:=0; + + case hMessage of + + WM_INITDIALOG: begin + TranslateDialogDefault(Dialog); + + MakeContactTypeList(GetDlgItem(Dialog,IDC_CONTACTTYPE)); + MakeDataTypeList (GetDlgItem(Dialog,IDC_RW_DATATYPE)); + + wnd:=GetDlgItem(Dialog,IDC_CNT_REFRESH); + OptSetButtonIcon(wnd,ACI_REFRESH); + SendMessage(wnd,BUTTONADDTOOLTIP,TWPARAM(TranslateW('Refresh')),BATF_UNICODE); + OptFillContactList(GetDlgItem(Dialog,IDC_CONTACTLIST)); + + MakeEditField(Dialog,IDC_RW_MODULE); + MakeEditField(Dialog,IDC_RW_SETTING); + MakeEditField(Dialog,IDC_RW_VALUE); + end; + + WM_ACT_SETVALUE: begin + NoProcess:=true; + ClearFields(Dialog); + + with tDataBaseAction(lParam) do + begin + // operation + if (flags and ACF_DBDELETE)<>0 then i:=IDC_RW_DELETE + else if (flags and ACF_DBWRITE )= 0 then i:=IDC_RW_READ + else i:=IDC_RW_WRITE; + CheckDlgButton(Dialog,i,BST_CHECKED); + + // contact + bb:=false; + wnd:=GetDlgItem(Dialog,IDC_CONTACTLIST); + case (flags and ACF_NOCONTACT) of + ACF_CURRENT: i:=0; + ACF_PARAM : i:=1; + ACF_RESULT : i:=2; + else + i:=3; + bb:=true; + SendMessage(wnd,CB_SETCURSEL,FindContact(wnd,dbcontact),0); + end; + CB_SelectData(GetDlgItem(Dialog,IDC_CONTACTTYPE),i); + EnableWindow(wnd,bb); + + SetDlgItemTextW(Dialog,IDC_RW_MODULE ,dbmodule); + SetDlgItemTextW(Dialog,IDC_RW_SETTING,dbsetting); + SetEditFlags(Dialog,IDC_RW_MODULE ,EF_SCRIPT,ord((flags and ACF_RW_MODULE )<>0)); + SetEditFlags(Dialog,IDC_RW_SETTING,EF_SCRIPT,ord((flags and ACF_RW_SETTING)<>0)); + + // values + bb:=true; + if (flags and ACF_LAST)<>0 then + begin + CheckDlgButton(Dialog,IDC_RW_LAST,BST_CHECKED); + bb:=false; + end; + if (flags and ACF_DBDELETE)<>0 then + bb:=false; + EnableWindow(GetDlgItem(Dialog,IDC_RW_VALUE),bb); + + if (flags and ACF_SAVE)<>0 then + CheckDlgButton(Dialog,IDC_RW_SAVE,BST_CHECKED); + EnableWindow(GetDlgItem(Dialog,IDC_RW_SAVE),(flags and ACF_DBWRITE)<>0); + + case (flags and ACF_VALUETYPE) of + ACF_DBBYTE : i:=0; + ACF_DBWORD : i:=1; + ACF_DBANSI : i:=3; + ACF_DBUTEXT: i:=4; + else + i:=2; + end; + CB_SelectData(GetDlgItem(Dialog,IDC_RW_DATATYPE),i); + + SetDlgItemTextW(Dialog,IDC_RW_VALUE,dbvalue); + SetEditFlags(Dialog,IDC_RW_VALUE,EF_SCRIPT,ord((flags and ACF_RW_VALUE)<>0)); + end; + NoProcess:=false; + end; + + WM_ACT_RESET: begin + NoProcess:=true; + ClearFields(Dialog); + + CB_SelectData(GetDlgItem(Dialog,IDC_CONTACTTYPE),0); + + SetDlgItemTextW(Dialog,IDC_RW_MODULE ,nil); + SetDlgItemTextW(Dialog,IDC_RW_SETTING,nil); + SetDlgItemTextW(Dialog,IDC_RW_VALUE ,nil); + SetEditFlags(Dialog,IDC_RW_MODULE ,EF_ALL,0); + SetEditFlags(Dialog,IDC_RW_SETTING,EF_ALL,0); + SetEditFlags(Dialog,IDC_RW_VALUE ,EF_ALL,0); + + CB_SelectData(GetDlgItem(Dialog,IDC_RW_DATATYPE),0); + CheckDlgButton(Dialog,IDC_RW_READ ,BST_CHECKED); + CheckDlgButton(Dialog,IDC_RW_SAVE ,BST_CHECKED); + + EnableWindow(GetDlgItem(Dialog,IDC_CONTACTLIST),true); + EnableWindow(GetDlgItem(Dialog,IDC_RW_VALUE),true); + NoProcess:=false; + end; + + WM_ACT_SAVE: begin + with tDataBaseAction(lParam) do + begin + // contact + i:=CB_GetData(GetDlgItem(Dialog,IDC_CONTACTTYPE)); + case i of + 0: flags:=flags or ACF_CURRENT; + 1: flags:=flags or ACF_PARAM; + 2: flags:=flags or ACF_RESULT; + 3: begin + wnd:=GetDlgItem(Dialog,IDC_CONTACTLIST); + dbcontact:=SendMessage(wnd,CB_GETITEMDATA,SendMessage(wnd,CB_GETCURSEL,0,0),0); + end; + end; + + {mFreeMem(dbmodule ); }dbmodule :=GetDlgText(Dialog,IDC_RW_MODULE); + {mFreeMem(dbsetting); }dbsetting:=GetDlgText(Dialog,IDC_RW_SETTING); + if (GetEditFlags(Dialog,IDC_RW_MODULE ) and EF_SCRIPT)<>0 then flags:=flags or ACF_RW_MODULE; + if (GetEditFlags(Dialog,IDC_RW_SETTING) and EF_SCRIPT)<>0 then flags:=flags or ACF_RW_SETTING; + + // operation + if IsDlgButtonChecked(Dialog,IDC_RW_WRITE )=BST_CHECKED then flags:=flags or ACF_DBWRITE + else if IsDlgButtonChecked(Dialog,IDC_RW_DELETE)=BST_CHECKED then flags:=flags or ACF_DBDELETE; + + // value + if IsDlgButtonChecked(Dialog,IDC_RW_LAST)<>BST_UNCHECKED then + flags:=flags or ACF_LAST + else if (flags and ACF_DBDELETE)=0 then + begin + {mFreeMem(dbvalue); }dbvalue:=GetDlgText(Dialog,IDC_RW_VALUE); + if (GetEditFlags(Dialog,IDC_RW_VALUE) and EF_SCRIPT)<>0 then flags:=flags or ACF_RW_VALUE; + end; + + if IsDlgButtonChecked(Dialog,IDC_RW_SAVE)<>BST_UNCHECKED then + flags:=flags or ACF_SAVE; + + i:=CB_GetData(GetDlgItem(Dialog,IDC_RW_DATATYPE)); + case i of + 0: flags:=flags or ACF_DBBYTE; + 1: flags:=flags or ACF_DBWORD; + 2: flags:=flags or 0; + 3: flags:=flags or ACF_DBANSI; + 4: flags:=flags or ACF_DBUTEXT; + end; + end; + end; + + WM_COMMAND: begin + case wParam shr 16 of + CBN_SELCHANGE: begin + if loword(wParam)=IDC_CONTACTTYPE then + begin + i:=CB_GetData(lParam); + case i of + 0,1,2: bb:=false; + else // 3 + bb:=true; + end; + EnableWindow(GetDlgItem(Dialog,IDC_CONTACTLIST),bb); + end; + if not NoProcess then + SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0); + end; + + EN_CHANGE: if not NoProcess then + SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0); + + BN_CLICKED: begin + case loword(wParam) of + IDC_RW_READ, + IDC_RW_WRITE, + IDC_RW_DELETE: begin + bb:=IsDlgButtonChecked(Dialog,IDC_RW_DELETE)=BST_UNCHECKED; + EnableWindow(GetDlgItem(Dialog,IDC_RW_DATATYPE),bb); + EnableWindow(GetDlgItem(Dialog,IDC_RW_LAST),bb); + if bb then + bb:=IsDlgButtonChecked(Dialog,IDC_RW_LAST)=BST_UNCHECKED; + EnableEditField(GetDlgItem(Dialog,IDC_RW_VALUE),bb); + + bb:=loword(wParam)=IDC_RW_WRITE; + EnableWindow(GetDlgItem(Dialog,IDC_RW_SAVE),bb); + end; + + IDC_RW_LAST: begin + EnableEditField(GetDlgItem(Dialog,IDC_RW_VALUE), + IsDlgButtonChecked(Dialog,IDC_RW_LAST)=BST_UNCHECKED); + end; + + IDC_CNT_REFRESH: begin + OptFillContactList(GetDlgItem(Dialog,IDC_CONTACTLIST)); + exit; + end; + end; + SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0); + end; + + end; + end; + + WM_HELP: begin + result:=1; + end; + + end; +end; + +//----- Export/interface functions ----- + +var + vc:tActModule; + +function CreateAction:tBaseAction; +begin + result:=tDataBaseAction.Create(vc.Hash); +end; + +function CreateDialog(parent:HWND):HWND; +begin + result:=CreateDialogW(hInstance,'IDD_ACTDATABASE',parent,@DlgProc); +end; + +procedure Init; +begin + vc.Next :=ModuleLink; + + vc.Name :='Database'; + vc.Dialog :=@CreateDialog; + vc.Create :=@CreateAction; + vc.Icon :='IDI_DATABASE'; + vc.Hash :=0; + + ModuleLink :=@vc; +end; + +begin + Init; +end. diff --git a/plugins/Actman/iac_global.pas b/plugins/Actman/iac_global.pas new file mode 100644 index 0000000000..03425c6027 --- /dev/null +++ b/plugins/Actman/iac_global.pas @@ -0,0 +1,571 @@ +unit iac_global; + +interface + +uses + windows, messages, + m_api; + +var + xmlparser:TXML_API_W; + +const + IcoLibPrefix = 'action_type_'; +const + NoDescription:PWideChar='No description'; +const + protostr = ''; +const + WM_ACT_SETVALUE = WM_USER + 13; + WM_ACT_RESET = WM_USER + 14; + WM_ACT_SAVE = WM_USER + 15; + WM_ACT_LISTCHANGE = WM_USER + 16; // group, action + +// Action flags +const + ACF_DISABLED = $10000000; // action disabled + // options editor only + ACF_REPLACED = $20000000; // action replaced by new in options + ACF_INTRODUCED = $40000000; // action is newly created (not saved) in options +const + ACF_MASK = $00FFFFFF; // mask for private action flags + +type + tLRType = record + value:uint_ptr; + rtype:byte; // rt* const + end; +type + pWorkData = ^tWorkData; + tWorkData = record + Parameter :LPARAM; + ActionList :pointer; + LastResult :uint_ptr; + ActionCount:integer; + ResultType :integer; // rt* const + Storage :array [0..9] of tLRType; + end; + +type + pBaseAction = ^tBaseAction; + tBaseAction = class + ActionDescr:pWideChar; // description (user name) + UID :dword; // hash of action type name + flags :dword; + + procedure Duplicate(var dst:tBaseAction); + + constructor Create(uid:dword); + destructor Destroy; override; +// function Clone:tBaseAction; virtual; + function DoAction(var WorkData:tWorkData):LRESULT; virtual; // process action + procedure Load(node:pointer;fmt:integer); virtual; // load/import action + procedure Save(node:pointer;fmt:integer); virtual; // save/export action + end; + +type + tCreateActionFunc = function:tBaseAction; + tCreateDialogFunc = function(parent:HWND):HWND; +// tCheckImportFunc = function(node:pointer;fmt:integer):boolean; + +type + pActModule = ^tActModule; + tActModule = record + Next :pActModule; + Name :pAnsiChar; // action type name + Dialog :tCreateDialogFunc; // action dialog creating + Create :tCreateActionFunc; // action object creation +// CheckImp :tCheckImportFunc; // check for action type + Icon :pAnsiChar; // icon resource name + // runtime data + DlgHandle:HWND; + Hash :dword; // will be calculated at registration cycle + end; + +const + ModuleLink:pActModule=nil; + +function ClearResult(var WorkData:tWorkData;num:integer=-1):uint_ptr; +function GetResultNumber(var WorkData:tWorkData;num:integer=-1):uint_ptr; + +procedure InsertString(wnd:HWND;num:dword;str:PAnsiChar); + +function GetLinkName(hash:dword):PAnsiChar; +function GetLink(hash:dword):pActModule; +function GetLinkByName(name:pAnsiChar):pActModule; + +function ImportContact (node:HXML ):TMCONTACT; +function ImportContactINI(node:pointer):TMCONTACT; + + +implementation + +uses Common, global, dbsettings, inouttext, + mirutils, mircontacts; + + +//----- tBaseAction code ----- +const + ioDisabled = 'disabled'; + ioName = 'name'; +const + opt_uid = 'uid'; + opt_descr = 'descr'; + opt_flags = 'flags'; + +constructor tBaseAction.Create(uid:dword); +begin + inherited Create; + + if uid<>0 then + begin + StrDupW(ActionDescr,NoDescription); + Self.UID:=uid; + flags:=0; + end; +end; + +destructor tBaseAction.Destroy; +begin + mFreeMem(ActionDescr); + + inherited Destroy; +end; + +procedure tBaseAction.Duplicate(var dst:tBaseAction); +begin + StrDupW(dst.ActionDescr,ActionDescr); + dst.UID :=UID; + dst.flags:=flags; +end; +{ +function tBaseAction.Clone:tBaseAction; +begin + //dummy + result:=nil; +end; +} +function tBaseAction.DoAction(var WorkData:tWorkData):LRESULT; +begin + result:=0; + // nothing +end; + +procedure tBaseAction.Load(node:pointer;fmt:integer); +var + section: array [0..127] of AnsiChar; + pc:pAnsiChar; +begin + case fmt of + 100..199, // for V2 + 0: begin + pc:=StrCopyE(section,pAnsiChar(node)); + mFreeMem(ActionDescr); // created by constructor + StrCopy(pc,opt_descr); ActionDescr:=DBReadUnicode(0,DBBranch,section,NoDescription); + StrCopy(pc,opt_flags); flags :=DBReadDword (0,DBBranch,section); + // UID reading in main program, set by constructor + end; + + 1: begin + with xmlparser do + begin + if StrToInt(getAttrValue(HXML(node),ioDisabled))=1 then + flags:=flags or ACF_DISABLED; + + StrDupW(ActionDescr,getAttrValue(HXML(node),ioName)); + end; + end; +{ + 2: begin + if GetParamSectionInt(node,ioDisabled))=1 then + flags:=flags or ACF_DISABLED; + + UF8ToWide(GetParamSectionStr(node,ioName),ActionDescr); + end; +} + end; +end; + +procedure tBaseAction.Save(node:pointer;fmt:integer); +var + section: array [0..127] of AnsiChar; + pc:PAnsiChar; +begin + case fmt of + 0: begin + pc:=StrCopyE(section,pAnsiChar(node)); + StrCopy(pc,opt_uid ); DBWriteDWord (0,DBBranch,section,UID); + StrCopy(pc,opt_flags); DBWriteDWord (0,DBBranch,section,flags); + StrCopy(pc,opt_descr); DBWriteUnicode(0,DBBranch,section,ActionDescr); + end; +{ + 1: begin + end; +} + 13: begin + tTextExport(node).AddText ('type' ,GetLinkName(UID)); + tTextExport(node).AddTextW('name' ,ActionDescr); + tTextExport(node).AddFlag ('disabled',(flags and ACF_DISABLED)<>0); + tTextExport(node).AddNewLine(); + tTextExport(node).ShiftRight(); + end; + end; +end; + +//----- LastResult processing ----- + +function ClearResult(var WorkData:tWorkData;num:integer=-1):uint_ptr; +var + rt:pbyte; + lr:^uint_ptr; +begin + result:=0; + + if num<0 then + begin + rt:=@WorkData.ResultType; + lr:=@WorkData.LastResult; + end + else if num<10 then + begin + rt:=@WorkData.Storage[num].rtype; + lr:=@WorkData.Storage[num].value; + end + else + exit; + + if rt^=rtInt then + result:=lr^ + else if rt^<>rtUnkn then + begin + mFreeMem(pWideChar(lr^)); + result:=0; + end; +end; + +function GetResultNumber(var WorkData:tWorkData;num:integer=-1):uint_ptr; +var + rt:pbyte; + lr:^uint_ptr; +begin + result:=0; + + if num<0 then + begin + rt:=@WorkData.ResultType; + lr:=@WorkData.LastResult; + end + else if num<10 then + begin + rt:=@WorkData.Storage[num].rtype; + lr:=@WorkData.Storage[num].value; + end + else + exit; + + if rt^=rtInt then + result:=lr^ + else if rt^<>rtUnkn then + begin + result:=NumToInt(pWideChar(lr^)); +{ + if (pWideChar(WorkData.LastResult)[0]='$') and + (AnsiChar(pWideChar(WorkData.LastResult)[1]) in sHexNum) then + result:=HexToInt(pWideChar(WorkData.LastResult)+1) + else + if (pWideChar(WorkData.LastResult)[0]='0') and + (pWideChar(WorkData.LastResult)[1]='x') and + (AnsiChar(pWideChar(WorkData.LastResult)[2]) in sHexNum) then + result:=HexToInt(pWideChar(WorkData.LastResult)+2) + else + result:=StrToInt(pWideChar(WorkData.LastResult)); +} + end; +end; + +procedure InsertString(wnd:HWND;num:dword;str:PAnsiChar); +var + buf:array [0..127] of WideChar; +begin + SendMessageW(wnd,CB_SETITEMDATA, + SendMessageW(wnd,CB_ADDSTRING,0, + lparam(TranslateW(FastAnsiToWideBuf(str,buf)))), + num); +{ + SendMessageW(wnd,CB_INSERTSTRING,num, + dword(TranslateW(FastAnsiToWideBuf(str,buf)))); +} +end; + +function GetLinkName(hash:dword):PAnsiChar; +var + link:pActModule; +begin + link:=ModuleLink; + while (link<>nil) and (link.Hash<>hash) do + link:=link^.Next; + if link<>nil then + result:=link^.Name + else + result:=nil; +end; + +function GetLink(hash:dword):pActModule; +begin + result:=ModuleLink; + while (result<>nil) and (result.Hash<>hash) do + result:=result^.Next; +end; + +function GetLinkByName(name:pAnsiChar):pActModule; +begin + result:=ModuleLink; + while (result<>nil) and (StrCmp(result.Name,name)<>0) do + result:=result^.Next; +end; + +const + ioCProto = 'cproto'; + ioIsChat = 'ischat'; + ioCUID = 'cuid'; + ioCUIDType = 'cuidtype'; + +function ImportContact(node:HXML):TMCONTACT; +var + proto:pAnsiChar; + tmpbuf:array [0..63] of AnsiChar; + dbv:TDBVARIANT; + tmp:pWideChar; + is_chat:boolean; + bufLen:int; +begin + with xmlparser do + begin + proto:=FastWideToAnsiBuf(getAttrValue(node,ioCProto),tmpbuf); + if (proto=nil) or (proto^=#0) then + begin + result:=0; + exit; + end; + is_chat:=StrToInt(getAttrValue(node,ioIsChat))<>0; + + tmp:=getAttrValue(node,ioCUID); + if is_chat then + begin + dbv.szVal.W:=tmp; + end + else + begin + FillChar(dbv,SizeOf(TDBVARIANT),0); + dbv._type:=StrToInt(getAttrValue(node,ioCUIDType)); + case dbv._type of + DBVT_BYTE : dbv.bVal:=StrToInt(tmp); + DBVT_WORD : dbv.wVal:=StrToInt(tmp); + DBVT_DWORD : dbv.dVal:=StrToInt(tmp); + DBVT_ASCIIZ: FastWideToAnsi(tmp,dbv.szVal.A); + DBVT_UTF8 : WideToUTF8(tmp,dbv.szVal.A); + DBVT_WCHAR : dbv.szVal.W:=tmp; + DBVT_BLOB : begin + dbv.pbVal := mir_base64_decode(FastWideToAnsi(tmp,pAnsiChar(dbv.pbVal)),bufLen); + dbv.cpbVal := bufLen; + end; + end; + end; + end; + result:=FindContactHandle(proto,dbv,is_chat); + if not is_chat then + case dbv._type of + DBVT_ASCIIZ, + DBVT_UTF8 : mFreeMem(dbv.szVal.A); + DBVT_BLOB : mFreeMem(dbv.pbVal); + end; +end; + +function ImportContactINI(node:pointer):TMCONTACT; +{ +var + proto:pAnsiChar; + dbv:TDBVARIANT; + tmp:pAnsiChar; + is_chat:boolean; +} +begin + result:=0; +{ + proto:=GetParamSectionStr(node,ioCProto); // LATIN chars must be + if (proto=nil) or (proto^=#0) then + begin + result:=0; + exit; + end; + is_chat:=GetParamSectionInt(node,ioIsChat)<>0; + + tmp:=GetParamSectionStr(node,ioCUID); + if is_chat then + begin + dbv.szVal.W:=UTF8ToWide(tmp); + end + else + begin + FillChar(dbv,SizeOf(TDBVARIANT),0); + dbv._type:=GetParamSectionInt(node,ioCUIDType); + case dbv._type of + DBVT_BYTE : dbv.bVal:=StrToInt(tmp); + DBVT_WORD : dbv.wVal:=StrToInt(tmp); + DBVT_DWORD : dbv.dVal:=StrToInt(tmp); + DBVT_ASCIIZ: dbv.szVal.A:=tmp; // must be LATIN + DBVT_UTF8 : dbv.szVal.A:=tmp; + DBVT_WCHAR : UTF8ToWide(tmp); + DBVT_BLOB : begin // must be LATIN (base64) + Base64Decode(tmp,dbv.pbVal); + end; + end; + end; + + result:=FindContactHandle(proto,dbv,is_chat); + + if is_chat or (dbv._type=DBVT_WCHAR) then + mFreeMem(dbv.szVal.W) + else if dbv._type=DBVT_BLOB then + mFreeMem(dbv.pbVal); +} +end; +{ +function CreateImportClass(node:pointer;fmt:integer):tBaseAction; +var + module:pActModule; + uid:dword; + section:array [0..127] of AnsiChar; +begin + result:=nil; + module:=ModuleLink; + case fmt of + 0: begin + StrCopy(StrCopyE(section,pAnsiChar(node)),opt_uid); + uid:=DBReadDWord(0,DBBranch,section,0); + + while module<>nil do + begin + module:=module^.Next; + end; + end; + 1: begin + end; + 2: begin + end; + end; +end; +} + +//----- DLL Handle Cache ----- +type + tDLLCacheElement = record + DllName :PAnsiChar; + DllHandle:THANDLE; + count :word; // count for end-of-macro flag + flags :byte; // handle free mode + end; + tDLLCache = array of tDLLCacheElement; + +const + actDLLCache: tDLLCache = nil; + +function GetDllHandle(adllname:pAnsiChar;mode:dword=0):THANDLE; +var + i,zero:integer; +begin + // 1 - search that name in cache + i:=0; + zero:=-1; + while i<=HIGH(actDLLCache) do + begin + with actDLLCache[i] do + begin + // remember first empty slot + if DllHandle=0 then + begin + if zero<0 then + zero:=i; + end + else if StrCmp(DllName,adllname)=0 then + begin + result:=DllHandle; + inc(count); + if mode=3 then // per-session + flags:=3; + exit; + end; + end; + inc(i); + end; + // 2 - not found, load library + result:=LoadLibraryA(adllname); + // 3 - add to cache if not per-action + if mode<>0 then + begin + if zero>=0 then + i:=zero + else + begin + SetLength(actDLLCache,i); + dec(i); + end; + + with actDLLCache[i] do + begin + StrDup(DllName,adllname); + DllHandle:=result; + count :=0; + flags :=mode; + end; + end; +end; + +procedure CloseDllHandle(handle:THANDLE); +var + i:integer; +begin + i:=HIGH(actDLLCache); + while i>=0 do + begin + with actDLLCache[i] do + begin + if DllHandle=handle then + begin + dec(count); + if count=0 then + begin + if flags=2 then // per-macro+not needed -> free + begin + FreeLibrary(DllHandle); + DllHandle:=0; + mFreeMem(DllName); + end; + end; + exit; + end; + end; + dec(i); + end; + // if not found in cache + FreeLibrary(handle); +end; + +procedure FreeDllHandleCache; +var + i:integer; +begin + i:=HIGH(actDLLCache); + while i>=0 do + begin + if actDLLCache[i].DllHandle<>0 then + begin + FreeLibrary(actDLLCache[i].DllHandle); + mFreeMem(actDLLCache[i].DllName); + end; + dec(i); + end; + SetLength(actDLLCache,0); +end; + +end. diff --git a/plugins/Actman/iac_ini.pas b/plugins/Actman/iac_ini.pas new file mode 100644 index 0000000000..03c8d7a9d6 --- /dev/null +++ b/plugins/Actman/iac_ini.pas @@ -0,0 +1,432 @@ +unit iac_ini; + +interface + +implementation + +uses + windows,messages,commctrl, + iac_global,global, + common,m_api,wrapper, inouttext, + dbsettings,editwrapper,mirutils; + +{$include i_cnst_ini.inc} +{$resource iac_ini.res} + +const + opt_file :PAnsiChar = 'inifile'; + opt_section:PAnsiChar = 'section'; + opt_param :PAnsiChar = 'param'; + opt_value :PAnsiChar = 'value'; + +const + ACF_INI_WRITE = $00000001; + ACF_INI_DELETE = $00000002; + ACF_INI_LR = $00000004; + ACF_INI_UTF = $00000008; + ACF_INI_FILE = $00000010; + ACF_INI_SECTION = $00000020; + ACF_INI_PARAM = $00000040; + ACF_INI_VALUE = $00000080; +type + tINIAction = class(tBaseAction) + private + inifile :pWideChar; + section :pWideChar; + parameter:pWideChar; + value :pWideChar; + public + constructor Create(uid:dword); + destructor Destroy; override; +// function Clone:tBaseAction; override; + function DoAction(var WorkData:tWorkData):LRESULT; override; + procedure Save(node:pointer;fmt:integer); override; + procedure Load(node:pointer;fmt:integer); override; + end; + +//----- Support functions ----- + +//----- Object realization ----- + +constructor tINIAction.Create(uid:dword); +begin + inherited Create(uid); +end; + +destructor tINIAction.Destroy; +begin + mFreeMem(inifile); + mFreeMem(section); + mFreeMem(parameter); + mFreeMem(value); + + inherited Destroy; +end; +{ +function tINIAction.Clone:tBaseAction; +begin + result:=tServiceAction.Create(0); + Duplicate(result); + +end; +} +function tINIAction.DoAction(var WorkData:tWorkData):LRESULT; +var + linifile, + lsection, + lparam, + lvalue:pWideChar; + ainifile, + asection, + aparam, + avalue:pAnsiChar; + buf:pAnsiChar; + cond:bool; +begin + result:=0; + cond:=true; + + if (flags and ACF_INI_FILE)<>0 then + linifile:=ParseVarString(inifile,WorkData.Parameter,pWideChar(WorkData.LastResult)) + else + linifile:=inifile; + if (linifile=nil) or (linifile^=#0) then + cond:=false; + + if cond then + begin + if (flags and ACF_INI_SECTION)<>0 then + lsection:=ParseVarString(section,WorkData.Parameter,pWideChar(WorkData.LastResult)) + else + lsection:=section; + if (lsection=nil) or (lsection^=#0) then + cond:=false; + end + else + lsection:=nil; + + if cond then + begin + if (flags and ACF_INI_PARAM)<>0 then + lparam:=ParseVarString(parameter,WorkData.Parameter,pWideChar(WorkData.LastResult)) + else + lparam:=parameter; + end + else + lparam:=nil; + + if cond then + begin + if (flags and ACF_INI_DELETE)<>0 then + begin + WritePrivateProfileStringW(lsection,lparam,nil,linifile); + end + else + begin + if (lparam<>nil) and (lparam^<>#0) then + begin + if (flags and ACF_INI_LR)<>0 then + lvalue:=pWideChar(WorkData.LastResult) + else if (flags and ACF_INI_VALUE)<>0 then + lvalue:=ParseVarString(value,WorkData.Parameter,pWideChar(WorkData.LastResult)) + else + lvalue:=value; + + WideToAnsi(linifile,ainifile); + WideToAnsi(lsection,asection); + WideToAnsi(lparam ,aparam); + + if (flags and ACF_INI_WRITE)<>0 then + begin + if (flags and ACF_INI_UTF)=0 then + WideToAnsi(lvalue,avalue,MirandaCP) + else + WideToUTF8(lvalue,avalue); + + WritePrivateProfileStringA(asection,aparam,avalue,ainifile); + + mFreeMem(avalue); + end + + else // single line only (Windows-way) + begin + mGetMem(buf,4096); buf^:=#0; + GetPrivateProfileStringA(asection,aparam,avalue,buf,4096,ainifile); + ClearResult(WorkData); + + if GetTextFormat(pByte(buf),StrLen(buf))=CP_UTF8 then + UTF8ToWide(buf,pWideChar(WorkData.LastResult)) + else + AnsiToWide(buf,pWideChar(WorkData.LastResult),MirandaCP); + WorkData.ResultType:=rtWide; + mFreeMem(buf); + end; + + mFreeMem(ainifile); + mFreeMem(asection); + mFreeMem(aparam); + + if ((flags and ACF_INI_VALUE)<>0) and + ((flags and ACF_INI_LR ) =0) then mFreeMem(lvalue); + end; + end; + end; + + if (flags and ACF_INI_FILE )<>0 then mFreeMem(linifile); + if (flags and ACF_INI_SECTION)<>0 then mFreeMem(lsection); + if (flags and ACF_INI_PARAM )<>0 then mFreeMem(lparam); +end; + +procedure tINIAction.Load(node:pointer;fmt:integer); +var + lsection: array [0..127] of AnsiChar; + pc:pAnsiChar; +begin + inherited Load(node,fmt); + case fmt of + 0: begin + pc:=StrCopyE(lsection,pAnsiChar(node)); + StrCopy(pc,opt_file ); inifile :=DBReadUnicode(0,DBBranch,lsection,nil); + StrCopy(pc,opt_section); section :=DBReadUnicode(0,DBBranch,lsection,nil); + StrCopy(pc,opt_param ); parameter:=DBReadUnicode(0,DBBranch,lsection,nil); + StrCopy(pc,opt_value ); value :=DBReadUnicode(0,DBBranch,lsection,nil); + end; +{ + 1: begin + end; +} + end; +end; + +procedure tINIAction.Save(node:pointer;fmt:integer); +var + lsection: array [0..127] of AnsiChar; + pc:pAnsiChar; +begin + inherited Save(node,fmt); + case fmt of + 0: begin + pc:=StrCopyE(lsection,pAnsiChar(node)); + StrCopy(pc,opt_file ); DBWriteUnicode(0,DBBranch,lsection,inifile); + StrCopy(pc,opt_section); DBWriteUnicode(0,DBBranch,lsection,section); + StrCopy(pc,opt_param ); DBWriteUnicode(0,DBBranch,lsection,parameter); + StrCopy(pc,opt_value ); DBWriteUnicode(0,DBBranch,lsection,value); + end; +{ + 1: begin + end; +} + 13: begin + tTextExport(node).AddFlag('write' ,(flags and ACF_INI_WRITE )<>0); + tTextExport(node).AddFlag('delete' ,(flags and ACF_INI_DELETE)<>0); + tTextExport(node).AddFlag('lastresult',(flags and ACF_INI_LR )<>0); + tTextExport(node).AddFlag('utf' ,(flags and ACF_INI_UTF )<>0); + if flags and (ACF_INI_WRITE or ACF_INI_DELETE or ACF_INI_LR or ACF_INI_UTF)<>0 then + tTextExport(node).AddNewLine(); + tTextExport(node).AddTextW('inifile' ,inifile ); tTextExport(node).AddNewLine(); + tTextExport(node).AddTextW('section' ,section ); tTextExport(node).AddNewLine(); + tTextExport(node).AddTextW('parameter',parameter); tTextExport(node).AddNewLine(); + if flags and (ACF_INI_DELETE or ACF_INI_LR)=0 then + begin + tTextExport(node).AddTextW('value',value); tTextExport(node).AddNewLine(); + end; + end; + end; +end; + +//----- Dialog realization ----- + +function FillFileName(Dialog:HWND;idc:integer):boolean; +var + pw,ppw:pWideChar; +begin + mGetMem(pw,1024*SizeOf(WideChar)); + ppw:=GetDlgText(Dialog,idc); + result:=ShowDlgW(pw,ppw); + if result then + begin + SetDlgItemTextW(Dialog,idc,pw); + SetEditFlags(Dialog,idc,EF_SCRIPT,0); + end; + mFreeMem(ppw); + mFreeMem(pw); +end; + +procedure ClearFields(Dialog:HWND); +begin + CheckDlgButton(Dialog,IDC_INI_READ ,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_INI_WRITE ,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_INI_DELETE,BST_UNCHECKED); + + CheckDlgButton(Dialog,IDC_INI_LR ,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_INI_UTF,BST_UNCHECKED); + + EnableEditField(Dialog,IDC_INI_VALUE,true); +end; + +function DlgProc(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; +const + NoProcess:boolean=true; +begin + result:=0; + + case hMessage of + WM_INITDIALOG: begin + TranslateDialogDefault(Dialog); + + MakeEditField(Dialog,IDC_INI_PATH); + MakeEditField(Dialog,IDC_INI_SECTION); + MakeEditField(Dialog,IDC_INI_PARAM); + MakeEditField(Dialog,IDC_INI_VALUE); + end; + + WM_ACT_SETVALUE: begin + NoProcess:=true; + ClearFields(Dialog); + with tINIAction(lParam) do + begin + SetDlgItemTextW(Dialog,IDC_INI_PATH ,inifile); + SetDlgItemTextW(Dialog,IDC_INI_SECTION,section); + SetDlgItemTextW(Dialog,IDC_INI_PARAM ,parameter); + SetDlgItemTextW(Dialog,IDC_INI_VALUE ,value); + + SetEditFlags(Dialog,IDC_INI_PATH ,EF_SCRIPT,ord((flags and ACF_INI_FILE )<>0)); + SetEditFlags(Dialog,IDC_INI_SECTION,EF_SCRIPT,ord((flags and ACF_INI_SECTION)<>0)); + SetEditFlags(Dialog,IDC_INI_PARAM ,EF_SCRIPT,ord((flags and ACF_INI_PARAM )<>0)); + + SetEditFlags(Dialog,IDC_INI_VALUE,EF_SCRIPT,ord((flags and ACF_INI_VALUE)<>0)); + if ((flags and ACF_INI_DELETE)<>0) or + ((flags and ACF_INI_LR )<>0) then + EnableEditField(Dialog,IDC_INI_VALUE,false); + + if (flags and ACF_INI_WRITE)<>0 then + CheckDlgButton(Dialog,IDC_INI_WRITE,BST_CHECKED) + else if (flags and ACF_INI_DELETE)<>0 then + CheckDlgButton(Dialog,IDC_INI_DELETE,BST_CHECKED) + else + CheckDlgButton(Dialog,IDC_INI_READ,BST_CHECKED); + + EnableWindow(GetDlgItem(Dialog,IDC_INI_LR),(flags and ACF_INI_DELETE)=0); + if (flags and ACF_INI_LR)<>0 then + CheckDlgButton(Dialog,IDC_INI_LR,BST_CHECKED); + + EnableWindow(GetDlgItem(Dialog,IDC_INI_UTF),(flags and ACF_INI_WRITE)<>0); + if (flags and ACF_INI_UTF)<>0 then + CheckDlgButton(Dialog,IDC_INI_UTF,BST_CHECKED); + end; + NoProcess:=false; + end; + + WM_ACT_RESET: begin + NoProcess:=true; + ClearFields(Dialog); + + SetDlgItemTextW(Dialog,IDC_INI_PATH ,nil); + SetDlgItemTextW(Dialog,IDC_INI_SECTION,nil); + SetDlgItemTextW(Dialog,IDC_INI_PARAM ,nil); + SetDlgItemTextW(Dialog,IDC_INI_VALUE ,nil); + SetEditFlags(Dialog,IDC_INI_PATH ,EF_ALL,0); + SetEditFlags(Dialog,IDC_INI_SECTION,EF_ALL,0); + SetEditFlags(Dialog,IDC_INI_PARAM ,EF_ALL,0); + SetEditFlags(Dialog,IDC_INI_VALUE ,EF_ALL,0); + + EnableWindow(GetDlgItem(Dialog,IDC_INI_LR ),true); + EnableWindow(GetDlgItem(Dialog,IDC_INI_UTF),false); + + CheckDlgButton(Dialog,IDC_INI_READ,BST_CHECKED); + NoProcess:=false; + end; + + WM_ACT_SAVE: begin + with tINIAction(lParam) do + begin + if IsDlgButtonChecked(Dialog,IDC_INI_WRITE)<>BST_UNCHECKED then + flags:=flags or ACF_INI_WRITE + else if IsDlgButtonChecked(Dialog,IDC_INI_DELETE)<>BST_UNCHECKED then + flags:=flags or ACF_INI_DELETE; + + if IsDlgButtonChecked(Dialog,IDC_INI_LR )<>BST_UNCHECKED then flags:=flags or ACF_INI_LR; + if IsDlgButtonChecked(Dialog,IDC_INI_UTF)<>BST_UNCHECKED then flags:=flags or ACF_INI_UTF; + + inifile :=GetDlgText(Dialog,IDC_INI_PATH); + section :=GetDlgText(Dialog,IDC_INI_SECTION); + parameter:=GetDlgText(Dialog,IDC_INI_PARAM); + value :=GetDlgText(Dialog,IDC_INI_VALUE); + if (GetEditFlags(Dialog,IDC_INI_PATH ) and EF_SCRIPT)<>0 then flags:=flags or ACF_INI_FILE; + if (GetEditFlags(Dialog,IDC_INI_SECTION) and EF_SCRIPT)<>0 then flags:=flags or ACF_INI_SECTION; + if (GetEditFlags(Dialog,IDC_INI_PARAM ) and EF_SCRIPT)<>0 then flags:=flags or ACF_INI_PARAM; + if (GetEditFlags(Dialog,IDC_INI_VALUE ) and EF_SCRIPT)<>0 then flags:=flags or ACF_INI_VALUE; + end; + end; + + WM_COMMAND: begin + case wParam shr 16 of + EN_CHANGE: if not NoProcess then + SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0); + + BN_CLICKED: begin + case loword(wParam) of + IDC_INI_INIBTN: begin + if not FillFileName(Dialog,IDC_INI_PATH) then + exit; + end; + + IDC_INI_READ, + IDC_INI_WRITE, + IDC_INI_DELETE: begin + EnableEditField(Dialog,IDC_INI_VALUE,loword(wParam)<>IDC_INI_DELETE); + + EnableWindow(GetDlgItem(Dialog,IDC_INI_LR), + IsDlgButtonChecked(Dialog,IDC_INI_DELETE)=BST_UNCHECKED); + EnableWindow(GetDlgItem(Dialog,IDC_INI_UTF), + IsDlgButtonChecked(Dialog,IDC_INI_WRITE)<>BST_UNCHECKED); + end; + + IDC_INI_LR: begin + EnableEditField(Dialog,IDC_INI_VALUE,IsDlgButtonChecked(Dialog,IDC_INI_LR)=BST_UNCHECKED); + end; + end; + + if not NoProcess then + SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0); + end; + end; + end; + + WM_HELP: begin + result:=1; + end; + + end; +end; + +//----- Export/interface functions ----- + +var + vc:tActModule; + +function CreateAction:tBaseAction; +begin + result:=tINIAction.Create(vc.Hash); +end; + +function CreateDialog(parent:HWND):HWND; +begin + result:=CreateDialogW(hInstance,'IDD_INI',parent,@DlgProc); +end; + +procedure Init; +begin + vc.Next :=ModuleLink; + + vc.Name :='INI'; + vc.Dialog :=@CreateDialog; + vc.Create :=@CreateAction; + vc.Icon :='IDI_INI'; + + ModuleLink :=@vc; +end; + +begin + Init; +end. diff --git a/plugins/Actman/iac_ini.rc b/plugins/Actman/iac_ini.rc new file mode 100644 index 0000000000..56658b91c4 --- /dev/null +++ b/plugins/Actman/iac_ini.rc @@ -0,0 +1,27 @@ +#include "i_cnst_ini.inc" + +LANGUAGE 0,0 + +IDD_INI DIALOGEX 0, 0, 168, 200, 0 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0 +{ + AUTORADIOBUTTON "Read" , IDC_INI_READ , 4, 2, 52, 11, WS_GROUP + AUTORADIOBUTTON "Write" , IDC_INI_WRITE , 57, 2, 52, 11 + AUTORADIOBUTTON "Delete" , IDC_INI_DELETE , 110, 2, 52, 11 + LTEXT "INI file name", -1 , 4 15, 160, 11 + EDITTEXT IDC_INI_PATH , 4, 26, 140, 12, ES_AUTOHSCROLL + PUSHBUTTON "..." , IDC_INI_INIBTN , 147, 26, 16, 12 + LTEXT "Section", -1 , 4 40, 160, 11 + EDITTEXT IDC_INI_SECTION, 4, 51, 160, 12, ES_AUTOHSCROLL + LTEXT "Parameter", -1 , 4 65, 160, 11 + EDITTEXT IDC_INI_PARAM , 4, 76, 160, 12, ES_AUTOHSCROLL + + LTEXT "Value", -1 , 4 90, 160, 11 + EDITTEXT IDC_INI_VALUE , 4, 101, 160, 12, ES_AUTOHSCROLL + AUTOCHECKBOX "Use LastResult", IDC_INI_LR , 4, 113, 160, 11 + AUTOCHECKBOX "UTF8 encoding" , IDC_INI_UTF, 4, 125, 160, 11 +} + +IDI_INI ICON "ico\ini.ico" diff --git a/plugins/Actman/iac_ini.res b/plugins/Actman/iac_ini.res new file mode 100644 index 0000000000..177a309738 Binary files /dev/null and b/plugins/Actman/iac_ini.res differ diff --git a/plugins/Actman/iac_inout.pas b/plugins/Actman/iac_inout.pas new file mode 100644 index 0000000000..42e36913ff --- /dev/null +++ b/plugins/Actman/iac_inout.pas @@ -0,0 +1,699 @@ +unit iac_inout; + +interface + +implementation + +uses + windows, messages, commctrl, + iac_global, global, + mirutils, mircontacts, common, dbsettings, + wrapper, editwrapper, io, syswin, + m_api; + +{$include i_cnst_inout.inc} +{$resource iac_inout.res} + +const + opt_file = 'file'; +const + ioObject = 'object'; + ioClipboard = 'clipboard'; + ioOper = 'oper'; + ioCopy = 'copy'; + ioFile = 'file'; + ioFileVariable = 'modvariables'; + ioWrite = 'write'; + ioAppend = 'append'; + ioEnc = 'enc'; +const + ACF_CLIPBRD = $00000002; // Clipboard operations, not window + ACF_ANSI = $00000004; // File: ANSI or Unicode (UTF8/UTF16) text + ACF_COPYTO = $00000008; // Clipboard operations: 'copy to' or 'paste from' + + ACF_FILE = $00000010; // File operations + ACF_FWRITE = $00000020; // read/write file + ACF_FAPPEND = $00000040; // append file + ACF_UTF8 = $00000080; // File: UTF8 or UTF16 + ACF_SIGN = $00000100; // File: with signature or not + ACF_FILE_PATH = $00000200; + + ACF_TEXTSEND = $00000400; + // dummy + ACF_MESSAGE = 0; + +const // V2 + ACF2_TXT_FILE = $00000001; + +type + tInOutAction = class(tBaseAction) + private + tfile:pWideChar; + public + constructor Create(uid:dword); + destructor Destroy; override; +// function Clone:tBaseAction; override; + function DoAction(var WorkData:tWorkData):LRESULT; override; + procedure Save(node:pointer;fmt:integer); override; + procedure Load(node:pointer;fmt:integer); override; + end; + +//----- Support functions ----- + +//----- Object realization ----- + +constructor tInOutAction.Create(uid:dword); +begin + inherited Create(uid); + + tfile:=nil; +end; + +destructor tInOutAction.Destroy; +begin + mFreeMem(tfile); + + inherited Destroy; +end; +{ +function tInOutAction.Clone:tBaseAction; +begin + result:=.Create(0); + Duplicate(result); + +end; +} +function tInOutAction.DoAction(var WorkData:tWorkData):LRESULT; +var + tmp:PWideChar; + blob,p:PAnsiChar; + w:PWideChar; + hContact:TMCONTACT; + wnd:HWND; + fexist:bool; + dbei:TDBEVENTINFO; + i:cardinal; + cp:integer; + fh:THANDLE; + lstr:pWideChar; + llen:integer; + buf:array [0..31] of WideChar; + b,b1:array [0..MAX_PATH] of AnsiChar; + + last:pWideChar; +begin + result:=0; + + if WorkData.ResultType=rtInt then + last:=pWideChar(IntToStr(buf,WorkData.LastResult)) + else + last:=pWideChar(WorkData.LastResult); + + // Clipboard + if (flags and ACF_CLIPBRD)<>0 then + begin + if (flags and ACF_COPYTO)<>0 then + CopyToClipboard(last,false) + else + begin + ClearResult(WorkData); + WorkData.LastResult:=uint_ptr(PasteFromClipboard(false)); + WorkData.ResultType:=rtWide; + end; + exit; + end; + + // File + if (flags and ACF_FILE)<>0 then + begin + if (flags and ACF_FILE_PATH)<>0 then + begin + if CallService(MS_DB_CONTACT_IS,WorkData.Parameter,0)<>0 then + hContact:=WorkData.Parameter + else + hContact:=0; + tmp:=ParseVarString(tfile,hContact,last) + end + else + tmp:=tfile; + + // File write + if (flags and (ACF_FAPPEND or ACF_FWRITE))<>0 then + begin + if (flags and ACF_ANSI)=ACF_ANSI then cp:=1 // Ansi + else if (flags and (ACF_UTF8 or ACF_SIGN))=ACF_UTF8 then cp:=2 // UTF8 + else if (flags and (ACF_UTF8 or ACF_SIGN))=ACF_SIGN then cp:=4 // Wide+Sign + else if (flags and (ACF_UTF8 or ACF_SIGN))=(ACF_UTF8 or ACF_SIGN) then cp:=3 // UTF8+Sign + else cp:=0; // Wide + + case cp of + 1: begin + llen:=StrLen(WideToAnsi(last,pAnsiChar(lstr),MirandaCP)); + end; + 2,3: begin + llen:=StrLen(WideToUTF8(last,pAnsiChar(lstr))); + end; + else + lstr:=last; + llen:=StrLenW(lstr)*SizeOf(WideChar); + end; + + fexist:=FileExists(tmp); + // Append file + if fexist and ((flags and ACF_FAPPEND)<>0) then + begin + fh:=Append(tmp); + if fh<>THANDLE(INVALID_HANDLE_VALUE) then + begin + BlockWrite(fh,lstr^,llen); + end; + if (cp<>0) and (cp<>4) then + mFreeMem(lstr); + end + // Write file + else if ((flags and ACF_FWRITE)<>0) or + (not fexist and ((flags and ACF_FAPPEND)<>0)) then + begin + fh:=ReWrite(tmp); + if fh<>THANDLE(INVALID_HANDLE_VALUE) then + begin + if cp=3 then + begin + i:=SIGN_UTF8; + BlockWrite(fh,i,3); // UTF8 sign + end + else if cp=4 then + begin + i:=SIGN_UNICODE; + BlockWrite(fh,i,2); // UTF16 sign + end; + + BlockWrite(fh,lstr^,llen); + if (cp<>0) and (cp<>4) then + mFreeMem(lstr); + end; + end + else + fh:=THANDLE(INVALID_HANDLE_VALUE); + end + // File read + else + begin + // remove file - download + if StrPosW(tmp,'://')<>nil then // remote + begin + GetTempPathA(MAX_PATH,b); + GetTempFileNameA(b,'wat',GetCurrentTime,b1); + GetFile(FastWideToAnsiBuf(tmp,b),b1); + if tmp<>tfile then + mFreeMem(tmp); + FastAnsiToWide(b1,tmp); + end + else + b1[0]:=#0; + fh:=Reset(tmp); + // process file + if fh<>THANDLE(INVALID_HANDLE_VALUE) then + begin + i:=GetFSize(tmp); + mGetMem (w ,i+SizeOf(WideChar)); + FillChar(w^,i+SizeOf(WideChar),0); + BlockRead(fh,w^,i); + if (flags and ACF_ANSI)<>0 then + begin + AnsiToWide(pAnsiChar(w),lstr,MirandaCP); + mFreeMem(w); + w:=lstr; + end + else if (flags and ACF_UTF8)<>0 then + begin + UTF8ToWide(pAnsiChar(w),lstr); + mFreeMem(w); + w:=lstr; + end + else + ChangeUnicode(w); + + ClearResult(WorkData); + WorkData.LastResult:=uint_ptr(w); + WorkData.ResultType:=rtWide; + end; + if b1[0]<>#0 then + DeleteFileA(b1); + end; + + if fh<>THANDLE(INVALID_HANDLE_VALUE) then + CloseHandle(fh); + if tmp<>tfile then + mFreeMem(tmp); + exit; + end; + + // Message + wnd:=WaitFocusedWndChild(GetForegroundWindow){GetFocus}; + + // with Autosend + if (flags and ACF_TEXTSEND)<>0 then + begin + if wnd<>0 then + hContact:=WndToContact(wnd) + else + hContact:=0; + + if hContact=0 then + begin + if CallService(MS_DB_CONTACT_IS,WorkData.Parameter,0)<>0 then + hContact:=WorkData.Parameter; + end; + + if hContact=0 then exit; + + p:=GetContactProtoAcc(hContact); + cp:=DBReadDWord(hContact,'Tab_SRMsg','ANSIcodepage',MirandaCP); + if DBReadByte(hContact,p,'ChatRoom',0)<>1 then + begin + i:=WideToCombo(last,blob,cp); +// if CallContactService(hContact,PSS_MESSAGEW,0,TLPARAM(blob))= +// ACKRESULT_FAILED then + CallContactService(hContact,PSS_MESSAGE,PREF_UNICODE,tlparam(blob)); + dbei.cbSize :=sizeof(dbei); + dbei.cbBlob :=i; + dbei.pBlob :=pByte(blob); + dbei.eventType:=EVENTTYPE_MESSAGE; + dbei.timestamp:=GetCurrentTime; + dbei.szModule :=p; + dbei.flags :=DBEF_SENT; + db_event_add(hContact, @dbei); + mFreeMem(blob); + end + else + SendToChat(hContact,last); + end + else + begin + GetWindowThreadProcessId(GetForegroundWindow,@i); + if (i=GetCurrentProcessId) and (wnd<>0) then + SendMessageW(wnd,EM_REPLACESEL,1,tlparam(last)) + else + SendString(0,last); + end; + +end; + +procedure tInOutAction.Load(node:pointer;fmt:integer); +var + section: array [0..127] of AnsiChar; + pc:pAnsiChar; + tmp:pWideChar; + flags2:dword; +begin + inherited Load(node,fmt); + case fmt of + 0: begin + pc:=StrCopyE(section,pAnsiChar(node)); + if (flags and ACF_FILE)<>0 then + begin + StrCopy(pc,opt_file); tfile:=DBReadUnicode(0,DBBranch,section,nil); + end; + end; + + 100: begin + pc:=StrCopyE(section,pAnsiChar(node)); + if (flags and ACF_FILE)<>0 then + begin + StrCopy(pc,opt_file); tfile:=DBReadUnicode(0,DBBranch,section,nil); + end; + + StrCopy(pc,'flags2'); flags2:=DBReadDWord(0,DBBranch,section,0); + if (flags2 and ACF2_TXT_FILE)<>0 then + flags:=flags or ACF_FILE_PATH; + end; + + 1: begin + with xmlparser do + begin + tmp:=getAttrValue(HXML(node),ioObject); + if lstrcmpiw(tmp,ioClipboard)=0 then + begin + flags:=flags or ACF_CLIPBRD; + tmp:=getAttrValue(HXML(node),ioOper); + if lstrcmpiw(tmp,ioCopy)=0 then flags:=flags or ACF_COPYTO; + // else if lstrcmpiw(tmp,'paste')=0 then ; + end + else + begin + if lstrcmpiw(tmp,ioFile)=0 then + begin + + if StrToInt(getAttrValue(HXML(node),ioFileVariable))=1 then + flags:=flags or ACF_FILE_PATH; + + flags:=flags or ACF_FILE; + StrDupW(tfile,getAttrValue(HXML(node),ioFile)); + tmp:=getAttrValue(HXML(node),ioOper); + if lstrcmpiw(tmp,ioWrite )=0 then flags:=flags or ACF_FWRITE + else if lstrcmpiw(tmp,ioAppend)=0 then flags:=flags or ACF_FAPPEND; + case StrToInt(getAttrValue(HXML(node),ioEnc)) of + 0: flags:=flags or ACF_ANSI; + 1: flags:=flags or ACF_UTF8; + 2: flags:=flags or ACF_UTF8 or ACF_SIGN; + 3: flags:=flags or 0; + 4: flags:=flags or ACF_SIGN; + end; + end; + end; + end; + end; +{ + 2: begin + pc:=GetParamSectionStr(node,ioObject); + if lstrcmpi(tmp,ioClipboard)=0 then + begin + flags:=flags or ACF_CLIPBRD; + pc:=GetParamSectionStr(node,ioOper); + if lstrcmpi(pc,ioCopy)=0 then flags:=flags or ACF_COPYTO; +// else if lstrcmpi(pc,'paste')=0 then ; + end + else + begin + if lstrcmpi(pc,ioFile)=0 then + begin + flags:=flags or ACF_FILE; + + if GetParamSectionInt(node,ioFileVariable))=1 then + flags:=flags or ACF_FILE_PATH; + + UTF8ToWide(GetParamSectionStr(node,ioFile),tfile); + + pc:=GetParamSectionStr(node,ioOper); + if lstrcmpi(pc,ioWrite )=0 then flags:=flags or ACF_FWRITE + else if lstrcmpi(pc,ioAppend)=0 then flags:=flags or ACF_FAPPEND; + + case GetParamSectionInt(node,ioEnc)) of + 0: flags:=flags or ACF_ANSI; + 1: flags:=flags or ACF_UTF8; + 2: flags:=flags or ACF_UTF8 or ACF_SIGN; + 3: flags:=flags or 0; + 4: flags:=flags or ACF_SIGN; + end; + end; + end; + end; +} + end; +end; + +procedure tInOutAction.Save(node:pointer;fmt:integer); +var + section: array [0..127] of AnsiChar; + pc:pAnsiChar; +begin + inherited Save(node,fmt); + case fmt of + 0: begin + pc:=StrCopyE(section,pAnsiChar(node)); + if (flags and ACF_FILE)<>0 then + begin + StrCopy(pc,opt_file); DBWriteUnicode(0,DBBranch,section,tfile); + end; + end; +{ + 1: begin + end; +} + 13: begin +{ + ACF_CLIPBRD = $00000002; // Clipboard operations, not window + ACF_ANSI = $00000004; // File: ANSI or Unicode (UTF8/UTF16) text + ACF_COPYTO = $00000008; // Clipboard operations: 'copy to' or 'paste from' + + ACF_FILE = $00000010; // File operations + ACF_FWRITE = $00000020; // read/write file + ACF_FAPPEND = $00000040; // append file + ACF_UTF8 = $00000080; // File: UTF8 or UTF16 + ACF_SIGN = $00000100; // File: with signature or not + ACF_FILE_PATH = $00000200; + + ACF_TEXTSEND = $00000400; +} + end; + end; +end; + +//----- Dialog realization ----- + +procedure FillFileName(Dialog:HWND;idc:integer); +var + pw,ppw:pWideChar; +begin + mGetMem(pw,1024*SizeOf(WideChar)); + ppw:=GetDlgText(Dialog,idc); + if ShowDlgW(pw,ppw) then + begin + SetDlgItemTextW(Dialog,idc,pw); + SetEditFlags(Dialog,idc,EF_SCRIPT,0); + end; + mFreeMem(ppw); + mFreeMem(pw); +end; + +procedure MakeTextTypeList(wnd:HWND); +begin + SendMessage(wnd,CB_RESETCONTENT,0,0); + InsertString(wnd,0,'Ansi'); + InsertString(wnd,1,'UTF8'); + InsertString(wnd,2,'UTF8+sign'); + InsertString(wnd,3,'UTF16'); + InsertString(wnd,4,'UTF16+sign'); + SendMessage(wnd,CB_SETCURSEL,0,0); +end; + +procedure SetSet(Dialog:HWND;num:integer); +var + lclip,lfile,lmess:boolean; +begin + case num of + 0: begin lclip:=true ; lfile:=false; lmess:=false; end; + 1: begin lclip:=false; lfile:=true ; lmess:=false; end; +// 2: begin lclip:=false; lfile:=false; lmess:=true; end; + else + lclip:=false; lfile:=false; lmess:=true; + end; + EnableWindow(GetDlgItem(Dialog,IDC_CLIP_COPYTO),lclip); + EnableWindow(GetDlgItem(Dialog,IDC_CLIP_PASTE ),lclip); + + EnableWindow(GetDlgItem(Dialog,IDC_FILE_READ ),lfile); + EnableWindow(GetDlgItem(Dialog,IDC_FILE_WRITE ),lfile); + EnableWindow(GetDlgItem(Dialog,IDC_FILE_APPEND ),lfile); + EnableWindow(GetDlgItem(Dialog,IDC_FILE_ENC ),lfile); + EnableWindow(GetDlgItem(Dialog,IDC_FILE_FILEBTN),lfile); + EnableEditField(Dialog,IDC_FILE_PATH,lfile); + + EnableWindow(GetDlgItem(Dialog,IDC_TEXT_SEND),lmess); +end; + +procedure ClearFields(Dialog:HWND); +begin + SetDlgItemTextW(Dialog,IDC_FILE_PATH,nil); + SetEditFlags(Dialog,IDC_FILE_PATH,EF_ALL,0); + + CheckDlgButton(Dialog,IDC_FLAG_CLIP ,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_FLAG_FILE ,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_FLAG_MESSAGE,BST_UNCHECKED); + + CheckDlgButton(Dialog,IDC_CLIP_COPYTO,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_CLIP_PASTE ,BST_UNCHECKED); + + CheckDlgButton(Dialog,IDC_FILE_READ ,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_FILE_WRITE ,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_FILE_APPEND,BST_UNCHECKED); + + CheckDlgButton(Dialog,IDC_TEXT_SEND,BST_UNCHECKED); +end; + +function DlgProc(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; +const + NoProcess:boolean=true; +var + i:integer; +begin + result:=0; + + case hMessage of + WM_INITDIALOG: begin + TranslateDialogDefault(Dialog); + + MakeTextTypeList(GetDlgItem(Dialog,IDC_FILE_ENC)); + + MakeEditField(Dialog,IDC_FILE_PATH); + end; + + WM_ACT_SETVALUE: begin + NoProcess:=true; + ClearFields(Dialog); + + with tInOutAction(lParam) do + begin + if (flags and ACF_CLIPBRD)<>0 then + begin + CheckDlgButton(Dialog,IDC_FLAG_CLIP,BST_CHECKED); + if (flags and ACF_COPYTO)<>0 then + CheckDlgButton(Dialog,IDC_CLIP_COPYTO,BST_CHECKED) + else + CheckDlgButton(Dialog,IDC_CLIP_PASTE,BST_CHECKED); + SetSet(Dialog,0); + end + + else if (flags and ACF_FILE)<>0 then + begin + CheckDlgButton(Dialog,IDC_FLAG_FILE,BST_CHECKED); + + if (flags and ACF_ANSI)<>0 then + i:=0 + else if (flags and ACF_UTF8)<>0 then + begin + if (flags and ACF_SIGN)<>0 then + i:=2 + else + i:=1 + end + else if (flags and ACF_SIGN)<>0 then + i:=4 + else + i:=3; + CB_SelectData(GetDlgItem(Dialog,IDC_FILE_ENC),i); + + if (flags and ACF_FAPPEND)<>0 then CheckDlgButton(Dialog,IDC_FILE_APPEND,BST_CHECKED) + else if (flags and ACF_FWRITE )<>0 then CheckDlgButton(Dialog,IDC_FILE_WRITE ,BST_CHECKED) + else CheckDlgButton(Dialog,IDC_FILE_READ ,BST_CHECKED); + SetDlgItemTextW(Dialog,IDC_FILE_PATH,tfile); + SetEditFlags(Dialog,IDC_FILE_PATH,EF_SCRIPT,ord((flags and ACF_FILE_PATH)<>0)); + + SetSet(Dialog,1); + end + else + begin + CheckDlgButton(Dialog,IDC_FLAG_MESSAGE,BST_CHECKED); + + if (flags and ACF_TEXTSEND)<>0 then CheckDlgButton(Dialog,IDC_TEXT_SEND,BST_CHECKED); + + SetSet(Dialog,2); + end; + end; + NoProcess:=false; + end; + + WM_ACT_RESET: begin + NoProcess:=true; + ClearFields(Dialog); + + CheckDlgButton(Dialog,IDC_FLAG_CLIP,BST_CHECKED); + CheckDlgButton(Dialog,IDC_CLIP_COPYTO,BST_CHECKED); + CheckDlgButton(Dialog,IDC_FILE_READ,BST_CHECKED); + SetSet(Dialog,0); // clipboard + NoProcess:=false; + end; + + WM_ACT_SAVE: begin + with tInOutAction(lParam) do + begin +// flags:=0; + // Clipboard + if IsDlgButtonChecked(Dialog,IDC_FLAG_CLIP)<>BST_UNCHECKED then + begin + flags:=flags or ACF_CLIPBRD; + if IsDlgButtonChecked(Dialog,IDC_CLIP_COPYTO)<>BST_UNCHECKED then + flags:=flags or ACF_COPYTO; + end + // text file + else if IsDlgButtonChecked(Dialog,IDC_FLAG_FILE)<>BST_UNCHECKED then + begin + flags:=flags or ACF_FILE; + case CB_GetData(GetDlgItem(Dialog,IDC_FILE_ENC)) of + 0: flags:=flags or ACF_ANSI; + 1: flags:=flags or ACF_UTF8; + 2: flags:=flags or ACF_UTF8 or ACF_SIGN; + 3: flags:=flags or 0; + 4: flags:=flags or ACF_SIGN; + end; + + tfile:=GetDlgText(Dialog,IDC_FILE_PATH); + if (GetEditFlags(Dialog,IDC_FILE_PATH) and EF_SCRIPT)<>0 then flags:=flags or ACF_FILE_PATH; + + if IsDlgButtonChecked(Dialog,IDC_FILE_APPEND)<>BST_UNCHECKED then + flags:=flags or ACF_FAPPEND + else if IsDlgButtonChecked(Dialog,IDC_FILE_WRITE)<>BST_UNCHECKED then + flags:=flags or ACF_FWRITE; + end + // Message + else + begin + if IsDlgButtonChecked(Dialog,IDC_TEXT_SEND)<>BST_UNCHECKED then + flags:=flags or ACF_TEXTSEND; + end; + end; + end; + + WM_COMMAND: begin + case wParam shr 16 of + CBN_SELCHANGE, + EN_CHANGE: if not NoProcess then + SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0); + + BN_CLICKED: begin + case loword(wParam) of + IDC_FLAG_CLIP: begin + SetSet(Dialog,0); + end; + IDC_FLAG_FILE: begin + SetSet(Dialog,1); + end; + IDC_FLAG_MESSAGE: begin + SetSet(Dialog,2); + end; + IDC_FILE_FILEBTN: begin + FillFileName(Dialog,IDC_FILE_PATH); + end; + end; + SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0); + end; + end; + end; + + WM_HELP: begin + result:=1; + end; + + end; +end; + +//----- Export/interface functions ----- + +var + vc:tActModule; + +function CreateAction:tBaseAction; +begin + result:=tInOutAction.Create(vc.Hash); +end; + +function CreateDialog(parent:HWND):HWND; +begin + result:=CreateDialogW(hInstance,'IDD_INOUT',parent,@DlgProc); +end; + +procedure Init; +begin + vc.Next :=ModuleLink; + + vc.Name :='In/Out'; + vc.Dialog :=@CreateDialog; + vc.Create :=@CreateAction; + vc.Icon :='IDI_INOUT'; + + ModuleLink :=@vc; +end; + +begin + Init; +end. diff --git a/plugins/Actman/iac_inout.rc b/plugins/Actman/iac_inout.rc new file mode 100644 index 0000000000..ca61e5f492 --- /dev/null +++ b/plugins/Actman/iac_inout.rc @@ -0,0 +1,30 @@ +#include "i_cnst_inout.inc" + +LANGUAGE 0,0 + +IDD_INOUT DIALOGEX 0, 0, 168, 200, 0 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0 +{ + AUTORADIOBUTTON "Clipboard" , IDC_FLAG_CLIP , 1, 2, 166, 11, WS_GROUP + AUTORADIOBUTTON "File" , IDC_FLAG_FILE , 1, 52, 166, 11 + AUTORADIOBUTTON "Message window", IDC_FLAG_MESSAGE, 1, 118, 166, 11 + + GROUPBOX "" , -1 , 1, 11, 166, 33 + AUTORADIOBUTTON "Copy to" , IDC_CLIP_COPYTO, 6, 18, 158, 11, WS_GROUP + AUTORADIOBUTTON "Paste from", IDC_CLIP_PASTE , 6, 29, 158, 11 + + GROUPBOX "" , -1 , 1, 61, 166, 52 + AUTORADIOBUTTON "Read" , IDC_FILE_READ , 4, 69, 52, 11, WS_GROUP + AUTORADIOBUTTON "Write" , IDC_FILE_WRITE , 57, 69, 52, 11 + AUTORADIOBUTTON "Append" , IDC_FILE_APPEND , 110, 69, 52, 11 + EDITTEXT IDC_FILE_PATH , 4, 82, 140, 12, ES_AUTOHSCROLL + PUSHBUTTON "..." , IDC_FILE_FILEBTN, 147, 82, 16, 12 + COMBOBOX IDC_FILE_ENC , 4, 97, 160, 76, CBS_DROPDOWNLIST | WS_VSCROLL + + GROUPBOX "" , -1 , 1, 127, 166, 22 + AUTOCHECKBOX "Autosend" , IDC_TEXT_SEND, 6, 135, 158, 11 +} + +IDI_INOUT ICON "ico\insert.ico" diff --git a/plugins/Actman/iac_inout.res b/plugins/Actman/iac_inout.res new file mode 100644 index 0000000000..f912dc3066 Binary files /dev/null and b/plugins/Actman/iac_inout.res differ diff --git a/plugins/Actman/iac_jump.pas b/plugins/Actman/iac_jump.pas new file mode 100644 index 0000000000..4ac0473405 --- /dev/null +++ b/plugins/Actman/iac_jump.pas @@ -0,0 +1,764 @@ +unit iac_jump; + +interface + +implementation + +uses + windows, messages, commctrl, + m_api, dbsettings, + global,iac_global, editwrapper, dlgshare, + common, mirutils, wrapper; + +{$include i_cnst_jump.inc} +{$resource iac_jump.res} + +const // condition code + aeGT = 1; + aeLT = 2; + aeEQ = 3; + aeXR = 4; + aeND = 5; + + aeEMP = 1; + aeEQU = 2; + aeCON = 3; + aeSTR = 4; + aeEND = 5; +const + opt_value = 'value'; + opt_condition = 'condition'; + opt_label = 'label'; +const + ioIf = 'IF'; + ioCond = 'cond'; + ioNop = 'nop'; + ioNot = 'not'; + ioValue = 'value'; + ioOper = 'oper'; + ioAction = 'action'; + ioLabel = 'label'; + ioBreak = 'break'; + ioJump = 'jump'; + ioPost = 'POST'; + ioCase = 'case'; + ioBack = 'back'; +const + ACF_NOP = $00000001; + ACF_MATH = $00000002; + ACF_NOT = $00000004; + ACF_CASE = $00000008; + ACF_BREAK = $00000010; + ACF_BACK = $00000020; + ACF_VALUE = $00000100; + +const // V2 + ADV_ACT_BREAK = 1; + ADV_COND_NOT = $80; + ADV_COND_GT = 1; + ADV_COND_LT = 2; + ADV_COND_EQ = 3; + +type + tJumpAction = class(tBaseAction) + private + value :pWideChar; + actlabel :pWideChar; + condition:integer; + public + constructor Create(uid:dword); + destructor Destroy; override; +// function Clone:tBaseAction; override; + function DoAction(var WorkData:tWorkData):LRESULT; override; + procedure Save(node:pointer;fmt:integer); override; + procedure Load(node:pointer;fmt:integer); override; + end; + +//----- Support functions ----- + +//----- Object realization ----- + +constructor tJumpAction.Create(uid:dword); +begin + inherited Create(uid); + + condition:=0; + value :=nil; + actlabel :=nil; +end; + +destructor tJumpAction.Destroy; +begin + mFreeMem(value); + mFreeMem(actlabel); + + inherited Destroy; +end; +{ +function tJumpAction.Clone:tBaseAction; +begin + result:=tJumpAction.Create(0); + Duplicate(result); + + result.condition:=condition; + StrDupW(result.value,value); + StrDupW(result.actlabel,actlabel); +end; +} +function tJumpAction.DoAction(var WorkData:tWorkData):LRESULT; +var + tmpint:int64; + vnum:int_ptr; + vstr,vlast:pWideChar; + buf:array [0..31] of WideChar; + res:boolean; + vlr,vval:pWideChar; + tmp:pWideChar; + delta:integer; + lptr:pBaseAction; +begin + result:=0; + + // Condition + if (flags and ACF_NOP)=0 then + begin + // preparing value + if WorkData.ResultType=rtInt then + vlast:=IntToStr(buf,WorkData.LastResult) + else + vlast:=pWideChar(WorkData.LastResult); + + if (flags and ACF_VALUE)<>0 then + begin + vstr:=ParseVarString(value,WorkData.Parameter,vlast); + end + else + vstr:=value; + + res:=false; + // now comparing + if (flags and ACF_MATH)<>0 then + begin + vnum:=int_ptr(GetResultNumber(WorkData)); + tmpint:=NumToInt(vstr); + case condition of + aeGT: res:=vnum>tmpint; + aeLT: res:=vnum0; + aeND: res:=(vnum and tmpint)<>0; + end; + + end + else + begin + if (condition=aeEMP) and ((vlast=nil) or (vlast[0]=#0)) then + res:=true + else + begin + if (flags and ACF_CASE)=0 then + begin + StrDupW(vlr,vlast); + StrDupW(vval,vstr); + CharUpperW(vlr); + CharUpperW(vval); + end + else + begin + vlr :=vlast; + vval:=vstr; + end; + + if (flags and ACF_BACK)<>0 then + begin + tmp:=vlr; + vlr:=vval; + vval:=tmp; + end; + + case condition of + aeEQU: res:=StrCmpW(vlr,vval)=0; + aeCON: res:=StrPosW(vlr,vval)<>nil; + aeSTR: res:=StrPosW(vlr,vval)=vlr; + aeEND: begin + delta:=StrLenW(vval)-StrLenW(vlr); + if delta>=0 then + res:=StrCmpW(vlr,vval+delta)=0; + end; + end; + + if (vlr<>vlast) and (vlr<>vstr) then + begin + mFreeMem(vlr); + mFreeMem(vval); + end; + end; + end; + + if (flags and ACF_NOT)<>0 then + res:=not res; + + if (flags and ACF_VALUE)<>0 then + mFreeMem(vstr); + end + else + res:=true; + + // Operation + if res then + if (flags and ACF_BREAK)<>0 then + result:=-1 + else + begin + lptr:=pBaseAction(WorkData.ActionList); + for delta:=0 to WorkData.ActionCount-1 do + begin + if StrCmpW(actlabel,lptr^.ActionDescr)=0 then + begin + result:=delta+1; + break; + end; + inc(lptr); + end; + end; +end; + +procedure tJumpAction.Load(node:pointer;fmt:integer); +var + section: array [0..127] of AnsiChar; + buf:array [0..31] of WideChar; + pc:pAnsiChar; + tmp:pWideChar; + sub:HXML; + oper,cond:byte; +begin + inherited Load(node,fmt); + case fmt of + 0: begin + pc:=StrCopyE(section,pAnsiChar(node)); + if (flags and ACF_NOP)=0 then + begin + StrCopy(pc,opt_value ); value :=DBReadUnicode(0,DBBranch,section,nil); + StrCopy(pc,opt_condition); condition:=DBReadByte (0,DBBranch,section,0); + end; + if (flags and ACF_BREAK)=0 then + begin + StrCopy(pc,opt_label); actlabel:=DBReadUnicode(0,DBBranch,section,nil); + end; + end; + + 100..199: begin + flags:=flags and not ACF_MASK; + pc:=StrCopyE(section,pAnsiChar(node)); + if fmt<>101 then // condition + begin + StrCopy(pc,opt_condition); cond:=DBReadByte(0,DBBranch,section); + if (cond and $0F)=0 then + flags:=flags or ACF_NOP + else + begin + if (cond and ADV_COND_NOT)<>0 then flags:=flags or ACF_NOT; + flags:=flags or ACF_MATH; + StrCopy(pc,opt_value); StrDupW(value,IntToStr(buf,DBReadDWord(0,DBBranch,section))); + + case cond and $0F of + ADV_COND_GT: condition:=aeGT; + ADV_COND_LT: condition:=aeLT; + ADV_COND_EQ: condition:=aeEQ; + end; + end; + end + else // skip condition, jump + begin + flags:=flags or ACF_NOP + end; + + if fmt>101 then // inverse condition, jump to label + begin + flags:=flags xor ACF_NOT; + buf[0]:='$'; buf[1]:='$'; + IntToStr(PWideChar(@buf[2]),fmt-102); + StrDupW(actlabel,buf); + end + else + begin + StrCopy(pc,'action'); oper:=DBReadByte(0,DBBranch,section) and $0F; + if (oper and ADV_ACT_BREAK)<>0 then + flags:= flags or ACF_BREAK + else + begin + StrCopy(pc,'operval'); actlabel:=DBReadUnicode(0,DBBranch,section); + end; + end; + end; + + 1: begin + with xmlparser do + begin + sub:=getNthChild(HXML(node),ioIf,0); + if sub<>0 then + begin + tmp:=getAttrValue(sub,ioOper); + if lstrcmpiw(tmp,'math')=0 then flags:=flags or ACF_MATH + else if lstrcmpiw(tmp,ioNop )=0 then flags:=flags or ACF_NOP; + + tmp:=getAttrValue(sub,ioCond); + if lstrcmpiw(tmp,ioNop)=0 then flags:=flags or ACF_NOP // compatibility + else if (flags and ACF_NOP)=0 then + begin + if flags and ACF_MATH<>0 then + begin + if lstrcmpiw(tmp,'gt' )=0 then condition:=aeGT + else if lstrcmpiw(tmp,'lt' )=0 then condition:=aeLT + else if lstrcmpiw(tmp,'eq' )=0 then condition:=aeEQ + else if lstrcmpiw(tmp,'xor')=0 then condition:=aeXR + else if lstrcmpiw(tmp,'and')=0 then condition:=aeND; + end + else + begin + if lstrcmpiw(tmp,'empty')=0 then condition:=aeEMP + else if lstrcmpiw(tmp,'eq' )=0 then condition:=aeEQU + else if lstrcmpiw(tmp,'cont' )=0 then condition:=aeCON + else if lstrcmpiw(tmp,'start')=0 then condition:=aeSTR + else if lstrcmpiw(tmp,'ends' )=0 then condition:=aeEND; + + if StrToInt(getAttrValue(sub,ioCase))=1 then + flags:=flags or ACF_CASE; + if StrToInt(getAttrValue(sub,ioBack))=1 then + flags:=flags or ACF_BACK; + end; + if StrToInt(getAttrValue(sub,ioNot))=1 then + flags:=flags or ACF_NOT; + + if ((flags and ACF_MATH)<>0) or (condition<>aeEMP) then + StrDupW(value,getAttrValue(sub,ioValue)); + end; + end; + + sub:=getNthChild(HXML(node),ioPost,0); + if sub<>0 then + begin + tmp:=getAttrValue(sub,ioOper); + if lstrcmpiw(tmp,ioBreak)=0 then flags:=flags or ACF_BREAK + else if lstrcmpiw(tmp,ioJump )=0 then StrDupW(actlabel,getAttrValue(sub,ioValue)); + end; + end; + end; +{ + 2: begin + pc:=GetParamSectionStr(node,ioOper); + if lstrcmpi(pc,'math')=0 then flags:=flags or ACF_MATH + else if lstrcmpi(pc,ioNop )=0 then flags:=flags or ACF_NOP; + + pc:=GetParamSectionStr(node,ioCond); + if lstrcmpi(pc,ioNop)=0 then flags:=flags or ACF_NOP // compatibility + else if (flags and ACF_NOP)=0 then + begin + if flags and ACF_MATH<>0 then + begin + if lstrcmpi(pc,'gt' )=0 then condition:=aeGT + else if lstrcmpi(pc,'lt' )=0 then condition:=aeLT + else if lstrcmpi(pc,'eq' )=0 then condition:=aeEQ + else if lstrcmpi(pc,'xor')=0 then condition:=aeXR + else if lstrcmpi(pc,'and')=0 then condition:=aeND; + end + else + begin + if lstrcmpi(pc,'empty')=0 then condition:=aeEMP + else if lstrcmpi(pc,'eq' )=0 then condition:=aeEQU + else if lstrcmpi(pc,'cont' )=0 then condition:=aeCON + else if lstrcmpi(pc,'start')=0 then condition:=aeSTR + else if lstrcmpi(pc,'ends' )=0 then condition:=aeEND; + + if GetParamSectionInt(node,ioCase)=1 then + flags:=flags or ACF_CASE; + if GetParamSectionInt(node,ioBack)=1 then + flags:=flags or ACF_BACK; + end; + if GetParamSectionInt(node,ioNot)=1 then + flags:=flags or ACF_NOT; + + if ((flags and ACF_MATH)<>0) or (condition<>aeEMP) then + UTF8ToWide(GetParamSectionStr(node,ioValue),value); + end; + + pc:=GetParamSectionStr(node,ioAction); + if lstrcmpi(pc,ioBreak)=0 then flags:=flags or ACF_BREAK + else if lstrcmpi(pc,ioJump )=0 then UTF8ToWide(GetParamSectionStr(node,ioLabel),actlabel); + end; +} + end; +end; + +procedure tJumpAction.Save(node:pointer;fmt:integer); +var + section: array [0..127] of AnsiChar; + pc:pAnsiChar; +begin + inherited Save(node,fmt); + case fmt of + 0: begin + pc:=StrCopyE(section,pAnsiChar(node)); + if (flags and ACF_NOP)=0 then + begin + StrCopy(pc,opt_value ); DBWriteUnicode(0,DBBranch,section,value); + StrCopy(pc,opt_condition); DBWriteByte (0,DBBranch,section,condition); + end; + if (flags and ACF_BREAK)=0 then + begin + StrCopy(pc,opt_label); DBWriteUnicode(0,DBBranch,section,actlabel); + end; + end; +{ + 1: begin + end; +} + 13: begin +{ + ACF_NOP = $00000001; + ACF_MATH = $00000002; + ACF_NOT = $00000004; + ACF_CASE = $00000008; + ACF_BREAK = $00000010; + ACF_BACK = $00000020; + ACF_VALUE = $00000100; +} + end; + end; +end; + +//----- Dialog realization ----- + +procedure FillMathList(Dialog:HWND); +var + wnd:HWND; +begin + wnd:=GetDlgItem(Dialog,IDC_JMP_MATH); + + SendMessage(wnd,CB_RESETCONTENT,0,0); + + InsertString(wnd,cardinal(aeGT),'> greater'); + InsertString(wnd,cardinal(aeLT),'< lesser'); + InsertString(wnd,cardinal(aeEQ),'= equ'); + InsertString(wnd,cardinal(aeXR),'^ xor'); + InsertString(wnd,cardinal(aeND),'& and'); + + SendMessage(wnd,CB_SETCURSEL,0,0); +end; + +procedure FillTextList(Dialog:HWND); +var + wnd:HWND; +begin + wnd:=GetDlgItem(Dialog,IDC_JMP_TEXT); + + SendMessage(wnd,CB_RESETCONTENT,0,0); + + InsertString(wnd,cardinal(aeEMP),'empty'); + InsertString(wnd,cardinal(aeEQU),'= equ'); + InsertString(wnd,cardinal(aeCON),'contains'); + InsertString(wnd,cardinal(aeSTR),'starts with'); + InsertString(wnd,cardinal(aeEND),'ends with'); + + SendMessage(wnd,CB_SETCURSEL,0,0); +end; + +procedure FillActionList(Dialog:HWND); +var + list,wnd:HWND; + i,act:integer; + arr:array [0..127] of WideChar; + li:LV_ITEMW; +begin + wnd:=GetDlgItem(Dialog,IDC_JMP_ACTLIST); + + SendMessage(wnd,CB_RESETCONTENT,0,0); + + list:=ActionListWindow; + act:=SendMessageW(list,LVM_GETITEMCOUNT,0,0); + i:=0; + li.mask :=LVIF_TEXT; + li.iSubItem :=0; + li.pszText :=@arr; + li.cchTextMax:=SizeOf(arr) div SizeOf(WideChar); + while iBST_UNCHECKED then + begin + bmath:=false; + btext:=false; + end + else if IsDlgButtonChecked(Dialog,IDC_FLAG_MATH)<>BST_UNCHECKED then + begin + bmath:=true; + btext:=false; + end + else + begin + bmath:=false; + btext:=true; + end; + EnableWindow(GetDlgItem(Dialog,IDC_JMP_MATH ),bmath); + EnableWindow(GetDlgItem(Dialog,IDC_JMP_TEXT ),btext); + EnableWindow(GetDlgItem(Dialog,IDC_FLAG_CASE),btext); + EnableWindow(GetDlgItem(Dialog,IDC_FLAG_BACK),btext); + EnableWindow(GetDlgItem(Dialog,IDC_FLAG_NOT ),bmath or btext); + EnableEditField(GetDlgItem(Dialog,IDC_JMP_VALUE),bmath or btext); + if btext then + begin + btext:=CB_GetData(GetDlgItem(Dialog,IDC_JMP_TEXT))<>aeEMP; + EnableWindow (GetDlgItem(Dialog,IDC_FLAG_CASE),btext); + EnableWindow (GetDlgItem(Dialog,IDC_FLAG_BACK),btext); + EnableEditField(GetDlgItem(Dialog,IDC_JMP_VALUE),btext); + end; +end; + +procedure ClearFields(Dialog:HWND); +begin + EnableWindow(GetDlgItem(Dialog,IDC_JMP_MATH ),true); + EnableWindow(GetDlgItem(Dialog,IDC_JMP_TEXT ),true); + EnableWindow(GetDlgItem(Dialog,IDC_FLAG_NOT ),true); + EnableWindow(GetDlgItem(Dialog,IDC_FLAG_CASE),true); + EnableEditField(GetDlgItem(Dialog,IDC_JMP_VALUE),true); + SetDlgItemTextW(Dialog,IDC_JMP_VALUE,nil); + SetEditFlags(Dialog,IDC_JMP_VALUE,EF_ALL,0); + + CheckDlgButton(Dialog,IDC_FLAG_NOP ,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_FLAG_MATH ,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_FLAG_TEXT ,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_FLAG_NOT ,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_FLAG_CASE ,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_FLAG_BACK ,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_FLAG_BREAK,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_FLAG_JUMP ,BST_UNCHECKED); +end; + +function DlgProc(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; +const + NoProcess:boolean=true; +var + bb:boolean; + wnd:HWND; + tmp:dword; +begin + result:=0; + + case hMessage of + WM_INITDIALOG: begin + FillMathList(Dialog); + FillTextList(Dialog); + + TranslateDialogDefault(Dialog); + + MakeEditField(Dialog,IDC_JMP_VALUE); + end; + + WM_ACT_SETVALUE: begin + NoProcess:=true; + ClearFields(Dialog); + with tJumpAction(lParam) do + begin + FillActionList(Dialog); +// SendDlgItemMessage(Dialog,IDC_JMP_ACTLIST,CB_SETCURSEL,0,0); + // Condition + if (flags and ACF_NOP)<>0 then + begin + CheckDlgButton(Dialog,IDC_FLAG_NOP,BST_CHECKED); + end + else + begin + if (flags and ACF_NOT)<>0 then + CheckDlgButton(Dialog,IDC_FLAG_NOT,BST_CHECKED); + SetDlgItemTextW(Dialog,IDC_JMP_VALUE,value); + SetEditFlags(Dialog,IDC_JMP_VALUE,EF_SCRIPT,ord((flags and ACF_VALUE)<>0)); + + // Math + if (flags and ACF_MATH)<>0 then + begin + CheckDlgButton(Dialog,IDC_FLAG_MATH,BST_CHECKED); + CB_SelectData(Dialog,IDC_JMP_MATH,condition); + end + // Text + else + begin + if (flags and ACF_CASE)<>0 then + CheckDlgButton(Dialog,IDC_FLAG_CASE,BST_CHECKED); + if (flags and ACF_BACK)<>0 then + CheckDlgButton(Dialog,IDC_FLAG_BACK,BST_CHECKED); + CheckDlgButton(Dialog,IDC_FLAG_TEXT,BST_CHECKED); + CB_SelectData(Dialog,IDC_JMP_TEXT,condition); + end; + end; + SetFields(Dialog); + + //Operation + if (flags and ACF_BREAK)<>0 then + begin + CheckDlgButton(Dialog,IDC_FLAG_BREAK,BST_CHECKED); + EnableWindow(GetDlgItem(Dialog,IDC_JMP_ACTLIST),false); + end + else + begin + CheckDlgButton(Dialog,IDC_FLAG_JUMP,BST_CHECKED); + EnableWindow(GetDlgItem(Dialog,IDC_JMP_ACTLIST),true); + SendDlgItemMessageW(Dialog,IDC_JMP_ACTLIST,CB_SELECTSTRING, + twparam(-1),tlparam(actlabel)); + end; + + end; + NoProcess:=false; + end; + + WM_ACT_RESET: begin + NoProcess:=true; + ClearFields(Dialog); + + CheckDlgButton(Dialog,IDC_FLAG_BREAK,BST_CHECKED); + CheckDlgButton(Dialog,IDC_FLAG_NOP ,BST_CHECKED); + SetFields(Dialog); + CB_SelectData(GetDlgItem(Dialog,IDC_JMP_MATH),aeEQ); + CB_SelectData(GetDlgItem(Dialog,IDC_JMP_TEXT),aeEQU); + EnableWindow(GetDlgItem(Dialog,IDC_JMP_ACTLIST),false); + NoProcess:=false; + end; + + WM_ACT_SAVE: begin + with tJumpAction(lParam) do + begin + // Condition + if IsDlgButtonChecked(Dialog,IDC_FLAG_NOP)<>BST_UNCHECKED then + flags:=flags or ACF_NOP + else + begin + if IsDlgButtonChecked(Dialog,IDC_FLAG_NOT)<>BST_UNCHECKED then + flags:=flags or ACF_NOT; + + value:=GetDlgText(Dialog,IDC_JMP_VALUE); + if (GetEditFlags(Dialog,IDC_JMP_VALUE) and EF_SCRIPT)<>0 then + flags:=flags or ACF_VALUE; + + // math + if IsDlgButtonChecked(Dialog,IDC_FLAG_MATH)<>BST_UNCHECKED then + begin + flags:=flags or ACF_MATH; + condition:=CB_GetData(GetDlgItem(Dialog,IDC_JMP_MATH)); + end + // text + else + begin + condition:=CB_GetData(GetDlgItem(Dialog,IDC_JMP_TEXT)); + if condition<>aeEMP then + begin + if IsDlgButtonChecked(Dialog,IDC_FLAG_CASE)<>BST_UNCHECKED then + flags:=flags or ACF_CASE; + + if IsDlgButtonChecked(Dialog,IDC_FLAG_BACK)<>BST_UNCHECKED then + flags:=flags or ACF_BACK; + end; + end; + end; + + // Operation + if IsDlgButtonChecked(Dialog,IDC_FLAG_BREAK)<>BST_UNCHECKED then + flags:=flags or ACF_BREAK + else + begin + actlabel:=GetDlgText(Dialog,IDC_JMP_ACTLIST); + end; + + end; + end; + + WM_ACT_LISTCHANGE: begin + if wParam=2 then + begin + wnd:=GetDlgItem(Dialog,IDC_JMP_ACTLIST); + tmp:=CB_GetData(wnd); + FillActionList(Dialog); + CB_SelectData(wnd,tmp); + end; + end; + + WM_COMMAND: begin + case wParam shr 16 of + EN_CHANGE: if not NoProcess then + SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0); + + CBN_SELCHANGE: begin + case loword(wParam) of + IDC_JMP_TEXT: begin + bb:=CB_GetData(lParam)<>aeEMP; + EnableWindow (GetDlgItem(Dialog,IDC_FLAG_CASE),bb); + EnableWindow (GetDlgItem(Dialog,IDC_FLAG_BACK),bb); + EnableEditField(GetDlgItem(Dialog,IDC_JMP_VALUE),bb); + end; + end; + SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0); + end; + + BN_CLICKED: begin + case loword(wParam) of + IDC_FLAG_NOP, + IDC_FLAG_MATH, + IDC_FLAG_TEXT: SetFields(Dialog); + IDC_FLAG_BREAK: begin + EnableWindow(GetDlgItem(Dialog,IDC_JMP_ACTLIST),false); + end; + IDC_FLAG_JUMP: begin + EnableWindow(GetDlgItem(Dialog,IDC_JMP_ACTLIST),true); + end; + end; + SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0); + end; + end; + end; + + WM_HELP: begin + result:=1; + end; + + end; +end; + +//----- Export/interface functions ----- + +var + vc:tActModule; + +function CreateAction:tBaseAction; +begin + result:=tJumpAction.Create(vc.Hash); +end; + +function CreateDialog(parent:HWND):HWND; +begin + result:=CreateDialogW(hInstance,'IDD_ACTJUMP',parent,@DlgProc); +end; + +procedure Init; +begin + vc.Next :=ModuleLink; + + vc.Name :='Jump'; + vc.Dialog :=@CreateDialog; + vc.Create :=@CreateAction; + vc.Icon :='IDI_JUMP'; + + ModuleLink :=@vc; +end; + +begin + Init; +end. diff --git a/plugins/Actman/iac_jump.rc b/plugins/Actman/iac_jump.rc new file mode 100644 index 0000000000..4731042c38 --- /dev/null +++ b/plugins/Actman/iac_jump.rc @@ -0,0 +1,32 @@ +#include "i_cnst_jump.inc" + +LANGUAGE 0,0 + +IDD_ACTJUMP DIALOGEX 0, 0, 168, 200, 0 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0 +{ + GROUPBOX "Condition", -1 , 1, 2, 166, 144 + + AUTORADIOBUTTON "NOP" , IDC_FLAG_NOP , 4, 11, 160, 11, WS_GROUP + AUTORADIOBUTTON "Math" , IDC_FLAG_MATH, 4, 24, 160, 11 + AUTORADIOBUTTON "Text" , IDC_FLAG_TEXT, 4, 53, 160, 11 + + COMBOBOX IDC_JMP_MATH , 12, 37, 152, 96, CBS_DROPDOWNLIST | WS_VSCROLL | CBS_AUTOHSCROLL + + AUTOCHECKBOX "Case sensitive", IDC_FLAG_CASE, 4, 66, 160, 11 + AUTOCHECKBOX "Opposite order", IDC_FLAG_BACK, 4, 78, 160, 11 + COMBOBOX IDC_JMP_TEXT , 12, 92, 152, 96, CBS_DROPDOWNLIST | WS_VSCROLL | CBS_AUTOHSCROLL + + AUTOCHECKBOX "NOT" , IDC_FLAG_NOT , 4, 118, 32, 11 + RTEXT "Value" , -1 , 86, 118, 78, 11, SS_CENTERIMAGE + EDITTEXT IDC_JMP_VALUE, 4, 132, 160, 11, ES_AUTOHSCROLL + + GROUPBOX "Operation", -1 , 1, 152, 166, 39, WS_GROUP + AUTORADIOBUTTON "BREAK" , IDC_FLAG_BREAK , 4, 161, 62, 12 + AUTORADIOBUTTON "JUMP" , IDC_FLAG_JUMP , 4, 174, 62, 12 + COMBOBOX IDC_JMP_ACTLIST, 66, 174, 99, 96, CBS_DROPDOWNLIST | WS_VSCROLL | CBS_AUTOHSCROLL +} + +IDI_JUMP ICON "ico\jump.ico" diff --git a/plugins/Actman/iac_jump.res b/plugins/Actman/iac_jump.res new file mode 100644 index 0000000000..387b85dfdd Binary files /dev/null and b/plugins/Actman/iac_jump.res differ diff --git a/plugins/Actman/iac_messagebox.pas b/plugins/Actman/iac_messagebox.pas new file mode 100644 index 0000000000..41a1068ab2 --- /dev/null +++ b/plugins/Actman/iac_messagebox.pas @@ -0,0 +1,388 @@ +unit iac_messagebox; + +interface + +implementation + +uses + editwrapper, + windows, messages, commctrl, + m_api, global, iac_global, + wrapper, mirutils, common, dbsettings; + +{$include i_cnst_message.inc} +{$resource iac_messagebox.res} + +const + ACF_MSG_TTL = $00000001; + ACF_MSG_TXT = $00000002; + +const + opt_msgtitle = 'msgtitle'; + opt_msgtext = 'msgtext'; + opt_boxopts = 'boxopts'; +const + ioTitle = 'title'; + ioText = 'text'; + ioType = 'type'; + ioArgVariable = 'argvariables'; + ioVariables = 'variables'; +type + tMessageAction = class(tBaseAction) + private + msgtitle:pWideChar; + msgtext :pWideChar; + boxopts :uint; + public + constructor Create(uid:dword); + destructor Destroy; override; +// function Clone:tBaseAction; override; + function DoAction(var WorkData:tWorkData):LRESULT; override; + procedure Save(node:pointer;fmt:integer); override; + procedure Load(node:pointer;fmt:integer); override; + end; + +//----- Object realization ----- + +constructor tMessageAction.Create(uid:dword); +begin + inherited Create(uid); + + msgtext :=nil; + msgtitle:=nil; + boxopts :=0; +end; + +destructor tMessageAction.Destroy; +begin + mFreeMem(msgtitle); + mFreeMem(msgtext); + + inherited Destroy; +end; +{ +function tMessageAction.Clone:tBaseAction; +begin + result:=tMessageAction.Create(0); + Duplicate(result); + + StrDupW(tMessageAction(result).msgtext ,msgtext); + StrDupW(tMessageAction(result).msgtitle,msgtitle); + tMessageAction(result).boxopts:=boxopts; +end; +} +function tMessageAction.DoAction(var WorkData:tWorkData):LRESULT; +var + i:integer; + buf:array [0..31] of WideChar; + tmpc:pWideChar; // LastResult value + tmpc1,tmpc2:pWideChar; // title/text after LastResult insertion + tmpcv1,tmpcv2:pWideChar; // title/text after Variables processing +begin + result:=0; + + if WorkData.ResultType=rtWide then + tmpc:=pWidechar(WorkData.LastResult) + else + begin + IntToStr(buf,WorkData.LastResult); + tmpc:=@buf; + end; + // LastResult + if StrPosW(msgtitle,'')<>nil then + begin + mGetMem(tmpc1,8192); + StrCopyW(tmpc1,msgtitle); + StrReplaceW(tmpc1,'',tmpc); + end + else + tmpc1:=msgtitle; + if StrPosW(msgtext,'')<>nil then + begin + mGetMem(tmpc2,8192); + StrCopyW(tmpc2,msgtext); + StrReplaceW(tmpc2,'',tmpc); + end + else + tmpc2:=msgtext; + // Variables + if (flags and ACF_MSG_TTL)<>0 then + tmpcv1:=ParseVarString(tmpc1,WorkData.Parameter,tmpc) + else + tmpcv1:=tmpc1; + if (flags and ACF_MSG_TXT)<>0 then + tmpcv2:=ParseVarString(tmpc2,WorkData.Parameter,tmpc) + else + tmpcv2:=tmpc2; + + i:=MessageBoxW(0,tmpcv2,tmpcv1,boxopts); + + // Keep old result just if has single OK button + if (boxopts and $0F)<>MB_OK then + begin + ClearResult(WorkData); + + WorkData.ResultType:=rtInt; + WorkData.LastResult:=i; + end; + + if tmpcv1<>tmpc1 then mFreeMem(tmpcv1); + if tmpcv2<>tmpc2 then mFreeMem(tmpcv2); + if tmpc1 <>msgtitle then mFreeMem(tmpc1); + if tmpc2 <>msgtext then mFreeMem(tmpc2); +end; + +procedure tMessageAction.Load(node:pointer;fmt:integer); +var + section: array [0..127] of AnsiChar; + pc: pAnsiChar; +begin + inherited Load(node,fmt); + case fmt of + 0: begin + pc:=StrCopyE(section,pAnsiChar(node)); + StrCopy(pc,opt_msgtitle); msgtitle:=DBReadUnicode(0,DBBranch,section); + StrCopy(pc,opt_msgtext ); msgtext :=DBReadUnicode(0,DBBranch,section); + StrCopy(pc,opt_boxopts ); boxopts :=DBReadDword (0,DBBranch,section); // v2 = byte + end; + + 1: begin + with xmlparser do + begin + StrDupW(msgtitle,getAttrValue(HXML(node),ioTitle)); + StrDupW(msgtext,getText(HXML(node))); + boxopts:=StrToInt(getAttrValue(HXML(node),ioType)); + + if StrToInt(getAttrValue(HXML(node),ioArgVariable))=1 then flags:=flags or ACF_MSG_TXT; + if StrToInt(getAttrValue(HXML(node),ioVariables ))=1 then flags:=flags or ACF_MSG_TTL; + end; + end; +{ + 2: begin + UTF8ToWide(GetParamSectionInt(node,ioTitle),msgtitle); + UTF8ToWide(GetParamSectionInt(node,ioText ),msgtext); + boxopts:=GetParamSectionInt(node,ioType); + + if GetParamSectionInt(node,ioArgVariable)=1 then flags:=flags or ACF_MSG_TXT; + if GetParamSectionInt(node,ioVariables )=1 then flags:=flags or ACF_MSG_TTL; + end; +} + end; +end; + +procedure tMessageAction.Save(node:pointer;fmt:integer); +var + section: array [0..127] of AnsiChar; + pc: pAnsiChar; +begin + inherited Save(node,fmt); + case fmt of + 0: begin + pc:=StrCopyE(section,pAnsiChar(node)); + StrCopy(pc,opt_msgtitle); DBWriteUnicode(0,DBBranch,section,msgtitle); + StrCopy(pc,opt_msgtext ); DBWriteUnicode(0,DBBranch,section,msgtext); + StrCopy(pc,opt_boxopts ); DBWriteDWord (0,DBBranch,section,boxopts); + end; +{ + 1: begin + end; +} + 13: begin + end; + end; +end; + +//----- Dialog realization ----- + +procedure SetMBRadioIcon(Dialog:HWND;h:THANDLE;id:dword;icon:uint_ptr); +begin + SendDlgItemMessage(Dialog,id,BM_SETIMAGE,IMAGE_ICON, + LoadImage(h,MAKEINTRESOURCE(icon),IMAGE_ICON,16,16,0{LR_SHARED})); +// SendDlgItemMessage(Dialog,id,BM_SETIMAGE,IMAGE_ICON,LoadIcon(0,icon)); +end; + +procedure SetMBRadioIcons(Dialog:HWND); +var + h:THANDLE; +begin + h:=LoadLibrary('user32.dll'); +// SetMBRadioIcon(IDC_MSGI_NONE,IDI_); //? + SetMBRadioIcon(Dialog,h,IDC_MSGI_ERROR,103{IDI_HAND}); + SetMBRadioIcon(Dialog,h,IDC_MSGI_QUEST,102{IDI_QUESTION}); + SetMBRadioIcon(Dialog,h,IDC_MSGI_WARN ,101{IDI_EXCLAMATION}); + SetMBRadioIcon(Dialog,h,IDC_MSGI_INFO ,104{IDI_ASTERISK}); + FreeLibrary(h); +end; + +procedure ClearFields(Dialog:HWND); +begin + CheckDlgButton(Dialog,IDC_MSG_RTL ,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_MSG_RIGHT,BST_UNCHECKED); + + CheckDlgButton(Dialog,IDC_MSGB_OK ,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_MSGB_OC ,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_MSGB_ARI,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_MSGB_YNC,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_MSGB_YN ,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_MSGB_RC ,BST_UNCHECKED); + + CheckDlgButton(Dialog,IDC_MSGI_NONE ,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_MSGI_ERROR,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_MSGI_QUEST,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_MSGI_WARN ,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_MSGI_INFO ,BST_UNCHECKED); +end; + +function DlgProc(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; +const + NoProcess:boolean=true; +begin + result:=0; + + case hMessage of + WM_INITDIALOG: begin + TranslateDialogDefault(Dialog); + + MakeEditField(Dialog,IDC_MSG_TITLE); + MakeEditField(Dialog,IDC_MSG_TEXT); + + SetMBRadioIcons(Dialog); + end; + + WM_ACT_SETVALUE: begin + NoProcess:=true; + ClearFields(Dialog); + with tMessageAction(lParam) do + begin + SetDlgItemTextW(Dialog,IDC_MSG_TITLE,msgtitle); + SetDlgItemTextW(Dialog,IDC_MSG_TEXT ,msgtext); + + SetEditFlags(Dialog,IDC_MSG_TITLE,EF_SCRIPT,ord((flags and ACF_MSG_TTL)<>0)); + SetEditFlags(Dialog,IDC_MSG_TEXT ,EF_SCRIPT,ord((flags and ACF_MSG_TXT)<>0)); + + if (boxopts and MB_RTLREADING)<>0 then CheckDlgButton(Dialog,IDC_MSG_RTL ,BST_CHECKED); + if (boxopts and MB_RIGHT )<>0 then CheckDlgButton(Dialog,IDC_MSG_RIGHT,BST_CHECKED); + + case boxopts and $0F of + MB_OKCANCEL : CheckDlgButton(Dialog,IDC_MSGB_OC ,BST_CHECKED); + MB_ABORTRETRYIGNORE : CheckDlgButton(Dialog,IDC_MSGB_ARI,BST_CHECKED); + MB_YESNOCANCEL : CheckDlgButton(Dialog,IDC_MSGB_YNC,BST_CHECKED); + MB_YESNO : CheckDlgButton(Dialog,IDC_MSGB_YN ,BST_CHECKED); + MB_RETRYCANCEL : CheckDlgButton(Dialog,IDC_MSGB_RC ,BST_CHECKED); +// MB_CANCELTRYCONTINUE: + else + CheckDlgButton(Dialog,IDC_MSGB_OK,BST_CHECKED); + end; + case boxopts and $F0 of + MB_ICONERROR : CheckDlgButton(Dialog,IDC_MSGI_ERROR,BST_CHECKED); + MB_ICONQUESTION : CheckDlgButton(Dialog,IDC_MSGI_QUEST,BST_CHECKED); + MB_ICONWARNING : CheckDlgButton(Dialog,IDC_MSGI_WARN ,BST_CHECKED); + MB_ICONINFORMATION: CheckDlgButton(Dialog,IDC_MSGI_INFO ,BST_CHECKED); + else + CheckDlgButton(Dialog,IDC_MSGI_NONE,BST_CHECKED); + end; + end; + NoProcess:=false; + end; + + WM_ACT_RESET: begin + NoProcess:=true; + ClearFields(Dialog); + + SetDlgItemTextW(Dialog,IDC_MSG_TITLE,nil); + SetDlgItemTextW(Dialog,IDC_MSG_TEXT ,nil); + SetEditFlags(Dialog,IDC_MSG_TITLE,EF_ALL,0); + SetEditFlags(Dialog,IDC_MSG_TEXT ,EF_ALL,0); + + CheckDlgButton(Dialog,IDC_MSGB_OK ,BST_CHECKED); + CheckDlgButton(Dialog,IDC_MSGI_NONE,BST_CHECKED); + NoProcess:=false; + end; + + WM_ACT_SAVE: begin + with tMessageAction(lParam) do + begin + {mFreeMem(msgtitle); }msgtitle:=GetDlgText(Dialog,IDC_MSG_TITLE); + {mFreeMem(msgtext ); }msgtext :=GetDlgText(Dialog,IDC_MSG_TEXT); + + if (GetEditFlags(Dialog,IDC_MSG_TITLE) and EF_SCRIPT)<>0 then flags:=flags or ACF_MSG_TTL; + if (GetEditFlags(Dialog,IDC_MSG_TEXT ) and EF_SCRIPT)<>0 then flags:=flags or ACF_MSG_TXT; + + if IsDlgButtonChecked(Dialog,IDC_MSG_RTL )=BST_CHECKED then boxopts:=boxopts or MB_RTLREADING; + if IsDlgButtonChecked(Dialog,IDC_MSG_RIGHT)=BST_CHECKED then boxopts:=boxopts or MB_RIGHT; + + if IsDlgButtonChecked(Dialog,IDC_MSGB_OC )=BST_CHECKED then boxopts:=boxopts or MB_OKCANCEL + else if IsDlgButtonChecked(Dialog,IDC_MSGB_ARI)=BST_CHECKED then boxopts:=boxopts or MB_ABORTRETRYIGNORE + else if IsDlgButtonChecked(Dialog,IDC_MSGB_YNC)=BST_CHECKED then boxopts:=boxopts or MB_YESNOCANCEL + else if IsDlgButtonChecked(Dialog,IDC_MSGB_YN )=BST_CHECKED then boxopts:=boxopts or MB_YESNO + else if IsDlgButtonChecked(Dialog,IDC_MSGB_RC )=BST_CHECKED then boxopts:=boxopts or MB_RETRYCANCEL + else{if IsDlgButtonChecked(Dialog,IDC_MSGB_OK )=BST_CHECKED then}boxopts:=boxopts or MB_OK; + + if IsDlgButtonChecked(Dialog,IDC_MSGI_ERROR)=BST_CHECKED then boxopts:=boxopts or MB_ICONHAND + else if IsDlgButtonChecked(Dialog,IDC_MSGI_QUEST)=BST_CHECKED then boxopts:=boxopts or MB_ICONQUESTION + else if IsDlgButtonChecked(Dialog,IDC_MSGI_WARN )=BST_CHECKED then boxopts:=boxopts or MB_ICONWARNING + else if IsDlgButtonChecked(Dialog,IDC_MSGI_INFO )=BST_CHECKED then boxopts:=boxopts or MB_ICONINFORMATION + ;//else if IsDlgButtonChecked(Dialog,IDC_MSGI_NONE)=BST_CHECKED then ; + end; + end; + + WM_COMMAND: begin + case wParam shr 16 of + EN_CHANGE, + BN_CLICKED: if not NoProcess then + SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0); + end; + end; + + WM_HELP: begin + MessageBoxW(0, + TranslateW( + 'Text replacing'#13#10+ + 'by last result'#13#10#13#10+ + 'Returns:'#13#10+ + '--------'#13#10+ + 'OK'#9'= 1'#13#10+ + 'CANCEL'#9'= 2'#13#10+ + 'ABORT'#9'= 3'#13#10+ + 'RETRY'#9'= 4'#13#10+ + 'IGNORE'#9'= 5'#13#10+ + 'YES'#9'= 6'#13#10+ + 'NO'#9'= 7'#13#10+ + 'CLOSE'#9'= 8'), + TranslateW('MessageBox'),0); + result:=1; + end; + end; +end; + +//----- Export/interface functions ----- + +var + vc:tActModule; + +function CreateAction:tBaseAction; +begin + result:=tMessageAction.Create(vc.Hash); +end; + +function CreateDialog(parent:HWND):HWND; +begin + result:=CreateDialogW(hInstance,'IDD_ACTMESSAGEBOX',parent,@DlgProc); +end; + +procedure Init; +begin + vc.Next :=ModuleLink; + + vc.Name :='MessageBox'; + vc.Dialog :=@CreateDialog; + vc.Create :=@CreateAction; + vc.Icon :='IDI_MESSAGE'; + vc.Hash :=0; + + ModuleLink :=@vc; +end; + +begin + Init; +end. diff --git a/plugins/Actman/iac_messagebox.rc b/plugins/Actman/iac_messagebox.rc new file mode 100644 index 0000000000..09710dfb2f --- /dev/null +++ b/plugins/Actman/iac_messagebox.rc @@ -0,0 +1,36 @@ +#include "i_cnst_message.inc" + +LANGUAGE 0,0 + +IDD_ACTMESSAGEBOX DIALOGEX 0, 0, 168, 200, 0 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0 +{ + RTEXT "Message title",-1, 2, 0, 164, 11, SS_CENTERIMAGE + EDITTEXT IDC_MSG_TITLE, 1, 12, 165, 12, ES_AUTOHSCROLL +// ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN + RTEXT "Message text" ,-1, 2, 26, 164, 11, SS_CENTERIMAGE + EDITTEXT IDC_MSG_TEXT , 1, 38, 165, 12, ES_AUTOHSCROLL +// ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN + + AUTOCHECKBOX "RTL" , IDC_MSG_RTL , 1, 54, 160, 11 + AUTOCHECKBOX "Right justified text", IDC_MSG_RIGHT, 1, 67, 160, 11 + + GROUPBOX "Icons" , -1 , 0, 89, 167, 30, WS_GROUP + AUTORADIOBUTTON "Error" , IDC_MSGI_ERROR, 5, 98, 24, 20, BS_ICON + AUTORADIOBUTTON "Question", IDC_MSGI_QUEST, 31, 98, 24, 20, BS_ICON + AUTORADIOBUTTON "Warning" , IDC_MSGI_WARN , 57, 98, 24, 20, BS_ICON + AUTORADIOBUTTON "Info" , IDC_MSGI_INFO , 83, 98, 24, 20, BS_ICON + AUTORADIOBUTTON "None" , IDC_MSGI_NONE , 109, 98, 53, 20//, BS_ICON + + GROUPBOX "Buttons" , -1, 0, 122, 167, 71, WS_GROUP + AUTORADIOBUTTON "OK" , IDC_MSGB_OK , 5, 131, 156, 10 + AUTORADIOBUTTON "OK, Cancel" , IDC_MSGB_OC , 5, 141, 156, 10 + AUTORADIOBUTTON "Abort, Retry, Ignore", IDC_MSGB_ARI, 5, 151, 156, 10 + AUTORADIOBUTTON "Yes, No, Cancel" , IDC_MSGB_YNC, 5, 161, 156, 10 + AUTORADIOBUTTON "Yes, No" , IDC_MSGB_YN , 5, 171, 156, 10 + AUTORADIOBUTTON "Retry, Cancel" , IDC_MSGB_RC , 5, 181, 156, 10 +} + +IDI_MESSAGE ICON "ico\message.ico" diff --git a/plugins/Actman/iac_messagebox.res b/plugins/Actman/iac_messagebox.res new file mode 100644 index 0000000000..70c7638087 Binary files /dev/null and b/plugins/Actman/iac_messagebox.res differ diff --git a/plugins/Actman/iac_notes.pas b/plugins/Actman/iac_notes.pas new file mode 100644 index 0000000000..182e1aba9e --- /dev/null +++ b/plugins/Actman/iac_notes.pas @@ -0,0 +1,173 @@ +unit iac_notes; + +interface + +implementation + +uses + windows, messages, commctrl, + common, wrapper, + mirutils, dbsettings, m_api, + global, iac_global; + +{$include i_cnst_notes.inc} +{$resource iac_notes.res} + +const + opt_text = 'text'; + +type + tNotesAction = class(tBaseAction) + private + note:PWideChar; + public + constructor Create(uid:dword); + destructor Destroy; override; +// function Clone:tBaseAction; override; + function DoAction(var WorkData:tWorkData):LRESULT; override; + procedure Save(node:pointer;fmt:integer); override; + procedure Load(node:pointer;fmt:integer); override; + end; + +//----- Support functions ----- + +//----- Object realization ----- + +constructor tNotesAction.Create(uid:dword); +begin + inherited Create(uid); +end; + +destructor tNotesAction.Destroy; +begin + + inherited Destroy; +end; + +function tNotesAction.DoAction(var WorkData:tWorkData):LRESULT; +begin + result:=0; +end; + +procedure tNotesAction.Load(node:pointer;fmt:integer); +var + section: array [0..127] of AnsiChar; + pc:pAnsiChar; +begin + inherited Load(node,0); + case fmt of + 0: begin + pc:=StrCopyE(section,pAnsiChar(node)); + StrCopy(pc,opt_text); note:=DBReadUnicode(0,DBBranch,section,nil); + end; +{ + 1: begin + end; +} + end; +end; + +procedure tNotesAction.Save(node:pointer;fmt:integer); +var + section: array [0..127] of AnsiChar; + pc:pAnsiChar; +begin + inherited Save(node,fmt); + case fmt of + 0: begin + pc:=StrCopyE(section,pAnsiChar(node)); + StrCopy(pc,opt_text); DBWriteUnicode(0,DBBranch,section,note); + end; +{ + 1: begin + end; +} + end; +end; + +//----- Dialog realization ----- + +procedure ClearFields(Dialog:HWND); +begin + SetDlgItemTextW(Dialog,IDC_TXT_TEXT,nil); +end; + +function DlgProc(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; +const + NoProcess:boolean=true; +begin + result:=0; + + case hMessage of + WM_INITDIALOG: begin + TranslateDialogDefault(Dialog); + end; + + WM_ACT_SETVALUE: begin + NoProcess:=true; + ClearFields(Dialog); + with tNotesAction(lParam) do + begin + SetDlgItemTextW(Dialog,IDC_TXT_TEXT,note); + end; + NoProcess:=false; + end; + + WM_ACT_RESET: begin + NoProcess:=true; + ClearFields(Dialog); + NoProcess:=false; + end; + + WM_ACT_SAVE: begin + with tNotesAction(lParam) do + begin + flags:=0; + note:=GetDlgText(Dialog,IDC_TXT_TEXT); + end; + end; + + WM_COMMAND: begin + case wParam shr 16 of + EN_CHANGE: if not NoProcess then + SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0); + end; + end; + + WM_HELP: begin + result:=1; + end; + + end; +end; + +//----- Export/interface functions ----- + +var + vc:tActModule; + +function CreateAction:tBaseAction; +begin + result:=tNotesAction.Create(vc.Hash); +end; + +function CreateDialog(parent:HWND):HWND; +begin + result:=CreateDialogW(hInstance,'IDD_ACTNOTES',parent,@DlgProc); +end; + +procedure Init; +begin + vc.Next :=ModuleLink; + + vc.Name :='Notes'; + vc.Dialog :=@CreateDialog; + vc.Create :=@CreateAction; + vc.Icon :='IDI_NOTES'; + + ModuleLink :=@vc; +end; + +begin + Init; +end. diff --git a/plugins/Actman/iac_notes.rc b/plugins/Actman/iac_notes.rc new file mode 100644 index 0000000000..a9ca1bc5ef --- /dev/null +++ b/plugins/Actman/iac_notes.rc @@ -0,0 +1,13 @@ +#include "i_cnst_notes.inc" + +LANGUAGE 0,0 + +IDD_ACTNOTES DIALOGEX 0, 0, 168, 200, 0 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0 +{ + EDITTEXT IDC_TXT_TEXT, 1, 4, 166, 192, ES_AUTOHSCROLL +} + +IDI_NOTES ICON "ico\notes.ico" diff --git a/plugins/Actman/iac_notes.res b/plugins/Actman/iac_notes.res new file mode 100644 index 0000000000..72d05137cd Binary files /dev/null and b/plugins/Actman/iac_notes.res differ diff --git a/plugins/Actman/iac_program.pas b/plugins/Actman/iac_program.pas new file mode 100644 index 0000000000..33924c4279 --- /dev/null +++ b/plugins/Actman/iac_program.pas @@ -0,0 +1,520 @@ +unit iac_program; + +interface + +implementation + +uses + editwrapper, + windows, messages, commctrl, + global, iac_global, m_api, wrapper, syswin, + mirutils, mircontacts, common, dbsettings; + +{$include i_cnst_program.inc} +{$resource iac_program.res} + +const + ACF_CURPATH = $00000001; // Current (not program) path + ACF_PRTHREAD = $00000002; // parallel Program + ACF_PRG_PRG = $00000004; // script for program path + ACF_PRG_ARG = $00000008; // script for program args + +const // V2 + ACF_OLD_CURPATH = $00000002; + ACF_OLD_PRTHREAD = $00000004; + ACF2_PRG_PRG = $00000001; + ACF2_PRG_ARG = $00000002; + +const + opt_prg = 'program'; + opt_args = 'arguments'; + opt_time = 'time'; + opt_show = 'show'; +const + ioArgs = 'args'; + ioProgram = 'program'; + ioCurrent = 'current'; + ioParallel = 'parallel'; + ioWait = 'wait'; + ioFileVariable = 'modvariables'; + ioArgVariable = 'argvariables'; + ioWindow = 'window'; + ioHidden = 'hidden'; + ioMinimized = 'minimized'; + ioMaximized = 'maximized'; +type + tProgramAction = class(tBaseAction) + private + prgname:pWideChar; + args :pWideChar; + show :dword; + time :dword; + public + constructor Create(uid:dword); + destructor Destroy; override; +// function Clone:tBaseAction; override; + function DoAction(var WorkData:tWorkData):LRESULT; override; + procedure Save(node:pointer;fmt:integer); override; + procedure Load(node:pointer;fmt:integer); override; + end; + +//----- Support functions ----- + +function replany(var str:pWideChar;aparam:LPARAM;alast:pWideChar):boolean; +var + buf:array [0..31] of WideChar; + tmp:pWideChar; +begin + if StrScanW(str,'<')<>nil then + begin + result:=true; + mGetMem(tmp,2048); + StrCopyW(tmp,str); + StrReplaceW(tmp,'',IntToStr(buf,aparam)); + StrReplaceW(tmp,'' ,alast); + + str:=tmp; + end + else + result:=false; +end; + +//----- Object realization ----- + +constructor tProgramAction.Create(uid:dword); +begin + inherited Create(uid); + + show :=0; + time :=0; + prgname:=nil; + args :=nil; +end; + +destructor tProgramAction.Destroy; +begin + mFreeMem(prgname); + mFreeMem(args); + + inherited Destroy; +end; +{ +function tProgramAction.Clone:tBaseAction; +begin + result:=tProgramAction.Create(0); + Duplicate(result); + + tProgramAction(result).show :=show; + tProgramAction(result).time :=time; + StrDupW(tProgramAction(result).prgname,prgname); + StrDupW(tProgramAction(result).args ,args); +end; +} +function tProgramAction.DoAction(var WorkData:tWorkData):LRESULT; +var + tmp,tmpp,lpath:PWideChar; + replPrg ,replArg :PWideChar; + replPrg1,replArg1:PWideChar; + pd:LPARAM; + vars1,vars2,prgs,argss:boolean; + buf:array [0..31] of WideChar; +begin + result:=0; + + if WorkData.ResultType=rtInt then + begin + StrDupW(pWideChar(WorkData.LastResult),IntToStr(buf,WorkData.LastResult)); + WorkData.ResultType:=rtWide; + end; + + replPrg:=prgname; + prgs :=replany(replPrg,WorkData.Parameter,pWideChar(WorkData.LastResult)); + + replArg:=args; + argss :=replany(replArg,WorkData.Parameter,pWideChar(WorkData.LastResult)); + + if ((flags and ACF_PRG_PRG)<>0) or + ((flags and ACF_PRG_ARG)<>0) then + begin + if CallService(MS_DB_CONTACT_IS,WorkData.Parameter,0)<>0 then + pd:=WorkData.Parameter + else + pd:=WndToContact(WaitFocusedWndChild(GetForegroundwindow){GetFocus}); + if (pd=0) and (WorkData.Parameter<>0) then + pd:=WorkData.Parameter; + end; + + if (flags and ACF_PRG_ARG)<>0 then + begin + vars2:=true; + tmp :=ParseVarString(replArg,pd,pWideChar(WorkData.LastResult)); + end + else + begin + vars2:=false; + tmp :=replArg; + end; + + if (flags and ACF_PRG_PRG)<>0 then + begin + vars1:=true; + tmpp :=ParseVarString(replPrg,pd,pWideChar(WorkData.LastResult)); + end + else + begin + vars1:=false; + tmpp:=replPrg; + end; + + if StrScanW(tmpp,'%')<>nil then + begin + mGetMem(replPrg1,8192*SizeOf(WideChar)); + ExpandEnvironmentStringsW(tmpp,replPrg1,8191); + if vars1 then mFreeMem(tmpp); + if prgs then mFreeMem(replPrg); + tmpp :=replPrg1; + prgs :=false; + vars1:=true; + end; + if StrScanW(tmp,'%')<>nil then + begin + mGetMem(replArg1,8192*SizeOf(WideChar)); + ExpandEnvironmentStringsW(tmp,replArg1,8191); + if vars2 then mFreeMem(tmp); + if argss then mFreeMem(replArg); + tmp :=replArg1; + argss:=false; + vars2:=true; + end; + + if (flags and ACF_CURPATH)=0 then + lpath:=ExtractW(tmpp,false) + else + lpath:=nil; + + if (flags and ACF_PRTHREAD)<>0 then + time:=0 + else if time=0 then + time:=INFINITE; + WorkData.LastResult:=ExecuteWaitW(tmpp,tmp,lpath,show,time,@pd); + WorkData.ResultType:=rtInt; + + if vars2 then mFreeMem(tmp); + if vars1 then mFreeMem(tmpp); + + if prgs then mFreeMem(replPrg); + if argss then mFreeMem(replArg); + + mFreeMem(lpath); +end; + +procedure tProgramAction.Load(node:pointer;fmt:integer); +var + section: array [0..127] of AnsiChar; + pc:pAnsiChar; + tmp:pWideChar; + flags2,lflags:dword; +begin + inherited Load(node,fmt); + case fmt of + 0: begin + pc:=StrCopyE(section,pAnsiChar(node)); + StrCopy(pc,opt_prg ); prgname:=DBReadUnicode(0,DBBranch,section,nil); + StrCopy(pc,opt_args); args :=DBReadUnicode(0,DBBranch,section,nil); + StrCopy(pc,opt_time); time :=DBReadDWord (0,DBBranch,section,0); + StrCopy(pc,opt_show); show :=DBReadDWord (0,DBBranch,section,SW_SHOW); + end; + + 100: begin + pc:=StrCopyE(section,pAnsiChar(node)); + StrCopy(pc,opt_prg ); prgname:=DBReadUnicode(0,DBBranch,section,nil); + StrCopy(pc,opt_args); args :=DBReadUnicode(0,DBBranch,section,nil); + StrCopy(pc,opt_time); time :=DBReadDWord (0,DBBranch,section,0); + StrCopy(pc,opt_show); show :=DBReadDWord (0,DBBranch,section,SW_SHOW); + + StrCopy(pc,'flags2'); flags2:=DBReadDWord(0,DBBranch,section,0); + lflags:=flags; + flags:=flags and not ACF_MASK; + + if (lflags and ACF_OLD_CURPATH )<>0 then flags:=flags or ACF_CURPATH; + if (lflags and ACF_OLD_PRTHREAD)<>0 then flags:=flags or ACF_PRTHREAD; + + if (flags2 and ACF2_PRG_PRG)<>0 then flags:=flags or ACF_PRG_PRG; + if (flags2 and ACF2_PRG_ARG)<>0 then flags:=flags or ACF_PRG_ARG; + end; + + 1: begin + with xmlparser do + begin + StrDupW(prgname,getText(HXML(node))); + StrDupW(args,getAttrValue(HXML(node),ioArgs)); + if StrToInt(getAttrValue(HXML(node),ioCurrent))=1 then + flags:=flags or ACF_CURPATH; + + if StrToInt(getAttrValue(HXML(node),ioParallel))=1 then + flags:=flags or ACF_PRTHREAD + else + time:=StrToInt(getAttrValue(HXML(node),ioWait)); + + if StrToInt(getAttrValue(HXML(node),ioFileVariable))=1 then + flags:=flags or ACF_PRG_PRG; + + if StrToInt(getAttrValue(HXML(node),ioArgVariable))=1 then + flags:=flags or ACF_PRG_ARG; + + tmp:=getAttrValue(HXML(node),ioWindow); + if lstrcmpiw(tmp,ioHidden )=0 then show:=SW_HIDE + else if lstrcmpiw(tmp,ioMinimized)=0 then show:=SW_SHOWMINIMIZED + else if lstrcmpiw(tmp,ioMaximized)=0 then show:=SW_SHOWMAXIMIZED + else show:=SW_SHOWNORMAL; + end; + end; +{ + 2: begin + UTF8ToWide(GetParamSectionStr(node,ioProgram),prgname); + UTF8ToWide(GetParamSectionStr(node,ioArgs ),args); + if GetParamSectionInt(node,ioCurrent)=1 then + flags:=flags or ACF_CURPATH; + + if GetParamSectionInt(node,ioParallel)=1 then + flags:=flags or ACF_PRTHREAD + else + time:=GetParamSectionInt(node,ioWait); + + if GetParamSectionInt(node,ioFileVariable)=1 then + flags:=flags or ACF_PRG_PRG; + + if GetParamSectionInt(node,ioArgVariable)=1 then + flags:=flags or ACF_PRG_ARG; + + pc:=GetParamSectionStr(node,ioWindow); + if lstrcmpi(pc,ioHidden )=0 then show:=SW_HIDE + else if lstrcmpi(pc,ioMinimized)=0 then show:=SW_SHOWMINIMIZED + else if lstrcmpi(pc,ioMaximized)=0 then show:=SW_SHOWMAXIMIZED + else show:=SW_SHOWNORMAL; + end; +} + end; +end; + +procedure tProgramAction.Save(node:pointer;fmt:integer); +var + section: array [0..127] of AnsiChar; + pc:pAnsiChar; +begin + inherited Save(node,fmt); + case fmt of + 0: begin + pc:=StrCopyE(section,pAnsiChar(node)); + StrCopy(pc,opt_prg ); DBWriteUnicode(0,DBBranch,section,prgname); + StrCopy(pc,opt_args); DBWriteUnicode(0,DBBranch,section,args); + StrCopy(pc,opt_time); DBWriteDWord (0,DBBranch,section,time); + StrCopy(pc,opt_show); DBWriteDWord (0,DBBranch,section,show); + end; +{ + 1: begin + end; +} + 13: begin + end; + end; +end; + +//----- Dialog realization ----- + +procedure MakeFileEncList(wnd:HWND); +begin + SendMessage(wnd,CB_RESETCONTENT,0,0); +{ + InsertString(wnd,0,'Ansi'); + InsertString(wnd,1,'UTF8'); + InsertString(wnd,2,'UTF8+sign'); + InsertString(wnd,3,'UTF16'); + InsertString(wnd,4,'UTF16+sign'); +} + SendMessage(wnd,CB_SETCURSEL,0,0); +end; + +procedure ClearFields(Dialog:HWND); +begin + CheckDlgButton(Dialog,IDC_FLAG_NORMAL,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_FLAG_HIDDEN,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_FLAG_MINIMIZE,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_FLAG_MAXIMIZE,BST_UNCHECKED); + + CheckDlgButton(Dialog,IDC_FLAG_CURPATH,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_FLAG_CONTINUE,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_FLAG_PARALLEL,BST_UNCHECKED); +end; + +function FillFileName(Dialog:HWND;idc:integer):boolean; +var + pw,ppw:pWideChar; +begin + mGetMem(pw,1024*SizeOf(WideChar)); + ppw:=GetDlgText(Dialog,idc); + result:=ShowDlgW(pw,ppw); + if result then + begin + SetDlgItemTextW(Dialog,idc,pw); + SetEditFlags(Dialog,idc,EF_SCRIPT,0); + end; + mFreeMem(ppw); + mFreeMem(pw); +end; + +function DlgProc(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; +const + NoProcess:boolean=true; +begin + result:=0; + + case hMessage of + WM_INITDIALOG: begin + TranslateDialogDefault(Dialog); + + MakeEditField(Dialog,IDC_EDIT_PRGPATH); + MakeEditField(Dialog,IDC_EDIT_PRGARGS); + end; + + WM_ACT_SETVALUE: begin + NoProcess:=true; + ClearFields(Dialog); + + with tProgramAction(lParam) do + begin + SetDlgItemTextW(Dialog,IDC_EDIT_PRGPATH ,prgname); + SetDlgItemTextW(Dialog,IDC_EDIT_PRGARGS ,args); + + SetEditFlags(Dialog,IDC_EDIT_PRGPATH,EF_SCRIPT,ord((flags and ACF_PRG_PRG)<>0)); + SetEditFlags(Dialog,IDC_EDIT_PRGARGS,EF_SCRIPT,ord((flags and ACF_PRG_ARG)<>0)); + + SetDlgItemInt(Dialog,IDC_EDIT_PROCTIME,time,false); + case show of + SW_HIDE : CheckDlgButton(Dialog,IDC_FLAG_HIDDEN,BST_CHECKED); + SW_SHOWMINIMIZED: CheckDlgButton(Dialog,IDC_FLAG_MINIMIZE,BST_CHECKED); + SW_SHOWMAXIMIZED: CheckDlgButton(Dialog,IDC_FLAG_MAXIMIZE,BST_CHECKED); + else + {SW_SHOWNORMAL :} CheckDlgButton(Dialog,IDC_FLAG_NORMAL,BST_CHECKED); + end; + if (flags and ACF_CURPATH)<>0 then + CheckDlgButton(Dialog,IDC_FLAG_CURPATH,BST_CHECKED); + if (flags and ACF_PRTHREAD)<>0 then + CheckDlgButton(Dialog,IDC_FLAG_PARALLEL,BST_CHECKED) + else + CheckDlgButton(Dialog,IDC_FLAG_CONTINUE,BST_CHECKED); + end; + NoProcess:=false; + end; + + WM_ACT_RESET: begin + NoProcess:=true; + ClearFields(Dialog); + + SetDlgItemTextW(Dialog,IDC_EDIT_PRGPATH,nil); + SetDlgItemTextW(Dialog,IDC_EDIT_PRGARGS,nil); + SetEditFlags(Dialog,IDC_EDIT_PRGPATH,EF_ALL,0); + SetEditFlags(Dialog,IDC_EDIT_PRGARGS,EF_ALL,0); + + CheckDlgButton(Dialog,IDC_FLAG_PARALLEL,BST_CHECKED); + CheckDlgButton(Dialog,IDC_FLAG_NORMAL ,BST_CHECKED); + SetDlgItemInt(Dialog,IDC_EDIT_PROCTIME,0,false); + NoProcess:=false; + end; + + WM_ACT_SAVE: begin + with tProgramAction(lParam) do + begin + {mFreeMem(prgname); }prgname:=GetDlgText(Dialog,IDC_EDIT_PRGPATH); + {mFreeMem(args ); }args :=GetDlgText(Dialog,IDC_EDIT_PRGARGS); +{ + p:=GetDlgText(IDC_EDIT_PRGPATH); + if p<>nil then + begin + CallService(MS_UTILS_PATHTORELATIVE,dword(p),dword(@buf)); + StrDupW(prgname,@buf); + mFreeMem(p); + end; +} + if IsDlgButtonChecked(Dialog,IDC_FLAG_PARALLEL)=BST_CHECKED then + flags:=flags or ACF_PRTHREAD; + if IsDlgButtonChecked(Dialog,IDC_FLAG_CURPATH)=BST_CHECKED then + flags:=flags or ACF_CURPATH; + + time:=GetDlgItemInt(Dialog,IDC_EDIT_PROCTIME,pbool(nil)^,false); + + if IsDlgButtonChecked(Dialog,IDC_FLAG_MINIMIZE)=BST_CHECKED then + show:=SW_SHOWMINIMIZED + else if IsDlgButtonChecked(Dialog,IDC_FLAG_MAXIMIZE)=BST_CHECKED then + show:=SW_SHOWMAXIMIZED + else if IsDlgButtonChecked(Dialog,IDC_FLAG_HIDDEN)=BST_CHECKED then + show:=SW_HIDE + else //if IsDlgButtonChecked(Dialog,IDC_FLAG_NORMAL)=BST_CHECKED then + show:=SW_SHOWNORMAL; + + if (GetEditFlags(Dialog,IDC_EDIT_PRGPATH) and EF_SCRIPT)<>0 then flags:=flags or ACF_PRG_PRG; + if (GetEditFlags(Dialog,IDC_EDIT_PRGARGS) and EF_SCRIPT)<>0 then flags:=flags or ACF_PRG_ARG; + end; + end; + + WM_COMMAND: begin + case wParam shr 16 of + EN_CHANGE: if not NoProcess then + SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0); + + BN_CLICKED: begin + case loword(wParam) of + IDC_PROGRAM: begin + if not FillFileName(Dialog,IDC_EDIT_PRGPATH) then + exit; + end; + end; + SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0); + end; + end; + end; + + WM_HELP: begin + MessageBoxW(0, + TranslateW('Text replacing'#13#10+ + 'by last result'#13#10#13#10+ + 'Text replacing'#13#10+ + 'by parameter'), + TranslateW('Text'),0); + result:=1; + end; + + end; +end; + +//----- Export/interface functions ----- + +var + vc:tActModule; + +function CreateAction:tBaseAction; +begin + result:=tProgramAction.Create(vc.Hash); +end; + +function CreateDialog(parent:HWND):HWND; +begin + result:=CreateDialogW(hInstance,'IDD_ACTPROGRAM',parent,@DlgProc); +end; + +procedure Init; +begin + vc.Next :=ModuleLink; + + vc.Name :='Program'; + vc.Dialog :=@CreateDialog; + vc.Create :=@CreateAction; + vc.Icon :='IDI_PROGRAM'; + vc.Hash :=0; + + ModuleLink :=@vc; +end; + +begin + Init; +end. diff --git a/plugins/Actman/iac_program.rc b/plugins/Actman/iac_program.rc new file mode 100644 index 0000000000..0460c5c9ac --- /dev/null +++ b/plugins/Actman/iac_program.rc @@ -0,0 +1,31 @@ +#include "i_cnst_program.inc" + +LANGUAGE 0,0 + +IDD_ACTPROGRAM DIALOGEX 0, 0, 168, 200, 0 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0 +{ + GROUPBOX "Process options" , -1, 1, 4, 166, 46, WS_GROUP + AUTORADIOBUTTON "Parallel" , IDC_FLAG_PARALLEL, 4, 13, 161, 11 + AUTORADIOBUTTON "Continued" , IDC_FLAG_CONTINUE, 4, 24, 161, 11 + EDITTEXT IDC_EDIT_PROCTIME, 4, 36, 31, 11, ES_RIGHT | ES_NUMBER + LTEXT "Process time, ms", -1, 37, 36, 128, 11, SS_CENTERIMAGE + + AUTOCHECKBOX "Current path" , IDC_FLAG_CURPATH, 4, 52, 161, 11 + + GROUPBOX "Window option" , -1, 1, 63, 166, 55, WS_GROUP + AUTORADIOBUTTON "Start normal" , IDC_FLAG_NORMAL , 4, 72, 162, 11 + AUTORADIOBUTTON "Start hidden" , IDC_FLAG_HIDDEN , 4, 83, 162, 11 + AUTORADIOBUTTON "Start minimized", IDC_FLAG_MINIMIZE, 4, 94, 162, 11 + AUTORADIOBUTTON "Start maximized", IDC_FLAG_MAXIMIZE, 4, 105, 162, 11 + + RTEXT "Program path", -1, 1, 135, 160, 8 + EDITTEXT IDC_EDIT_PRGPATH, 1, 144, 148, 12, ES_AUTOHSCROLL + PUSHBUTTON "..." , IDC_PROGRAM , 151, 144, 16, 12 + RTEXT "Program args", -1, 1, 159, 160, 8 + EDITTEXT IDC_EDIT_PRGARGS, 1, 168, 166, 12, ES_AUTOHSCROLL +} + +IDI_PROGRAM ICON "ico\program.ico" diff --git a/plugins/Actman/iac_program.res b/plugins/Actman/iac_program.res new file mode 100644 index 0000000000..a7754455b4 Binary files /dev/null and b/plugins/Actman/iac_program.res differ diff --git a/plugins/Actman/iac_service.pas b/plugins/Actman/iac_service.pas new file mode 100644 index 0000000000..205bc67a6f --- /dev/null +++ b/plugins/Actman/iac_service.pas @@ -0,0 +1,676 @@ +unit iac_service; + +interface + +implementation + +uses + windows, messages, commctrl, + global, iac_global, + m_api, + sedit,strans,mApiCardM, + mirutils,mircontacts,dbsettings, editwrapper, + sparam,srvblock, + syswin,wrapper,common; + +{$resource iac_service.res} + +const + ACF_PARNUM = $00000001; // Param is number + ACF_UNICODE = $00000002; // Param is Unicode string + ACF_CURRENT = $00000004; // Param is ignored, used current user handle + // from current message window + ACF_RESULT = $00000008; // Param is previous action result + ACF_PARAM = $00000010; // Param is Call parameter + ACF_STRUCT = $00000020; + ACF_PARTYPE = ACF_PARNUM or ACF_UNICODE or + ACF_CURRENT or ACF_RESULT or + ACF_PARAM or ACF_STRUCT; + + ACF_RSTRING = $00010000; // Service result is string + ACF_RUNICODE = $00020000; // Service result is Widestring + ACF_RSTRUCT = $00040000; // Service result in structure + ACF_RFREEMEM = $00080000; // Need to free memory +{ + ACF_SCRIPT_PARAM set in "sparam" unit + ACF_SCRIPT_SERVICE set in "srvblock" unit +} + // dummy + ACF_STRING = 0; + +const // V2 + ACF2_SRV_WPAR = $00000001; + ACF2_SRV_LPAR = $00000002; + ACF2_SRV_SRVC = $00000004; + ACF2_FREEMEM = $00000100; + ACF_OLD_WPARNUM = $00000001; + ACF_OLD_LPARNUM = $00000002; + ACF_OLD_WUNICODE = $00000004; + ACF_OLD_LUNICODE = $00000008; + ACF_OLD_WCURRENT = $00000010; + ACF_OLD_LCURRENT = $00000020; + ACF_OLD_WPARHEX = $00000040; + ACF_OLD_LPARHEX = $00000080; + + ACF_OLD_WRESULT = $00010000; + ACF_OLD_LRESULT = $00020000; + ACF_OLD_WPARAM = $00040000; + ACF_OLD_LPARAM = $00080000; + ACF_OLD_WSTRUCT = $00100000; + ACF_OLD_LSTRUCT = $00200000; + + ACF_OLD_STRING = $00000800; + ACF_OLD_UNICODE = $00001000; + ACF_OLD_STRUCT = $00008000; + +const + opt_service = 'service'; + opt_flags2 = 'flags2'; + opt_wparam = 'wparam'; + opt_lparam = 'lparam'; +const + ioService = 'service'; + ioType = 'type'; + ioResult = 'result'; + ioCurrent = 'current'; + ioParam = 'param'; + ioStruct = 'struct'; + ioValue = 'value'; + ioNumber = 'number'; + ioUnicode = 'unicode'; + ioVariables = 'variables'; + ioWParam = 'WPARAM'; + ioLParam = 'LPARAM'; + ioOutput = 'OUTPUT'; + ioFree = 'free'; + ioAnsi = 'ansi'; + ioInt = 'int'; + +type + tServiceAction = class(tBaseAction) + private + service:PAnsiChar; + wparam :pWideChar; + lparam :pWideChar; + flags2 :dword; + public + constructor Create(uid:dword); + destructor Destroy; override; +// function Clone:tBaseAction; override; + function DoAction(var WorkData:tWorkData):LRESULT; override; + procedure Save(node:pointer;fmt:integer); override; + procedure Load(node:pointer;fmt:integer); override; + end; + +//----- Support functions ----- + +//----- Object realization ----- + +constructor tServiceAction.Create(uid:dword); +begin + inherited Create(uid); +end; + +procedure ClearParam(flags:dword; var param); +begin + if (flags and (ACF_CURRENT or ACF_RESULT or ACF_PARAM))=0 then + mFreeMem(pointer(param)); +end; + +destructor tServiceAction.Destroy; +begin + mFreeMem(service); + ClearParam(flags ,wparam); + ClearParam(flags2,lparam); + + inherited Destroy; +end; +{ +function tServiceAction.Clone:tBaseAction; +begin + result:=tServiceAction.Create(0); + Duplicate(result); + + tServiceAction(result).flags2 :=flags2; + StrDup(tServiceAction(result).service,service); + + if (flags and (ACF_PARNUM or ACF_RESULT or ACF_PARAM))=0 then + StrDup(pAnsiChar(tServiceAction(result).wparam),pAnsiChar(wparam)) + else if ((flags and ACF_PARNUM)<>0) and ((flags and ACF_SCRIPT_PARAM)<>0) then + StrDup(pAnsiChar(tServiceAction(result).wparam),pAnsiChar(wparam)) + else + tServiceAction(result).wparam:=wparam; + + if (flags2 and (ACF_PARNUM or ACF_RESULT or ACF_PARAM))=0 then + StrDup(pAnsiChar(tServiceAction(result).lparam),pAnsiChar(lparam)) + else if ((flags2 and ACF_PARNUM)<>0) and ((flags and ACF_SCRIPT_PARAM)<>0) then + StrDup(pAnsiChar(tServiceAction(result).lparam),pAnsiChar(lparam)) + else + tServiceAction(result).lparam:=lparam; +end; +} +procedure PreProcess(flags:dword;var l_param:LPARAM;const WorkData:tWorkData); +var + tmp1:pWideChar; +begin + with WorkData do + begin + if (flags and ACF_STRUCT)<>0 then + begin + l_param:=uint_ptr(MakeStructure(pAnsiChar(l_param),Parameter,LastResult,ResultType)) + end + else if (flags and ACF_PARAM)<>0 then + begin + l_param:=Parameter; + end + else if (flags and ACF_RESULT)<>0 then + begin + l_param:=LastResult; + end + else if (flags and ACF_CURRENT)<>0 then + begin + l_param:=WndToContact(WaitFocusedWndChild(GetForegroundwindow){GetFocus}); + end + else + begin + if (flags and ACF_SCRIPT_PARAM)<>0 then + l_param:=uint_ptr(ParseVarString(pWideChar(l_param),Parameter)); + + tmp1:=pWideChar(l_param); + if (flags and ACF_PARNUM)=0 then + begin + if (flags and ACF_UNICODE)=0 then + WideToAnsi(tmp1,pAnsiChar(l_param),MirandaCP) + else + StrDupW(pWideChar(l_param),tmp1); + end + else + l_param:=NumToInt(tmp1); + + if (flags and ACF_SCRIPT_PARAM)<>0 then + mFreeMem(tmp1); + end; + end; +end; + +procedure PostProcess(flags:dword;var l_param:LPARAM; var WorkData:tWorkData); +var + code:integer; + len:integer; + pc:pAnsiChar; +begin + if (flags and ACF_STRUCT)<>0 then + begin + with WorkData do + begin + LastResult:=GetStructureResult(l_param,@code,@len); + case code of +{ + SST_LAST: begin + result:=LastResult; + end; +} + SST_PARAM: begin //?? + LastResult:=Parameter; + ResultType:=rtInt; + end; + SST_BYTE,SST_WORD,SST_DWORD, + SST_QWORD,SST_NATIVE: begin + ResultType:=rtInt; + end; + SST_BARR: begin + StrDup(pAnsiChar(pc),pAnsiChar(LastResult),len); + AnsiToWide(pAnsiChar(pc),PWideChar(LastResult),MirandaCP); + mFreeMem(pAnsiChar(pc)); + ResultType:=rtWide; + end; + SST_WARR: begin + StrDupW(pWideChar(LastResult),pWideChar(LastResult),len); + ResultType:=rtWide; + end; + SST_BPTR: begin + AnsiToWide(pAnsiChar(LastResult),pWideChar(LastResult),MirandaCP); + ResultType:=rtWide; + end; + SST_WPTR: begin + StrDupW(pWideChar(LastResult),pWideChar(LastResult)); + ResultType:=rtWide; + end; + end; + FreeStructure(l_param); + l_param:=0; + end + end; +end; + +function tServiceAction.DoAction(var WorkData:tWorkData):LRESULT; +var + buf:array [0..255] of AnsiChar; + lservice:pAnsiChar; + lwparam,llparam:TLPARAM; + res:int_ptr; +begin + result:=0; + + lservice:=service; + lwparam :=TLPARAM(wparam); + llparam :=TLPARAM(lparam); + // Service name processing + if (flags and ACF_SCRIPT_SERVICE)<>0 then + lservice:=ParseVarString(lservice,WorkData.Parameter); + + StrCopy(buf,lservice); + if StrPos(lservice,protostr)<>nil then + if CallService(MS_DB_CONTACT_IS,WorkData.Parameter,0)=0 then + begin + if (flags and ACF_SCRIPT_SERVICE)<>0 then + mFreeMem(lservice); + exit; + end + else + StrReplace(buf,protostr,GetContactProtoAcc(WorkData.Parameter)); + + if ServiceExists(buf)<>0 then + begin + + PreProcess(flags ,lwparam,WorkData); + PreProcess(flags2,llparam,WorkData); + + res:=CallServiceSync(buf,lwparam,llparam); + ClearResult(WorkData); + + // result type processing + if (flags and (ACF_RSTRING or ACF_UNICODE))<>0 then + begin +//!! delete old or not? + if (flags and ACF_RUNICODE)=0 then + AnsiToWide(pAnsiChar(res),pWideChar(WorkData.LastResult),MirandaCP) + else + StrDupW(pWideChar(WorkData.LastResult),pWideChar(res)); + WorkData.ResultType:=rtWide; + + if (flags and ACF_RFREEMEM)<>0 then + mFreeMem(pAnsiChar(res)); //?? Miranda MM?? + end + else if (flags and ACF_RSTRUCT)=0 then + WorkData.ResultType:=rtInt + else if (flags and ACF_RSTRUCT)<>0 then + begin + PostProcess(flags ,lwparam,WorkData); + PostProcess(flags2,llparam,WorkData); + end; + + // free string (ansi+unicode) parameters + if ((flags and ACF_PARTYPE)=ACF_STRING) or + ((flags and ACF_PARTYPE)=ACF_UNICODE) then + mFreeMem(pointer(lwparam)); + if ((flags2 and ACF_PARTYPE)=ACF_STRING) or + ((flags2 and ACF_PARTYPE)=ACF_UNICODE) then + mFreeMem(pointer(llparam)); + end; + if (flags and ACF_SCRIPT_SERVICE)<>0 then + mFreeMem(lservice); +end; + +procedure LoadParam(section:PAnsiChar;flags:dword; var param:pointer); +begin + if (flags and (ACF_CURRENT or ACF_RESULT or ACF_PARAM))=0 then + begin + if (flags and ACF_STRUCT)<>0 then + param:=DBReadUTF8(0,DBBranch,section,nil) + else + param:=DBReadUnicode(0,DBBranch,section,nil); + end; +end; + +function ReadParam(act:HXML; var param:pWideChar;isvar:boolean):dword; +var + tmp:pWideChar; +begin + result:=0; + if act=0 then + exit; + with xmlparser do + begin + tmp:=getAttrValue(act,ioType); + if lstrcmpiw(tmp,ioCurrent)=0 then result:=result or ACF_CURRENT + else if lstrcmpiw(tmp,ioResult )=0 then result:=result or ACF_RESULT + else if lstrcmpiw(tmp,ioParam )=0 then result:=result or ACF_PARAM + else if lstrcmpiw(tmp,ioStruct )=0 then + begin + result:=result or ACF_STRUCT; +//!!!! param:=ReadStruct(act); + end + else + begin + StrDupW(pWideChar(param),getAttrValue(act,ioValue)); + + if lstrcmpiw(tmp,ioNumber )=0 then result:=result or ACF_PARNUM + else if lstrcmpiw(tmp,ioUnicode)=0 then result:=result or ACF_UNICODE; +// else if lstrcmpiw(tmp,ioAnsi)=0 then; + end; + end; +end; +{ +function ReadParamINI(node:pointer;prefix:pAnsiChar;var param:pWideChar;isvar:boolean):dword; +var + pc,pc1:pAnsiChar; + buf:array [0..63] of AnsiChar; +begin + result:=0; + pc1:=StrCopyE(buf,prefix); + pc:=GetParamSectionStr(node,StrCopy(pc1,ioType)); + if lstrcmpi(pc,ioCurrent)=0 then result:=result or ACF_CURRENT + else if lstrcmpi(pc,ioResult )=0 then result:=result or ACF_RESULT + else if lstrcmpi(pc,ioParam )=0 then result:=result or ACF_PARAM + else if lstrcmpi(pc,ioStruct )=0 then + begin + result:=result or ACF_STRUCT; +//!!!! param:=ReadStruct(act); + end + else + begin + UTF8ToWide(GetParamSectionInt(node,StrCopy(pc1,ioValue)),param); + + if lstrcmpi(pc,ioNumber )=0 then result:=result or ACF_PARNUM + else if lstrcmpi(pc,ioUnicode)=0 then result:=result or ACF_UNICODE; +// else if lstrcmpi(pc,ioAnsi)=0 then; + end; +end; +} +procedure tServiceAction.Load(node:pointer;fmt:integer); +var + section:array [0..127] of AnsiChar; + buf:array [0..31] of WideChar; + pc:pAnsiChar; + sub:HXML; + tmp:pWideChar; + lflags,lflags2:dword; +begin + inherited Load(node,fmt); + + case fmt of + 0: begin + pc:=StrCopyE(section,pAnsiChar(node)); + + StrCopy(pc,opt_service); service:=DBReadString(0,DBBranch,section,nil); + StrCopy(pc,opt_flags2 ); flags2 :=DBReadDword (0,DBBranch,section); + + StrCopy(pc,opt_wparam); LoadParam(section,flags ,pointer(wparam)); + StrCopy(pc,opt_lparam); LoadParam(section,flags2,pointer(lparam)); + end; + + 100: begin + pc:=StrCopyE(section,pAnsiChar(node)); + + StrCopy(pc,opt_service); service:=DBReadString(0,DBBranch,section,nil); + StrCopy(pc,opt_flags2 ); flags2 :=DBReadDword (0,DBBranch,section); + + + if (flags and (ACF_OLD_WCURRENT or ACF_OLD_WRESULT or ACF_OLD_WPARAM))=0 then + begin + StrCopy(pc,opt_wparam); + + if (flags and ACF_OLD_WSTRUCT)<>0 then + wparam:=PWideChar(DBReadUTF8(0,DBBranch,section,nil)) + else if ((flags and ACF_OLD_WPARNUM)=0) or ((flags2 and ACF2_SRV_WPAR)<>0) then + wparam:=DBReadUnicode(0,DBBranch,section,nil) + else + StrDupW(wparam,IntToStr(buf,DBReadDWord(0,DBBranch,section))); + end; + + if (flags and (ACF_OLD_LCURRENT or ACF_OLD_LRESULT or ACF_OLD_LPARAM))=0 then + begin + StrCopy(pc,opt_lparam); + + if (flags and ACF_OLD_LSTRUCT)<>0 then + lparam:=PWideChar(DBReadUTF8(0,DBBranch,section,nil)) + else if ((flags and ACF_OLD_LPARNUM)=0) or ((flags2 and ACF2_SRV_LPAR)<>0) then + lparam:=DBReadUnicode(0,DBBranch,section,nil) + else + StrDupW(lparam,IntToStr(buf,DBReadDWord(0,DBBranch,section))); + end; + + lflags :=flags; + lflags2:=flags2; + flags :=flags and not ACF_MASK; + flags2:=0; + + if (lflags2 and ACF2_SRV_SRVC)<>0 then flags:=flags or ACF_SCRIPT_SERVICE; + + if (lflags and ACF_OLD_WPARNUM )<>0 then flags:=flags or ACF_PARNUM; + if (lflags and ACF_OLD_WUNICODE)<>0 then flags:=flags or ACF_UNICODE; + if (lflags and ACF_OLD_WCURRENT)<>0 then flags:=flags or ACF_CURRENT; + if (lflags and ACF_OLD_WRESULT )<>0 then flags:=flags or ACF_RESULT; + if (lflags and ACF_OLD_WPARAM )<>0 then flags:=flags or ACF_PARAM; + if (lflags and ACF_OLD_WSTRUCT )<>0 then flags:=flags or ACF_STRUCT; + if (lflags2 and ACF2_SRV_WPAR )<>0 then flags:=flags or ACF_SCRIPT_PARAM; + + if (lflags and ACF_OLD_LPARNUM )<>0 then flags2:=flags2 or ACF_PARNUM; + if (lflags and ACF_OLD_LUNICODE)<>0 then flags2:=flags2 or ACF_UNICODE; + if (lflags and ACF_OLD_LCURRENT)<>0 then flags2:=flags2 or ACF_CURRENT; + if (lflags and ACF_OLD_LRESULT )<>0 then flags2:=flags2 or ACF_RESULT; + if (lflags and ACF_OLD_LPARAM )<>0 then flags2:=flags2 or ACF_PARAM; + if (lflags and ACF_OLD_LSTRUCT )<>0 then flags2:=flags2 or ACF_STRUCT; + if (lflags2 and ACF2_SRV_LPAR )<>0 then flags2:=flags2 or ACF_SCRIPT_PARAM; + + if (lflags and ACF_OLD_STRING )<>0 then flags:=flags or ACF_RSTRING; + if (lflags and ACF_OLD_UNICODE)<>0 then flags:=flags or ACF_RUNICODE; + if (lflags and ACF_OLD_STRUCT )<>0 then flags:=flags or ACF_RSTRUCT; + if (lflags2 and ACF2_FREEMEM )<>0 then flags:=flags or ACF_RFREEMEM; + + end; + + 1: begin + with xmlparser do + begin + FastWideToAnsi(getAttrValue(HXML(node),ioService),service); +//!!!! StrDupW(service,getAttrValue(HXML(node),ioService)); + if StrToInt(getAttrValue(HXML(node),ioVariables))=1 then + flags:=flags or ACF_SCRIPT_SERVICE; + + sub:=getNthChild(HXML(node),ioWParam,0); + if StrToInt(getAttrValue(sub,ioVariables))=1 then + flags:=flags or ACF_SCRIPT_PARAM; + flags:=flags or ReadParam(sub,wparam,(flags and ACF_SCRIPT_PARAM)<>0); + + sub:=getNthChild(HXML(node),ioLParam,0); + if StrToInt(getAttrValue(sub,ioVariables))=1 then + flags2:=flags2 or ACF_SCRIPT_PARAM; + flags2:=flags2 or ReadParam(sub,lparam,(flags2 and ACF_SCRIPT_PARAM)<>0); + + sub:=getNthChild(HXML(node),ioOutput,0); + if StrToInt(getAttrValue(sub,ioFree))=1 then flags:=flags or ACF_RFREEMEM; + + tmp:=getAttrValue(sub,ioType); + if lstrcmpiw(tmp,ioUnicode)=0 then flags:=flags or ACF_RUNICODE + else if lstrcmpiw(tmp,ioAnsi )=0 then flags:=flags or ACF_RSTRING + else if lstrcmpiw(tmp,ioStruct )=0 then flags:=flags or ACF_RSTRUCT + else if lstrcmpiw(tmp,ioInt )=0 then ; + end; + end; +{ + 2: begin + StrDup(service,GetParamSectionStr(node,ioService)); +//!!!! UTF8ToWide(GetParamSectionStr(node,ioService),service); + if GetParamSectionInt(node,ioVariables)=1 then + flags:=flags or ACF_SCRIPT_SERVICE; + + if GetParamSectionInt(node,ioWParam+'.'+ioVariables))=1 then + flags:=flags or ACF_SCRIPT_PARAM; + flags:=flags or ReadParamINI(node,ioWParam+'.',wparam,(flags and ACF_SCRIPT_PARAM)<>0); + + if GetParamSectionInt(node,ioLParam+'.'+ioVariables))=1 then + flags2:=flags2 or ACF_SCRIPT_PARAM; + flags2:=flags2 or ReadParamINI(node,ioLParam+'.',lparam,(flags2 and ACF_SCRIPT_PARAM)<>0); + + if GetParamSectionInt(node,ioFree)=1 then flags:=flags or ACF_RFREEMEM; + + pc:=GetParamSectionStr(node,ioType); + if lstrcmpi(pñ,ioUnicode)=0 then flags:=flags or ACF_RUNICODE + else if lstrcmpi(pñ,ioAnsi )=0 then flags:=flags or ACF_RSTRING + else if lstrcmpi(pñ,ioStruct )=0 then flags:=flags or ACF_RSTRUCT +// else if lstrcmpi(pñ,ioInt )=0 then ; + end; +} + end; +end; + +procedure SaveParam(section:PAnsiChar;flags:dword; param:pointer); +begin + if (flags and (ACF_CURRENT or ACF_RESULT or ACF_PARAM))=0 then + begin + if pointer(param)<>nil then + begin + if (flags and ACF_STRUCT)<>0 then + DBWriteUTF8(0,DBBranch,section,param) + else + DBWriteUnicode(0,DBBranch,section,param); + end; + end; +end; + +procedure tServiceAction.Save(node:pointer;fmt:integer); +var + section: array [0..127] of AnsiChar; + pc:pAnsiChar; +begin + inherited Save(node,fmt); + + case fmt of + 0: begin + pc:=StrCopyE(section,pAnsiChar(node)); + + StrCopy(pc,opt_service); DBWriteString(0,DBBranch,section,service); + StrCopy(pc,opt_flags2 ); DBWriteDWord (0,DBBranch,section,flags2); + + StrCopy(pc,opt_wparam); SaveParam(section,flags ,pointer(wparam)); + StrCopy(pc,opt_lparam); SaveParam(section,flags2,pointer(lparam)); + end; +{ + 1: begin + end; +} + 13: begin + end; + end; +end; + +//----- Dialog realization ----- + +function DlgProc(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; +var + ServiceBlock:HWND; + rc:TRECT; + sv:tServiceValue; +begin + result:=0; + + case hMessage of + WM_DESTROY: begin + end; + + WM_INITDIALOG: begin + GetClientRect(Dialog,rc); + ServiceBlock:=CreateServiceBlock(Dialog,0,0,rc.right,rc.bottom,ACF_NOVISUAL or ACF_SCRIPT_EXPAND); + SetWindowLongPtrW(Dialog,GWLP_USERDATA,ServiceBlock); + SetServiceListMode(ServiceBlock,DBReadByte(0,DBBranch,'SrvListMode')); + + TranslateDialogDefault(Dialog); + end; + + WM_ACT_SETVALUE: begin + ServiceBlock:=GetWindowLongPtrW(Dialog,GWLP_USERDATA); + with tServiceAction(lParam) do + begin + sv.service:=service; + sv.w_flag :=flags; + sv.wparam :=wparam; + sv.l_flag :=flags2; + sv.lparam :=lparam; + sv.flags :=flags; + end; + SetSrvBlockValue(ServiceBlock,sv); + end; + + WM_ACT_RESET: begin + ClearServiceBlock(GetWindowLongPtrW(Dialog,GWLP_USERDATA)); + end; + + WM_ACT_SAVE: begin + with tServiceAction(lParam) do + begin + ServiceBlock:=GetWindowLongPtrW(Dialog,GWLP_USERDATA); + GetSrvBlockValue(ServiceBlock,sv); + + service:=sv.service; + wparam :=sv.wparam; + lparam :=sv.lparam; + flags2 :=sv.l_flag; + flags :=sv.flags or sv.w_flag; + end; + end; + + //?? + WM_SHOWWINDOW: begin +{ + // hide window by ShowWindow function + if (lParam=0) and (wParam=0) then + begin + pc:=pAnsiChar(SetWindowLongPtrW(GetDlgItem(Dialog,IDC_WSTRUCT),GWLP_USERDATA,0)); + mFreeMem(pc); + pc:=pAnsiChar(SetWindowLongPtrW(GetDlgItem(Dialog,IDC_LSTRUCT),GWLP_USERDATA,0)); + mFreeMem(pc); + end; +} + end; + + WM_COMMAND: begin + case wParam shr 16 of + CBN_EDITCHANGE, + BN_CLICKED: + SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0); + end; + end; + + WM_HELP: begin + ServiceBlock:=GetWindowLongPtrW(Dialog,GWLP_USERDATA); + SendMessage(ServiceBlock,WM_HELP,0,0); + + result:=1; + end; + + end; +end; + +//----- Export/interface functions ----- + +var + vc:tActModule; + +function CreateAction:tBaseAction; +begin + result:=tServiceAction.Create(vc.Hash); +end; + +function CreateDialog(parent:HWND):HWND; +begin + result:=CreateDialogW(hInstance,'IDD_ACTSERVICE',parent,@DlgProc); +end; + +procedure Init; +begin + vc.Next :=ModuleLink; + + vc.Name :='Service'; + vc.Dialog :=@CreateDialog; + vc.Create :=@CreateAction; + vc.Icon :='IDI_SERVICE'; + vc.Hash :=0; + + ModuleLink :=@vc; +end; + +begin + Init; +end. diff --git a/plugins/Actman/iac_service.rc b/plugins/Actman/iac_service.rc new file mode 100644 index 0000000000..ff9f972ff4 --- /dev/null +++ b/plugins/Actman/iac_service.rc @@ -0,0 +1,11 @@ + +LANGUAGE 0,0 + +IDD_ACTSERVICE DIALOGEX 0, 0, 168, 200, 0 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0 +{ +} + +IDI_SERVICE ICON "ico\service.ico" diff --git a/plugins/Actman/iac_service.res b/plugins/Actman/iac_service.res new file mode 100644 index 0000000000..c26f2d4319 Binary files /dev/null and b/plugins/Actman/iac_service.res differ diff --git a/plugins/Actman/iac_settings.pas b/plugins/Actman/iac_settings.pas new file mode 100644 index 0000000000..3997fbe73d --- /dev/null +++ b/plugins/Actman/iac_settings.pas @@ -0,0 +1,175 @@ +unit iac_settings; + +interface + +implementation + +uses + windows, messages, commctrl, + global,iac_global, dlgshare, lowlevelc, + m_api, mirutils, dbsettings, common, wrapper; + +{$include i_cnst_settings.inc} +{$resource iac_settings.res} + + +//----- Support functions ----- + + +//----- Dialog realization ----- + +procedure FillServiceModeList(wnd:HWND); +begin + SendMessage(wnd,CB_RESETCONTENT,0,0); + InsertString(wnd,0 ,'value'); + InsertString(wnd,1 ,'name'); + InsertString(wnd,2 ,'value (name)'); + InsertString(wnd,3 ,'name ''value'''); + SendMessage(wnd,CB_SETCURSEL,0,0); +end; + +procedure ClearFields(Dialog:HWND); +begin + CheckDlgButton(Dialog,IDC_CNT_FILTER,BST_UNCHECKED); + SetDlgItemTextW(Dialog,IDC_EDIT_FORMAT,''); + + CheckDlgButton(Dialog,IDC_FR_FLAG,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_VL_FLAG,BST_UNCHECKED); +end; + +function DlgProc(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; +var + fCLformat:pWideChar; + lp:TLPARAM; + stat:integer; +begin + result:=0; + + case hMessage of + WM_INITDIALOG: begin + TranslateDialogDefault(Dialog); + + OptSetButtonIcon(GetDlgItem(Dialog,IDC_CNT_APPLY),ACI_APPLY); + + OptSetButtonIcon(GetDlgItem(Dialog,IDC_SRV_APPLY),ACI_APPLY); + FillServiceModeList(GetDlgItem(Dialog,IDC_SERVICELIST)); + end; + + WM_ACT_SETVALUE: begin + ClearFields(Dialog); + end; + + WM_ACT_RESET: begin + ClearFields(Dialog); + // Contact list settings + CheckDlgButton (Dialog,IDC_CNT_FILTER,DBReadByte(0,DBBranch,'CLfilter',BST_UNCHECKED)); + fCLformat:=DBReadUnicode(0,DBBranch,'CLformat'); + SetDlgItemTextW(Dialog,IDC_EDIT_FORMAT,fCLformat); + mFreeMem(fCLformat); + + // Servicelist mode settings + CB_SelectData(Dialog,IDC_SERVICELIST,DBReadByte(0,DBBranch,'SrvListMode')); + end; + + WM_SHOWWINDOW: begin + // Show window by ShowWindow function + if (lParam=0) and (wParam=1) then + begin + lp:=LV_GetLParam(MacroListWindow); + if (lp and ACF_FIRSTRUN)<>0 then + stat:=BST_CHECKED + else + stat:=BST_UNCHECKED; + CheckDlgButton(Dialog,IDC_FR_FLAG,stat); + + if (lp and ACF_VOLATILE)<>0 then + stat:=BST_CHECKED + else + stat:=BST_UNCHECKED; + CheckDlgButton(Dialog,IDC_VL_FLAG,stat); + end; + end; + + WM_COMMAND: begin + case wParam shr 16 of + BN_CLICKED: begin + case loword(wParam) of + IDC_SRV_APPLY: begin + DBWriteByte(0,DBBranch,'SrvListMode', + CB_GetData(GetDlgItem(Dialog,IDC_SERVICELIST))); + end; + + IDC_CNT_APPLY: begin + fCLformat:=GetDlgText(Dialog,IDC_EDIT_FORMAT); + DBWriteUnicode(0,DBBranch,'CLformat',fCLformat); + mFreeMem(fCLformat); + end; + + IDC_CNT_FILTER: begin + DBWriteByte(0,DBBranch,'CLfilter',IsDlgButtonChecked(Dialog,IDC_CNT_FILTER)); + end; + + IDC_FR_FLAG: begin + lp:=LV_GetLParam(MacroListWindow); + if IsDlgButtonChecked(Dialog,IDC_FR_FLAG)=BST_UNCHECKED then + lp:=lp and not ACF_FIRSTRUN + else + lp:=lp or ACF_FIRSTRUN; + LV_SetLParam(MacroListWindow,lp); + + SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0); + end; + + IDC_VL_FLAG: begin + lp:=LV_GetLParam(MacroListWindow); + if IsDlgButtonChecked(Dialog,IDC_VL_FLAG)=BST_UNCHECKED then + lp:=lp and not ACF_VOLATILE + else + lp:=lp or ACF_VOLATILE; + LV_SetLParam(MacroListWindow,lp); + + SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0); + end; + end; + end; + end; + end; + + WM_HELP: begin + result:=1; + end; + + end; +end; + +//----- Export/interface functions ----- + +var + vc:tActModule; + +function CreateAction:tBaseAction; +begin + result:=nil; +end; + +function CreateDialog(parent:HWND):HWND; +begin + result:=CreateDialogW(hInstance,'IDD_SETTINGS',parent,@DlgProc); +end; + +procedure Init; +begin + vc.Next :=ModuleLink; + + vc.Name :='Settings'; + vc.Dialog :=@CreateDialog; + vc.Create :=@CreateAction; + vc.Icon :='IDI_SETTINGS'; + vc.Hash :=1; + + ModuleLink :=@vc; +end; + +begin + Init; +end. diff --git a/plugins/Actman/iac_settings.rc b/plugins/Actman/iac_settings.rc new file mode 100644 index 0000000000..69487dd87d --- /dev/null +++ b/plugins/Actman/iac_settings.rc @@ -0,0 +1,27 @@ +#include "i_cnst_settings.inc" + +LANGUAGE 0,0 + +IDD_SETTINGS DIALOGEX 0, 0, 168, 200, 0 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0 +{ + GROUPBOX "Contact list", -1, 1, 2, 166, 77, WS_GROUP + AUTOCHECKBOX "Active accounts only",IDC_CNT_FILTER, 4, 11, 160, 11 + RTEXT "Contact list format",-1, 4, 24, 160, 11 + EDITTEXT IDC_EDIT_FORMAT, 22, 38, 142, 12, ES_AUTOHSCROLL + CONTROL "Apply",IDC_CNT_APPLY,"MButtonClass",WS_TABSTOP,4,36,16,16,$18000000 + CTEXT "You can use %name%, %uid%, %account% and %group% substitutes",-1, 4, 53, 160, 24 + + RTEXT "Service list format",-1, 0, 82, 166, 11 + COMBOBOX IDC_SERVICELIST , 19, 94, 148, 96, CBS_DROPDOWNLIST | WS_VSCROLL + CONTROL "Apply",IDC_SRV_APPLY,"MButtonClass",WS_TABSTOP,1,93,16,16,$18000000 + + GROUPBOX "Current Macro", -1, 1, 116, 166, 40, WS_GROUP + AUTOCHECKBOX "Select for FirstRun",IDC_FR_FLAG, 4, 126, 160, 12 + AUTOCHECKBOX "Select as Volatile" ,IDC_VL_FLAG, 4, 138, 160, 12 +// AUTOCHECKBOX "hContact in wParam" ,IDC_HC_WPAR, 4, 138, 160, 12 +} + +IDI_SETTINGS ICON "ico\settings.ico" diff --git a/plugins/Actman/iac_settings.res b/plugins/Actman/iac_settings.res new file mode 100644 index 0000000000..1aaef00324 Binary files /dev/null and b/plugins/Actman/iac_settings.res differ diff --git a/plugins/Actman/iac_storage.pas b/plugins/Actman/iac_storage.pas new file mode 100644 index 0000000000..500d366334 --- /dev/null +++ b/plugins/Actman/iac_storage.pas @@ -0,0 +1,297 @@ +unit iac_storage; + +interface + +implementation + +uses + windows, messages, + common, wrapper, + mirutils,m_api,dbsettings, inouttext, + global,iac_global; + +{$include i_cnst_storage.inc} +{$resource iac_storage.res} + +const + opt_number = 'number'; +const + ioNumber = 'number'; + ioOper = 'oper'; + ioCopy = 'copy'; +const + ACF_COPYFROM = $00000001; +type + tStorageAction = class(tBaseAction) + private + Number:integer; + public + constructor Create(uid:dword); + destructor Destroy; override; +// function Clone:tBaseAction; override; + function DoAction(var WorkData:tWorkData):LRESULT; override; + procedure Save(node:pointer;fmt:integer); override; + procedure Load(node:pointer;fmt:integer); override; + end; + +//----- Support functions ----- + +//----- Object realization ----- + +constructor tStorageAction.Create(uid:dword); +begin + inherited Create(uid); + + Number:=0; +end; + +destructor tStorageAction.Destroy; +begin + + inherited Destroy; +end; +{ +function tStorageAction.Clone:tBaseAction; +begin + result:=.Create(0); + Duplicate(result); + +end; +} +function tStorageAction.DoAction(var WorkData:tWorkData):LRESULT; +var + num:integer; + st,dt:pByte; + sv,dv:^uint_ptr; +begin + result:=0; + + if Number in [0..9] then + begin + // copy to slot + if (flags and ACF_COPYFROM)=0 then + begin + num:=Number; + st:=@WorkData.ResultType; + dt:=@WorkData.Storage[Number].rtype; + sv:=@WorkData.LastResult; + dv:=@WorkData.Storage[Number].value; + end + // copy from slot + else + begin + num:=-1; + dt:=@WorkData.ResultType; + st:=@WorkData.Storage[Number].rtype; + dv:=@WorkData.LastResult; + sv:=@WorkData.Storage[Number].value; + end; + + ClearResult(WorkData,num); + dt^:=st^; + + if WorkData.ResultType=rtInt then // Number + dv^:=sv^ + + else if WorkData.ResultType=rtWide then // Unicode + StrDupW(pWideChar(dv^),pWideChar(sv^)) + + else if WorkData.ResultType<>rtUnkn then // Ansi and UTF8 + StrDup(pAnsiChar(dv^),pAnsiChar(sv^)); + end; + +{ + // copy to slot + if (flags and ACF_COPYFROM)=0 then + begin + if Number in [0..9] then + begin + ClearResult(WorkData,Number); + WorkData.Storage[Number].rtype:=WorkData.ResultType; + + if WorkData.ResultType=rtInt then // Number + WorkData.Storage[Number].value:=WorkData.LastResult + + else if WorkData.ResultType=rtWide then // Unicode + StrDupW(pWideChar(WorkData.Storage[Number].value),pWideChar(WorkData.LastResult)) + + else if WorkData.ResultType<>rtUnkn then // Ansi and UTF8 + StrDup(pAnsiChar(WorkData.Storage[Number].value),pAnsiChar(WorkData.LastResult)); + + end; + end + // copy from slot + else + begin + if Number in [0..9] then + begin + ClearResult(WorkData); + WorkData.ResultType:=WorkData.Storage[Number].rtype; + + if WorkData.ResultType=rtInt then // Number + WorkData.LastResult:=WorkData.Storage[Number].value + + else if WorkData.ResultType=rtWide then // Unicode + StrDupW(pWideChar(WorkData.LastResult),pWideChar(WorkData.Storage[Number].value)) + + else if WorkData.ResultType<>rtUnkn then // Ansi and UTF8 + StrDup(pAnsiChar(WorkData.LastResult),pAnsiChar(WorkData.Storage[Number].value)); + + end; + end; +} +end; + +procedure tStorageAction.Load(node:pointer;fmt:integer); +var + section: array [0..127] of AnsiChar; + pc:pAnsiChar; +begin + inherited Load(node,fmt); + case fmt of + 0: begin + pc:=StrCopyE(section,pAnsiChar(node)); + StrCopy(pc,opt_number); Number:=DBReadByte(0,DBBranch,section,0); + end; + + 1: begin + with xmlparser do + begin + if lstrcmpiw(getAttrValue(HXML(node),ioOper),ioCopy)=1 then + flags:=flags or ACF_COPYFROM; + Number:=StrToInt(getAttrValue(HXML(node),ioNumber)); + end; + end; + end; +end; + +procedure tStorageAction.Save(node:pointer;fmt:integer); +var + section: array [0..127] of AnsiChar; + pc:pAnsiChar; +begin + inherited Save(node,fmt); + case fmt of + 0: begin + pc:=StrCopyE(section,pAnsiChar(node)); + StrCopy(pc,opt_number); DBWriteByte(0,DBBranch,section,Number); + end; +{ + 1: begin + end; +} + 13: begin + tTextExport(node).AddDWord('slot',Number); + tTextExport(node).AddFlag ('copy',(flags or ACF_COPYFROM)<>0); + end; + end; +end; + +//----- Dialog realization ----- + +procedure FillStorageCombo(wnd:HWND); +var + i:integer; + buf:array [0..31] of AnsiChar; + p:pAnsiChar; +begin + SendMessage(wnd,CB_RESETCONTENT,0,0); + + p:=StrCopyE(buf,'Slot #')-1; + for i:=0 to 9 do + begin + p^:=AnsiChar(ORD('0')+i); + InsertString(wnd,i,buf); + end; + + SendMessage(wnd,CB_SETCURSEL,0,0); +end; + +procedure ClearFields(Dialog:HWND); +begin + CheckDlgButton(Dialog,IDC_FLAG_TO ,BST_UNCHECKED); + CheckDlgButton(Dialog,IDC_FLAG_FROM,BST_UNCHECKED); +end; + +function DlgProc(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; +begin + result:=0; + + case hMessage of + WM_INITDIALOG: begin + TranslateDialogDefault(Dialog); + + FillStorageCombo(GetDlgItem(Dialog,IDC_STORAGELIST)); + end; + + WM_ACT_SETVALUE: begin + ClearFields(Dialog); + with tStorageAction(lParam) do + begin + if (flags and ACF_COPYFROM)=0 then + CheckDlgButton(Dialog,IDC_FLAG_TO ,BST_CHECKED) + else + CheckDlgButton(Dialog,IDC_FLAG_FROM,BST_CHECKED); + + CB_SelectData(GetDlgItem(Dialog,IDC_STORAGELIST),Number); + end; + end; + + WM_ACT_RESET: begin + ClearFields(Dialog); + CheckDlgButton(Dialog,IDC_FLAG_TO,BST_CHECKED); + CB_SelectData(GetDlgItem(Dialog,IDC_STORAGELIST),0); + end; + + WM_ACT_SAVE: begin + with tStorageAction(lParam) do + begin + if IsDlgButtonChecked(Dialog,IDC_FLAG_FROM)<>BST_UNCHECKED then + flags:=flags or ACF_COPYFROM; + + Number:=CB_GetData(GetDlgItem(Dialog,IDC_STORAGELIST)); + end; + end; +{ + WM_COMMAND: begin + case wParam shr 16 of + end; + end; +} + WM_HELP: begin + result:=1; + end; + + end; +end; + +//----- Export/interface functions ----- + +var + vc:tActModule; + +function CreateAction:tBaseAction; +begin + result:=tStorageAction.Create(vc.Hash); +end; + +function CreateDialog(parent:HWND):HWND; +begin + result:=CreateDialogW(hInstance,'IDD_ACTSTORAGE',parent,@DlgProc); +end; + +procedure Init; +begin + vc.Next :=ModuleLink; + + vc.Name :='Storage'; + vc.Dialog :=@CreateDialog; + vc.Create :=@CreateAction; + vc.Icon :='IDI_STORAGE'; + + ModuleLink :=@vc; +end; + +begin + Init; +end. diff --git a/plugins/Actman/iac_storage.rc b/plugins/Actman/iac_storage.rc new file mode 100644 index 0000000000..6e4391e15c --- /dev/null +++ b/plugins/Actman/iac_storage.rc @@ -0,0 +1,16 @@ +#include "i_cnst_storage.inc" + +LANGUAGE 0,0 + +IDD_ACTSTORAGE DIALOGEX 0, 0, 168, 200, 0 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0 +{ + AUTORADIOBUTTON "LastResult to " , IDC_FLAG_TO , 1, 2, 166, 11, WS_GROUP + AUTORADIOBUTTON "LastResult from", IDC_FLAG_FROM , 1, 15, 166, 11 + + COMBOBOX IDC_STORAGELIST, 19, 30, 148, 128, CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL +} + +IDI_STORAGE ICON "ico\storage.ico" diff --git a/plugins/Actman/iac_storage.res b/plugins/Actman/iac_storage.res new file mode 100644 index 0000000000..b87ec5fec2 Binary files /dev/null and b/plugins/Actman/iac_storage.res differ diff --git a/plugins/Actman/iac_text.pas b/plugins/Actman/iac_text.pas new file mode 100644 index 0000000000..68f9acf7ba --- /dev/null +++ b/plugins/Actman/iac_text.pas @@ -0,0 +1,521 @@ +unit iac_text; + +interface + +implementation + +uses + windows, messages, commctrl, + global, iac_global, m_api, editwrapper, + dbsettings, common, io, inouttext, + mirutils, syswin, wrapper; + +{$include i_cnst_text.inc} +{$resource iac_text.res} + +const + BufferSize = 32768; // chars + +const + opt_text = 'text'; +const + ioVariables = 'variables'; + ioText = 'text'; + ioPost = 'post'; +const + ACF_TEXTSCRIPT = $00000001; + ACF_POSTPROCESS = $00000002; + +const // V2 + ACF2_TXT_TEXT = $00000002; + +type + tTextAction = class(tBaseAction) + private + text: pWideChar; + public + constructor Create(uid:dword); + destructor Destroy; override; +// function Clone:tBaseAction; override; + function DoAction(var WorkData:tWorkData):LRESULT; override; + procedure Save(node:pointer;fmt:integer); override; + procedure Load(node:pointer;fmt:integer); override; + end; + +//----- Support functions ----- + +//----- Object realization ----- + +constructor tTextAction.Create(uid:dword); +begin + inherited Create(uid); + + text:=nil; +end; + +destructor tTextAction.Destroy; +begin + mFreeMem(text); + + inherited Destroy; +end; +{ +function tTextAction.Clone:tBaseAction; +begin + result:=.Create(0); + Duplicate(result); + +end; +} +type + trec = record + text:PAnsiChar; + one, two:integer; + end; + +function GetFileString(fname:PAnsiChar;linenum:integer):pWideChar; +var + pc,FileBuf,CurLine:PAnsiChar; + f:THANDLE; + NumLines, j:integer; +begin + f:=Reset(fname); + if f<>INVALID_HANDLE_VALUE then + begin + j:=FileSize(f); + mGetMem(FileBuf,j+1); + BlockRead(f,FileBuf^,j); + while (FileBuf+j)^<' ' do dec(j); + (FileBuf+j+1)^:=#0; + CloseHandle(f); + pc:=FileBuf; + CurLine:=pc; + NumLines:=1; + while pc^<>#0 do // count number of lines + begin + if pc^=#13 then + begin + if linenum=NumLines then + break; + inc(pc); + if pc^=#10 then + inc(pc); + inc(NumLines); + CurLine:=pc; + end + else + inc(pc); + end; + if (linenum>NumLines) or (linenum=0) then //ls - lastline + else if linenum<0 then + begin + randomize; + j:=random(NumLines)+1; + pc:=FileBuf; + NumLines:=1; + CurLine:=pc; + repeat + if (pc^=#13) or (pc^=#0) then + begin + if j=NumLines then + break; + if pc^<>#0 then + begin + inc(pc); + if pc^=#10 then + inc(pc); + end; + inc(NumLines); + CurLine:=pc; + end + else + inc(pc); + until false; + end; + pc^:=#0; + StrReplace(CurLine,'\n',#13#10); + StrReplace(CurLine,'\t',#09); + AnsiToWide(CurLine,result,CP_ACP); + mFreeMem(FileBuf); + end + else + result:=nil; +end; + +function Split(buf:PWideChar;amacro:PWideChar;var r:trec):integer; +type + tconv = packed record + case boolean of + false: (res:int); + true: (lo,hi:word); + end; +var + i:integer; + p,pp,lp:pWideChar; + ls:array [0..511] of WideChar; +begin + result:=0; + i:=StrIndexW(buf,amacro); + if i>0 then + begin + dec(i); + p:=buf+i+StrLenW(amacro); + pp:=p; + while (p^<>#0) and (p^<>')') do + inc(p); + ls[0]:=#0; + if p^<>#0 then // correct syntax + begin + lp:=ls; + while (pp<>p) and (pp^<>',') do // filename + begin + lp^:=pp^; + inc(lp); + inc(pp); + end; + lp^:=#0; + WideToAnsi(ls,r.text,MirandaCP); + r.one:=-1; + r.two:=-1; + if pp^=',' then + begin + inc(pp); + r.one:=StrToInt(pp); + while (pp<>p) and (pp^<>',') do inc(pp); + if pp^=',' then + begin + inc(pp); + r.two:=StrToInt(pp); + end; + end; + tconv(result).lo:=p-buf-i+1; // length + tconv(result).hi:=i; // position + end; + end; +end; + +procedure PasteFileString(dst:pWideChar); +var + i:integer; + lp:pWideChar; + buf:array [0..511] of AnsiChar; + r:trec; +begin + repeat + i:=Split(dst,'^f(',r); + if i>0 then + begin + StrDeleteW(dst,i shr 16,loword(i)); + ConvertFileName(r.text,buf); +// CallService(MS_UTILS_PATHTOABSOLUTE,WPARAM(r.text),LPARAM(@buf)); + lp:=GetFileString(@buf,r.one); + if lp<>nil then + begin + StrInsertW(lp,dst,i shr 16); + mFreeMem(lp); + end; + end + else + break; + until false; +end; + +procedure PasteClipboard(dst:pWideChar); +var + p:pWideChar; + fh:tHandle; +begin + if StrPosW(dst,'^v')<>nil then + begin + if OpenClipboard(0) then + begin + fh:=GetClipboardData(cf_UnicodeText); + p:=GlobalLock(fh); + StrReplaceW(dst,'^v',p); + GlobalUnlock(fh); + CloseClipboard; + end + end +end; + +procedure PasteSelectedText(dst:pWideChar); +var + sel:integer; + buf:pWideChar; + wnd:HWND; +begin + if StrPosW(dst,'^s')<>nil then + begin + wnd:=WaitFocusedWndChild(GetForegroundWindow){GetFocus}; + if wnd<>0 then + begin + sel:=SendMessageW(wnd,EM_GETSEL,0,0); + if loword(sel)=(sel shr 16) then + StrReplaceW(dst,'^s',nil) + else + begin + buf:=GetDlgText(wnd,false); + buf[sel shr 16]:=#0; + StrReplaceW(dst,'^s',buf+loword(sel)); + mFreeMem(buf); + end; + end + else + StrReplaceW(dst,'^s',nil); + end; +end; + +function tTextAction.DoAction(var WorkData:tWorkData):LRESULT; +var + buf:array [0..31] of WideChar; + w,tmp,last:pWideChar; +begin + result:=0; + + tmp:=text; + if (flags and ACF_POSTPROCESS)=0 then + if (flags and ACF_TEXTSCRIPT)<>0 then + begin + if WorkData.ResultType=rtInt then + last:=pWideChar(IntToStr(buf,WorkData.LastResult)) + else + last:=pWideChar(WorkData.LastResult); + + tmp:=ParseVarString(text,WorkData.Parameter,last); + end; + + mGetMem (w ,BufferSize*SizeOf(WideChar)); + FillChar(w^,BufferSize*SizeOf(WideChar),0); + StrCopyW(w,tmp); + if (flags and ACF_POSTPROCESS)=0 then + if (flags and ACF_TEXTSCRIPT)<>0 then + mFreeMem(tmp); + + PasteClipboard(w); // ^v + PasteFileString(w); // ^f + + PasteSelectedText(w); // ^s + // ^a - get ALL text? + + if WorkData.ResultType=rtInt then + begin + StrReplaceW(w,'^l',IntToStr(buf,WorkData.LastResult)); // ^l + StrReplaceW(w,'^h',IntToHex(buf,WorkData.LastResult)); // ^h + end + else + begin + StrReplaceW(w,'^l',pWideChar(WorkData.LastResult)); + StrReplaceW(w,'^h',IntToHex(buf,NumToInt(pWideChar(WorkData.LastResult)))); + end; + + StrReplaceW(w,'^t',#9); // ^t + StrReplaceW(w,'^e',nil); // ^e + + if (flags and ACF_POSTPROCESS)<>0 then + if (flags and ACF_TEXTSCRIPT)<>0 then + begin + if WorkData.ResultType=rtInt then + last:=pWideChar(IntToStr(buf,WorkData.LastResult)) + else + last:=pWideChar(WorkData.LastResult); + + tmp:=ParseVarString(w,WorkData.Parameter,last); + mFreeMem(w); + w:=tmp; + end; + + ClearResult(WorkData); + WorkData.LastResult:=uint_ptr(w); + WorkData.ResultType:=rtWide; +end; + +procedure tTextAction.Load(node:pointer;fmt:integer); +var + section: array [0..127] of AnsiChar; + pc:pAnsiChar; + flags2:dword; +begin + inherited Load(node,fmt); + case fmt of + 0: begin + pc:=StrCopyE(section,pAnsiChar(node)); + + StrCopy(pc,opt_text); text:=DBReadUnicode(0,DBBranch,section,nil); + end; + + 100: begin + pc:=StrCopyE(section,pAnsiChar(node)); + + StrCopy(pc,opt_text); text:=DBReadUnicode(0,DBBranch,section,nil); + + StrCopy(pc,'flags2'); flags2:=DBReadDWord(0,DBBranch,section,0); + flags:=flags and not ACF_MASK; + + if (flags2 and ACF2_TXT_TEXT)<>0 then flags:=flags or ACF_TEXTSCRIPT; + end; + + 101: begin // v2, from "Advanced" + pc:=StrCopyE(section,pAnsiChar(node)); + StrCopy(pc,'varval'); text:=DBReadUnicode(0,DBBranch,section); + flags:=flags or ACF_TEXTSCRIPT; + end; + + 1: begin + with xmlparser do + begin + StrDupW(text,getText(HXML(node))); + if StrToInt(getAttrValue(HXML(node),ioVariables))=1 then + flags:=flags or ACF_TEXTSCRIPT; + if StrToInt(getAttrValue(HXML(node),ioPost))=1 then + flags:=flags or ACF_POSTPROCESS; + end; + end; +{ + 2: begin + UTF8ToWide(GetParamSectionInt(node,ioText),text); + if GetParamSectionInt(node,ioVariables)=1 then + flags:=flags or ACF_TEXTSCRIPT; + end; +} + end; +end; + +procedure tTextAction.Save(node:pointer;fmt:integer); +var + section: array [0..127] of AnsiChar; + pc:pAnsiChar; +begin + inherited Save(node,fmt); + case fmt of + 0: begin + pc:=StrCopyE(section,pAnsiChar(node)); + + StrCopy(pc,opt_text); DBWriteUnicode(0,DBBranch,section,text); + end; +{ + 1: begin + end; +} + 13: begin + tTextExport(node).AddTextW('text' ,text); + tTextExport(node).AddFlag ('script' ,(flags or ACF_TEXTSCRIPT )<>0); + tTextExport(node).AddFlag ('postprocess',(flags or ACF_POSTPROCESS)<>0); + end; + end; +end; + +//----- Dialog realization ----- + +procedure ClearFields(Dialog:HWND); +begin + SetDlgItemTextW(Dialog,IDC_TXT_TEXT,nil); + SetEditFlags (Dialog,IDC_TXT_TEXT,EF_ALL,0); + CheckDlgButton (Dialog,IDC_TXT_POST,BST_UNCHECKED); +end; + +function DlgProc(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; +const + NoProcess:boolean=true; +begin + result:=0; + + case hMessage of + WM_INITDIALOG: begin + TranslateDialogDefault(Dialog); + + MakeEditField(Dialog,IDC_TXT_TEXT); + end; + + WM_ACT_SETVALUE: begin + NoProcess:=true; + ClearFields(Dialog); + + with tTextAction(lParam) do + begin + SetDlgItemTextW(Dialog,IDC_TXT_TEXT,text); + SetEditFlags(Dialog,IDC_TXT_TEXT,EF_SCRIPT,ord((flags and ACF_TEXTSCRIPT)<>0)); + if (flags and ACF_POSTPROCESS)<>0 then + CheckDlgButton(Dialog,IDC_TXT_POST,BST_CHECKED); + end; + NoProcess:=false; + end; + + WM_ACT_RESET: begin + NoProcess:=true; + ClearFields(Dialog); + NoProcess:=false; + end; + + WM_ACT_SAVE: begin + with tTextAction(lParam) do + begin + flags:=0; + + {mFreeMem(text); }text:=GetDlgText(Dialog,IDC_TXT_TEXT); + if (GetEditFlags(Dialog,IDC_TXT_TEXT) and EF_SCRIPT)<>0 then + flags:=flags or ACF_TEXTSCRIPT; + + if IsDlgButtonChecked(Dialog,IDC_TXT_POST)=BST_CHECKED then + flags:=flags or ACF_POSTPROCESS; + end; + end; + + WM_COMMAND: begin + case wParam shr 16 of + BN_CLICKED: + if loword(wParam)=IDC_TXT_POST then + SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0); + + EN_CHANGE: if not NoProcess then + SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0); + end; + end; + + WM_HELP: begin + MessageBoxW(0, + TranslateW('^s - selected (and replaced) part'#13#10+ + '^e - replaced by empty string'#13#10+ + '^v - paste text from Clipboard'#13#10+ + '^t - replaced by tabulation'#13#10+ + '^l - replaced by last result as unicode'#13#10+ + '^h - replaced by last result as hex'#13#10+ + '^f(name[,str])'#13#10+ + ' paste line from text file.'#13#10+ + ' brackets contents must be w/o spaces'), + TranslateW('Text'),0); + result:=1; + end; + + end; +end; + +//----- Export/interface functions ----- + +var + vc:tActModule; + +function CreateAction:tBaseAction; +begin + result:=tTextAction.Create(vc.Hash); +end; + +function CreateDialog(parent:HWND):HWND; +begin + result:=CreateDialogW(hInstance,'IDD_ACTTEXT',parent,@DlgProc); +end; + +procedure Init; +begin + vc.Next :=ModuleLink; + + vc.Name :='Text'; + vc.Dialog :=@CreateDialog; + vc.Create :=@CreateAction; + vc.Icon :='IDI_TEXT'; + + ModuleLink :=@vc; +end; + +begin + Init; +end. diff --git a/plugins/Actman/iac_text.rc b/plugins/Actman/iac_text.rc new file mode 100644 index 0000000000..63fd664420 --- /dev/null +++ b/plugins/Actman/iac_text.rc @@ -0,0 +1,14 @@ +#include "i_cnst_text.inc" + +LANGUAGE 0,0 + +IDD_ACTTEXT DIALOGEX 0, 0, 168, 200, 0 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0 +{ + EDITTEXT IDC_TXT_TEXT, 1, 4, 166, 12, ES_AUTOHSCROLL + AUTOCHECKBOX "Process script after",IDC_TXT_POST, 4, 18, 160, 11 +} + +IDI_TEXT ICON "ico\text.ico" diff --git a/plugins/Actman/iac_text.res b/plugins/Actman/iac_text.res new file mode 100644 index 0000000000..21f8140ee7 Binary files /dev/null and b/plugins/Actman/iac_text.res differ diff --git a/plugins/Actman/ico/advance.ico b/plugins/Actman/ico/advance.ico index 6cc054ccc3..fa6c604542 100644 Binary files a/plugins/Actman/ico/advance.ico and b/plugins/Actman/ico/advance.ico differ diff --git a/plugins/Actman/ico/apply.ico b/plugins/Actman/ico/apply.ico index 27def2fb4b..80c3802c09 100644 Binary files a/plugins/Actman/ico/apply.ico and b/plugins/Actman/ico/apply.ico differ diff --git a/plugins/Actman/ico/call.ico b/plugins/Actman/ico/call.ico new file mode 100644 index 0000000000..ddddb59074 Binary files /dev/null and b/plugins/Actman/ico/call.ico differ diff --git a/plugins/Actman/ico/chain.ico b/plugins/Actman/ico/chain.ico index d3a9c9b59c..3a98b8ac30 100644 Binary files a/plugins/Actman/ico/chain.ico and b/plugins/Actman/ico/chain.ico differ diff --git a/plugins/Actman/ico/contact.ico b/plugins/Actman/ico/contact.ico index 5f06f02312..8174fa221a 100644 Binary files a/plugins/Actman/ico/contact.ico and b/plugins/Actman/ico/contact.ico differ diff --git a/plugins/Actman/ico/delete.ico b/plugins/Actman/ico/delete.ico index 3770daf2fc..eea851da19 100644 Binary files a/plugins/Actman/ico/delete.ico and b/plugins/Actman/ico/delete.ico differ diff --git a/plugins/Actman/ico/down.ico b/plugins/Actman/ico/down.ico index 79ec3929df..d4fdb83bbf 100644 Binary files a/plugins/Actman/ico/down.ico and b/plugins/Actman/ico/down.ico differ diff --git a/plugins/Actman/ico/export.ico b/plugins/Actman/ico/export.ico index 7c6b07c71a..ddddb59074 100644 Binary files a/plugins/Actman/ico/export.ico and b/plugins/Actman/ico/export.ico differ diff --git a/plugins/Actman/ico/format.ico b/plugins/Actman/ico/format.ico index 7c6b07c71a..ddddb59074 100644 Binary files a/plugins/Actman/ico/format.ico and b/plugins/Actman/ico/format.ico differ diff --git a/plugins/Actman/ico/import.ico b/plugins/Actman/ico/import.ico index a3d5232741..481da4dbaf 100644 Binary files a/plugins/Actman/ico/import.ico and b/plugins/Actman/ico/import.ico differ diff --git a/plugins/Actman/ico/ini.ico b/plugins/Actman/ico/ini.ico new file mode 100644 index 0000000000..481da4dbaf Binary files /dev/null and b/plugins/Actman/ico/ini.ico differ diff --git a/plugins/Actman/ico/insert.ico b/plugins/Actman/ico/insert.ico index a3d5232741..481da4dbaf 100644 Binary files a/plugins/Actman/ico/insert.ico and b/plugins/Actman/ico/insert.ico differ diff --git a/plugins/Actman/ico/jump.ico b/plugins/Actman/ico/jump.ico new file mode 100644 index 0000000000..3a98b8ac30 Binary files /dev/null and b/plugins/Actman/ico/jump.ico differ diff --git a/plugins/Actman/ico/message.ico b/plugins/Actman/ico/message.ico index 6cc054ccc3..fa6c604542 100644 Binary files a/plugins/Actman/ico/message.ico and b/plugins/Actman/ico/message.ico differ diff --git a/plugins/Actman/ico/new.ico b/plugins/Actman/ico/new.ico index fcfa03a6ad..73937210e0 100644 Binary files a/plugins/Actman/ico/new.ico and b/plugins/Actman/ico/new.ico differ diff --git a/plugins/Actman/ico/notes.ico b/plugins/Actman/ico/notes.ico new file mode 100644 index 0000000000..fa6c604542 Binary files /dev/null and b/plugins/Actman/ico/notes.ico differ diff --git a/plugins/Actman/ico/program.ico b/plugins/Actman/ico/program.ico index 0ce8a9a24d..30c7df1875 100644 Binary files a/plugins/Actman/ico/program.ico and b/plugins/Actman/ico/program.ico differ diff --git a/plugins/Actman/ico/reload.ico b/plugins/Actman/ico/reload.ico index feadf04bf2..dc070c5083 100644 Binary files a/plugins/Actman/ico/reload.ico and b/plugins/Actman/ico/reload.ico differ diff --git a/plugins/Actman/ico/rw.ico b/plugins/Actman/ico/rw.ico index df5cd0f6c7..d5927ebb08 100644 Binary files a/plugins/Actman/ico/rw.ico and b/plugins/Actman/ico/rw.ico differ diff --git a/plugins/Actman/ico/service.ico b/plugins/Actman/ico/service.ico index 7c6b07c71a..ddddb59074 100644 Binary files a/plugins/Actman/ico/service.ico and b/plugins/Actman/ico/service.ico differ diff --git a/plugins/Actman/ico/settings.ico b/plugins/Actman/ico/settings.ico new file mode 100644 index 0000000000..ddddb59074 Binary files /dev/null and b/plugins/Actman/ico/settings.ico differ diff --git a/plugins/Actman/ico/storage.ico b/plugins/Actman/ico/storage.ico new file mode 100644 index 0000000000..dc070c5083 Binary files /dev/null and b/plugins/Actman/ico/storage.ico differ diff --git a/plugins/Actman/ico/test.ico b/plugins/Actman/ico/test.ico index 06db21a127..345530ba76 100644 Binary files a/plugins/Actman/ico/test.ico and b/plugins/Actman/ico/test.ico differ diff --git a/plugins/Actman/ico/text.ico b/plugins/Actman/ico/text.ico new file mode 100644 index 0000000000..fa6c604542 Binary files /dev/null and b/plugins/Actman/ico/text.ico differ diff --git a/plugins/Actman/ico/up.ico b/plugins/Actman/ico/up.ico index 6efc4d7257..56fde31eda 100644 Binary files a/plugins/Actman/ico/up.ico and b/plugins/Actman/ico/up.ico differ diff --git a/plugins/Actman/ico/vcheck.ico b/plugins/Actman/ico/vcheck.ico deleted file mode 100644 index d7c042119c..0000000000 Binary files a/plugins/Actman/ico/vcheck.ico and /dev/null differ diff --git a/plugins/Actman/ico/vuncheck.ico b/plugins/Actman/ico/vuncheck.ico deleted file mode 100644 index 05c93a1281..0000000000 Binary files a/plugins/Actman/ico/vuncheck.ico and /dev/null differ diff --git a/plugins/Actman/inoutini.pas b/plugins/Actman/inoutini.pas new file mode 100644 index 0000000000..38dab2be45 --- /dev/null +++ b/plugins/Actman/inoutini.pas @@ -0,0 +1,153 @@ +unit inoutini; + +interface + +uses windows, lowlevelc; + +{ +type + pINIioStruct = ^tINIioStruct; + tINIioStruct = record + storage, + section, + namespace:pAnsiChar; + end; +} +function Import(list:tMacroList;fname:PWideChar;aflags:dword):integer; + +implementation + +uses + io, common, m_api, question, + iac_global, global, memini; + +const + ioAction = 'Action'; + ioClass = 'class'; + ioName = 'name'; + ioVolatile = 'volatile'; +const + imp_yes = 1; + imp_yesall = 2; + imp_no = 3; + imp_noall = 4; + imp_append = 5; + +function ImportAction(section:pointer):tBaseAction; +var + pa:pActModule; +begin + if section<>nil then + begin + pa:=GetLinkByName(GetParamSectionStr(section,ioClass,nil)); + if pa<>nil then + begin + result:=pa.Create; + result.Load(section,2); + end + else + result:=tBaseAction(1); + end + else + result:=nil; +end; + +function Import(list:tMacroList;fname:PWideChar;aflags:dword):integer; +var + i:integer; + impact:integer; + buf:array [0..511] of WideChar; + oldid:dword; + arr:array [0..63] of tBaseAction; + act:tBaseAction; + p:pMacroRecord; + storage:pointer; + pc,pc1,ppc,ppc1:pAnsiChar; + pcw:pWideChar; +begin + result:=0; + + for i:=0 to list.Count-1 do + with list[i]^ do + if (flags and (ACF_IMPORT or ACF_ASSIGNED))= + (ACF_IMPORT or ACF_ASSIGNED) then + flags:=flags and not (ACF_IMPORT or ACF_OVERLOAD); + + if (fname=nil) or (fname^=#0) then + exit; + storage:=OpenStorage(fname); + if storage=nil then + exit; + + impact:=imp_yes; + + pc:=GetSectionList(storage,''); // list with "empty" namespaces + ppc:=pc; + while pc^<>#0 do + begin + UTF8ToWide(pc,pcw); + + p:=list.GetMacro(pcw); + oldid:=$FFFFFFFF; + if p<>nil then + begin + if (impact<>imp_yesall) and (impact<>imp_noall) then + begin + StrCopyW(buf,TranslateW('Action "$" exists, do you want to rewrite it?')); + impact:=ShowQuestion(StrReplaceW(buf,'$',pcw)); + end; + if (impact=imp_yesall) or (impact=imp_yes) then + begin + oldid:=p^.id; + FreeMacro(p); + end; + end; + // if new or overwriting then read macro details/actions + if (p=nil) or (impact=imp_yesall) or (impact=imp_yes) or (impact=imp_append) then + begin + with List[list.NewMacro()]^ do + begin + if (p<>nil) and (oldid<>$FFFFFFFF) then // set old id to keep UseAction setting + begin + flags:=flags or ACF_IMPORT or ACF_OVERLOAD; + id:=oldid; + end + else + flags:=flags or ACF_IMPORT; + + if GetParamInt(storage,pc,ioVolatile)=1 then flags:=flags or ACF_VOLATILE; + StrCopyW(descr,pcw,MacroNameLen-1); + + // reading actions + ActionCount:=0; // amount of loaded + pc1:=GetSectionList(storage,pc); + ppc1:=pc1; + while pc1^<>#0 do + begin + act:=ImportAction(SearchSection(storage,pc1,pc)); + if act=nil then + break; + if uint_ptr(act)<>1 then + begin + arr[ActionCount]:=act; + inc(ActionCount); + end; + end; + FreeSectionList(ppc1); + // moving actions to their place + if Actioncount>0 then + begin + GetMem(ActionList,SizeOf(tBaseAction)*ActionCount); + move(arr,ActionList^,SizeOf(tBaseAction)*ActionCount); + end; + inc(result); + end; + end; + + end; + FreeSectionList(ppc); + + CloseStorage(storage); +end; + +end. diff --git a/plugins/Actman/inoutxml.pas b/plugins/Actman/inoutxml.pas new file mode 100644 index 0000000000..cd11c1a963 --- /dev/null +++ b/plugins/Actman/inoutxml.pas @@ -0,0 +1,155 @@ +unit inoutxml; + +interface + +uses windows, lowlevelc; + +function Import(list:tMacroList;fname:PWideChar;aflags:dword):integer; + +implementation + +uses + io, common, m_api, question, + iac_global, global; + +const + ioAction = 'Action'; + ioClass = 'class'; + ioName = 'name'; + ioVolatile = 'volatile'; +const + imp_yes = 1; + imp_yesall = 2; + imp_no = 3; + imp_noall = 4; + imp_append = 5; + +function ImportAction(actnode:HXML):tBaseAction; +var + pa:pActModule; + buf:array [0..127] of AnsiChar; +begin + result:=nil; + if actnode=0 then exit; + with xmlparser do + begin + pa:=GetLinkByName(FastWideToAnsiBuf(getAttrValue(actnode,ioClass),buf)); + if pa<>nil then + begin + result:=pa.Create; + result.Load(pointer(actnode),1); + end + else + result:=tBaseAction(1); + end; +end; + +function Import(list:tMacroList;fname:PWideChar;aflags:dword):integer; +var + f:THANDLE; + i,nodenum,actcnt:integer; + tmp,res:pWideChar; + root,actnode:HXML; + impact:integer; + buf:array [0..511] of WideChar; + oldid:dword; + arr:array [0..63] of tBaseAction; + act:tBaseAction; + p:pMacroRecord; +begin + result:=0; + + for i:=0 to list.Count-1 do + with list[i]^ do + if (flags and (ACF_IMPORT or ACF_ASSIGNED))= + (ACF_IMPORT or ACF_ASSIGNED) then + flags:=flags and not (ACF_IMPORT or ACF_OVERLOAD); + + if (fname=nil) or (fname^=#0) then + exit; + i:=GetFSize(fname); + if i=0 then + exit; + mGetMem (res ,i+SizeOf(WideChar)); + FillChar(res^,i+SizeOf(WideChar),0); + f:=Reset(fname); + BlockRead(f,res^,i); + CloseHandle(f); + +//MessageBoxW(0,res,'SRC',0); + xmlparser.cbSize:=SizeOf(TXML_API_W); + CallService(MS_SYSTEM_GET_XI,0,lparam(@xmlparser)); + with xmlparser do + begin + root:=parseString(ChangeUnicode(res),@i,nil); + nodenum:=0; + impact:=imp_yes; + repeat + actnode:=getNthChild(root,ioAction,nodenum); + if actnode=0 then break; +//?? if StrCmpW(getName(actnode),ioAction)<>0 then break; + tmp:=getAttrValue(actnode,ioName); + if tmp<>nil then //!! + begin + p:=list.GetMacro(tmp); + oldid:=$FFFFFFFF; + if p<>nil then + begin + if (impact<>imp_yesall) and (impact<>imp_noall) then + begin + StrCopyW(buf,TranslateW('Action "$" exists, do you want to rewrite it?')); + impact:=ShowQuestion(StrReplaceW(buf,'$',tmp)); + end; + if (impact=imp_yesall) or (impact=imp_yes) then + begin + oldid:=p^.id; + FreeMacro(p); + end; + end; + // if new or overwriting then read macro details/actions + if (p=nil) or (impact=imp_yesall) or (impact=imp_yes) or (impact=imp_append) then + begin + with List[list.NewMacro()]^ do + begin + if (p<>nil) and (oldid<>$FFFFFFFF) then // set old id to keep UseAction setting + begin + flags:=flags or ACF_IMPORT or ACF_OVERLOAD; + id:=oldid; + end + else + flags:=flags or ACF_IMPORT; + if StrToInt(getAttrValue(actnode,ioVolatile))=1 then flags:=flags or ACF_VOLATILE; + StrCopyW(descr,tmp,MacroNameLen-1); + + // reading actions + actcnt:=0; // count in file + ActionCount:=0; // amount of loaded + repeat + act:=ImportAction(getChild(actnode,actcnt)); + if act=nil then + break; + if uint_ptr(act)<>1 then + begin + arr[ActionCount]:=act; + inc(ActionCount); + end; + inc(actcnt); + until false; + // moving actions to their place + if Actioncount>0 then + begin + GetMem(ActionList,SizeOf(tBaseAction)*ActionCount); + move(arr,ActionList^,SizeOf(tBaseAction)*ActionCount); + end; + inc(result); + end; + end; + end; + inc(nodenum); + until false; + destroyNode(root); + end; + mFreeMem(res); +end; + +end. diff --git a/plugins/Actman/lowlevelc.pas b/plugins/Actman/lowlevelc.pas new file mode 100644 index 0000000000..fe6d9bde31 --- /dev/null +++ b/plugins/Actman/lowlevelc.pas @@ -0,0 +1,296 @@ +unit lowlevelc; + +interface + +uses + windows, + iac_global; + +// Macro flags +const + ACF_ASSIGNED = $80000000; // macro assigned + ACF_FIRSTRUN = $40000000; // FirstRun flag + ACF_USEDNOW = $20000000; // macro in use (reserved) + ACF_VOLATILE = $10000000; // don't save in DB + + ACF_TOSAVE = ACF_ASSIGNED or ACF_FIRSTRUN; + +type + pActionList = ^tActionList; + tActionList = array [0..1023] of tBaseAction; + +const + MacroNameLen = 64; +type + pMacroRecord = ^tMacroRecord; + tMacroRecord = record + id :dword; + flags :dword; // ACF_* flags + descr :array [0..MacroNameLen-1] of WideChar; + ActionList :pActionList; + ActionCount:integer; + end; + +type // array dimension - just for indexing + pMacroList = ^taMacroList; + taMacroList = array [0..1023] of tMacroRecord; + +type + tMacroList = class + private + fMacroList:pMacroList; + fMacroCount:cardinal; + + procedure ReallocMacroList; + function GetMacroElement(i:integer):pMacroRecord; + public + + constructor Create(isize:cardinal); + destructor Destroy; override; + + procedure Clear(filter:dword=0); + function Clone:tMacroList; + function NewMacro:cardinal; + + function GetMacro(id:uint_ptr ):pMacroRecord; overload; + function GetMacro(name:pWideChar):pMacroRecord; overload; + function GetMacroNameById(id:dword):PWideChar; + + property List[i:integer]:pMacroRecord read GetMacroElement; default; + property Count: cardinal read fMacroCount; + end; + +procedure FreeMacro(Macro:pMacroRecord;mask:dword=0); + +var + MacroList:tMacroList; + + +implementation + +uses Common; + +const + MacroListPage = 8; + + +function tMacroList.GetMacroElement(i:integer):pMacroRecord; +begin + result:=@fMacroList[i]; +end; + +function tMacroList.GetMacro(id:uint_ptr):pMacroRecord; +var + i:integer; +begin + for i:=0 to fMacroCount-1 do + begin + if ((fMacroList^[i].flags and ACF_ASSIGNED)<>0) and + (id=fMacroList^[i].id) then + begin + result:=@(fMacroList^[i]); + exit; + end; + end; + result:=nil; +end; + +function tMacroList.GetMacro(name:pWideChar):pMacroRecord; +var + i:integer; +begin + for i:=0 to fMacroCount-1 do + begin + if ((fMacroList^[i].flags and ACF_ASSIGNED)<>0) and + (StrCmpW(name,fMacroList^[i].descr)=0) then + begin + result:=@(fMacroList^[i]); + exit; + end; + end; + result:=nil; +end; + +function tMacroList.GetMacroNameById(id:dword):PWideChar; +var + p:pMacroRecord; +begin + p:=GetMacro(id); + if p<>nil then + result:=@(p^.descr) + else + result:=nil; +end; + +procedure FreeActionList(var src:pActionList; count:integer; mask:dword); +var + i:integer; +begin + for i:=0 to count-1 do + begin + if (mask=0) or ((src^[i].flags and mask)<>0) then + src^[i].Free; + end; + FreeMem(src); + src:=nil; +end; + +procedure FreeMacro(Macro:pMacroRecord;mask:dword=0); +begin + with Macro^ do + begin + if (flags and ACF_ASSIGNED)<>0 then + begin + flags:=0; // make Unassigned + FreeActionList(ActionList,ActionCount,mask); + ActionCount:=0; + end; + end; +end; + +procedure tMacroList.Clear(filter:dword=0); +var + i:integer; +begin + for i:=0 to fMacroCount-1 do + begin + FreeMacro(@(fMacroList[i]),filter); + end; + fMacroCount:=0; + FreeMem(fMacroList); + fMacroList:=nil; +end; + +destructor tMacroList.Destroy; +begin + fMacroCount:=0; + FreeMem(fMacroList); + fMacroList:=nil; + + inherited Destroy; +end; + +function CloneActionList(src:pActionList;count:integer):pActionList; +begin + if src=nil then + begin + result:=nil; + exit; + end; + GetMem(result ,count*SizeOf(tBaseAction)); + move(src^,result^,count*SizeOf(tBaseAction)) +end; + +procedure CloneMacro(var dst:pMacroRecord; src:pMacroRecord); +begin + if (src^.flags and ACF_ASSIGNED)<>0 then + begin + move(src^,dst^,SizeOf(tMacroRecord)); + dst^.ActionList:=CloneActionList(src^.ActionList,src^.ActionCount); + end; +end; + +function tMacroList.Clone:tMacroList; +var + src,dst:pMacroRecord; + i:integer; + cnt:integer; +begin + result:=nil; + + if fMacroList<>nil then + begin + cnt:=0; + for i:=0 to fMacroCount-1 do + if (fMacroList^[i].flags and ACF_ASSIGNED)<>0 then + inc(cnt); + if cnt>0 then + begin + result:=tMacroList.Create(cnt); + + src:=pMacroRecord(self.fMacroList); + dst:=pMacroRecord(result.fMacroList); + + while cnt>0 do + begin + if (src^.flags and ACF_ASSIGNED)<>0 then + begin + CloneMacro(dst,src); + inc(dst); + dec(cnt); + end; + inc(src); + end; + end; + end; + if result=nil then + result:=tMacroList.Create(0); +end; + +procedure tMacroList.ReallocMacroList; +var + i:cardinal; + tmp:pMacroList; +begin + i:=(fMacroCount+MacroListPage)*SizeOf(tMacroRecord); + GetMem(tmp,i); + FillChar(tmp^,i,0); + if fMacroCount>0 then + begin + move(fMacroList^,tmp^,fMacroCount*SizeOf(tMacroRecord)); + FreeMem(fMacroList); + end; + fMacroList:=tmp; + inc(fMacroCount,MacroListPage); +end; + +constructor tMacroList.Create(isize:cardinal); +begin + inherited Create; + + if isize" , IDC_FLAG_GT , 138, 33, 32, 11 - AUTORADIOBUTTON "<" , IDC_FLAG_LT , 170, 33, 32, 11 - AUTORADIOBUTTON "=" , IDC_FLAG_EQ , 202, 33, 32, 11 - AUTORADIOBUTTON "NOP" , IDC_FLAG_NOP , 234, 33, 32, 11 - AUTOCHECKBOX "NOT" , IDC_FLAG_NOT , 138, 44, 32, 11 - RTEXT "Value" , IDC_STAT_VAL , 170, 44, 78, 11, SS_CENTERIMAGE - EDITTEXT IDC_ADV_VALUE , 250, 44, 48, 11, ES_RIGHT //| ES_NUMBER - - AUTOCHECKBOX "Math" , IDC_FLAG_MATH , 138, 61, 64, 13, WS_GROUP - COMBOBOX IDC_ADV_OPER , 204, 61, 44, 96, - CBS_DROPDOWNLIST | WS_VSCROLL - EDITTEXT IDC_ADV_VAL1 , 250, 61, 48, 13, ES_RIGHT //| ES_NUMBER - - AUTOCHECKBOX "Variables" , IDC_FLAG_VARS , 138, 78, 124, 12 - CONTROL "V", IDC_ADV_HVARS, "MButtonClass",WS_TABSTOP, 285,75,16,16,$18000000 -// PUSHBUTTON "vars" , IDC_ADV_HVARS , 264, 78, 37, 12 - EDITTEXT IDC_ADV_VARS , 144, 92, 157, 68, - ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN - AUTOCHECKBOX "Result as integer", IDC_ADV_ASINT , 135, 161, 164, 13, BS_RIGHT | BS_LEFTTEXT - - GROUPBOX "Operation" , IDC_OPERATION , 135, 174, 166, 49, WS_GROUP - AUTORADIOBUTTON "JUMP" , IDC_FLAG_JUMP , 138, 183, 62, 12 - AUTORADIOBUTTON "BREAK" , IDC_FLAG_BREAK, 138, 196, 62, 12 - AUTORADIOBUTTON "NOP" , IDC_FLAG_ANOP , 138, 209, 62, 12 - COMBOBOX IDC_ADV_VAL2 , 200, 183, 99, 96, CBS_DROPDOWNLIST | WS_VSCROLL | CBS_AUTOHSCROLL - -// Chain - RTEXT "Other Action groups",IDC_STAT_GROUPS,135, 24, 160, 10 - COMBOBOX IDC_GROUP_LIST, 135, 35, 166, 128, - CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_VSCROLL - -// Read / write setting - - AUTORADIOBUTTON "Own settings", IDC_RW_CURRENT, 135, 50, 80, 11, BS_RIGHT | BS_LEFTTEXT | WS_GROUP - AUTORADIOBUTTON "Manual" , IDC_RW_MANUAL , 135, 62, 80, 11, BS_RIGHT | BS_LEFTTEXT - AUTORADIOBUTTON "Parameter" , IDC_RW_PARAM , 217, 50, 80, 11 - AUTORADIOBUTTON "Last result" , IDC_RW_RESULT , 217, 62, 80, 11 - - RTEXT "Module" , IDC_RW_STATM , 135, 75, 160, 8, SS_CENTERIMAGE - AUTOCHECKBOX "", IDC_RW_MVAR,135,84,8,8,BS_ICON | BS_PUSHLIKE - EDITTEXT IDC_RW_MODULE , 144, 84, 157, 12, ES_AUTOHSCROLL - RTEXT "Setting" , IDC_RW_STATS , 135, 99, 160, 8, SS_CENTERIMAGE - AUTOCHECKBOX "", IDC_RW_SVAR,135,108,8,8,BS_ICON | BS_PUSHLIKE - EDITTEXT IDC_RW_SETTING, 144, 108, 157, 12, ES_AUTOHSCROLL - - GROUPBOX "Operation" , IDC_RW_OPER , 135, 124, 166, 21, WS_GROUP - AUTORADIOBUTTON "Read" , IDC_RW_READ , 138, 133, 52, 11 - AUTORADIOBUTTON "Write" , IDC_RW_WRITE , 191, 133, 52, 11 - AUTORADIOBUTTON "Delete" , IDC_RW_DELETE , 244, 133, 52, 11 - - GROUPBOX "Value" , IDC_RW_VAL , 135, 146, 166, 76, WS_GROUP - - COMBOBOX IDC_RW_DATATYPE, 220, 155, 79, 96, - CBS_DROPDOWNLIST | WS_VSCROLL - - AUTOCHECKBOX "Last result" , IDC_RW_LAST , 140, 179, 156, 11, BS_RIGHT | BS_LEFTTEXT - EDITTEXT IDC_RW_VALUE , 149, 191, 147, 11, ES_AUTOHSCROLL | ES_RIGHT// | ES_NUMBER - AUTOCHECKBOX "", IDC_RW_TVAR,140,191,8,8,BS_ICON | BS_PUSHLIKE - EDITTEXT IDC_RW_TEXT , 149, 191, 147, 29, - ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN - -// MessageBox - - AUTOCHECKBOX "", IDC_MSG_TTL,135,32,8,8,BS_ICON | BS_PUSHLIKE - EDITTEXT IDC_MSG_TITLE, 144, 32, 157, 12, - ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN - RTEXT "Message text" ,IDC_MSG_STAT2, 137, 46, 164, 11, SS_CENTERIMAGE - AUTOCHECKBOX "", IDC_MSG_TXT,135,58,8,8,BS_ICON | BS_PUSHLIKE - EDITTEXT IDC_MSG_TEXT , 144, 58, 157, 49, - ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN - AUTOCHECKBOX "Keep last result" , IDC_MSG_KEEP, 138, 109, 163, 11, BS_RIGHT | BS_LEFTTEXT - - GROUPBOX "Icons" , IDC_MSG_ICONS , 135, 123, 166, 28, WS_GROUP - AUTORADIOBUTTON "Error" , IDC_MSGI_ERROR, 140, 130, 24, 20, BS_ICON - AUTORADIOBUTTON "Question", IDC_MSGI_QUEST, 166, 130, 24, 20, BS_ICON - AUTORADIOBUTTON "Warning" , IDC_MSGI_WARN , 192, 130, 24, 20, BS_ICON - AUTORADIOBUTTON "Info" , IDC_MSGI_INFO , 218, 130, 24, 20, BS_ICON - AUTORADIOBUTTON "None" , IDC_MSGI_NONE , 246, 130, 53, 20//, BS_ICON - - GROUPBOX "Buttons" , IDC_MSG_BTNS, 135, 152, 166, 71, WS_GROUP - AUTORADIOBUTTON "OK" , IDC_MSGB_OK , 140, 161, 156, 10 - AUTORADIOBUTTON "OK, Cancel" , IDC_MSGB_OC , 140, 171, 156, 10 - AUTORADIOBUTTON "Abort, Retry, Ignore", IDC_MSGB_ARI, 140, 181, 156, 10 - AUTORADIOBUTTON "Yes, No, Cancel" , IDC_MSGB_YNC, 140, 191, 156, 10 - AUTORADIOBUTTON "Yes, No" , IDC_MSGB_YN , 140, 201, 156, 10 - AUTORADIOBUTTON "Retry, Cancel" , IDC_MSGB_RC , 140, 211, 156, 10 - - RTEXT "Message title",IDC_MSG_STAT1, 137, 20, 164, 11, SS_CENTERIMAGE } - -IDD_ASK DIALOGEX 0, 0, 276, 72, 0 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_CONTROLPARENT -CAPTION "Choose action" -FONT 8, "MS Shell Dlg", 0, 0 -{ - CTEXT "", IDC_ASK,4,4,268,42,SS_CENTERIMAGE - - CONTROL "", -1, "STATIC", SS_ETCHEDHORZ, 2, 50, 272, 2 - - DEFPUSHBUTTON "&Yes" , IDOK , 4, 54, 40, 16 - PUSHBUTTON "&No" , IDCANCEL , 52, 54, 40, 16 - PUSHBUTTON "A&ppend" , IDC_APPEND, 100, 54, 52, 16 - PUSHBUTTON "Yes to &All", IDC_YESALL, 160, 54, 52, 16 - PUSHBUTTON "N&o to All" , IDC_NOALL , 220, 54, 52, 16 -} - -IDI_NEW ICON "ico\new.ico" -IDI_UP ICON "ico\up.ico" -IDI_DOWN ICON "ico\down.ico" -IDI_DELETE ICON "ico\delete.ico" -IDI_RELOAD ICON "ico\reload.ico" -IDI_TEST ICON "ico\test.ico" -IDI_EXPORT ICON "ico\export.ico" -IDI_IMPORT ICON "ico\import.ico" - -IDI_CONTACT ICON "ico\contact.ico" -IDI_SERVICE ICON "ico\service.ico" -IDI_PROGRAM ICON "ico\program.ico" -IDI_INSERT ICON "ico\insert.ico" -IDI_ADVANCE ICON "ico\advance.ico" -IDI_CHAIN ICON "ico\chain.ico" -IDI_RW ICON "ico\rw.ico" -IDI_MESSAGE ICON "ico\message.ico" -IDI_FORMAT ICON "ico\format.ico" - -IDI_APPLY ICON "ico\apply.ico" - -IDI_VAR_CHECKED ICON "ico\vcheck.ico" -IDI_VAR_UNCHECKED ICON "ico\vuncheck.ico" - +/* VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,2,0,1 - PRODUCTVERSION 0,2,0,1 + FILEVERSION 0,3,0,1 + PRODUCTVERSION 0,3,0,1 FILEFLAGSMASK $3F FILEOS 4 FILETYPE 2 @@ -313,12 +54,12 @@ BEGIN VALUE "CompanyName","" VALUE "Comments", "Plugin for managing different Miranda actions "0 VALUE "FileDescription", "Action manager for Miranda NG"0 - VALUE "FileVersion", "0, 2, 0, 1 "0 + VALUE "FileVersion", "0, 3, 0, 1 "0 VALUE "InternalName", "ActManager"0 VALUE "OriginalFilename", "actman.dll"0 VALUE "ProductName", "Action Manager Dynamic Link Library (DLL)"0 - VALUE "ProductVersion", "0, 2, 0, 1 "0 - VALUE "SpecialBuild", "18.08.2011 "0 + VALUE "ProductVersion", "0, 3, 0, 1 "0 + VALUE "SpecialBuild", "18.11.2012 "0 END END BLOCK "VarFileInfo" @@ -326,3 +67,4 @@ BEGIN VALUE "Translation",0,1200 END END +*/ \ No newline at end of file diff --git a/plugins/Actman/options.res b/plugins/Actman/options.res index 6385d76f43..951c81f7f6 100644 Binary files a/plugins/Actman/options.res and b/plugins/Actman/options.res differ diff --git a/plugins/Actman/question.pas b/plugins/Actman/question.pas index 84bbd60604..d936b65794 100644 --- a/plugins/Actman/question.pas +++ b/plugins/Actman/question.pas @@ -3,13 +3,14 @@ unit question; interface uses windows,messages; -function QuestionDlg(Dialog:HWnd;hMessage:UINT;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; +function ShowQuestion(ask:pWideChar):integer; implementation uses m_api; {$include i_const.inc} +{$resource ask.res} const imp_yes = 1; @@ -18,7 +19,7 @@ const imp_noall = 4; imp_append = 5; -function QuestionDlg(Dialog:HWnd;hMessage:UINT;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; +function QuestionDlg(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; var i:integer; begin @@ -48,4 +49,10 @@ begin end; end; +function ShowQuestion(ask:pWideChar):integer; +begin + result:=DialogBoxParam(hInstance,MAKEINTRESOURCE(IDD_ASK),0, + @QuestionDlg,TLPARAM(ask)); +end; + end. diff --git a/plugins/Actman/readme.txt b/plugins/Actman/readme.txt index 0c6359ebe3..1831a1efe2 100644 --- a/plugins/Actman/readme.txt +++ b/plugins/Actman/readme.txt @@ -101,7 +101,7 @@ This subaction is for database reading/writing (see Operation block). Value and value type is for type of data, reading or writing from/to database. 'Last result' mean that value is result of previous action. Group of radioboxes is for contact type. - 'Own settings' - all settings only for our contact (our profle settings) + 'Own settings' - all settings only for our contact (our profile settings) 'Parameter' - settings for contact with handle, passed from start parameter 'Last result' - contact handle is result of last action 'Manual' - contact handle selected from combobox diff --git a/plugins/Actman/services.ini b/plugins/Actman/services.ini index fcf82289c6..7d0bda9289 100644 --- a/plugins/Actman/services.ini +++ b/plugins/Actman/services.ini @@ -2,15 +2,19 @@ ;if wparam or lparam consists of list, "|" is separator ;in list: if translation not needed, just add space before help ;numeric parameter format: numberhelp -;hContact will setup "Current contact" feature -;structure will setup "structure" feature +;'hContact' will setup "Current contact" feature +;'structure' will setup "structure" feature +;'Unicode' as first word will setup "Unicode text" feature +; not sure what next are usable +;'parameter' will setup "Parameter" feature +;'result' will setup "last result" feature ;if "return" starts from int/hex/str/struct then separator, result type will set -;[Event:Event (name or constant] +;[Event:Event (name or constant)] ;alias=constant name ;descr=text -;plugin=placement (including "core" and empty = "unknown" +;plugin=placement (including "core" and empty = "unknown") ;wparam= ;lparam= @@ -19,6 +23,14 @@ ;descr: structure description ;plugin: where defined +[Service:DB/UI/ChangePassword] +alias=MS_DB_CHANGEPASSWORD +wparam=0 +lparam=0 +return=0 +descr=Show window for new/changed profile password +plugin=db3x_mmap + [Service:CListFrames/HideALLFramesTB] alias=MS_CLIST_FRAMES_HIDEALLFRAMESTB wparam=0 @@ -97,7 +109,7 @@ alias=MS_DBEDIT_IMPORT wparam=hContact lparam=Ansi Text return=int 0 -descr=Import settings\contacts from file +descr=Import settings/contacts from file plugin=Database Editor++ (dbeditorpp.dll) [Service:DBEditorpp/MenuCommand] @@ -124,7 +136,7 @@ descr=displays File Transfer window [Service:Help/AboutCommand] wparam=0 on Desktop|parent window handle lparam=0 -Show "About..." window +descr=Show "About..." window [Service:Help/IndexCommand] wparam=0 @@ -134,7 +146,7 @@ descr=Open support (originaly - Miranda wiki) page [Service:Help/WebsiteCommand] wparam=0 lparam=0 -descr=Go to Miranda IM Homepage +descr=Go to Miranda Homepage [Service:Help/BugCommand] wparam=0 @@ -175,23 +187,11 @@ lparam=-1 Ignore all|1 Ignore messages|2 Ignore URLs|3 Ignore files|4 Ignore Use return=int 0, if successful descr=Unignore Contact -[Service:mDynDNS/GetIP] -wparam=0 auto|1 mDynDNS-checkip|2 DNS querry -lparam=structure|*b.arr 16| -return=struct -descr=Returns the IP (empty string on failure) - -[Service:MIMLocker/Lock] -wparam=0 -wparam=0 -plugin=MIMLocker (MIMLocker.dll) -descr=Locks & hides Miranda's contact list and message sessions until password is entered - [Service:Miranda/System/Restart] alias=MS_SYSTEM_RESTART wparam=0 restart in default profile or profile manager|1 restart with current profile lparam=0 -descr=Restarts Miranda ver.0.8+ +descr=Restarts Miranda [Service:mRadio/PlayStop] alias=MS_RADIO_PLAYSTOP @@ -239,14 +239,26 @@ descr=Open Options dialog [Service:Opt/OpenOptions] alias=MS_OPT_OPENOPTIONS wparam=0 -lparam=structure|0|native|bptr|bptr|bptr| +lparam=structure|0|dword|b.ptr|b.ptr|b.ptr| return=int 0, if successful descr=Opens the options dialog, optionally at the specified page +[Service:PackUpdater/CheckUpdates] +wparam=0 +lparam=0 +plugin=Pack Updater (packupdater.dll) +descr=Check for updates + +[Service:PackUpdater/EmptyFolder] +wparam=0 +lparam=0 with confirmation| 1 - without confirmation +plugin=Pack Updater (packupdater.dll) +descr=Empty updater download folder + [Service:Popup/EnableDisableMenuCommand] wparam=0 lparam=0 -plugin=Popup Plus (popup.dll) +plugin=Popup Plus (popup.dll) latest YAPP (yapp.dll) descr=Enables or disables Popup windows [Service:Popup/ShowMessage] @@ -262,14 +274,14 @@ alias=MS_POPUP_SHOWMESSAGEW wparam=Unicode Text lparam=1 Warning|2 Notify|3 Error return=int 0, if successful -plugin=YAPP only +plugin=YAPP or Popup descr=Popup window [Service:Popup/ToggleEnabled] wparam=0 lparam=0 plugin=YAPP (yapp.dll) -descr=Enables or disables Popup windows +descr=Enables or disables Popup windows (maybe deprecated) [Service:Proto/CallContactService] alias=MS_PROTO_CALLCONTACTSERVICE @@ -278,6 +290,13 @@ lparam=structure|0|native|b.ptr|native|native| return=result of protocol service call descr=Send a general request through the protocol chain for a contact +[Service:Proto/GetContactBaseAccount] +alias=MS_PROTO_GETCONTACTBASEACCOUNT +wparam=hContact +lparam=0 +return=str, account name +descr=Return account name associated to contact (no need to free it) + [Service:Protos/ShowAccountManager] alias=MS_PROTO_SHOWACCMGR wparam=0 @@ -293,7 +312,7 @@ descr=Show the dialog to select the contact [Service:QuickSearch_PLUGIN/Show] wparam=0|filter text -lparam=0 wparam is unicode|1 wparam is Ansi|2 reserved +lparam=0 wParam is unicode|1 wParam is Ansi|2 Reserved plugin=Quick Search (Mod) (quicksearch.dll) descr= @@ -347,23 +366,16 @@ descr=remove all temporary contacts from db alias=MS_AV_CONTACTOPTIONS wparam=hContact lparam=0 -plugin=Avatar service (loadavatars.dll) +plugin=Avatar service (AVS.dll) descr=Call avatar option dialog for contact [Service:SV_Avatars/SetAvatar] alias=MS_AV_SETAVATAR wparam=hContact lparam=0|Filename -plugin=Avatar service (loadavatars.dll) +plugin=Avatar service (AVS.dll) descr=Set (and optionally protect) a local contact picture for the given hContact. If lParam = NIL, the service will open a file selection dialog. -[Service:Update/CheckForUpdates] -wparam=0 -lparam=0 -return=int 0 -plugin=Updater (updater.dll) -descr=Check for plugin updates - [Service:UserInfo/ShowDialog] alias=MS_USERINFO_SHOWDIALOG wparam=0 System|hContact @@ -495,3 +507,47 @@ native (LPARAM) lParam| short=0|param|b.ptr|native|native| descr= plugin= + +[Const:CALLSERVICE_NOTFOUND] +value=$80000000 +value64=$8000000000000000 +;signed=0 +;plugin=core + +[Const:ID_STATUS_OFFLINE] +value=40071 +[Const:ID_STATUS_ONLINE] +value=40072 +[Const:ID_STATUS_AWAY] +value=40073 +[Const:ID_STATUS_DND] +value=40074 +[Const:ID_STATUS_NA] +value=40075 +[Const:ID_STATUS_OCCUPIED] +value=40076 +[Const:ID_STATUS_FREECHAT] +value=40077 +[Const:ID_STATUS_INVISIBLE] +value=40078 +[Const:ID_STATUS_ONTHEPHONE] +value=40079 +[Const:ID_STATUS_OUTTOLUNCH] +value=40080 +[Const:ID_STATUS_IDLE] +value=40081 + +[Function:user32.dll$MessageBoxA] +;dll= +calltype=stdcall +argcount=4 +argvalue1=0 +argvalue2=Ansi message +argvalue3=Ansi caption +argvalue4=0 +argname1=hWnd +argname2=lpText +argname3=lpCaption +argname4=uType +return=int 0 +descr=Displays a modal dialog box that contains a system icon, a set of buttons, and a brief application-specific message, such as status or error information. diff --git a/plugins/Actman/sparam.res b/plugins/Actman/sparam.res new file mode 100644 index 0000000000..0491ec8f83 Binary files /dev/null and b/plugins/Actman/sparam.res differ diff --git a/plugins/Actman/structopts.res b/plugins/Actman/structopts.res new file mode 100644 index 0000000000..f651b686f2 Binary files /dev/null and b/plugins/Actman/structopts.res differ diff --git a/plugins/Actman/tasks.res b/plugins/Actman/tasks.res new file mode 100644 index 0000000000..bc72f06406 Binary files /dev/null and b/plugins/Actman/tasks.res differ diff --git a/plugins/Actman/tasks/i_opt_dlg.inc b/plugins/Actman/tasks/i_opt_dlg.inc index c8025c278d..bf8d45f63c 100644 --- a/plugins/Actman/tasks/i_opt_dlg.inc +++ b/plugins/Actman/tasks/i_opt_dlg.inc @@ -275,13 +275,14 @@ function DeleteTask(Dialog:HWND):integer; var li:LV_ITEM; wnd:HWND; - i:integer; + i,j:integer; begin result:=0; wnd:=GetDlgItem(Dialog,IDC_TASK_NAME); - for i:=ListView_GetItemCount(wnd)-1 downto 0 do + j:=SendMessage(wnd,LVM_GETITEMCOUNT,0,0); + for i:=j-1 downto 0 do begin - if ListView_GetItemState(wnd,i,LVIS_SELECTED)<>0 then + if SendMessage(wnd,LVM_GETITEMSTATE,i,LVIS_SELECTED)<>0 then begin li.iItem :=i; li.mask :=LVIF_PARAM; @@ -299,7 +300,7 @@ begin CheckTaskList(Dialog,false); end; -function NewHKTableProc(Dialog:HWnd;hMessage:UINT;wParam:WPARAM;lParam:LPARAM):lresult; stdcall; +function NewHKTableProc(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; var i:integer; begin @@ -403,7 +404,7 @@ begin SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,LPARAM(@ti)); end; -function DlgProcOpt(Dialog:HWnd;hMessage:UINT;wParam:WPARAM;lParam:LPARAM):lresult; stdcall; +function DlgProcOpt(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; var wnd:HWND; lv:LV_COLUMNW; diff --git a/plugins/Actman/tasks/i_options.inc b/plugins/Actman/tasks/i_options.inc index 527e8d0c88..da5cce0c40 100644 --- a/plugins/Actman/tasks/i_options.inc +++ b/plugins/Actman/tasks/i_options.inc @@ -83,6 +83,7 @@ begin StrCopy(p,opt_name ); name :=DBReadUnicode(0,DBBranch,section); StrCopy(p,opt_action); action :=DBReadDWord (0,DBBranch,section); StrCopy(p,opt_days ); dayoffset:=DBReadByte (0,DBBranch,section); + //!! smallint? StrCopy(p,opt_repeat); count :=Shortint(DBReadWord(0,DBBranch,section)); StrCopy(p,opt_time_lo ); starttime.dwLowDateTime :=DBReadDWord(0,DBBranch,section); diff --git a/plugins/Actman/tasks/scheduler.pas b/plugins/Actman/tasks/scheduler.pas index 05e9cb6a58..1ec1202f26 100644 --- a/plugins/Actman/tasks/scheduler.pas +++ b/plugins/Actman/tasks/scheduler.pas @@ -2,21 +2,15 @@ unit scheduler; interface -procedure Init; -procedure DeInit; -function AddOptionPage(var tmpl:pAnsiChar;var proc:pointer;var name:PAnsiChar):integer; - implementation uses windows, commctrl, messages, - mirutils, common, dbsettings, io, m_api, wrapper, + mirutils, common, dbsettings, m_api, wrapper, global; {$R tasks.res} -{$include m_actman.inc} - var hevent: THANDLE; @@ -28,11 +22,6 @@ var // ------------ base interface functions ------------- -var - hendis, - hcount, - hdel: THANDLE; - procedure Init; begin @@ -45,19 +34,18 @@ begin else SetAllTasks; - hcount:=CreateServiceFunction(MS_ACT_TASKCOUNT ,@TaskCount); - hendis:=CreateServiceFunction(MS_ACT_TASKENABLE,@TaskEnable); - hdel :=CreateServiceFunction(MS_ACT_TASKDELETE,@TaskDelete); + CreateServiceFunction(MS_ACT_TASKCOUNT ,@TaskCount); + CreateServiceFunction(MS_ACT_TASKENABLE,@TaskEnable); + CreateServiceFunction(MS_ACT_TASKDELETE,@TaskDelete); + hevent:=CreateHookableEvent(ME_ACT_BELL); end; procedure DeInit; begin + DestroyHookableEvent(hevent); StopAllTasks; - DestroyServiceFunction(hendis); - DestroyServiceFunction(hdel); - DestroyServiceFunction(hcount); ClearTasks; end; diff --git a/plugins/Actman/ua.res b/plugins/Actman/ua.res new file mode 100644 index 0000000000..8316b81f51 Binary files /dev/null and b/plugins/Actman/ua.res differ diff --git a/plugins/Actman/ua/action.ico b/plugins/Actman/ua/action.ico index 06db21a127..9e4c60d9d3 100644 Binary files a/plugins/Actman/ua/action.ico and b/plugins/Actman/ua/action.ico differ diff --git a/plugins/Actman/ua/i_inoutjson.inc b/plugins/Actman/ua/i_inoutjson.inc new file mode 100644 index 0000000000..b560e99fb1 --- /dev/null +++ b/plugins/Actman/ua/i_inoutjson.inc @@ -0,0 +1,361 @@ +{} +var + jsonparser:TJSONSERVICEINTERFACE; + +const + ioAction :PWideChar = 'Action'; + ioUA :PWideChar = 'UA'; + + ioName :PWideChar = 'name'; + + ioTwoState :PWideChar = 'twostate'; + ioSaveState :PWideChar = 'savestate'; + + ioHotkey :PWideChar = 'Hotkey'; + ioToolbar :PWideChar = 'Toolbar'; + ioTabSRMM :PWideChar = 'TabSRMM'; + ioMenuItem :PWideChar = 'Menu'; + + ioTooltip :PWideChar = 'tooltip'; + ioTooltipPressed :PWideChar = 'tt_pressed'; + + ioType :PWideChar = 'type'; + ioMenuPopup :PWideChar = 'Popup'; + ioMenuName :PWideChar = 'Name'; + ioMenuShow :PWideChar = 'Show'; + ioMenuUsed :PWideChar = 'Used'; + ioMenuSeparated :PWideChar = 'Separated'; + ioNoTRanslate :PWideChar = 'NoTranslate'; + + +function ImportMenuItems(node:JSONNODE;var MenuItem:tUAMenuItem):integer; +begin + result:=0; + + with jsonparser do + begin + with MenuItem do + begin + menu_opt:=0; + // popup + StrDupW(szMenuPopup,getAttrValue(node,ioMenuPopup)); + // name + StrDupW(szMenuNameVars,getAttrValue(node,ioMenuName)); + // show + StrDupW(szMenuShowWhenVars,getAttrValue(node,ioMenuShow)); + // used + if StrToInt(getAttrValue(node,ioMenuUsed))<>0 then + menu_opt:=menu_opt or UAF_MENUUSE; + // separated + if StrToInt(getAttrValue(node,ioMenuSeparated))<>0 then + menu_opt:=menu_opt or UAF_MENUSEP; + // no translate + if StrToInt(getAttrValue(node,ioMenuNotranslate))<>0 then + menu_opt:=menu_opt or UAF_NOTRANAS; + end; + end; +end; + +function ImportUAction(actnode:JSONNODE;var UA:tMyActionItem):integer; +var + num,i:integer; + sub:JSONNODE; +begin + result:=0; + if actnode=0 then exit; + + with jsonparser do + begin + // we don't need that node as is, just it's child for UA +// actnode:=GetNthChild(actnode,ioUA,0); + + UA.flags:=0; + // ----- Common ----- + if StrToInt(getAttrValue(actnode,ioTwoState))<>0 then + UA.flags:=UA.flags or UAF_2STATE; + + if StrToInt(getAttrValue(actnode,ioSaveState))<>0 then + UA.flags:=UA.flags or UAF_SAVESTATE; + + // sub:=AddChild(actnode,ioRegister,nil); + if StrToInt(getAttrValue(actnode,ioHotkey))<>0 then + UA.flags:=UA.flags or UAF_REGHOTKEY; + if StrToInt(getAttrValue(actnode,ioToolbar))<>0 then + UA.flags:=UA.flags or UAF_REGTTBB; + if StrToInt(getAttrValue(actnode,ioTabSRMM))<>0 then + UA.flags:=UA.flags or UAF_REGTABB; + + // ----- Hotkey ----- + // nothing + + // ----- Modern CList toolbar ----- + // source - ANSI text + sub:=GetNthChild(actnode,ioToolbar,0); + WideToAnsi(GetAttrValue(sub,ioTooltip ),UA.szTTBTooltip ,MirandaCP); + WideToAnsi(GetAttrValue(sub,ioTooltipPressed),UA.szTTBTooltipPressed,MirandaCP); + + // ----- TabSRMM toolbar ----- + sub:=GetNthChild(actnode,ioTabSRMM,0); + StrDupW(UA.szTabBTooltip ,getAttrValue(sub,ioTooltip)); + StrDupW(UA.szTabBTooltipPressed,getAttrValue(sub,ioTooltipPressed)); + + // ----- Menus ----- + num:=0; + repeat + sub:=getNextChild(actnode,ioMenuItem,@num); + if sub=0 then break; + + i:=StrToInt(getAttrValue(sub,ioType)); + ImportMenuItems(sub, + UA.UAMenuItem[tMenuType(i)]); + until false; + end; +end; + +function Import(fname:PWideChar;aflags:dword):integer; +var + i,j,act:integer; + root,actnode:JSONNODE; + pcw,res:pWideChar; + f:THANDLE; + num,num1:integer; + ptr,ptr1:pChain; +begin + result:=0; + + if (fname=nil) or (fname^=#0) then + exit; + i:=GetFSize(fname); + if i=0 then + exit; + + num:=CallService(MS_ACT_GETLIST,0,LPARAM(@ptr)); + if num=0 then exit; + ptr1:=ptr; + + mGetMem (res ,i+SizeOf(WideChar)); + FillChar(res^,i+SizeOf(WideChar),0); + f:=Reset(fname); + BlockRead(f,res^,i); + CloseHandle(f); + + CallService(MS_JSON_GETINTERFACE,0,lparam(@jsonparser)); + with jsonparser do + begin + root:=parseString(ChangeUnicode(res),@i,nil); + j:=0; + repeat + actnode:=getNthChild(root,ioAction,j); + if actnode=0 then break; + // search id by name? + pcw:=GetAttrValue(actnode,ioName); + ptr:=ptr1; + inc(pbyte(ptr),4); + for i:=0 to num-1 do + begin + if (ptr.flags and ACCF_IMPORTED)<>0 then + begin + if StrCmpw(pcw,ptr.descr)=0 then + begin + // delete old UA for overwrited actions + if (ptr.flags and ACCF_OVERLOAD)<>0 then + begin + for act:=0 to HIGH(UActionList) do + begin + if ptr.id=UActionList[act].dwActID then + begin + DeleteUAction(act,true); + break; + end; + end; + end; + num1:=AddUAction(-1,ptr); + ImportUAction(getNthChild(actnode,ioUA,0),UActionList[num1]); + break; + end; + end; + inc(ptr); + end; + + inc(j); + until false; + + DestroyNode(root); + end; + CallService(MS_ACT_FREELIST,0,LPARAM(ptr1)); + mFreeMem(res); + result:=1; + if settings<>0 then + begin + FillActionList(settings); + ShowAction(settings,-1); + end; +end; + +//-------------------------- + +function ExportMenuItems(node:JSONNODE;MenuItem:tUAMenuItem):HXML; +begin + with jsonparser do + begin + result:=AddChild(node,ioMenuItem,nil); + with MenuItem do + begin + // popup + if (szMenuPopup<>nil) and (szMenuPopup^<>#0) then + AddAttr(result,ioMenuPopup,szMenuPopup); + // name + if (szMenuNameVars<>nil) and (szMenuNameVars^<>#0) then + AddAttr(result,ioMenuName,szMenuNameVars); + // show + if (szMenuShowWhenVars<>nil) and (szMenuShowWhenVars^<>#0) then + AddAttr(result,ioMenuShow,szMenuShowWhenVars); + // used + AddAttrInt(result,ioMenuUsed,ord((menu_opt AND UAF_MENUUSE)<>0)); + // separated + AddAttrInt(result,ioMenuSeparated,ord((menu_opt AND UAF_MENUSEP)<>0)); + // no translate + AddAttrInt(result,ioNoTranslate,ord((menu_opt AND UAF_NOTRANS)<>0)); + end; + end; +end; + +procedure WriteUAction(root:JSONNODE;id:dword;name:pWideChar); +var + i:integer; + lmenu:tMenuType; + pc:pWideChar; + actnode,sub:JSONNODE; + UA:pMyActionItem; +begin + with jsonparser do + begin + for i:=0 to HIGH(UActionList) do + begin + if UActionList[i].dwActID=id then + begin + UA:=@UActionList[i]; + actnode:=getChildByAttrValue(root,ioAction,ioName,name); + if actnode=0 then break; + // we don't need that node as is, just it's child for UA + actnode:=addChild(actnode,ioUA,nil); + + // ----- Common ----- + AddAttrInt(actnode,ioTwoState ,ORD((UA.flags and UAF_2STATE )<>0)); + AddAttrInt(actnode,ioSaveState,ORD((UA.flags and UAF_SAVESTATE)<>0)); + + // sub:=AddChild(actnode,ioRegister,nil); + AddAttrInt(actnode,ioHotkey ,ORD((UA.flags and UAF_REGHOTKEY)<>0)); + AddAttrInt(actnode,ioToolbar,ORD((UA.flags and UAF_REGTTBB )<>0)); + AddAttrInt(actnode,ioTabSRMM,ORD((UA.flags and UAF_REGTABB )<>0)); + + // ----- Hotkey ----- + // nothing + + // ----- Modern CList toolbar ----- + // source - ANSI text + if ((UA.szTTBTooltip <>nil) and (UA.szTTBTooltip^ <>#0)) or + ((UA.szTTBTooltipPressed<>nil) and (UA.szTTBTooltipPressed^<>#0)) then + begin + sub:=AddChild(actnode,ioToolbar,nil); + if (UA.szTTBTooltip<>nil) and (UA.szTTBTooltip^<>#0) then + begin + AnsiToWide(UA.szTTBTooltip,pc,MirandaCP); + AddAttr(sub,ioTooltip,pc); + mFreeMem(pc); + end; + if (UA.szTTBTooltipPressed<>nil) and (UA.szTTBTooltipPressed^<>#0) then + begin + AnsiToWide(UA.szTTBTooltipPressed,pc,MirandaCP); + AddAttr(sub,ioTooltipPressed,pc); + mFreeMem(pc); + end; + end; + + // ----- TabSRMM toolbar ----- + if ((UA.szTabBTooltip <>nil) and (UA.szTabBTooltip^ <>#0)) or + ((UA.szTabBTooltipPressed<>nil) and (UA.szTabBTooltipPressed^<>#0)) then + begin + sub:=AddChild(actnode,ioTabSRMM,nil); + if (UA.szTabBTooltip<>nil) and (UA.szTabBTooltip^<>#0) then + AddAttr(sub,ioTooltip,UA.szTabBTooltip); + if (UA.szTabBTooltipPressed<>nil) and (UA.szTabBTooltipPressed^<>#0) then + AddAttr(sub,ioTooltipPressed,UA.szTabBTooltipPressed); + end; + + // ----- Menus ----- + for lmenu:=main_menu to HIGH(tMenuType) do + begin + sub:=ExportMenuItems(actnode,UA.UAMenuItem[lmenu]); + AddAttrInt(sub,ioType,ORD(lmenu)); + end; + + break; + end; + end; + end; +end; + +function Export(fname:pWideChar;aflags:dword):integer; +var + i,num:integer; + f:THANDLE; + root:JSONNODE; + res:pWideChar; + ptr,ptr1:pChain; +begin + result:=0; + CallService(MS_JSON_GETINTERFACE,0,lparam(@jsonparser)); + with jsonparser do + begin + // we need append file, not rewrite + i:=GetFSize(fname); + if i=0 then exit; + + mGetMem (res ,i+SizeOf(WideChar)); + FillChar(res^,i+SizeOf(WideChar),0); + f:=Reset(fname); + BlockRead(f,res^,i); + CloseHandle(f); + root:=parseString(res,@i,nil); + mFreeMem(res); + + num:=CallService(MS_ACT_GETLIST,0,LPARAM(@ptr)); + if num>0 then + begin + ptr1:=ptr; + inc(pbyte(ptr),4); + for i:=0 to num-1 do + begin + if ((aflags and ACIO_SELECTED)=0) or + ((ptr.flags and ACCF_EXPORT)<>0) then + begin + WriteUAction(root,ptr.id,ptr.descr); + end; + inc(ptr); + end; + CallService(MS_ACT_FREELIST,0,LPARAM(ptr1)); + end; + + res:=toString(root,@i); + + f:=Rewrite(fname); + BlockWrite(f,res^,i*SizeOf(WideChar)); + CloseHandle(f); + xmlparser.FreeMem(res); + DestroyNode(root); + end; + result:=1; +end; + +function ActInOut(wParam:WPARAM;lParam:LPARAM):int_ptr; cdecl; +begin + if (wParam and ACIO_EXPORT)=0 then + begin + result:=Import(pWideChar(lParam),wParam); + end + else + begin + result:=Export(pWideChar(lParam),wParam); + end; +end; diff --git a/plugins/Actman/ua/i_inoutxm.inc b/plugins/Actman/ua/i_inoutxm.inc index 098a262b1e..bf53ff954a 100644 --- a/plugins/Actman/ua/i_inoutxm.inc +++ b/plugins/Actman/ua/i_inoutxm.inc @@ -25,6 +25,7 @@ const ioMenuShow :PWideChar = 'Show'; ioMenuUsed :PWideChar = 'Used'; ioMenuSeparated :PWideChar = 'Separated'; + ioNoTranslate :PWideChar = 'NoTranslate'; function ImportMenuItems(node:HXML;var MenuItem:tUAMenuItem):integer; @@ -48,6 +49,9 @@ begin // separated if StrToInt(getAttrValue(node,ioMenuSeparated))<>0 then menu_opt:=menu_opt or UAF_MENUSEP; + // no translate + if StrToInt(getAttrValue(node,ioNoTranslate))<>0 then + menu_opt:=menu_opt or UAF_NOTRANS; end; end; end; @@ -150,18 +154,18 @@ begin inc(pbyte(ptr),4); for i:=0 to num-1 do begin - if (ptr.flags and ACCF_IMPORTED)<>0 then + if (ptr.flags and ACF_SELECTED)<>0 then begin if StrCmpw(pcw,ptr.descr)=0 then begin // delete old UA for overwrited actions - if (ptr.flags and ACCF_OVERLOAD)<>0 then + if (ptr.flags and ACF_OVERLOAD)<>0 then begin for act:=0 to HIGH(UActionList) do begin if ptr.id=UActionList[act].dwActID then begin - DeleteUAction(act); + DeleteUAction(act,true); break; end; end; @@ -191,7 +195,7 @@ end; //-------------------------- -function ExportMenuItems(node:HXML;MenuItem:tUAMenuItem):HXML; +function ExportMenuItems(node:HXML;const MenuItem:tUAMenuItem):HXML; begin with xmlparser do begin @@ -211,6 +215,8 @@ begin AddAttrInt(result,ioMenuUsed,ord((menu_opt AND UAF_MENUUSE)<>0)); // separated AddAttrInt(result,ioMenuSeparated,ord((menu_opt AND UAF_MENUSEP)<>0)); + // no translate + AddAttrInt(result,ioNoTranslate,ord((menu_opt AND UAF_NOTRANS)<>0)); end; end; end; diff --git a/plugins/Actman/ua/i_opt_dlg.inc b/plugins/Actman/ua/i_opt_dlg.inc index e9d7dc5048..6e5cc4d117 100644 --- a/plugins/Actman/ua/i_opt_dlg.inc +++ b/plugins/Actman/ua/i_opt_dlg.inc @@ -1,127 +1,133 @@ {} const settings:HWND = 0; -const - NumControls = 17; - - IDsArray:array [0..NumControls-1] of integer =( - // Menu settings controls - IDC_UA_SEPARATE ,IDC_UA_POPUPT ,IDC_UA_POPUPV, - IDC_UA_VARNAMEST,IDC_UA_VARNAMESV,IDC_UA_VARNAMESH, - IDC_UA_SHOWVART ,IDC_UA_SHOWVARV ,IDC_UA_SHOWVARH, - IDC_UA_TWOSTATE ,IDC_UA_SAVSTATE ,IDC_UA_COMMON, - // toolbar settings controls - IDC_UA_TTNORMALT,IDC_UA_TTNORMALV,IDC_UA_TTPRESSEDT,IDC_UA_TTPRESSEDV, - IDC_UA_GLOBAL - ); - - // Show-hide controls by place type - SHArray:array [0..NumTypes-1, 0..NumControls-1] of integer = ( - // CList Modern toolbar - (SW_HIDE,SW_HIDE,SW_HIDE, SW_HIDE,SW_HIDE,SW_HIDE, SW_SHOW,SW_SHOW,SW_SHOW, - SW_SHOW,SW_SHOW,SW_SHOW, SW_SHOW,SW_SHOW,SW_SHOW,SW_SHOW, SW_HIDE), - // TabSRMM toolbar - (SW_HIDE,SW_HIDE,SW_HIDE, SW_HIDE,SW_HIDE,SW_HIDE, SW_HIDE,SW_HIDE,SW_HIDE, - SW_SHOW,SW_SHOW,SW_SHOW, SW_SHOW,SW_SHOW,SW_SHOW,SW_SHOW, SW_SHOW), - // Core Hotkey - (SW_HIDE,SW_HIDE,SW_HIDE, SW_HIDE,SW_HIDE,SW_HIDE, SW_HIDE,SW_HIDE,SW_HIDE, - SW_HIDE,SW_HIDE,SW_HIDE, SW_HIDE,SW_HIDE,SW_HIDE,SW_HIDE, SW_HIDE), - // Main menu - (SW_SHOW,SW_SHOW,SW_SHOW, SW_SHOW,SW_SHOW,SW_SHOW, SW_SHOW,SW_SHOW,SW_SHOW, - SW_SHOW,SW_SHOW,SW_SHOW, SW_HIDE,SW_HIDE,SW_HIDE,SW_HIDE, SW_HIDE), - // Contact menu - (SW_SHOW,SW_SHOW,SW_SHOW, SW_SHOW,SW_SHOW,SW_SHOW, SW_SHOW,SW_SHOW,SW_SHOW, - SW_SHOW,SW_SHOW,SW_SHOW, SW_HIDE,SW_HIDE,SW_HIDE,SW_HIDE, SW_SHOW), - // Tray menu - (SW_SHOW,SW_SHOW,SW_SHOW, SW_SHOW,SW_SHOW,SW_SHOW, SW_SHOW,SW_SHOW,SW_SHOW, - SW_SHOW,SW_SHOW,SW_SHOW, SW_HIDE,SW_HIDE,SW_HIDE,SW_HIDE, SW_HIDE), - // Protocol menu - (SW_SHOW,SW_SHOW,SW_SHOW, SW_SHOW,SW_SHOW,SW_SHOW, SW_SHOW,SW_SHOW,SW_SHOW, - SW_SHOW,SW_SHOW,SW_SHOW, SW_HIDE,SW_HIDE,SW_HIDE,SW_HIDE, SW_HIDE), - // Status menu - (SW_SHOW,SW_SHOW,SW_SHOW, SW_SHOW,SW_SHOW,SW_SHOW, SW_SHOW,SW_SHOW,SW_SHOW, - SW_SHOW,SW_SHOW,SW_SHOW, SW_HIDE,SW_HIDE,SW_HIDE,SW_HIDE, SW_HIDE) - ); - // additional show/hide controls check by Variables installings (1 - need to check) - SHVarArray:array [0..NumControls-1] of byte = ( - 0,0,0, 0,0,1, 1,1,1, - 0,0,0,0,0,0,0, 0); - // additional enable/disable controls check (1 - always enable) - EnDisArray:array [0..NumControls-1] of byte = ( - 0,0,0, 0,0,0, 0,0,0, - 1,1,1,0,0,0,0, 1); var hIC:THANDLE; -procedure CheckPlacesAbility; -var - i:integer; -begin - for i:=0 to NumTypes-1 do - begin - with NamesArray[i] do - begin - enable:=(service=nil) or (ServiceExists(service)<>0); - end; - end; -end; +//----- Static (no option-depended) control view ----- -function CompareItem(lParam1,lParam2:LPARAM;SortType:LPARAM):int; stdcall; +procedure HideAllControls(Dialog:HWND); begin - result:=UActionList[lParam1].wSortIndex-UActionList[lParam2].wSortIndex; + ShowWindow(GetDlgItem(Dialog,IDC_UA_GLOBAL ),SW_HIDE); + + ShowWindow(GetDlgItem(Dialog,IDC_UA_BLOCK ),SW_HIDE); + ShowWindow(GetDlgItem(Dialog,IDC_UA_MENU ),SW_HIDE); + ShowWindow(GetDlgItem(Dialog,IDC_UA_NOTRANSLATE),SW_HIDE); + ShowWindow(GetDlgItem(Dialog,IDC_UA_SEPARATE ),SW_HIDE); + ShowWindow(GetDlgItem(Dialog,IDC_UA_POPUPT ),SW_HIDE); + ShowWindow(GetDlgItem(Dialog,IDC_UA_VARNAMEST ),SW_HIDE); +// ShowWindow(GetDlgItem(Dialog,IDC_UA_NOTRANSLATE),SW_HIDE); + + ShowWindow(GetDlgItem(Dialog,IDC_UA_TTNORMALT ),SW_HIDE); + ShowWindow(GetDlgItem(Dialog,IDC_UA_TTPRESSEDT ),SW_HIDE); + + ShowWindow(GetDlgItem(Dialog,IDC_UA_SHOWVART ),SW_HIDE); + + + ShowEditField(Dialog,IDC_UA_SHOWVARV ,SW_HIDE); + ShowEditField(Dialog,IDC_UA_VARNAMESV ,SW_HIDE); + ShowEditField(Dialog,IDC_UA_POPUPV ,SW_HIDE); + ShowEditField(Dialog,IDC_UA_TTNORMALV ,SW_HIDE); + ShowEditField(Dialog,IDC_UA_TTPRESSEDV,SW_HIDE); end; -// Show or hide option items -procedure SetupControls(Dialog:HWND;atype:integer;item:integer=-1); +// Show or hide option items ("static options") +procedure ShowHideControls(Dialog:HWND;atype:integer;item:integer=-1); var - i: cardinal; - typ:integer; - wnd,wnd1:HWND; - enable:boolean; + show:integer; begin - if atype<0 then - begin - for i:=0 to NumControls-1 do - begin - ShowWindow(GetDlgItem(Dialog,IDsArray[i]),SW_HIDE); - end; - end - else + HideAllControls(Dialog); + if atype>=0 then begin - wnd1:=GetDlgItem(Dialog,IDC_UA_PLACELIST); - if item<0 then - item:=SendMessage(wnd1,LVM_GETNEXTITEM,-1,LVNI_FOCUSED); - enable:=ListView_GetCheckState(wnd1,item)<>0; + if LoByte(atype)<>uaHotkey then + show:=SW_SHOW + else + show:=SW_HIDE; + ShowWindow(GetDlgItem(Dialog,IDC_UA_TWOSTATE),show); + ShowWindow(GetDlgItem(Dialog,IDC_UA_SAVSTATE),show); + ShowWindow(GetDlgItem(Dialog,IDC_UA_COMMON ),show); - for i:=0 to NumControls-1 do - begin - typ:=SHArray[LoByte(atype)+HiByte(atype)][i]; - if typ=SW_SHOW then - if (SHVarArray[i]<>0) and (not IsVarsInstalled) then - typ:=SW_HIDE; - wnd:=GetDlgItem(Dialog,IDsArray[i]); - ShowWindow(wnd,typ); - EnableWindow(wnd,enable or (EnDisArray[i]<>0)); - end; + case LoByte(atype) of + uaTTB: begin + ShowWindow(GetDlgItem(Dialog,IDC_UA_SHOWVART ),SW_SHOW); + ShowEditField(Dialog,IDC_UA_SHOWVARV ,SW_SHOW); + + ShowWindow(GetDlgItem(Dialog,IDC_UA_TTNORMALT ),SW_SHOW); + ShowWindow(GetDlgItem(Dialog,IDC_UA_TTPRESSEDT),SW_SHOW); + ShowEditField(Dialog,IDC_UA_TTNORMALV ,SW_SHOW); + ShowEditField(Dialog,IDC_UA_TTPRESSEDV,SW_SHOW); + end; + uaTAB: begin + ShowWindow(GetDlgItem(Dialog,IDC_UA_GLOBAL ),SW_SHOW); - // common settings - EnableWindow(GetDlgItem(Dialog,IDC_UA_SAVSTATE), - IsDlgButtonChecked(Dialog,IDC_UA_TWOSTATE)<>BST_UNCHECKED); + ShowWindow(GetDlgItem(Dialog,IDC_UA_TTNORMALT ),SW_SHOW); + ShowWindow(GetDlgItem(Dialog,IDC_UA_TTPRESSEDT),SW_SHOW); + ShowEditField(Dialog,IDC_UA_TTNORMALV ,SW_SHOW); + ShowEditField(Dialog,IDC_UA_TTPRESSEDV,SW_SHOW); + end; + uaHotkey: begin + end; + uaMenu: begin + if tMenuType(HiByte(atype))=contact_menu then + ShowWindow(GetDlgItem(Dialog,IDC_UA_GLOBAL),SW_SHOW); - // personal settings - case LoByte(atype) of - uaTTB, uaTAB: begin - enable:=false; - if IsDlgButtonChecked(Dialog,IDC_UA_TWOSTATE)<>BST_UNCHECKED then - if IsWindowEnabled(GetDlgItem(Dialog,IDC_UA_TTNORMALV)) then - enable:=true; - EnableWindow(GetDlgItem(Dialog,IDC_UA_TTPRESSEDV),enable); + ShowWindow(GetDlgItem(Dialog,IDC_UA_BLOCK ),SW_SHOW); + ShowWindow(GetDlgItem(Dialog,IDC_UA_MENU ),SW_SHOW); + +//!! ShowWindow(GetDlgItem(Dialog,IDC_UA_SEPARATE ),SW_SHOW); +//!! ShowWindow(GetDlgItem(Dialog,IDC_UA_SEPARATE ),SW_SHOW); + + ShowWindow(GetDlgItem(Dialog,IDC_UA_SHOWVART ),SW_SHOW); + ShowEditField(Dialog,IDC_UA_SHOWVARV ,SW_SHOW); + + ShowWindow(GetDlgItem(Dialog,IDC_UA_POPUPT ),SW_SHOW); + ShowWindow(GetDlgItem(Dialog,IDC_UA_VARNAMEST ),SW_SHOW); + ShowEditField(Dialog,IDC_UA_VARNAMESV ,SW_SHOW); + ShowEditField(Dialog,IDC_UA_POPUPV ,SW_SHOW); + +// ShowWindow(GetDlgItem(Dialog,IDC_UA_NOTRANSLATE),SW_SHOW); end; end; end; end; +procedure EnableDisableCheck(Dialog:HWND); +var + wnd:HWND; + item:integer; + two,enable:boolean; +begin + wnd:=GetDlgItem(Dialog,IDC_UA_PLACELIST); + item:=SendMessage(wnd,LVM_GETNEXTITEM,-1,LVNI_FOCUSED); + enable:=ListView_GetCheckState(wnd,item)<>0; + + // common settings + two:=IsDlgButtonChecked(Dialog,IDC_UA_TWOSTATE)<>BST_UNCHECKED; + EnableWindow(GetDlgItem(Dialog,IDC_UA_SAVSTATE),two); + + // all others + EnableWindow(GetDlgItem(Dialog,IDC_UA_BLOCK ),enable); + EnableWindow(GetDlgItem(Dialog,IDC_UA_MENU ),enable); + + EnableWindow(GetDlgItem(Dialog,IDC_UA_NOTRANSLATE),enable); + EnableWindow(GetDlgItem(Dialog,IDC_UA_SEPARATE ),enable); + EnableWindow(GetDlgItem(Dialog,IDC_UA_POPUPT ),enable); + EnableWindow(GetDlgItem(Dialog,IDC_UA_VARNAMEST ),enable); + + EnableWindow(GetDlgItem(Dialog,IDC_UA_TTNORMALT ),enable); + EnableWindow(GetDlgItem(Dialog,IDC_UA_TTPRESSEDT ),enable); + + EnableWindow(GetDlgItem(Dialog,IDC_UA_SHOWVART ),enable); + + EnableEditField(Dialog,IDC_UA_SHOWVARV ,enable); + EnableEditField(Dialog,IDC_UA_VARNAMESV ,enable); + EnableEditField(Dialog,IDC_UA_POPUPV ,enable); + EnableEditField(Dialog,IDC_UA_TTNORMALV ,enable); + + EnableEditField(Dialog,IDC_UA_TTPRESSEDV,enable and two); +end; + // Clear all screen buttons/text fields (reset) procedure ClearControls(Dialog:HWND); var @@ -129,20 +135,111 @@ var begin s:=settings; settings:=0; - CheckDlgButton (Dialog,IDC_UA_TWOSTATE ,BST_UNCHECKED); - CheckDlgButton (Dialog,IDC_UA_SAVSTATE ,BST_UNCHECKED); + // common + CheckDlgButton (Dialog,IDC_UA_TWOSTATE,BST_UNCHECKED); + CheckDlgButton (Dialog,IDC_UA_SAVSTATE,BST_UNCHECKED); + + // menu items + SetDlgItemTextW(Dialog,IDC_UA_BLOCK ,'>'); + CheckDlgButton (Dialog,IDC_UA_SEPARATE ,BST_UNCHECKED); + CheckDlgButton (Dialog,IDC_UA_NOTRANSLATE,BST_UNCHECKED); + SetDlgItemTextW(Dialog,IDC_UA_POPUPV ,nil); + SetDlgItemTextW(Dialog,IDC_UA_VARNAMESV ,nil); + + SetDlgItemTextW(Dialog,IDC_UA_SHOWVARV ,nil); + // buttons + SetDlgItemTextW(Dialog,IDC_UA_TTNORMALV ,nil); + SetDlgItemTextW(Dialog,IDC_UA_TTPRESSEDV,nil); + + // contact related + CheckDlgButton (Dialog,IDC_UA_GLOBAL,BST_UNCHECKED); - CheckDlgButton (Dialog,IDC_UA_SEPARATE ,BST_UNCHECKED); - SetDlgItemTextW(Dialog,IDC_UA_POPUPV ,nil); - SetDlgItemTextW(Dialog,IDC_UA_VARNAMESV,nil); - SetDlgItemTextW(Dialog,IDC_UA_SHOWVARV ,nil); settings:=s; end; +procedure InitActionSettings(Dialog:HWND); +begin + MakeEditField(Dialog,IDC_UA_TTNORMALV); + MakeEditField(Dialog,IDC_UA_TTPRESSEDV); + + MakeEditField(Dialog,IDC_UA_POPUPV); + MakeEditField(Dialog,IDC_UA_VARNAMESV); + + MakeEditField(Dialog,IDC_UA_SHOWVARV); + SetEditFlags(GetDlgItem(Dialog,IDC_UA_SHOWVARV),EF_FORCE,EF_FORCES); +end; + +function CompareItem(lParam1,lParam2:LPARAM;SortType:LPARAM):int; stdcall; +begin + result:=UActionList[lParam1].wSortIndex-UActionList[lParam2].wSortIndex; +end; + +procedure FillActionList(wnd:HWND); +var + i:integer; + li:LV_ITEMW; + il:HIMAGELIST; + lmenu:tMenuType; +begin + wnd:=GetDlgItem(wnd,IDC_UA_ACTIONLIST); + SendMessage(wnd,LVM_DELETEALLITEMS,0,0); + + il:=ImageList_Create(16,16,ILC_COLOR32 or ILC_MASK,0,1); + for i:=0 to HIGH(UActionList) do + begin + li.mask :=LVIF_TEXT+LVIF_PARAM+LVIF_IMAGE; + li.iSubItem:=0; + li.iItem :=i; + li.lParam :=i; + li.pszText :=UActionList[i].szActDescr; + li.iImage:=ImageList_ReplaceIcon(il, -1, + HICON(CallService(MS_SKIN2_GETICONBYHANDLE,0,LPARAM(UActionList[i].hIcolibIcon)))); + li.iItem :=SendMessageW(wnd,LVM_INSERTITEMW,0,LPARAM(@li)); + + for lmenu:=main_menu to HIGH(tMenuType) do + UActionList[i].UAMenuItem[lmenu].changed:=false; + end; + ImageList_Destroy(SendMessage(wnd,LVM_SETIMAGELIST,LVSIL_SMALL,il)); + + SendMessage(wnd,LVM_SORTITEMS,0,LPARAM(@CompareItem)); + + ListView_SetItemState(wnd,0, + LVIS_FOCUSED or LVIS_SELECTED, + LVIS_FOCUSED or LVIS_SELECTED); +end; + +// refresh icons in UA list (at least) +function IconChanged(wParam:WPARAM;lParam:LPARAM):int;cdecl; +var + i:integer; + li:LV_ITEMW; + il:HIMAGELIST; + wnd:HWND; +begin + result:=0; + wnd:=GetDlgItem(settings,IDC_UA_ACTIONLIST); + + il:=ImageList_Create(16,16,ILC_COLOR32 or ILC_MASK,0,1); + for i:=0 to HIGH(UActionList) do + begin + li.mask :=LVIF_IMAGE; + li.iSubItem:=0; + li.iItem :=i; + li.iImage:=ImageList_ReplaceIcon(il, -1, + HICON(CallService(MS_SKIN2_GETICONBYHANDLE,0,TLPARAM(UActionList[i].hIcolibIcon)))); + SendMessageW(wnd,LVM_SETITEM,0,TLPARAM(@li)); + end; + ImageList_Destroy(SendMessage(wnd,LVM_SETIMAGELIST,LVSIL_SMALL,il)); +//!!refresh? +end; + +//----- Dynamic (option-depended) view ----- + procedure ShowSubAction(Dialog:HWND;aType:integer;item:integer=-1); var UA:pMyActionItem; s:HWND; + i:integer; begin s:=settings; settings:=0; @@ -169,6 +266,11 @@ begin SetDlgItemTextA(Dialog,IDC_UA_TTNORMALV ,UA.szTTBTooltip); SetDlgItemTextA(Dialog,IDC_UA_TTPRESSEDV,UA.szTTBTooltipPressed); SetDlgItemTextW(Dialog,IDC_UA_SHOWVARV ,UA.szTTBShowWhenVars); + + if (UA.flags and UAF_TTBTTUV)<>0 then i:=EF_SCRIPT else i:=0; + SetEditFlags(Dialog,IDC_UA_TTNORMALV ,EF_ALL,i); + if (UA.flags and UAF_TTBTTPV)<>0 then i:=EF_SCRIPT else i:=0; + SetEditFlags(Dialog,IDC_UA_TTPRESSEDV,EF_ALL,i); end; uaTAB: begin // TabSRMM toolbar @@ -181,9 +283,15 @@ begin begin if (menu_opt and UAF_MENUSEP)<>0 then CheckDlgButton(Dialog,IDC_UA_SEPARATE,BST_CHECKED); + if (menu_opt and UAF_NOTRANS)<>0 then + CheckDlgButton(Dialog,IDC_UA_NOTRANSLATE,BST_CHECKED); SetDlgItemTextW(Dialog,IDC_UA_POPUPV ,szMenuPopup); SetDlgItemTextW(Dialog,IDC_UA_VARNAMESV,szMenuNameVars); SetDlgItemTextW(Dialog,IDC_UA_SHOWVARV ,szMenuShowWhenVars); + if (menu_opt and UAF_MNAMVAR)<>0 then i:=EF_SCRIPT else i:=0; + SetEditFlags(Dialog,IDC_UA_VARNAMESV,EF_ALL,i); + if (menu_opt and UAF_MSUBVAR)<>0 then i:=EF_SCRIPT else i:=0; + SetEditFlags(Dialog,IDC_UA_POPUPV,EF_ALL,i); end; end; @@ -191,7 +299,8 @@ begin // Settings in Customize/Hotkeys end; end; - SetupControls(Dialog,aType,-1); + ShowHideControls(Dialog,aType,-1); + EnableDisableCheck(Dialog); settings:=s; end; @@ -255,10 +364,12 @@ begin else begin ClearControls(Dialog); - SetupControls(Dialog,-1,-1); + ShowHideControls(Dialog,-1,-1); end; end; +//----- Saving ----- + procedure SetChangedFlag(Dialog:HWND); var num,atype:integer; @@ -276,8 +387,14 @@ begin mFreeMem(szMenuNameVars ); szMenuNameVars :=GetDlgText(Dialog,IDC_UA_VARNAMESV); mFreeMem(szMenuShowWhenVars); szMenuShowWhenVars:=GetDlgText(Dialog,IDC_UA_SHOWVARV); menu_opt:=0; + if IsDlgButtonchecked(Dialog,IDC_UA_NOTRANSLATE)<>BST_UNCHECKED then + menu_opt:=menu_opt or UAF_NOTRANS; if IsDlgButtonchecked(Dialog,IDC_UA_SEPARATE)<>BST_UNCHECKED then menu_opt:=menu_opt or UAF_MENUSEP; + if (GetEditFlags(Dialog,IDC_UA_VARNAMESV) and EF_SCRIPT)<>0 then + menu_opt:=menu_opt or UAF_MNAMVAR; + if (GetEditFlags(Dialog,IDC_UA_POPUPV) and EF_SCRIPT)<>0 then + menu_opt:=menu_opt or UAF_MSUBVAR; end; end; @@ -331,6 +448,10 @@ begin mFreeMem(szTTBTooltip ); szTTBTooltip :=GetDlgText(Dialog,IDC_UA_TTNORMALV ,true); mFreeMem(szTTBTooltipPressed); szTTBTooltipPressed:=GetDlgText(Dialog,IDC_UA_TTPRESSEDV,true); mFreeMem(szTTBShowWhenVars ); szTTBShowWhenVars :=GetDlgText(Dialog,IDC_UA_SHOWVARV); + if (GetEditFlags(Dialog,IDC_UA_TTNORMALV ) and EF_SCRIPT)<>0 then + flags:=flags or UAF_TTBTTUV; + if (GetEditFlags(Dialog,IDC_UA_TTPRESSEDV) and EF_SCRIPT)<>0 then + flags:=flags or UAF_TTBTTPV; end; uaTAB: begin // TabSRMM toolbar @@ -354,70 +475,46 @@ begin end; end; -procedure FillActionList(wnd:HWND); +procedure ChangeBlock(Dialog:HWND); var - i:integer; - li:LV_ITEMW; - il:HIMAGELIST; - lmenu:tMenuType; + pc:pWideChar; + sh_main,sh_add:integer; begin - wnd:=GetDlgItem(wnd,IDC_UA_ACTIONLIST); - SendMessage(wnd,LVM_DELETEALLITEMS,0,0); - - il:=ImageList_Create(16,16,ILC_COLOR32 or ILC_MASK,0,1); - for i:=0 to HIGH(UActionList) do - begin - li.mask :=LVIF_TEXT+LVIF_PARAM+LVIF_IMAGE; - li.iSubItem:=0; - li.iItem :=i; - li.lParam :=i; - li.pszText :=UActionList[i].szActDescr; - li.iImage:=ImageList_AddIcon(il, - HICON(CallService(MS_SKIN2_GETICONBYHANDLE,0,LPARAM(UActionList[i].hIcolibIcon)))); - li.iItem :=SendMessageW(wnd,LVM_INSERTITEMW,0,LPARAM(@li)); - - for lmenu:=main_menu to HIGH(tMenuType) do - UActionList[i].UAMenuItem[lmenu].changed:=false; - end; - ImageList_Destroy(SendMessage(wnd,LVM_SETIMAGELIST,LVSIL_SMALL,il)); - - SendMessage(wnd,LVM_SORTITEMS,0,LPARAM(@CompareItem)); - - ListView_SetItemState(wnd,0, - LVIS_FOCUSED or LVIS_SELECTED, - LVIS_FOCUSED or LVIS_SELECTED); -end; - -// refresh icons in UA list (at least) -function IconChanged(wParam:WPARAM;lParam:LPARAM):int;cdecl; -var - i:integer; - li:LV_ITEMW; - il:HIMAGELIST; - wnd:HWND; -begin - result:=0; - wnd:=GetDlgItem(settings,IDC_UA_ACTIONLIST); - - il:=ImageList_Create(16,16,ILC_COLOR32 or ILC_MASK,0,1); - for i:=0 to HIGH(UActionList) do + if IsWindowVisible(GetDlgItem(Dialog,IDC_UA_POPUPV)) then begin - li.mask :=LVIF_IMAGE; - li.iSubItem:=0; - li.iItem :=i; - li.iImage:=ImageList_AddIcon(il, - HICON(CallService(MS_SKIN2_GETICONBYHANDLE,0,TLPARAM(UActionList[i].hIcolibIcon)))); - SendMessageW(wnd,LVM_SETITEM,0,TLPARAM(@li)); + pc:='<'; + sh_main:=SW_HIDE; + sh_add :=SW_SHOW; + end + else + begin + pc:='>'; + sh_main:=SW_SHOW; + sh_add :=SW_HIDE; end; - ImageList_Destroy(SendMessage(wnd,LVM_SETIMAGELIST,LVSIL_SMALL,il)); -//!!refresh? + ShowWindow(GetDlgItem(Dialog,IDC_UA_NOTRANSLATE),sh_add); + ShowWindow(GetDlgItem(Dialog,IDC_UA_SEPARATE ),sh_add); + ShowWindow(GetDlgItem(Dialog,IDC_UA_POPUPT ),sh_main); + ShowWindow(GetDlgItem(Dialog,IDC_UA_VARNAMEST ),sh_main); + ShowEditField(Dialog,IDC_UA_VARNAMESV,sh_main); + ShowEditField(Dialog,IDC_UA_POPUPV ,sh_main); + + SetDlgItemTextW(Dialog,IDC_UA_BLOCK,pc); + if sh_main=SW_SHOW then + pc:='Main settings' + else + pc:='Custom settings'; + SetDlgItemTextW(Dialog,IDC_UA_MENU,TranslateW(pc)); end; -function DlgProcOpt(Dialog:HWnd;hMessage:UINT;wParam:WPARAM;lParam:LPARAM):lresult; stdcall; +//----- Main Dialog ----- + +function DlgProcOpt(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; var wnd:HWND; lv:LV_COLUMNW; i:integer; + twostate:bool; begin result:=0; case hMessage of @@ -430,6 +527,8 @@ begin settings:=0; TranslateDialogDefault(Dialog); + InitActionSettings(Dialog); + wnd:=GetDlgItem(Dialog,IDC_UA_PLACELIST); SendMessage(wnd,LVM_SETEXTENDEDLISTVIEWSTYLE,LVS_EX_CHECKBOXES,LVS_EX_CHECKBOXES); SendMessage(wnd,LVM_SETUNICODEFORMAT,1,0); @@ -450,16 +549,6 @@ begin FillActionList(Dialog); ShowAction(Dialog,-1); -// if isVarsInstalled then - begin - SendDlgItemMessage(Dialog,IDC_UA_VARNAMESH,BM_SETIMAGE,IMAGE_ICON, - CallService(MS_VARS_GETSKINITEM,0,VSI_HELPICON)); - SendDlgItemMessage(Dialog,IDC_UA_SHOWVARH,BM_SETIMAGE,IMAGE_ICON, - CallService(MS_VARS_GETSKINITEM,0,VSI_HELPICON)); -// SendDlgItemMessage(Dialog,IDC_UA_VARNAMESH,BUTTONSETASFLATBTN,0,0); -// SendDlgItemMessage(Dialog,IDC_UA_SHOWVARH ,BUTTONSETASFLATBTN,0,0); - end; - settings:=Dialog; hIC:=HookEvent(ME_SKIN2_ICONSCHANGED,@IconChanged); end; @@ -480,28 +569,36 @@ begin begin case loword(wParam) of IDC_UA_TWOSTATE: begin - SetupControls(Dialog, + twostate:=IsDlgButtonChecked(Dialog,IDC_UA_TWOSTATE)<>BST_UNCHECKED; + EnableWindow(GetDlgItem(Dialog,IDC_UA_SAVSTATE),twostate); + + if LoByte(LV_GetLParam(GetDlgItem(Dialog,IDC_UA_PLACELIST))) in [uaTTB,uaTAB] then + EnableEditField(Dialog,IDC_UA_TTPRESSEDV, + twostate and IsWindowEnabled(GetDlgItem(Dialog,IDC_UA_TTNORMALV)) + ); + + ShowHideControls(Dialog, LV_GetLParam(GetDlgItem(Dialog,IDC_UA_PLACELIST)),-1); - { - EnableWindow(GetDlgItem(Dialog,IDC_UA_TTPRESSEDV), - IsDlgButtonChecked(Dialog,IDC_UA_TWOSTATE)<>BST_UNCHECKED); - } - if IsDlgButtonChecked(Dialog,IDC_UA_TWOSTATE)=BST_UNCHECKED then - DeleteIcolibIconP( + + if twostate then + AddIcolibIconP( UActionList[LV_GetLParam(GetDlgItem(Dialog,IDC_UA_ACTIONLIST),-1)]) else - AddIcolibIconP( + DeleteIcolibIconP( UActionList[LV_GetLParam(GetDlgItem(Dialog,IDC_UA_ACTIONLIST),-1)]); SendMessage(GetParent(Dialog),PSM_CHANGED,0,0); end; - IDC_UA_VARNAMESH: ShowVarHelp(Dialog,IDC_UA_VARNAMESV); - IDC_UA_SHOWVARH : ShowVarHelp(Dialog,IDC_UA_SHOWVARV); - +//was commented. why? IDC_UA_SAVSTATE, IDC_UA_GLOBAL: SendMessage(GetParent(Dialog),PSM_CHANGED,0,0); + IDC_UA_BLOCK: begin + ChangeBlock(Dialog); + end; + + IDC_UA_NOTRANSLATE, IDC_UA_SEPARATE: begin SetChangedFlag(Dialog); SendMessage(GetParent(Dialog),PSM_CHANGED,0,0); @@ -547,6 +644,7 @@ begin LV_GetLParam(GetDlgItem(Dialog,IDC_UA_PLACELIST), PNMLISTVIEW(lParam)^.iItem)); end + // checkboxes else if (settings<>0) and ((PNMLISTVIEW(lParam)^.uOldState or PNMLISTVIEW(lParam)^.uNewState)=$3000) then begin @@ -558,8 +656,7 @@ begin LVIS_FOCUSED or LVIS_SELECTED, LVIS_FOCUSED or LVIS_SELECTED) else - SetupControls(Dialog,LV_GetLParam(wnd,PNMLISTVIEW(lParam)^.iItem), - PNMLISTVIEW(lParam)^.iItem); + EnableDisableCheck(Dialog); SendMessage(GetParent(Dialog),PSM_CHANGED,0,0); end; diff --git a/plugins/Actman/ua/i_options.inc b/plugins/Actman/ua/i_options.inc index 91f54e89d8..977ff7891b 100644 --- a/plugins/Actman/ua/i_options.inc +++ b/plugins/Actman/ua/i_options.inc @@ -26,7 +26,10 @@ begin begin p:=StrCopyE(p,opt_UA); p^:='/'; inc(p); - +{!! + p^:='*'; inc(p); p^:=#0; + DBDeleteGroup(0,DBBranch,setting); +!!} StrCopy(p,opt_Flags); DBDeleteSetting(0,DBBranch,setting); StrCopy(p,opt_TTBTooltip ); DBDeleteSetting(0,DBBranch,setting); @@ -196,8 +199,6 @@ end; *) procedure SetAllActionUsers(var ActionItem:tMyActionItem; initial:boolean); var - setting:array [0..63] of AnsiChar; - p:pAnsiChar; luse:boolean; lmenu:tMenuType; begin @@ -248,90 +249,4 @@ begin DestroyServiceFunction(ActionItem.hMenuService); ActionItem.hMenuService:=0; end; - - // First run (ok ok, if ppl ask for it....) - p:=GetUABranch(setting,ActionItem.dwActID); - if p<>nil then - begin - p:=StrCopyE(p,opt_UA); - p^:='/'; inc(p); - StrCopy(p,'_FirstRun'); - if DBReadByte(0,DBBranch,setting,0)<>0 then - begin - CAllService(MS_ACT_RUNBYID,ActionItem.dwActID,0); - DBDeleteSetting(0,DBBranch,setting); - end; - end; - -end; - -procedure DeleteUAction(num:integer); -var - ActionItem:pMyActionItem; - setting:array [0..63] of AnsiChar; - p:pAnsiChar; - luse:boolean; - lmenu:tMenuType; -begin - DeleteUASettings(num); - - ActionItem:=@UActionList[num]; - - DeleteIcolibIcon(ActionItem^); - - if (ActionItem.flags and UAF_REGHOTKEY)<>0 then - DeleteCoreHotkey(ActionItem^); - - if (ActionItem.flags and UAF_REGTTBB)<>0 then - DeleteTTBButton(ActionItem^); - mFreeMem(ActionItem.szTTBTooltip); - mFreeMem(ActionItem.szTTBTooltipPressed); - mFreeMem(ActionItem.szTTBShowWhenVars); - - if (ActionItem.flags and UAF_REGTABB)<>0 then - DeleteTabBBButton(ActionItem^); - mFreeMem(ActionItem.szTabBTooltip); - mFreeMem(ActionItem.szTabBTooltipPressed); - - luse:=false; - for lmenu:=main_menu to HIGH(tMenuType) do - begin - with ActionItem.UAMenuItem[lmenu] do - begin - if (menu_opt and UAF_MENUUSE)<>0 then - begin - luse:=true; - DeleteMenuItem(ActionItem^,lmenu); - end; - mFreeMem(szMenuPopup); - mFreeMem(szMenuNameVars); - mFreeMem(szMenuShowWhenVars); - end; - end; - - if (not luse) and (ActionItem.hMenuService<>0) then - begin - DestroyServiceFunction(ActionItem.hMenuService); - ActionItem.hMenuService:=0; - end; - - p:=GetUABranch(setting,ActionItem.dwActID); - if p<>nil then - begin - p:=StrCopyE(p,opt_UA); - p^:='/'; inc(p); - StrCopy(p,'_FirstRun'); - DBDeleteSetting(0,DBBranch,setting); - end; - - // Free Memory - mFreeMem(ActionItem.szNameID); - mFreeMem(ActionItem.szActDescr); - - // compact list - if num0 then - flags:=UAF_DISABLED; StrDupW(szActDescr,ptr^.descr); wSortIndex:=idx; @@ -57,6 +55,71 @@ begin end; end; +// "compact" means need to compact list/delete settings (Delete, not just exit) +procedure DeleteUAction(num:integer;compact:boolean); +var + ActionItem:pMyActionItem; + luse:boolean; + lmenu:tMenuType; +begin + if compact then + DeleteUASettings(num); + + ActionItem:=@UActionList[num]; + + DeleteIcolibIcon(ActionItem^); + + if (ActionItem.flags and UAF_REGHOTKEY)<>0 then + DeleteCoreHotkey(ActionItem^); + + if (ActionItem.flags and UAF_REGTTBB)<>0 then + DeleteTTBButton(ActionItem^); + mFreeMem(ActionItem.szTTBTooltip); + mFreeMem(ActionItem.szTTBTooltipPressed); + mFreeMem(ActionItem.szTTBShowWhenVars); + + if (ActionItem.flags and UAF_REGTABB)<>0 then + DeleteTabBBButton(ActionItem^); + mFreeMem(ActionItem.szTabBTooltip); + mFreeMem(ActionItem.szTabBTooltipPressed); + + luse:=false; + for lmenu:=main_menu to HIGH(tMenuType) do + begin + with ActionItem.UAMenuItem[lmenu] do + begin + if (menu_opt and UAF_MENUUSE)<>0 then + begin + luse:=true; + DeleteMenuItem(ActionItem^,lmenu); + end; + mFreeMem(szMenuPopup); + mFreeMem(szMenuNameVars); + mFreeMem(szMenuShowWhenVars); + end; + end; + + if (not luse) and (ActionItem.hMenuService<>0) then + begin + DestroyServiceFunction(ActionItem.hMenuService); + ActionItem.hMenuService:=0; + end; + + // Free Memory + mFreeMem(ActionItem.szNameID); + mFreeMem(ActionItem.szActDescr); + + if compact then + begin + // compact list + if num0 then + if wParam<>0 then +// if (wParam and (ACTM_NEW or ACTM_RENAME or ACTM_SORT or ACTM_DELETE))<>0 then for i:=0 to count-1 do begin // search corresponding element @@ -87,7 +150,9 @@ begin end; // if we have no item in list for this action - then add new one if idx<0 then - AddUAction(-1,ptr) + begin + idx:=AddUAction(-1,ptr); + end else begin if (wParam and ACTM_RENAME)<>0 then @@ -99,10 +164,11 @@ begin StrDupW (UActionList[idx].szActDescr,ptr^.descr); end; end; - - if (wParam and (ACTM_SORT or ACTM_DELETE or ACTM_NEW))<>0 then - UActionList[idx].wSortIndex:=i; end; +// not so necessary to check really +// if (wParam and (ACTM_SORT or ACTM_DELETE or ACTM_NEW))<>0 then + UActionList[idx].wSortIndex:=i; + inc(ptr); end; end @@ -130,26 +196,24 @@ begin end; end; if not bFound then - DeleteUAction(j); + DeleteUAction(j,true); end; end; if count>0 then CallService(MS_ACT_FREELIST,0,TLPARAM(ptr1)); + // show changes in dialog if settings<>0 then begin FillActionList(settings); ShowAction(settings,-1); - SendMessage(GetParent(settings),PSM_CHANGED,0,0); - end - else + end; + + SaveUAs; + FillChar(arMenuRec[0],Length(arMenuRec)*SizeOf(tuaMenuRecA),0); + for i:=0 to HIGH(UActionList) do begin - SaveUAs; - FillChar(arMenuRec[0],Length(arMenuRec)*SizeOf(tuaMenuRecA),0); - for i:=0 to HIGH(UActionList) do - begin - SetAllActionUsers(UActionList[i],false); - end; + SetAllActionUsers(UActionList[i],false); end; end; diff --git a/plugins/Actman/ua/i_uaplaces.inc b/plugins/Actman/ua/i_uaplaces.inc index 4b1f46a762..222065b460 100644 --- a/plugins/Actman/ua/i_uaplaces.inc +++ b/plugins/Actman/ua/i_uaplaces.inc @@ -1,5 +1,5 @@ {} - +(* const MenuServices:array [tMenuType] of pAnsiChar = ( 'CList/AddMainMenuItem' {MS_CLIST_ADDMAINMENUITEM }, @@ -8,6 +8,7 @@ const 'CList/AddProtoMenuItem' {MS_CLIST_ADDPROTOMENUITEM }, 'CList/AddStatusMenuItem' {MS_CLIST_ADDSTATUSMENUITEM } ); +*) type tuaMenuRec = record hMenuRoot:HMENU; @@ -25,7 +26,7 @@ begin result:=CallService(MS_ACT_RUNBYID, lParam, wParam); end; -procedure SetTTBState(var ActionItem:tMyActionItem); +procedure SetTTBState(const ActionItem:tMyActionItem); var lflag:integer; begin @@ -47,7 +48,7 @@ begin CallService(MS_TTB_SETBUTTONSTATE,ActionItem.hTTBButton,lflag); end; -procedure SetTABState(hContact:THANDLE;var ActionItem:tMyActionItem;pressed:integer); +procedure SetTABState(hContact:THANDLE;const ActionItem:tMyActionItem;pressed:integer); var tabb:TBBButton; pc:pWideChar; @@ -224,8 +225,8 @@ begin if (ActionItem.flags and UAF_HKREGGED)=0 then begin FillChar(hkd,SizeOf(hkd),0); - hkd.cbSize := SizeOf(hkd); - hkd.dwFlags := HKD_UNICODE; + hkd.cbSize := SizeOf(hkd); // HOTKEYDESC_SIZE_V1 for pre-0.9 + hkd.dwFlags := HKD_UNICODE; // since 0.9 only hkd.pszName := ActionItem.szNameID; hkd.pszDescription.w:= ActionItem.szActDescr; hkd.pszSection .w:= MODULE_NAME; @@ -341,12 +342,12 @@ end; procedure CreateMenuItem(var ActionItem:tMyActionItem;mtype:tMenuType); var - i:integer; + extra:pWideChar; ActItem:pMyActionItem; ActMItem,UAMenuItem:pUAMenuItem; clmi:TCListMenuItem; + i:integer; res:boolean; - extra:pWideChar; begin {} UAMenuItem:=@ActionItem.UAMenuItem[mtype]; @@ -375,16 +376,26 @@ begin end; end; end; - // popup menu not found + // need to create popup menu if not res then begin FillChar(clmi,SizeOf(clmi),0); clmi.cbSize:=SizeOf(clmi); - clmi.flags :=CMIF_UNICODE; + if (UAMenuItem.menu_opt and UAF_NOTRANS)<>0 then + clmi.flags :=CMIF_UNICODE or CMIF_KEEPUNTRANSLATED + else + clmi.flags :=CMIF_UNICODE{ or CMIF_ICONFROMICOLIB}; if (UAMenuItem.szMenuPopup<>nil) and (UAMenuItem.szMenuPopup^<>#0) then - clmi.szName.w:=ParseVarString(UAMenuItem.szMenuPopup) + begin + if (UAMenuItem.menu_opt and UAF_MSUBVAR)<>0 then + clmi.szName.w:=ParseVarString(UAMenuItem.szMenuPopup) + else + clmi.szName.w:=UAMenuItem.szMenuPopup; + end else + clmi.szName.w:=nil; + if clmi.szName.w=nil then clmi.szName.w:=ActionItem.szActDescr; clmi.hIcon :=AddRootMenuIcon(clmi.szName.w); @@ -395,8 +406,9 @@ begin (UAMenuItem.menu_opt and UAF_MENUSEP)<>0)); UAMenuItem.hMenuRoot:=MakeMenuItem(mtype,@clmi); - //CallService(MenuServices[mtype],0,LPARAM(@clmi)); - if clmi.szName.w<>ActionItem.szActDescr then + + if (clmi.szName.w<>ActionItem.szActDescr) and + (clmi.szName.w<>UAMenuItem.szMenuPopup) then mFreeMem(clmi.szName.w); for i:=1 to HIGH(arMenuRec) do @@ -417,7 +429,10 @@ begin {}{} FillChar(clmi,SizeOf(clmi),0); clmi.cbSize:=SizeOf(clmi); - clmi.flags:=CMIF_UNICODE; + if (UAMenuItem.menu_opt and UAF_NOTRANS)<>0 then + clmi.flags :=CMIF_UNICODE or CMIF_KEEPUNTRANSLATED + else + clmi.flags :=CMIF_UNICODE{ or CMIF_ICONFROMICOLIB}; if (ActionItem.flags and (UAF_2STATE+UAF_PRESSED))<>(UAF_2STATE+UAF_PRESSED) then begin clmi.hIcon:=ActionItem.hIcolibIcon; @@ -426,22 +441,26 @@ begin else begin clmi.hIcon:=ActionItem.hIcolibIconPressed; - clmi.flags:=CMIF_UNICODE or CMIF_CHECKED; + clmi.flags:=clmi.flags or CMIF_CHECKED; extra:='1'; end; - with ActionItem.UAMenuItem[mtype] do + if (UAMenuItem.szMenuNameVars<>nil) and (UAMenuItem.szMenuNameVars^<>#0) then begin - if (szMenuNameVars<>nil) and (szMenuNameVars^<>#0) then - clmi.szName.w:=ParseVarString(szMenuNameVars,0,extra) + if (UAMenuItem.menu_opt and UAF_MNAMVAR)<>0 then + clmi.szName.w:=ParseVarString(UAMenuItem.szMenuNameVars,0,extra) else - clmi.szName.w:=ActionItem.szActDescr; + clmi.szName.w:=UAMenuItem.szMenuNameVars; + end + else + clmi.szName.w:=nil; + if clmi.szName.w=nil then + clmi.szName.w:=ActionItem.szActDescr; - if hMenuRoot<>0 then - begin - clmi.flags:=clmi.flags or CMIF_ROOTHANDLE; - clmi.szPopupName.w:=pWideChar(hMenuRoot); - end; + if UAMenuItem.hMenuRoot<>0 then + begin + clmi.flags:=clmi.flags or CMIF_ROOTHANDLE; + clmi.szPopupName.w:=pWideChar(UAMenuItem.hMenuRoot); end; clmi.pszService:=ActionItem.szNameID; @@ -456,13 +475,14 @@ begin UAMenuItem.hMenuItem:=MakeMenuItem(mtype,@clmi); //CallService(MenuServices[mtype],0,LPARAM(@clmi)); - if clmi.szName.w<>ActionItem.szActDescr then + if (clmi.szName.w<>ActionItem.szActDescr) and + (clmi.szName.w<>UAMenuItem.szMenuNameVars) then mFreeMem(clmi.szName.w); {} end; -function PreBuildMenu(mtype:tMenuType;hContact:THANDLE=0):int; +function PreBuildMenu(mtype:tMenuType;hContact:TMCONTACT=0):int; var i:integer; mi:TCListMenuItem; @@ -504,7 +524,7 @@ begin if (mi.flags and CMIF_HIDDEN)=0 then begin //!!!! icon (check for contact menu) - mi.flags:=mi.flags or CMIM_ICON or CMIM_FLAGS; + mi.flags:=mi.flags or CMIM_ICON or CMIM_FLAGS{ or CMIF_ICONFROMICOLIB}; if (mtype=contact_menu) and IsLocalItem(UActionList[i]) then begin @@ -543,14 +563,22 @@ begin // new name mi.flags:=mi.flags or CMIM_NAME or CMIF_UNICODE; if (szMenuNameVars<>nil) and (szMenuNameVars^<>#0) then - mi.szName.w:=ParseVarString(szMenuNameVars,hContact,extra); - + begin + if (menu_opt and UAF_MNAMVAR)<>0 then + mi.szName.w:=ParseVarString(szMenuNameVars,hContact,extra) + else + mi.szName.w:=szMenuNameVars; + end + else + mi.szName.w:=nil; if mi.szName.w=nil then mi.szName.w:=szActDescr; end; CallService(MS_CLIST_MODIFYMENUITEM,hMenuItem,LPARAM(@mi)); - if mi.szName.w<>szActDescr then + + if (mi.szName.w<>szActDescr) and + (mi.szName.w<>szMenuNameVars) then mFreeMem(mi.szName.w); end; end; @@ -624,13 +652,24 @@ begin if ActionItem.szTTBTooltip =nil then pc1:=pc - else pc1:=ActionItem.szTTBTooltip; + else + begin + if (ActionItem.flags and UAF_TTBTTUV)<>0 then + pc1:=ParseVarString(ActionItem.szTTBTooltip) + else + pc1:=ActionItem.szTTBTooltip; + end; if ((ActionItem.flags and UAF_2STATE)=0) or (ActionItem.szTTBTooltipPressed=nil) then pc2:=pc1 else - pc2:=ActionItem.szTTBTooltipPressed; + begin + if (ActionItem.flags and UAF_TTBTTPV)<>0 then + pc2:=ParseVarString(ActionItem.szTTBTooltipPressed) + else + pc2:=ActionItem.szTTBTooltipPressed; + end; mtButton.Name :=pc; mtButton.pszTooltipUp :=pc1; @@ -639,6 +678,11 @@ begin ActionItem.hTTBButton:=TopToolbar_AddButton(@mtButton); if ActionItem.hTTBButton=THANDLE(-1) then ActionItem.hTTBButton:=0; + if (pc2<>pc1) and (pc2<>ActionItem.szTTBTooltipPressed) then + mFreeMem(pc2); + if (pc1<>pc) and (pc1<>ActionItem.szTTBTooltip) then + mFreeMem(pc1); + mFreeMem(pc); end; end; @@ -751,7 +795,7 @@ end; function OnTabButtonPressed(wParam:WPARAM;lParam:LPARAM):int; cdecl; var cbcd:pCustomButtonClickData; -// tabb:TBBButton; +// tabb:BBButton; // pc:pWideChar; i:integer; begin diff --git a/plugins/Actman/ua/i_uavars.inc b/plugins/Actman/ua/i_uavars.inc index bab2ac12a1..f2cf1ba42f 100644 --- a/plugins/Actman/ua/i_uavars.inc +++ b/plugins/Actman/ua/i_uavars.inc @@ -29,9 +29,6 @@ type type pMyActionItem = ^tMyActionItem; tMyActionItem = record - flags :dword; - dwActID :dword; // action ID - wSortIndex :word; // list/menu/toolbar order // UseActions/Action_ID szNameID :pAnsiChar; // uaction ID szActDescr :pWideChar; // action name @@ -50,6 +47,10 @@ type lastContact :THANDLE; // for contact menu hMenuService :THANDLE; // common menu service UAMenuItem :array [tMenuType] of tUAMenuItem; + // moved to the end for better align + flags :dword; + dwActID :dword; // action ID + wSortIndex :word; // list/menu/toolbar order end; const @@ -61,6 +62,8 @@ const UAF_REGTABB = 1 shl 5; // TabSRMM toolbar UAF_USING = UAF_REGHOTKEY or UAF_REGTTBB or UAF_REGTABB; + UAF_TTBTTPV = 1 shl 9; // TTB pressed hint script + UAF_TTBTTUV = 1 shl 10; // TTB unpressed hint script UAF_2STATE = 1 shl 11; // Buttons/menu items are 2-state UAF_PRESSED = 1 shl 12; // Button pressed/menu item selected UAF_SAVESTATE = 1 shl 13; // Save or not "pressed" state @@ -76,7 +79,10 @@ const // menu options UAF_MENUSEP = 1 shl 1; // menu item separated + UAF_MSUBVAR = 1 shl 2; // submenu name script + UAF_MNAMVAR = 1 shl 3; // menu name script UAF_MENUUSE = 1 shl 8; // use this menu + UAF_NOTRANS = 1 shl 9; // do not translate menus type tNameRec = record @@ -119,6 +125,3 @@ var UActionList:array of tMyActionItem; var szMyPath:array [0..MAX_PATH] of WideChar; -var - hServiceWithLParam:THANDLE; - hTTBService:THANDLE; diff --git a/plugins/Actman/ua/i_uconst.inc b/plugins/Actman/ua/i_uconst.inc index 34dde3ee9e..cffbfdcc76 100644 --- a/plugins/Actman/ua/i_uconst.inc +++ b/plugins/Actman/ua/i_uconst.inc @@ -2,33 +2,35 @@ const IDD_UA = 1031; - IDC_UA_ACTIONLIST = 1025; - IDC_UA_PLACELIST = 1026; + IDC_UA_ACTIONLIST = 1025; + IDC_UA_PLACELIST = 1026; // menu settings - IDC_UA_SEPARATE = 1027; - IDC_UA_POPUPT = 1028; - IDC_UA_POPUPV = 1029; + IDC_UA_POPUPT = 1030; + IDC_UA_POPUPV = 1031; - IDC_UA_VARNAMEST = 1030; - IDC_UA_VARNAMESV = 1031; - IDC_UA_VARNAMESH = 1032; + IDC_UA_VARNAMEST = 1032; + IDC_UA_VARNAMESV = 1033; - IDC_UA_SHOWVART = 1033; - IDC_UA_SHOWVARV = 1034; - IDC_UA_SHOWVARH = 1035; + IDC_UA_SHOWVART = 1034; + IDC_UA_SHOWVARV = 1035; + + IDC_UA_BLOCK = 1040; + IDC_UA_SEPARATE = 1041; + IDC_UA_NOTRANSLATE = 1042; + IDC_UA_MENU = 1043; // toolbar settings - IDC_UA_TTNORMALT = 2028; - IDC_UA_TTNORMALV = 2029; - IDC_UA_TTPRESSEDT = 2030; - IDC_UA_TTPRESSEDV = 2031; + IDC_UA_TTNORMALT = 2028; + IDC_UA_TTNORMALV = 2029; + IDC_UA_TTPRESSEDT = 2030; + IDC_UA_TTPRESSEDV = 2031; // common - IDC_UA_COMMON = 2000; - IDC_UA_TWOSTATE = 2001; - IDC_UA_SAVSTATE = 2002; + IDC_UA_COMMON = 2000; + IDC_UA_TWOSTATE = 2001; + IDC_UA_SAVSTATE = 2002; - IDC_UA_GLOBAL = 2003; + IDC_UA_GLOBAL = 2003; IDI_ACTION = 101; diff --git a/plugins/Actman/ua/ua.pas b/plugins/Actman/ua/ua.pas index 62b9604286..e6e33aeaad 100644 --- a/plugins/Actman/ua/ua.pas +++ b/plugins/Actman/ua/ua.pas @@ -2,21 +2,15 @@ unit ua; interface -procedure Init; -procedure DeInit; -function AddOptionPage(var tmpl:pAnsiChar;var proc:pointer;var name:PAnsiChar):integer; - implementation uses windows, commctrl, messages, - mirutils, common, dbsettings, io, m_api, wrapper, + mirutils, common, dbsettings, io, m_api, wrapper, editwrapper, global; {$R ua.res} -{$include m_actman.inc} - {$include i_uconst.inc} {$include i_uavars.inc} @@ -53,53 +47,54 @@ var // ------------ base interface functions ------------- +procedure CheckPlacesAbility; var - iohook:THANDLE; - hontabloaded, - honttbloaded, - ontabbtnpressed, - onactchanged:THANDLE; - hPreBuildMMenu, - hPreBuildCMenu, - hPreBuildTMenu:THANDLE; + i:integer; +begin + for i:=0 to NumTypes-1 do + begin + with NamesArray[i] do + begin + enable:=(service=nil) or (ServiceExists(service)<>0); + end; + end; +end; procedure Init; begin GetModuleFileNameW(hInstance,szMyPath,MAX_PATH); - hServiceWithLParam:=CreateServiceFunction(SERVICE_WITH_LPARAM_NAME,@ServiceCallWithLParam); - hTTBService :=CreateServiceFunction(TTB_SERVICE_NAME ,@TTBServiceCall); + CreateServiceFunction(SERVICE_WITH_LPARAM_NAME,@ServiceCallWithLParam); + CreateServiceFunction(TTB_SERVICE_NAME ,@TTBServiceCall); CheckPlacesAbility; CreateUActionList; - honttbloaded :=HookEvent(ME_TTB_MODULELOADED ,@OnTTBLoaded); - hontabloaded :=HookEvent(ME_MSG_TOOLBARLOADED,@OnTabBBLoaded); - ontabbtnpressed:=HookEvent(ME_MSG_BUTTONPRESSED,@OnTabButtonPressed); - onactchanged :=HookEvent(ME_ACT_CHANGED ,@ActListChange); + HookEvent(ME_TTB_MODULELOADED ,@OnTTBLoaded); + HookEvent(ME_MSG_TOOLBARLOADED,@OnTabBBLoaded); + HookEvent(ME_MSG_BUTTONPRESSED,@OnTabButtonPressed); + HookEvent(ME_ACT_CHANGED ,@ActListChange); - hPreBuildMMenu:=HookEvent(ME_CLIST_PREBUILDMAINMENU , PreBuildMainMenu); - hPreBuildCMenu:=HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PreBuildContactMenu); - hPreBuildTMenu:=HookEvent(ME_CLIST_PREBUILDTRAYMENU , PreBuildTrayMenu); + HookEvent(ME_CLIST_PREBUILDMAINMENU , PreBuildMainMenu); + HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PreBuildContactMenu); + HookEvent(ME_CLIST_PREBUILDTRAYMENU , PreBuildTrayMenu); - iohook:=HookEvent(ME_ACT_INOUT,@ActInOut); + HookEvent(ME_ACT_INOUT,@ActInOut); end; procedure DeInit; +var + i:integer; begin + if Length(UActionList)>0 then + begin + for i:=HIGH(UActionList) downto 0 do + begin + DeleteUAction(i,false); + end; + SetLength(UActionList,0); + end; SetLength(arMenuRec,0); - - UnhookEvent(hPreBuildMMenu); - UnhookEvent(hPreBuildCMenu); - UnhookEvent(hPreBuildTMenu); - - UnhookEvent(honttbloaded); - UnhookEvent(hontabloaded); - UnhookEvent(ontabbtnpressed); - UnhookEvent(onactchanged); - UnhookEvent(iohook); - DestroyServiceFunction(hServiceWithLParam); - DestroyServiceFunction(hTTBService); end; function AddOptionPage(var tmpl:pAnsiChar;var proc:pointer;var name:PAnsiChar):integer; diff --git a/plugins/Actman/ua/ua.rc b/plugins/Actman/ua/ua.rc index 76d8c0ad77..6e0fdde413 100644 --- a/plugins/Actman/ua/ua.rc +++ b/plugins/Actman/ua/ua.rc @@ -7,44 +7,47 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 0, 0 { - CTEXT "Action list",-1, 2,2,132,10, SS_CENTERIMAGE + CTEXT "Action list",-1, 0,2,134,11, SS_CENTERIMAGE CONTROL "", IDC_UA_ACTIONLIST, "SysListView32", WS_BORDER | WS_TABSTOP | LVS_NOCOLUMNHEADER | LVS_SHOWSELALWAYS | LVS_REPORT | LVS_SINGLESEL, - 2, 12, 132, 212, WS_EX_CONTROLPARENT + 0, 13, 134, 212, WS_EX_CONTROLPARENT - CTEXT "Where to use",-1, 138,2,160,10, SS_CENTERIMAGE + CTEXT "Where to use",-1, 138,2,160,11, SS_CENTERIMAGE CONTROL "", IDC_UA_PLACELIST, "SysListView32", WS_BORDER | WS_TABSTOP | LVS_NOCOLUMNHEADER | LVS_SHOWSELALWAYS | LVS_REPORT | LVS_SINGLESEL, - 138, 12, 160, 74, WS_EX_CONTROLPARENT + 138, 13, 160, 74, WS_EX_CONTROLPARENT - GROUPBOX "Common" , IDC_UA_COMMON , 138, 88,160,38 - AUTOCHECKBOX "2 state button/item" , IDC_UA_TWOSTATE, 140, 96,156,14, BS_LEFTTEXT | BS_RIGHT - AUTOCHECKBOX "Save button/item state", IDC_UA_SAVSTATE, 140,110,156,14, BS_LEFTTEXT | BS_RIGHT + GROUPBOX "Common" , IDC_UA_COMMON , 138, 88,164,38 + AUTOCHECKBOX "2 state button/item" , IDC_UA_TWOSTATE, 140, 96,160,14, BS_LEFTTEXT | BS_RIGHT + AUTOCHECKBOX "Save button/item state", IDC_UA_SAVSTATE, 140,110,160,14, BS_LEFTTEXT | BS_RIGHT - AUTOCHECKBOX "Contact related", IDC_UA_GLOBAL, 138,128,160,14, BS_LEFTTEXT | BS_RIGHT + AUTOCHECKBOX "Contact related", IDC_UA_GLOBAL, 138,128,164,14, BS_LEFTTEXT | BS_RIGHT // Buttons settings block - RTEXT "Normal button tooltip",IDC_UA_TTNORMALT, 138,148,160,8 - EDITTEXT IDC_UA_TTNORMALV, 138,158,160,12, ES_AUTOHSCROLL + RTEXT "Normal button tooltip",IDC_UA_TTNORMALT, 138,144,164,12, SS_CENTERIMAGE + EDITTEXT IDC_UA_TTNORMALV, 138,157,164,12, ES_AUTOHSCROLL - RTEXT "Pressed button tooltip",IDC_UA_TTPRESSEDT, 138,172,160,8 - EDITTEXT IDC_UA_TTPRESSEDV, 138,182,160,12, ES_AUTOHSCROLL + RTEXT "Pressed button tooltip",IDC_UA_TTPRESSEDT, 138,172,164,12, SS_CENTERIMAGE + EDITTEXT IDC_UA_TTPRESSEDV, 138,185,164,12, ES_AUTOHSCROLL - // Menu settings block - AUTOCHECKBOX "Separated",IDC_UA_SEPARATE, 138,142,160,14, BS_LEFTTEXT | BS_RIGHT + PUSHBUTTON ">" , IDC_UA_BLOCK, 292,146, 10,52 + GROUPBOX "Main settings", IDC_UA_MENU , 138,142,152,58 - RTEXT "Root popup:",IDC_UA_POPUPT,138,158,80,12, SS_CENTERIMAGE - EDITTEXT IDC_UA_POPUPV, 218,158,80,12, ES_AUTOHSCROLL + // Block #1 (Menu data block) + RTEXT "Root popup:",IDC_UA_POPUPT, 140,150,146,12, SS_CENTERIMAGE + EDITTEXT IDC_UA_POPUPV, 141,162,146,12, ES_AUTOHSCROLL - RTEXT "Menu item name:",IDC_UA_VARNAMEST, 138,172,140,8 - EDITTEXT IDC_UA_VARNAMESV, 138,182,140,12, ES_AUTOHSCROLL - CONTROL "V",IDC_UA_VARNAMESH,"MButtonClass",WS_TABSTOP, 282,180,16,16, $18000000 + RTEXT "Menu item name:",IDC_UA_VARNAMEST, 140,174,146,12, SS_CENTERIMAGE + EDITTEXT IDC_UA_VARNAMESV, 141,186,146,12, ES_AUTOHSCROLL - RTEXT "Show only if variables return 1",IDC_UA_SHOWVART, 138,200,140,8 - EDITTEXT IDC_UA_SHOWVARV,138,210,140,12,ES_AUTOHSCROLL - CONTROL "V",IDC_UA_SHOWVARH,"MButtonClass",WS_TABSTOP, 282,208,16,16, $18000000 + // Block #2 (Menu settings block) + AUTOCHECKBOX "Separated" ,IDC_UA_SEPARATE , 140,150,148,14, BS_LEFTTEXT | BS_RIGHT + AUTOCHECKBOX "Do not translate",IDC_UA_NOTRANSLATE, 140,166,148,14, BS_LEFTTEXT | BS_RIGHT + + RTEXT "Show only if variables return 1",IDC_UA_SHOWVART, 138,200,164,12, SS_CENTERIMAGE + EDITTEXT IDC_UA_SHOWVARV, 138,213,164,12, ES_AUTOHSCROLL } diff --git a/plugins/Actman/ua/ua.res b/plugins/Actman/ua/ua.res index c8f5fd5ea1..25b0f7f2ca 100644 Binary files a/plugins/Actman/ua/ua.res and b/plugins/Actman/ua/ua.res differ -- cgit v1.2.3