separate-extcmd.diff
changeset 87 78238d26911a
parent 64 d328b18462bd
child 92 66f7e2aa040c
equal deleted inserted replaced
86:ac5fed257211 87:78238d26911a
     1 Move extcmd code from hooks
     1 Move extcmd code from hooks
     2 
     2 
     3 diff -r 75d573fb8845 mcabber/mcabber/Makefile.am
     3 diff -r fd72b1e3bf26 mcabber/mcabber/Makefile.am
     4 --- a/mcabber/mcabber/Makefile.am	Fri Jan 18 11:23:51 2013 +0200
     4 --- a/mcabber/mcabber/Makefile.am	Wed Nov 12 22:23:32 2014 +0200
     5 +++ b/mcabber/mcabber/Makefile.am	Sun Jan 27 00:38:57 2013 +0200
     5 +++ b/mcabber/mcabber/Makefile.am	Wed Nov 12 22:24:18 2014 +0200
     6 @@ -7,7 +7,7 @@
     6 @@ -7,7 +7,8 @@
     7  		  xmpp.c xmpp.h xmpp_helper.c xmpp_helper.h xmpp_defines.h \
     7  		  xmpp.c xmpp.h xmpp_helper.c xmpp_helper.h xmpp_defines.h \
     8  		  xmpp_iq.c xmpp_iq.h xmpp_iqrequest.c xmpp_iqrequest.h \
     8  		  xmpp_iq.c xmpp_iq.h xmpp_iqrequest.c xmpp_iqrequest.h \
     9  		  xmpp_muc.c xmpp_muc.h xmpp_s10n.c xmpp_s10n.h \
     9  		  xmpp_muc.c xmpp_muc.h xmpp_s10n.c xmpp_s10n.h \
    10 -		  caps.c caps.h help.c help.h
    10 -		  caps.c caps.h help.c help.h carbons.c carbons.h
    11 +		  caps.c caps.h help.c help.h extcmd.c extcmd.h
    11 +		  caps.c caps.h help.c help.h carbons.c carbons.h \
       
    12 +		  extcmd.c extcmd.h
    12  
    13  
    13  if OTR
    14  if OTR
    14  mcabber_SOURCES += otr.c otr.h nohtml.c nohtml.h
    15  mcabber_SOURCES += otr.c otr.h nohtml.c nohtml.h
    15 @@ -43,6 +43,7 @@
    16 @@ -43,6 +44,7 @@
    16  			 xmpp_iq.h xmpp_iqrequest.h \
    17  			 xmpp_iq.h xmpp_iqrequest.h \
    17  			 xmpp_muc.h xmpp_s10n.h \
    18  			 xmpp_muc.h xmpp_s10n.h \
    18  			 caps.h fifo.h help.h modules.h api.h \
    19  			 caps.h fifo.h help.h modules.h api.h \
    19 +			 extcmd.h \
    20 +			 extcmd.h \
    20  			 $(top_builddir)/include/config.h
    21  			 $(top_builddir)/include/config.h
    21  
    22  
    22  if OTR
    23  if OTR
    23 diff -r 75d573fb8845 mcabber/mcabber/extcmd.c
    24 diff -r fd72b1e3bf26 mcabber/mcabber/extcmd.c
    24 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25 +++ b/mcabber/mcabber/extcmd.c	Sun Jan 27 00:38:57 2013 +0200
    26 +++ b/mcabber/mcabber/extcmd.c	Wed Nov 12 22:24:18 2014 +0200
    26 @@ -0,0 +1,152 @@
    27 @@ -0,0 +1,152 @@
    27 +/*
    28 +/*
    28 + * extcmd.c      -- External event handler command
    29 + * extcmd.c      -- External event handler command
    29 + *
    30 + *
    30 + * Copyright (C) 2005-2010 Mikael Berthe <mikael@lilotux.net>
    31 + * Copyright (C) 2005-2010 Mikael Berthe <mikael@lilotux.net>
   174 +  }
   175 +  }
   175 +  g_free(datafname);
   176 +  g_free(datafname);
   176 +}
   177 +}
   177 +
   178 +
   178 +/* vim: set expandtab cindent cinoptions=>2\:2(0 ts=2 sw=2:  For Vim users... */
   179 +/* vim: set expandtab cindent cinoptions=>2\:2(0 ts=2 sw=2:  For Vim users... */
   179 diff -r 75d573fb8845 mcabber/mcabber/extcmd.h
   180 diff -r fd72b1e3bf26 mcabber/mcabber/extcmd.h
   180 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   181 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   181 +++ b/mcabber/mcabber/extcmd.h	Sun Jan 27 00:38:57 2013 +0200
   182 +++ b/mcabber/mcabber/extcmd.h	Wed Nov 12 22:24:18 2014 +0200
   182 @@ -0,0 +1,15 @@
   183 @@ -0,0 +1,15 @@
   183 +#ifndef __MCABBER_EXTCMD_H__
   184 +#ifndef __MCABBER_EXTCMD_H__
   184 +#define __MCABBER_EXTCMD_H__ 1
   185 +#define __MCABBER_EXTCMD_H__ 1
   185 +
   186 +
   186 +#define EXT_CMD_TYPE_MESSAGE   "MSG"
   187 +#define EXT_CMD_TYPE_MESSAGE   "MSG"
   193 +
   194 +
   194 +void hk_ext_cmd_init(const char *command);
   195 +void hk_ext_cmd_init(const char *command);
   195 +void hk_ext_cmd(const char *bjid, const char *type, const char *info, const char *data);
   196 +void hk_ext_cmd(const char *bjid, const char *type, const char *info, const char *data);
   196 +
   197 +
   197 +#endif
   198 +#endif
   198 diff -r 75d573fb8845 mcabber/mcabber/hooks.c
   199 diff -r fd72b1e3bf26 mcabber/mcabber/hooks.c
   199 --- a/mcabber/mcabber/hooks.c	Fri Jan 18 11:23:51 2013 +0200
   200 --- a/mcabber/mcabber/hooks.c	Wed Nov 12 22:23:32 2014 +0200
   200 +++ b/mcabber/mcabber/hooks.c	Sun Jan 27 00:38:57 2013 +0200
   201 +++ b/mcabber/mcabber/hooks.c	Wed Nov 12 22:24:18 2014 +0200
   201 @@ -24,6 +24,7 @@
   202 @@ -24,6 +24,7 @@
   202  #include <string.h>
   203  #include <string.h>
   203  #include <sys/types.h>
   204  #include <sys/types.h>
   204  #include <unistd.h>
   205  #include <unistd.h>
   205 +#include <ctype.h>
   206 +#include <ctype.h>
   229    unsigned mucnicklen = 0;
   230    unsigned mucnicklen = 0;
   230 -  const char *ename = NULL;
   231 -  const char *ename = NULL;
   231    gboolean attention = FALSE, mucprivmsg = FALSE;
   232    gboolean attention = FALSE, mucprivmsg = FALSE;
   232    gboolean error_msg_subtype = (type == LM_MESSAGE_SUB_TYPE_ERROR);
   233    gboolean error_msg_subtype = (type == LM_MESSAGE_SUB_TYPE_ERROR);
   233  #ifdef MODULES_ENABLE
   234  #ifdef MODULES_ENABLE
   234 @@ -373,19 +372,6 @@
   235 @@ -374,19 +373,6 @@
   235        (!is_room || (is_groupchat && log_muc_conf && !timestamp)))
   236        (!is_room || (is_groupchat && log_muc_conf && !timestamp)))
   236      hlog_write_message(bjid, timestamp, 0, wmsg);
   237      hlog_write_message(bjid, timestamp, 0, wmsg);
   237  
   238  
   238 -  if (settings_opt_get_int("events_ignore_active_window") &&
   239 -  if (settings_opt_get_int("events_ignore_active_window") &&
   239 -      current_buddy && scr_get_chatmode()) {
   240 -      current_buddy && scr_get_chatmode()) {
   249 -    ename = roster_getname(bjid);
   250 -    ename = roster_getname(bjid);
   250 -
   251 -
   251    // Display the sender in the log window
   252    // Display the sender in the log window
   252    if ((!is_groupchat) && !(message_flags & HBB_PREFIX_ERR) &&
   253    if ((!is_groupchat) && !(message_flags & HBB_PREFIX_ERR) &&
   253        settings_opt_get_int("log_display_sender")) {
   254        settings_opt_get_int("log_display_sender")) {
   254 @@ -411,12 +397,24 @@
   255 @@ -413,12 +399,24 @@
   255    }
   256    }
   256  #endif
   257  #endif
   257  
   258  
   258 +  if (settings_opt_get_int("events_ignore_active_window") &&
   259 +  if (settings_opt_get_int("events_ignore_active_window") &&
   259 +      current_buddy && scr_get_chatmode()) {
   260 +      current_buddy && scr_get_chatmode()) {
   275 +               is_groupchat ? EXT_CMD_INFO_GROUPCHAT : EXT_CMD_INFO_RECEIVED,
   276 +               is_groupchat ? EXT_CMD_INFO_GROUPCHAT : EXT_CMD_INFO_RECEIVED,
   276 +               wmsg);
   277 +               wmsg);
   277  
   278  
   278    // Beep, if enabled:
   279    // Beep, if enabled:
   279    // - if it's a private message
   280    // - if it's a private message
   280 @@ -494,7 +492,7 @@
   281 @@ -496,7 +494,7 @@
   281  #endif
   282  #endif
   282  
   283  
   283    // External command
   284    // External command
   284 -  hk_ext_cmd(bjid, 'M', 'S', NULL);
   285 -  hk_ext_cmd(bjid, 'M', 'S', NULL);
   285 +  hk_ext_cmd(bjid, EXT_CMD_TYPE_MESSAGE, EXT_CMD_INFO_SENT, NULL);
   286 +  hk_ext_cmd(bjid, EXT_CMD_TYPE_MESSAGE, EXT_CMD_INFO_SENT, NULL);
   286  
   287  
   287    g_free(bmsg);
   288    g_free(bmsg);
   288    g_free(mmsg);
   289    g_free(mmsg);
   289 @@ -509,10 +507,7 @@
   290 @@ -511,10 +509,7 @@
   290    char *bn;
   291    char *bn;
   291    char *logsmsg;
   292    char *logsmsg;
   292    const char *rn = (resname ? resname : "");
   293    const char *rn = (resname ? resname : "");
   293 -  const char *ename = NULL;
   294 -  const char *ename = NULL;
   294 -
   295 -
   296 -    ename = roster_getname(bjid);
   297 -    ename = roster_getname(bjid);
   297 +  char newstatus[2] = { '?', '\0' };
   298 +  char newstatus[2] = { '?', '\0' };
   298  
   299  
   299    oldstat = roster_getstatus(bjid, resname);
   300    oldstat = roster_getstatus(bjid, resname);
   300  
   301  
   301 @@ -564,27 +559,28 @@
   302 @@ -566,27 +561,28 @@
   302    scr_draw_roster();
   303    scr_draw_roster();
   303    hlog_write_status(bjid, timestamp, status, status_msg);
   304    hlog_write_status(bjid, timestamp, status, status_msg);
   304  
   305  
   305 +  newstatus[0] = imstatus2char[status];
   306 +  newstatus[0] = imstatus2char[status];
   306 +
   307 +
   462 -  }
   463 -  }
   463 -  g_free(datafname);
   464 -  g_free(datafname);
   464 -}
   465 -}
   465 -
   466 -
   466  /* vim: set expandtab cindent cinoptions=>2\:2(0 sw=2 ts=2:  For Vim users... */
   467  /* vim: set expandtab cindent cinoptions=>2\:2(0 sw=2 ts=2:  For Vim users... */
   467 diff -r 75d573fb8845 mcabber/mcabber/hooks.h
   468 diff -r fd72b1e3bf26 mcabber/mcabber/hooks.h
   468 --- a/mcabber/mcabber/hooks.h	Fri Jan 18 11:23:51 2013 +0200
   469 --- a/mcabber/mcabber/hooks.h	Wed Nov 12 22:23:32 2014 +0200
   469 +++ b/mcabber/mcabber/hooks.h	Sun Jan 27 00:38:57 2013 +0200
   470 +++ b/mcabber/mcabber/hooks.h	Wed Nov 12 22:24:18 2014 +0200
   470 @@ -66,9 +66,6 @@
   471 @@ -67,9 +67,6 @@
   471  guint hk_subscription(LmMessageSubType mstype, const gchar *bjid,
   472  guint hk_subscription(LmMessageSubType mstype, const gchar *bjid,
   472                        const gchar *msg);
   473                        const gchar *msg);
   473  
   474  
   474 -void hk_ext_cmd_init(const char *command);
   475 -void hk_ext_cmd_init(const char *command);
   475 -void hk_ext_cmd(const char *bjid, guchar type, guchar info, const char *data);
   476 -void hk_ext_cmd(const char *bjid, guchar type, guchar info, const char *data);
   476 -
   477 -
   477  #endif /* __MCABBER_HOOKS_H__ */
   478  #endif /* __MCABBER_HOOKS_H__ */
   478  
   479  
   479  /* vim: set expandtab cindent cinoptions=>2\:2(0 sw=2 ts=2:  For Vim users... */
   480  /* vim: set expandtab cindent cinoptions=>2\:2(0 sw=2 ts=2:  For Vim users... */
   480 diff -r 75d573fb8845 mcabber/mcabber/main.c
   481 diff -r fd72b1e3bf26 mcabber/mcabber/main.c
   481 --- a/mcabber/mcabber/main.c	Fri Jan 18 11:23:51 2013 +0200
   482 --- a/mcabber/mcabber/main.c	Wed Nov 12 22:23:32 2014 +0200
   482 +++ b/mcabber/mcabber/main.c	Sun Jan 27 00:38:57 2013 +0200
   483 +++ b/mcabber/mcabber/main.c	Wed Nov 12 22:24:18 2014 +0200
   483 @@ -19,14 +19,18 @@
   484 @@ -19,14 +19,18 @@
   484   * USA
   485   * USA
   485   */
   486   */
   486  
   487  
   487 -#include <stdio.h>
   488 -#include <stdio.h>
   505 +#include <poll.h>      // POLLIN, POLLERR, POLLPRI
   506 +#include <poll.h>      // POLLIN, POLLERR, POLLPRI
   506 +
   507 +
   507  #include <glib.h>
   508  #include <glib.h>
   508  #include <config.h>
   509  #include <config.h>
   509  #include <poll.h>
   510  #include <poll.h>
   510 @@ -44,6 +48,7 @@
   511 @@ -45,6 +49,7 @@
   511  #include "xmpp.h"
       
   512  #include "help.h"
   512  #include "help.h"
   513  #include "events.h"
   513  #include "events.h"
       
   514  #include "compl.h"
   514 +#include "extcmd.h"
   515 +#include "extcmd.h"
   515  
   516  
   516  #ifndef MODULES_ENABLE
   517  #ifndef MODULES_ENABLE
   517  # include "fifo.h"
   518  # include "fifo.h"
   518 @@ -348,10 +353,10 @@
   519 @@ -351,10 +356,10 @@
   519        case 'h':
   520        case 'h':
   520        case '?':
   521        case '?':
   521          printf("Usage: %s [-h|-V|-f mcabberrc_file]\n\n", argv[0]);
   522          printf("Usage: %s [-h|-V|-f mcabberrc_file]\n\n", argv[0]);
   522 -        return (c == 'h' ? 0 : -1);
   523 -        return (c == 'h' ? 0 : -1);
   523 +        return (c == 'h' ? EXIT_SUCCESS : EXIT_FAILURE);
   524 +        return (c == 'h' ? EXIT_SUCCESS : EXIT_FAILURE);
   526 -        return 0;
   527 -        return 0;
   527 +        return EXIT_SUCCESS;
   528 +        return EXIT_SUCCESS;
   528        case 'f':
   529        case 'f':
   529          configFile = g_strdup(optarg);
   530          configFile = g_strdup(optarg);
   530          break;
   531          break;
   531 @@ -360,7 +365,7 @@
   532 @@ -363,7 +368,7 @@
   532  
   533  
   533    if (optind < argc) {
   534    if (optind < argc) {
   534      fprintf(stderr, "Usage: %s [-h|-V|-f mcabberrc_file]\n\n", argv[0]);
   535      fprintf(stderr, "Usage: %s [-h|-V|-f mcabberrc_file]\n\n", argv[0]);
   535 -    return -1;
   536 -    return -1;
   536 +    return EXIT_FAILURE;
   537 +    return EXIT_FAILURE;
   537    }
   538    }
   538  
   539  
   539    /* Initialize command system, roster and default key bindings */
   540    /* Initialize command system, roster and default key bindings */
   540 @@ -529,7 +534,7 @@
   541 @@ -518,7 +523,7 @@
   541  
   542  
   542    printf("\n\nThanks for using mcabber!\n");
   543    printf("\n\nThanks for using mcabber!\n");
   543  
   544  
   544 -  return 0;
   545 -  return 0;
   545 +  return EXIT_SUCCESS;
   546 +  return EXIT_SUCCESS;