/[weechat]/weechat/src/plugins/plugins.c
ViewVC logotype

Diff of /weechat/src/plugins/plugins.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.33 by flashcode, Wed Oct 26 23:07:03 2005 UTC revision 1.34 by flashcode, Fri Oct 28 07:31:22 2005 UTC
# Line 62  plugin_find_buffer (char *server, char * Line 62  plugin_find_buffer (char *server, char *
62      ptr_channel = NULL;      ptr_channel = NULL;
63      ptr_buffer = NULL;      ptr_buffer = NULL;
64            
65      if (server && server[0])      /* nothing given => print on current buffer */
66      {      if ((!server || !server[0]) && (!channel || !channel[0]))
67          ptr_server = server_search (server);          ptr_buffer = gui_current_window->buffer;
         if (!ptr_server)  
             return NULL;  
     }  
68      else      else
69      {      {
70          ptr_server = SERVER(gui_current_window->buffer);          if (server && server[0])
         if (!ptr_server)  
             ptr_server = SERVER(gui_buffers);  
     }  
       
     if (channel && channel[0])  
     {  
         if (ptr_server)  
71          {          {
72              ptr_channel = channel_search (ptr_server, channel);              ptr_server = server_search (server);
73              if (ptr_channel)              if (!ptr_server)
74                  ptr_buffer = ptr_channel->buffer;                  return NULL;
75          }          }
76      }          else
77      else          {
78      {              ptr_server = SERVER(gui_current_window->buffer);
79          if (!channel)              if (!ptr_server)
80                    ptr_server = SERVER(gui_buffers);
81            }
82            
83            if (channel && channel[0])
84          {          {
85              if (ptr_server)              if (ptr_server)
                 ptr_buffer = ptr_server->buffer;  
             else  
86              {              {
87                  ptr_buffer = gui_current_window->buffer;                  ptr_channel = channel_search (ptr_server, channel);
88                  if (ptr_buffer->dcc)                  if (ptr_channel)
89                      ptr_buffer = gui_buffers;                      ptr_buffer = ptr_channel->buffer;
90              }              }
91          }          }
92          else          else
93          {          {
94              if (ptr_server)              if (ptr_server)
95                  ptr_buffer = ptr_server->buffer;                  ptr_buffer = ptr_server->buffer;
96                else
97                    ptr_buffer = gui_current_window->buffer;
98          }          }
99      }      }
100            
101      if (!ptr_buffer)      if (!ptr_buffer)
102          return NULL;          return NULL;
103            
104      return (ptr_buffer->dcc) ? NULL : ptr_buffer;      return (ptr_buffer->dcc) ? gui_buffers : ptr_buffer;
105  }  }
106    
107  /*  /*
# Line 315  plugin_cmd_handler_add (t_weechat_plugin Line 309  plugin_cmd_handler_add (t_weechat_plugin
309    
310  /*  /*
311   * plugin_msg_handler_exec: execute a message handler   * plugin_msg_handler_exec: execute a message handler
312   *                          return: number of handlers executed (0 means no handler found)   *                          return: code for informing WeeChat whether message
313     *                          should be ignored or not
314   */   */
315    
316  int  int
# Line 323  plugin_msg_handler_exec (char *server, c Line 318  plugin_msg_handler_exec (char *server, c
318  {  {
319      t_weechat_plugin *ptr_plugin;      t_weechat_plugin *ptr_plugin;
320      t_plugin_handler *ptr_handler;      t_plugin_handler *ptr_handler;
321      int count;      int return_code, final_return_code;
322        
323        final_return_code = PLUGIN_RC_OK;
324            
     count = 0;  
325      for (ptr_plugin = weechat_plugins; ptr_plugin;      for (ptr_plugin = weechat_plugins; ptr_plugin;
326           ptr_plugin = ptr_plugin->next_plugin)           ptr_plugin = ptr_plugin->next_plugin)
327      {      {
# Line 338  plugin_msg_handler_exec (char *server, c Line 334  plugin_msg_handler_exec (char *server, c
334                  if (ptr_handler->running == 0)                  if (ptr_handler->running == 0)
335                  {                  {
336                      ptr_handler->running = 1;                      ptr_handler->running = 1;
337                      if ((int) (ptr_handler->handler) (ptr_plugin,                      return_code = ((int) (ptr_handler->handler) (ptr_plugin,
338                                                        server,                                                                   server,
339                                                        irc_command,                                                                   irc_command,
340                                                        irc_message,                                                                   irc_message,
341                                                        ptr_handler->handler_args,                                                                   ptr_handler->handler_args,
342                                                        ptr_handler->handler_pointer))                                                                   ptr_handler->handler_pointer));
                         count++;  
343                      ptr_handler->running = 0;                      ptr_handler->running = 0;
344                        
345                        if (return_code >= 0)
346                        {
347                            if (return_code & PLUGIN_RC_OK_IGNORE_WEECHAT)
348                                final_return_code = PLUGIN_RC_OK_IGNORE_WEECHAT;
349                            if (return_code & PLUGIN_RC_OK_IGNORE_PLUGINS)
350                                return final_return_code;
351                        }
352                  }                  }
353              }              }
354          }          }
355      }      }
356            
357      return count;      return final_return_code;
358  }  }
359    
360  /*  /*
# Line 385  plugin_cmd_handler_exec (char *server, c Line 388  plugin_cmd_handler_exec (char *server, c
388                                                                  ptr_handler->handler_args,                                                                  ptr_handler->handler_args,
389                                                                  ptr_handler->handler_pointer);                                                                  ptr_handler->handler_pointer);
390                      ptr_handler->running = 0;                      ptr_handler->running = 0;
391                      return (return_code) ? 1 : 0;                      return (return_code == PLUGIN_RC_KO) ? 0 : 1;
392                  }                  }
393              }              }
394          }          }
# Line 658  plugin_load (char *filename) Line 661  plugin_load (char *filename)
661                      new_plugin->name, new_plugin->version);                      new_plugin->name, new_plugin->version);
662                    
663          /* init plugin */          /* init plugin */
664          if (!((t_weechat_init_func *)init_func) (new_plugin))          if (((t_weechat_init_func *)init_func) (new_plugin) < 0)
665          {          {
666              irc_display_prefix (NULL, PREFIX_ERROR);              irc_display_prefix (NULL, PREFIX_ERROR);
667              gui_printf (NULL,              gui_printf (NULL,

Legend:
Removed from v.1.33  
changed lines
  Added in v.1.34

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26