separate-extcmd.diff
changeset 92 66f7e2aa040c
parent 87 78238d26911a
equal deleted inserted replaced
91:51d326d5cb92 92:66f7e2aa040c
       
     1 # HG changeset patch
       
     2 # Parent  4eeccf092a681b87a1a9d53f7de321f7653e1489
     1 Move extcmd code from hooks
     3 Move extcmd code from hooks
     2 
     4 
     3 diff -r fd72b1e3bf26 mcabber/mcabber/Makefile.am
     5 diff -r 4eeccf092a68 mcabber/mcabber/Makefile.am
     4 --- a/mcabber/mcabber/Makefile.am	Wed Nov 12 22:23:32 2014 +0200
     6 --- a/mcabber/mcabber/Makefile.am	Fri Dec 09 01:38:25 2016 +0200
     5 +++ b/mcabber/mcabber/Makefile.am	Wed Nov 12 22:24:18 2014 +0200
     7 +++ b/mcabber/mcabber/Makefile.am	Fri Dec 09 01:48:53 2016 +0200
     6 @@ -7,7 +7,8 @@
     8 @@ -7,7 +7,8 @@
     7  		  xmpp.c xmpp.h xmpp_helper.c xmpp_helper.h xmpp_defines.h \
     9  		  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 \
    10  		  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 \
    11  		  xmpp_muc.c xmpp_muc.h xmpp_s10n.c xmpp_s10n.h \
    10 -		  caps.c caps.h help.c help.h carbons.c carbons.h
    12 -		  caps.c caps.h help.c help.h carbons.c carbons.h
    19  			 caps.h fifo.h help.h modules.h api.h \
    21  			 caps.h fifo.h help.h modules.h api.h \
    20 +			 extcmd.h \
    22 +			 extcmd.h \
    21  			 $(top_builddir)/include/config.h
    23  			 $(top_builddir)/include/config.h
    22  
    24  
    23  if OTR
    25  if OTR
    24 diff -r fd72b1e3bf26 mcabber/mcabber/extcmd.c
    26 diff -r 4eeccf092a68 mcabber/mcabber/extcmd.c
    25 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26 +++ b/mcabber/mcabber/extcmd.c	Wed Nov 12 22:24:18 2014 +0200
    28 +++ b/mcabber/mcabber/extcmd.c	Fri Dec 09 01:48:53 2016 +0200
    27 @@ -0,0 +1,152 @@
    29 @@ -0,0 +1,152 @@
    28 +/*
    30 +/*
    29 + * extcmd.c      -- External event handler command
    31 + * extcmd.c      -- External event handler command
    30 + *
    32 + *
    31 + * Copyright (C) 2005-2010 Mikael Berthe <mikael@lilotux.net>
    33 + * Copyright (C) 2005-2010 Mikael Berthe <mikael@lilotux.net>
   175 +  }
   177 +  }
   176 +  g_free(datafname);
   178 +  g_free(datafname);
   177 +}
   179 +}
   178 +
   180 +
   179 +/* vim: set expandtab cindent cinoptions=>2\:2(0 ts=2 sw=2:  For Vim users... */
   181 +/* vim: set expandtab cindent cinoptions=>2\:2(0 ts=2 sw=2:  For Vim users... */
   180 diff -r fd72b1e3bf26 mcabber/mcabber/extcmd.h
   182 diff -r 4eeccf092a68 mcabber/mcabber/extcmd.h
   181 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   183 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   182 +++ b/mcabber/mcabber/extcmd.h	Wed Nov 12 22:24:18 2014 +0200
   184 +++ b/mcabber/mcabber/extcmd.h	Fri Dec 09 01:48:53 2016 +0200
   183 @@ -0,0 +1,15 @@
   185 @@ -0,0 +1,15 @@
   184 +#ifndef __MCABBER_EXTCMD_H__
   186 +#ifndef __MCABBER_EXTCMD_H__
   185 +#define __MCABBER_EXTCMD_H__ 1
   187 +#define __MCABBER_EXTCMD_H__ 1
   186 +
   188 +
   187 +#define EXT_CMD_TYPE_MESSAGE   "MSG"
   189 +#define EXT_CMD_TYPE_MESSAGE   "MSG"
   194 +
   196 +
   195 +void hk_ext_cmd_init(const char *command);
   197 +void hk_ext_cmd_init(const char *command);
   196 +void hk_ext_cmd(const char *bjid, const char *type, const char *info, const char *data);
   198 +void hk_ext_cmd(const char *bjid, const char *type, const char *info, const char *data);
   197 +
   199 +
   198 +#endif
   200 +#endif
   199 diff -r fd72b1e3bf26 mcabber/mcabber/hooks.c
   201 diff -r 4eeccf092a68 mcabber/mcabber/hooks.c
   200 --- a/mcabber/mcabber/hooks.c	Wed Nov 12 22:23:32 2014 +0200
   202 --- a/mcabber/mcabber/hooks.c	Fri Dec 09 01:38:25 2016 +0200
   201 +++ b/mcabber/mcabber/hooks.c	Wed Nov 12 22:24:18 2014 +0200
   203 +++ b/mcabber/mcabber/hooks.c	Fri Dec 09 01:48:53 2016 +0200
   202 @@ -24,6 +24,7 @@
   204 @@ -22,6 +22,7 @@
   203  #include <string.h>
   205  #include <string.h>
   204  #include <sys/types.h>
   206  #include <sys/types.h>
   205  #include <unistd.h>
   207  #include <unistd.h>
   206 +#include <ctype.h>
   208 +#include <ctype.h>
   207  
   209  
   208  #include "hooks.h"
   210  #include "hooks.h"
   209  #include "screen.h"
   211  #include "screen.h"
   210 @@ -35,6 +36,7 @@
   212 @@ -33,6 +34,7 @@
   211  #include "utf8.h"
   213  #include "utf8.h"
   212  #include "commands.h"
   214  #include "commands.h"
   213  #include "main.h"
   215  #include "main.h"
   214 +#include "extcmd.h"
   216 +#include "extcmd.h"
   215  
   217  
   230    unsigned mucnicklen = 0;
   232    unsigned mucnicklen = 0;
   231 -  const char *ename = NULL;
   233 -  const char *ename = NULL;
   232    gboolean attention = FALSE, mucprivmsg = FALSE;
   234    gboolean attention = FALSE, mucprivmsg = FALSE;
   233    gboolean error_msg_subtype = (type == LM_MESSAGE_SUB_TYPE_ERROR);
   235    gboolean error_msg_subtype = (type == LM_MESSAGE_SUB_TYPE_ERROR);
   234  #ifdef MODULES_ENABLE
   236  #ifdef MODULES_ENABLE
   235 @@ -374,19 +373,6 @@
   237 @@ -377,19 +376,6 @@
   236        (!is_room || (is_groupchat && log_muc_conf && !timestamp)))
   238        (!is_room || (is_groupchat && log_muc_conf && !timestamp)))
   237      hlog_write_message(bjid, timestamp, 0, wmsg);
   239      hlog_write_message(bjid, timestamp, 0, wmsg);
   238  
   240  
   239 -  if (settings_opt_get_int("events_ignore_active_window") &&
   241 -  if (settings_opt_get_int("events_ignore_active_window") &&
   240 -      current_buddy && scr_get_chatmode()) {
   242 -      current_buddy && scr_get_chatmode()) {
   250 -    ename = roster_getname(bjid);
   252 -    ename = roster_getname(bjid);
   251 -
   253 -
   252    // Display the sender in the log window
   254    // Display the sender in the log window
   253    if ((!is_groupchat) && !(message_flags & HBB_PREFIX_ERR) &&
   255    if ((!is_groupchat) && !(message_flags & HBB_PREFIX_ERR) &&
   254        settings_opt_get_int("log_display_sender")) {
   256        settings_opt_get_int("log_display_sender")) {
   255 @@ -413,12 +399,24 @@
   257 @@ -416,12 +402,24 @@
   256    }
   258    }
   257  #endif
   259  #endif
   258  
   260  
   259 +  if (settings_opt_get_int("events_ignore_active_window") &&
   261 +  if (settings_opt_get_int("events_ignore_active_window") &&
   260 +      current_buddy && scr_get_chatmode()) {
   262 +      current_buddy && scr_get_chatmode()) {
   276 +               is_groupchat ? EXT_CMD_INFO_GROUPCHAT : EXT_CMD_INFO_RECEIVED,
   278 +               is_groupchat ? EXT_CMD_INFO_GROUPCHAT : EXT_CMD_INFO_RECEIVED,
   277 +               wmsg);
   279 +               wmsg);
   278  
   280  
   279    // Beep, if enabled:
   281    // Beep, if enabled:
   280    // - if it's a private message
   282    // - if it's a private message
   281 @@ -496,7 +494,7 @@
   283 @@ -503,7 +501,7 @@
   282  #endif
   284  #endif
   283  
   285  
   284    // External command
   286    // External command
   285 -  hk_ext_cmd(bjid, 'M', 'S', NULL);
   287 -  hk_ext_cmd(bjid, 'M', 'S', NULL);
   286 +  hk_ext_cmd(bjid, EXT_CMD_TYPE_MESSAGE, EXT_CMD_INFO_SENT, NULL);
   288 +  hk_ext_cmd(bjid, EXT_CMD_TYPE_MESSAGE, EXT_CMD_INFO_SENT, NULL);
   287  
   289  
   288    g_free(bmsg);
   290    g_free(bmsg);
   289    g_free(mmsg);
   291    g_free(mmsg);
   290 @@ -511,10 +509,7 @@
   292 @@ -518,10 +516,7 @@
   291    char *bn;
   293    char *bn;
   292    char *logsmsg;
   294    char *logsmsg;
   293    const char *rn = (resname ? resname : "");
   295    const char *rn = (resname ? resname : "");
   294 -  const char *ename = NULL;
   296 -  const char *ename = NULL;
   295 -
   297 -
   297 -    ename = roster_getname(bjid);
   299 -    ename = roster_getname(bjid);
   298 +  char newstatus[2] = { '?', '\0' };
   300 +  char newstatus[2] = { '?', '\0' };
   299  
   301  
   300    oldstat = roster_getstatus(bjid, resname);
   302    oldstat = roster_getstatus(bjid, resname);
   301  
   303  
   302 @@ -566,27 +561,28 @@
   304 @@ -572,27 +567,28 @@
   303    scr_draw_roster();
   305    build_buddylist = TRUE;
   304    hlog_write_status(bjid, timestamp, status, status_msg);
   306    hlog_write_status(bjid, timestamp, status, status_msg);
   305  
   307  
   306 +  newstatus[0] = imstatus2char[status];
   308 +  newstatus[0] = imstatus2char[status];
   307 +
   309 +
   308  #ifdef MODULES_ENABLE
   310  #ifdef MODULES_ENABLE
   330 +  newstatus[0] = toupper(newstatus[0]);
   332 +  newstatus[0] = toupper(newstatus[0]);
   331 +  hk_ext_cmd(bjid, EXT_CMD_TYPE_STATUS, newstatus, status_msg);
   333 +  hk_ext_cmd(bjid, EXT_CMD_TYPE_STATUS, newstatus, status_msg);
   332  }
   334  }
   333  
   335  
   334  void hk_mystatuschange(time_t timestamp, enum imstatus old_status,
   336  void hk_mystatuschange(time_t timestamp, enum imstatus old_status,
   335 @@ -711,7 +707,7 @@
   337 @@ -717,7 +713,7 @@
   336    /* Call external command */
   338    /* Call external command */
   337    str_unread = g_strdup_printf("%u %u %u %u", unread_count, attention_count,
   339    str_unread = g_strdup_printf("%u %u %u %u", unread_count, attention_count,
   338                                 muc_unread, muc_attention);
   340                                 muc_unread, muc_attention);
   339 -  hk_ext_cmd("", 'U', (guchar)MIN(255, unread_count), str_unread);
   341 -  hk_ext_cmd("", 'U', (guchar)MIN(255, unread_count), str_unread);
   340 +  hk_ext_cmd("", EXT_CMD_TYPE_UNREAD, str_unread, NULL);
   342 +  hk_ext_cmd("", EXT_CMD_TYPE_UNREAD, str_unread, NULL);
   341    g_free(str_unread);
   343    g_free(str_unread);
   342  }
   344  }
   343  
   345  
   344 @@ -751,123 +747,4 @@
   346 @@ -757,123 +753,4 @@
   345    return 0;
   347    return 0;
   346  }
   348  }
   347  
   349  
   348 -
   350 -
   349 -/* External commands */
   351 -/* External commands */
   463 -  }
   465 -  }
   464 -  g_free(datafname);
   466 -  g_free(datafname);
   465 -}
   467 -}
   466 -
   468 -
   467  /* vim: set expandtab cindent cinoptions=>2\:2(0 sw=2 ts=2:  For Vim users... */
   469  /* vim: set expandtab cindent cinoptions=>2\:2(0 sw=2 ts=2:  For Vim users... */
   468 diff -r fd72b1e3bf26 mcabber/mcabber/hooks.h
   470 diff -r 4eeccf092a68 mcabber/mcabber/hooks.h
   469 --- a/mcabber/mcabber/hooks.h	Wed Nov 12 22:23:32 2014 +0200
   471 --- a/mcabber/mcabber/hooks.h	Fri Dec 09 01:38:25 2016 +0200
   470 +++ b/mcabber/mcabber/hooks.h	Wed Nov 12 22:24:18 2014 +0200
   472 +++ b/mcabber/mcabber/hooks.h	Fri Dec 09 01:48:53 2016 +0200
   471 @@ -67,9 +67,6 @@
   473 @@ -67,9 +67,6 @@
   472  guint hk_subscription(LmMessageSubType mstype, const gchar *bjid,
   474  guint hk_subscription(LmMessageSubType mstype, const gchar *bjid,
   473                        const gchar *msg);
   475                        const gchar *msg);
   474  
   476  
   475 -void hk_ext_cmd_init(const char *command);
   477 -void hk_ext_cmd_init(const char *command);
   476 -void hk_ext_cmd(const char *bjid, guchar type, guchar info, const char *data);
   478 -void hk_ext_cmd(const char *bjid, guchar type, guchar info, const char *data);
   477 -
   479 -
   478  #endif /* __MCABBER_HOOKS_H__ */
   480  #endif /* __MCABBER_HOOKS_H__ */
   479  
   481  
   480  /* vim: set expandtab cindent cinoptions=>2\:2(0 sw=2 ts=2:  For Vim users... */
   482  /* vim: set expandtab cindent cinoptions=>2\:2(0 sw=2 ts=2:  For Vim users... */
   481 diff -r fd72b1e3bf26 mcabber/mcabber/main.c
   483 diff -r 4eeccf092a68 mcabber/mcabber/main.c
   482 --- a/mcabber/mcabber/main.c	Wed Nov 12 22:23:32 2014 +0200
   484 --- a/mcabber/mcabber/main.c	Fri Dec 09 01:38:25 2016 +0200
   483 +++ b/mcabber/mcabber/main.c	Wed Nov 12 22:24:18 2014 +0200
   485 +++ b/mcabber/mcabber/main.c	Fri Dec 09 01:48:53 2016 +0200
   484 @@ -19,14 +19,18 @@
   486 @@ -17,14 +17,18 @@
   485   * USA
   487   * along with this program; if not, see <http://www.gnu.org/licenses/>.
   486   */
   488   */
   487  
   489  
   488 -#include <stdio.h>
   490 -#include <stdio.h>
   489 -#include <stdlib.h>
   491 -#include <stdlib.h>
   490 -#include <unistd.h>
   492 -#include <unistd.h>
   514  #include "compl.h"
   516  #include "compl.h"
   515 +#include "extcmd.h"
   517 +#include "extcmd.h"
   516  
   518  
   517  #ifndef MODULES_ENABLE
   519  #ifndef MODULES_ENABLE
   518  # include "fifo.h"
   520  # include "fifo.h"
   519 @@ -351,10 +356,10 @@
   521 @@ -425,10 +430,10 @@
   520        case 'h':
   522        case 'h':
   521        case '?':
   523        case '?':
   522          printf("Usage: %s [-h|-V|-f mcabberrc_file]\n\n", argv[0]);
   524          printf("Usage: %s [-h|-V|-f mcabberrc_file]\n\n", argv[0]);
   523 -        return (c == 'h' ? 0 : -1);
   525 -        return (c == 'h' ? 0 : -1);
   524 +        return (c == 'h' ? EXIT_SUCCESS : EXIT_FAILURE);
   526 +        return (c == 'h' ? EXIT_SUCCESS : EXIT_FAILURE);
   527 -        return 0;
   529 -        return 0;
   528 +        return EXIT_SUCCESS;
   530 +        return EXIT_SUCCESS;
   529        case 'f':
   531        case 'f':
   530          configFile = g_strdup(optarg);
   532          configFile = g_strdup(optarg);
   531          break;
   533          break;
   532 @@ -363,7 +368,7 @@
   534 @@ -437,7 +442,7 @@
   533  
   535  
   534    if (optind < argc) {
   536    if (optind < argc) {
   535      fprintf(stderr, "Usage: %s [-h|-V|-f mcabberrc_file]\n\n", argv[0]);
   537      fprintf(stderr, "Usage: %s [-h|-V|-f mcabberrc_file]\n\n", argv[0]);
   536 -    return -1;
   538 -    return -1;
   537 +    return EXIT_FAILURE;
   539 +    return EXIT_FAILURE;
   538    }
   540    }
   539  
   541  
   540    /* Initialize command system, roster and default key bindings */
   542    /* Initialize command system, roster and default key bindings */
   541 @@ -518,7 +523,7 @@
   543 @@ -644,7 +649,7 @@
   542  
   544  
   543    printf("\n\nThanks for using mcabber!\n");
   545    printf("\n\nThanks for using mcabber!\n");
   544  
   546  
   545 -  return 0;
   547 -  return 0;
   546 +  return EXIT_SUCCESS;
   548 +  return EXIT_SUCCESS;