From 83310365c69bd40365ee0ae0e16c99c28e24cd0b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 19 Jun 2015 14:24:12 +0000 Subject: - all static protocol services replaced with functions; - m_protomod.h removed as useless git-svn-id: http://svn.miranda-ng.org/main/trunk@14260 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Watrack/proto/proto.pas | 138 ++---------------------------------- plugins/Watrack/status/i_hotkey.inc | 4 +- 2 files changed, 7 insertions(+), 135 deletions(-) (limited to 'plugins/Watrack') diff --git a/plugins/Watrack/proto/proto.pas b/plugins/Watrack/proto/proto.pas index e26ce14f17..625e4fa031 100644 --- a/plugins/Watrack/proto/proto.pas +++ b/plugins/Watrack/proto/proto.pas @@ -84,129 +84,6 @@ begin db_event_add(hContact, @dbeo); end; -{SEND-time text translation} -(* -const - BufSize = 16384; - -function FormatToBBW(src:PWideChar):PWideChar; -var - buf:array [0..32] of WideChar; - p:PWideChar; - i,j:integer; -begin - result:=src; - StrReplaceW(src,'{b}' ,'[b]'); - StrReplaceW(src,'{/b}' ,'[/b]'); - StrReplaceW(src,'{u}' ,'[u]'); - StrReplaceW(src,'{/u}' ,'[/u]'); - StrReplaceW(src,'{i}' ,'[i]'); - StrReplaceW(src,'{/i}' ,'[/i]'); - StrReplaceW(src,'{/cf}','[/color]'); - StrReplaceW(src,'{/bg}',''); - StrCopyW(buf,'[color='); - repeat - i:=StrPosW(src,'{cf'); - if i=0 then break; - j:=i; - dec(i); - while (src[j]<>#0) and (src[j]<>'}') do inc(j); - if src[j]='}' then inc(j); - case StrToInt(src+i+3) of - 4,10: p:='green]'; - 5,6: p:='red]'; - 7,14: p:='magenta]'; - 3,11, - 12,13: p:='blue]'; - 8,9: p:='yellow]'; - 2,15: p:='black]'; - else - {1,16:} p:='white]'; - end; - StrCopyW(buf+7,p); - StrCopyW(src+i,src+j); - StrInsertW(buf,src,i); - until false; - repeat - i:=StrIndex(src,'{bg'); - if i=0 then break; - j:=i; - dec(i); - while (src[j]<>#0) and (src[j]<>'}') do inc(j); - if src[j]='}' then inc(j); - StrCopyW(src+i,src+j); - until false; -end; - -function SendMessageProcW(wParam:WPARAM; lParam:LPARAM):integer; cdecl; -var - ccs:PCCSDATA; - uns,s,ss:pWideChar; - p:PAnsiChar; - present:boolean; - i:integer; -begin - if DisablePlugin<>dsPermanent then - begin - ccs:=PCCSDATA(lParam); - if ccs^.wParam=0 then - present:=StrPos('%music%',PAnsiChar(ccs^.lParam))<>nil - else // not needed? - begin - uns:=PWideChar(ccs^.lParam+StrLen(PAnsiChar(ccs^.lParam))+1); - present:=StrPos(uns,'%music%')<>nil; - end; - - if present then - begin - if CallService(MS_WAT_GETMUSICINFO,0,0)=WAT_RES_NOTFOUND then - s:=nil - else - begin - if SimpleMode<>BST_UNCHECKED then - i:=0 - else - i:=CallService(MS_PROTO_GETCONTACTBASEPROTO,ccs^.hContact,0); - s:=GetMacros(TM_MESSAGE,i); - end; - // if s<>nil then // for empty strings - begin - mGetMem(ss,BufSize*SizeOf(pWideChar)); - FillChar(ss^,BufSize*SizeOf(pWideChar),0); - if ccs^.wParam=0 then - AnsiToWide(PAnsiChar(ccs^.lParam),uns,UserCP); - StrCopyW(ss,uns); - if ccs^.wParam=0 then - mFreeMem(uns); - StrReplaceW(ss,'%music%',s); - mFreeMem(s); - if StrPos(ss,'{')<>nil then - FormatToBBW(ss); - s:=PWideChar(ccs^.lParam); - WideToAnsi(ss,p,UserCP); - if ccs^.wParam=0 then - begin - ccs^.lParam:=tlparam(p); - end - else - begin - move(PAnsiChar(ss)^,(PAnsiChar(ss)+StrLen(p)+1)^, - (StrLenW(ss)+1)*SizeOf(WideChar)); - StrCopy(PAnsiChar(ss),p); - ccs^.lParam:=tlparam(ss); - end; - result:=CallService(MS_PROTO_CHAINSEND,wParam,lParam); - mFreeMem(p); - ccs^.lParam:=tlparam(s); - mFreeMem(ss); - exit; - end; - end; - end; - result:=CallService(MS_PROTO_CHAINSEND,wParam,lParam); -end; -*) - function ReceiveMessageProcW(wParam:WPARAM; lParam:LPARAM):int_ptr; cdecl; const bufsize = 4096*SizeOf(WideChar); @@ -237,13 +114,13 @@ begin (StrCmp(PPROTORECVEVENT(ccs^.lParam)^.szMessage.a, wpRequest,Length(wpRequest))=0) then begin - StrCopy(PAnsiChar(buf),PAnsiChar(CallService(MS_PROTO_GETCONTACTBASEPROTO,ccs^.hContact,0))); + StrCopy(PAnsiChar(buf),Proto_GetProtoName(ccs^.hContact)); i:=DBReadWord(ccs^.hContact,PAnsiChar(buf),'ApparentMode'); StrCat(PAnsiChar(buf),PS_GETSTATUS); if (i=ID_STATUS_OFFLINE) or ((i=0) and (CallService(PAnsiChar(buf),0,0)=ID_STATUS_INVISIBLE)) then begin - result:=CallService(MS_PROTO_CHAINRECV,wParam,lParam); + result:=Proto_ChainRecv(wParam,ccs); end else if DBReadByte(ccs^.hContact,strCList,ShareOptText,0)<>0 then // or (NotListedAllow and (DBReadByte(ccs^.hContact,strCList,'NotOnList',0)) @@ -385,7 +262,7 @@ begin Translate('You Get Error'),MB_ICONERROR); end else - result:=CallService(MS_PROTO_CHAINRECV,wParam,lParam); + result:=Proto_ChainRecv(wParam,ccs); mFreeMem(buf); end; @@ -409,7 +286,7 @@ begin while hContact<>0 do begin if not IsChat(hContact) then - CallService(MS_PROTO_ADDTOCONTACT,hContact,lparam(PluginShort)); + Proto_AddToContact(hContact,PluginShort); hContact:=db_find_next(hContact); end; end; @@ -418,7 +295,7 @@ function HookAddUser(hContact:WPARAM;lParam:LPARAM):int; cdecl; begin result:=0; if not IsChat(hContact) then - CallService(MS_PROTO_ADDTOCONTACT,hContact,tlparam(PluginShort)); + Proto_AddToContact(hContact,PluginShort); end; function OnContactMenu(hContact:WPARAM;lParam:LPARAM):int;cdecl; @@ -442,12 +319,9 @@ begin desc.cbSize:=PROTOCOLDESCRIPTOR_V3_SIZE;//SizeOf(desc); desc.szName:=PluginShort; desc._type :=PROTOTYPE_TRANSLATION; + Proto_RegisterModule(@desc); - CallService(MS_PROTO_REGISTERMODULE,0,lparam(@desc)); -// CreateProtoServiceFunction(PluginShort,PSS_MESSAGE ,@SendMessageProcW); -// CreateProtoServiceFunction(PluginShort,PSS_MESSAGEW,@SendMessageProcW); hSRM:=CreateProtoServiceFunction(PluginShort,PSR_MESSAGE ,@ReceiveMessageProcW); -// CreateProtoServiceFunction(PluginShort,PSR_MESSAGEW,@ReceiveMessageProcW); end; function IconChanged(wParam:WPARAM;lParam:LPARAM):int;cdecl; diff --git a/plugins/Watrack/status/i_hotkey.inc b/plugins/Watrack/status/i_hotkey.inc index 115be86655..e8f6ac3ea6 100644 --- a/plugins/Watrack/status/i_hotkey.inc +++ b/plugins/Watrack/status/i_hotkey.inc @@ -20,10 +20,8 @@ begin CurWin:=GetFocus; if CurWin<>0 then begin -// j:=WndToContact(WaitFocusedWndChild(GetForegroundwindow){GetFocus}); j:=WndToContact(CurWin); - p:=GetContactProtoAcc(j); -// p:=PAnsiChar(CallService(MS_PROTO_GETCONTACTBASEPROTO,j,0)); + p:=Proto_GetBaseAccountName(j); if DBReadByte(j,p,'ChatRoom',0)=1 then begin isUnicode:=false; -- cgit v1.2.3