@@ -118,24 +118,12 @@ CChatSocket::~CChatSocket()
118
118
119
119
if (m_bWasConnected)
120
120
{
121
- CPlugin * pSavedPlugin = m_pDoc->m_CurrentPlugin ;
122
121
123
122
// tell each plugin about the departing user
124
- for (POSITION pluginpos = m_pDoc->m_PluginList .GetHeadPosition (); pluginpos; )
125
- {
126
- CPlugin * pPlugin = m_pDoc->m_PluginList .GetNext (pluginpos);
127
-
128
- if (!(pPlugin->m_bEnabled )) // ignore disabled plugins
129
- continue ;
130
-
131
- // see what the plugin makes of this,
132
- pPlugin->ExecutePluginScript (ON_PLUGIN_CHAT_USERDISCONNECT,
133
- pPlugin->m_dispid_plugin_On_Chat_UserDisconnect ,
134
- m_iChatID, // user ID
135
- string (m_strRemoteUserName) // user name
136
- );
137
- } // end of doing each plugin
138
- m_pDoc->m_CurrentPlugin = pSavedPlugin;
123
+ m_pDoc->SendToAllPluginCallbacks (ON_PLUGIN_CHAT_USERDISCONNECT,
124
+ m_iChatID, // user ID
125
+ string (m_strRemoteUserName),
126
+ false , false );
139
127
} // end of needing to notify about him
140
128
}
141
129
@@ -185,7 +173,6 @@ void CChatSocket::OnReceive(int nErrorCode)
185
173
186
174
char buff [1000 ];
187
175
int count = Receive (buff, sizeof (buff) - 1 );
188
- POSITION pluginpos;
189
176
190
177
if (count == SOCKET_ERROR)
191
178
{
@@ -258,24 +245,12 @@ POSITION pluginpos;
258
245
SendChatMessage (CHAT_STAMP, MakeStamp (m_zChatStamp)); // send it
259
246
}
260
247
261
- CPlugin * pSavedPlugin = m_pDoc->m_CurrentPlugin ;
262
-
263
248
// tell each plugin about the new user
264
- for (pluginpos = m_pDoc->m_PluginList .GetHeadPosition (); pluginpos; )
265
- {
266
- CPlugin * pPlugin = m_pDoc->m_PluginList .GetNext (pluginpos);
267
-
268
- if (!(pPlugin->m_bEnabled )) // ignore disabled plugins
269
- continue ;
270
-
271
- // see what the plugin makes of this,
272
- pPlugin->ExecutePluginScript (ON_PLUGIN_CHAT_NEWUSER,
273
- pPlugin->m_dispid_plugin_On_Chat_NewUser ,
274
- m_iChatID, // user ID
275
- string (m_strRemoteUserName) // user name
276
- );
277
- } // end of doing each plugin
278
- m_pDoc->m_CurrentPlugin = pSavedPlugin;
249
+ m_pDoc->SendToAllPluginCallbacks (ON_PLUGIN_CHAT_NEWUSER,
250
+ m_iChatID, // user ID
251
+ string (m_strRemoteUserName),
252
+ false ,
253
+ false );
279
254
280
255
if (count <= 0 )
281
256
return ; // only the negotiation text here
@@ -354,32 +329,18 @@ POSITION pluginpos;
354
329
355
330
count = 0 ; // can't see how this packet can be reasonably terminated
356
331
357
- CPlugin * pSavedPlugin = m_pDoc->m_CurrentPlugin ;
358
-
359
- // tell each plugin what we are about to display
360
- for (pluginpos = m_pDoc->m_PluginList .GetHeadPosition (); pluginpos; )
361
- {
362
- CPlugin * pPlugin = m_pDoc->m_PluginList .GetNext (pluginpos);
363
-
364
- if (!(pPlugin->m_bEnabled )) // ignore disabled plugins
365
- continue ;
366
-
367
- // see what the plugin makes of this,
368
- if (!pPlugin->ExecutePluginScript (ON_PLUGIN_CHAT_ACCEPT,
369
- pPlugin->m_dispid_plugin_On_Chat_Accept ,
370
- CFormat (" %s,%s" ,
371
- (LPCTSTR) inet_ntoa (m_ServerAddr.sin_addr ),
372
- (LPCTSTR) m_strRemoteUserName
373
- )))
332
+ if (!m_pDoc->SendToAllPluginCallbacks (ON_PLUGIN_CHAT_ACCEPT,
333
+ CFormat (" %s,%s" ,
334
+ (LPCTSTR) inet_ntoa (m_ServerAddr.sin_addr ),
335
+ (LPCTSTR) m_strRemoteUserName
336
+ ),
337
+ true )) // stop on false response
374
338
{
375
- m_pDoc->m_CurrentPlugin = pSavedPlugin;
376
339
// tell them our rejection
377
340
SendData (" NO" );
378
341
OnClose (0 );
379
342
return ; // false means plugin rejects him
380
343
}
381
- } // end of doing each plugin
382
- m_pDoc->m_CurrentPlugin = pSavedPlugin;
383
344
384
345
if (m_pDoc->m_bValidateIncomingCalls )
385
346
{
@@ -421,24 +382,12 @@ POSITION pluginpos;
421
382
SendChatMessage (CHAT_STAMP, MakeStamp (m_zChatStamp)); // send it
422
383
}
423
384
424
- pSavedPlugin = m_pDoc->m_CurrentPlugin ;
425
-
426
385
// tell each plugin about the new user
427
- for (POSITION pluginpos = m_pDoc->m_PluginList .GetHeadPosition (); pluginpos; )
428
- {
429
- CPlugin * pPlugin = m_pDoc->m_PluginList .GetNext (pluginpos);
430
-
431
- if (!(pPlugin->m_bEnabled )) // ignore disabled plugins
432
- continue ;
433
-
434
- // see what the plugin makes of this,
435
- pPlugin->ExecutePluginScript (ON_PLUGIN_CHAT_NEWUSER,
436
- pPlugin->m_dispid_plugin_On_Chat_NewUser ,
437
- m_iChatID, // user ID
438
- string (m_strRemoteUserName) // user name
439
- );
440
- } // end of doing each plugin
441
- m_pDoc->m_CurrentPlugin = pSavedPlugin;
386
+ m_pDoc->SendToAllPluginCallbacks (ON_PLUGIN_CHAT_NEWUSER,
387
+ m_iChatID, // user ID
388
+ string (m_strRemoteUserName),
389
+ false ,
390
+ false );
442
391
443
392
if (count <= 0 )
444
393
return ; // only the negotiation text here
@@ -733,29 +682,14 @@ void CChatSocket::ProcessChatMessage (const int iMessage, const CString strMessa
733
682
734
683
#endif
735
684
736
- CPlugin * pSavedPlugin = m_pDoc->m_CurrentPlugin ;
685
+ if (!m_pDoc->SendToAllPluginCallbacks (ON_PLUGIN_CHAT_MESSAGE,
686
+ m_iChatID, // who we are
687
+ iMessage, // message number
688
+ string (strMessage), // message text
689
+ false ,
690
+ true )) // stop on false response
691
+ return ; // false means plugin handled it
737
692
738
- // tell each plugin what we are about to display
739
- for (POSITION pluginpos = m_pDoc->m_PluginList .GetHeadPosition (); pluginpos; )
740
- {
741
- CPlugin * pPlugin = m_pDoc->m_PluginList .GetNext (pluginpos);
742
-
743
- if (!(pPlugin->m_bEnabled )) // ignore disabled plugins
744
- continue ;
745
-
746
- // see what the plugin makes of this,
747
- if (!pPlugin->ExecutePluginScript (ON_PLUGIN_CHAT_MESSAGE,
748
- pPlugin->m_dispid_plugin_On_Chat_Message ,
749
- m_iChatID, // who we are
750
- iMessage, // message number
751
- string (strMessage) // message text
752
- ))
753
- {
754
- m_pDoc->m_CurrentPlugin = pSavedPlugin;
755
- return ; // false means plugin handled it
756
- }
757
- } // end of doing each plugin
758
- m_pDoc->m_CurrentPlugin = pSavedPlugin;
759
693
760
694
switch (iMessage)
761
695
{
@@ -821,28 +755,13 @@ void CChatSocket::SendChatMessage (const int iMessage,
821
755
822
756
#endif
823
757
824
- CPlugin * pSavedPlugin = m_pDoc->m_CurrentPlugin ;
825
- // tell each plugin what we are about to display
826
- for (POSITION pluginpos = m_pDoc->m_PluginList .GetHeadPosition (); pluginpos; )
827
- {
828
- CPlugin * pPlugin = m_pDoc->m_PluginList .GetNext (pluginpos);
829
-
830
- if (!(pPlugin->m_bEnabled )) // ignore disabled plugins
831
- continue ;
832
-
833
- // see what the plugin makes of this,
834
- if (!pPlugin->ExecutePluginScript (ON_PLUGIN_CHAT_MESSAGE_OUT,
835
- pPlugin->m_dispid_plugin_On_Chat_MessageOut ,
836
- m_iChatID, // which chat ID
837
- iMessage, // message number
838
- string (strMessage) // message text
839
- ))
840
- {
841
- m_pDoc->m_CurrentPlugin = pSavedPlugin;
758
+ if (!m_pDoc->SendToAllPluginCallbacks (ON_PLUGIN_CHAT_MESSAGE_OUT,
759
+ m_iChatID, // which chat ID
760
+ iMessage, // message number
761
+ string (strMessage), // message text
762
+ false ,
763
+ true )) // stop on false response
842
764
return ; // false means plugin discarded it
843
- }
844
- } // end of doing each plugin
845
- m_pDoc->m_CurrentPlugin = pSavedPlugin;
846
765
847
766
if (iMessage == CHAT_SNOOP && m_bYouAreSnooping)
848
767
m_bYouAreSnooping = false ;
0 commit comments