lastmsg/lastmsg.c
author Mikael Berthe <mikael@lilotux.net>
Mon, 22 Mar 2010 22:20:39 +0100
changeset 13 efe544108ca1
parent 12 3b30c879c8cc
child 15 d7cced6660a7
permissions -rw-r--r--
Update lastmsg module to API dev:11
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     1
/*
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     2
   Copyright 2010 Mikael Berthe
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     3
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     4
  Module "lastmsg"    -- adds a /lastmsg command
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     5
                         Displays last personal messages
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     6
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     7
  This modules stores messages received in a MUC room while
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     8
  you are away (or not available) if they contain your nickname.
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     9
  When you're back, you can display them in the status window with
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    10
  the /lastmsg command.
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    11
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    12
This module is free software: you can redistribute it and/or modify
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    13
it under the terms of the GNU General Public License as published by
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    14
the Free Software Foundation, either version 2 of the License, or
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    15
(at your option) any later version.
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    16
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    17
This program is distributed in the hope that it will be useful,
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    18
but WITHOUT ANY WARRANTY; without even the implied warranty of
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    19
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    20
GNU General Public License for more details.
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    21
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    22
You should have received a copy of the GNU General Public License
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    23
along with this program.  If not, see <http://www.gnu.org/licenses/>.
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    24
*/
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    25
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    26
#include <mcabber/modules.h>
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    27
#include <mcabber/commands.h>
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    28
#include <mcabber/hooks.h>
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    29
#include <mcabber/logprint.h>
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    30
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    31
static void lastmsg_init(void);
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    32
static void lastmsg_uninit(void);
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    33
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    34
/* Module description */
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    35
module_info_t info_lastmsg = {
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    36
        .branch         = MCABBER_BRANCH,
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    37
        .api            = MCABBER_API_VERSION,
11
573a48de8ee1 Update lastmsg module to API dev:6
Mikael Berthe <mikael@lilotux.net>
parents: 10
diff changeset
    38
        .version        = "0.02",
10
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    39
        .description    = "Add a command /lastmsg",
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    40
        .requires       = NULL,
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    41
        .init           = lastmsg_init,
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    42
        .uninit         = lastmsg_uninit,
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    43
        .next           = NULL,
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    44
};
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    45
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    46
static GSList *lastmsg_list;
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    47
12
3b30c879c8cc Update lastmsg module to API dev:8
Mikael Berthe <mikael@lilotux.net>
parents: 11
diff changeset
    48
static guint last_message_hid, last_status_hid;
3b30c879c8cc Update lastmsg module to API dev:8
Mikael Berthe <mikael@lilotux.net>
parents: 11
diff changeset
    49
10
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    50
struct lastm_T {
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    51
    gchar *mucname;
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    52
    gchar *nickname;
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    53
    gchar *msg;
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    54
};
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    55
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    56
static void do_lastmsg(char *args)
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    57
{
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    58
  if (!lastmsg_list) {
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    59
    scr_log_print(LPRINT_NORMAL, "You have no new message.");
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    60
    return;
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    61
  }
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    62
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    63
  for (GSList *li = lastmsg_list; li ; li = g_slist_next(li)) {
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    64
    struct lastm_T *lastm_item = li->data;
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    65
    scr_LogPrint(LPRINT_NORMAL, "In <#%s>, \"%s\" said:\n%s",
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    66
                 lastm_item->mucname, lastm_item->nickname,
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    67
                 lastm_item->msg);
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    68
    g_free(lastm_item->mucname);
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    69
    g_free(lastm_item->nickname);
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    70
    g_free(lastm_item->msg);
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    71
  }
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    72
  g_slist_free(lastmsg_list);
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    73
  lastmsg_list = NULL;
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    74
}
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    75
12
3b30c879c8cc Update lastmsg module to API dev:8
Mikael Berthe <mikael@lilotux.net>
parents: 11
diff changeset
    76
static guint last_message_hh(const gchar *hookname, hk_arg_t *args,
3b30c879c8cc Update lastmsg module to API dev:8
Mikael Berthe <mikael@lilotux.net>
parents: 11
diff changeset
    77
                             gpointer userdata)
10
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    78
{
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    79
  enum imstatus status;
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    80
  const gchar *bjid, *res, *msg;
11
573a48de8ee1 Update lastmsg module to API dev:6
Mikael Berthe <mikael@lilotux.net>
parents: 10
diff changeset
    81
  gboolean muc = FALSE, urgent = FALSE;
10
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    82
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    83
  status = xmpp_getstatus();
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    84
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    85
  if (status != notavail && status != away)
13
efe544108ca1 Update lastmsg module to API dev:11
Mikael Berthe <mikael@lilotux.net>
parents: 12
diff changeset
    86
    return HOOK_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
10
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    87
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    88
  bjid = res = NULL;
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    89
  msg = NULL;
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    90
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    91
  for ( ; args->name; args++) {
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    92
    if (!g_strcmp0(args->name, "jid"))
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    93
      bjid = args->value;
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    94
    else if (!g_strcmp0(args->name, "resource"))
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    95
      res = args->value;
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    96
    else if (!g_strcmp0(args->name, "message"))
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    97
      msg = args->value;
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    98
    else if (!g_strcmp0(args->name, "groupchat")) {
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    99
      if (!g_strcmp0(args->value, "true"))
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   100
        muc = TRUE;
11
573a48de8ee1 Update lastmsg module to API dev:6
Mikael Berthe <mikael@lilotux.net>
parents: 10
diff changeset
   101
    } else if (!g_strcmp0(args->name, "urgent")) {
573a48de8ee1 Update lastmsg module to API dev:6
Mikael Berthe <mikael@lilotux.net>
parents: 10
diff changeset
   102
      if (!g_strcmp0(args->value, "true"))
573a48de8ee1 Update lastmsg module to API dev:6
Mikael Berthe <mikael@lilotux.net>
parents: 10
diff changeset
   103
        urgent = TRUE;
10
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   104
    }
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   105
  }
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   106
11
573a48de8ee1 Update lastmsg module to API dev:6
Mikael Berthe <mikael@lilotux.net>
parents: 10
diff changeset
   107
  if (muc && urgent && bjid && res && msg) {
10
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   108
    struct lastm_T *lastm_item;
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   109
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   110
    lastm_item = g_new(struct lastm_T, 1);
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   111
    lastm_item->mucname  = g_strdup(bjid);
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   112
    lastm_item->nickname = g_strdup(res);
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   113
    lastm_item->msg      = g_strdup(msg);
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   114
    lastmsg_list = g_slist_append(lastmsg_list, lastm_item);
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   115
  }
13
efe544108ca1 Update lastmsg module to API dev:11
Mikael Berthe <mikael@lilotux.net>
parents: 12
diff changeset
   116
  return HOOK_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
10
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   117
}
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   118
12
3b30c879c8cc Update lastmsg module to API dev:8
Mikael Berthe <mikael@lilotux.net>
parents: 11
diff changeset
   119
static guint last_status_hh(const gchar *hookname, hk_arg_t *args,
3b30c879c8cc Update lastmsg module to API dev:8
Mikael Berthe <mikael@lilotux.net>
parents: 11
diff changeset
   120
                            gpointer userdata)
10
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   121
{
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   122
  gboolean not_away = FALSE;
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   123
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   124
  for ( ; args->name; args++) {
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   125
    if (!g_strcmp0(args->name, "new_status")) {
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   126
      if (args->value &&
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   127
          (args->value[0] != imstatus2char[away]) &&
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   128
          (args->value[0] != imstatus2char[notavail])) {
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   129
        not_away = TRUE;
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   130
        break;
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   131
      }
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   132
    }
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   133
  }
12
3b30c879c8cc Update lastmsg module to API dev:8
Mikael Berthe <mikael@lilotux.net>
parents: 11
diff changeset
   134
  if (!not_away || !lastmsg_list)
13
efe544108ca1 Update lastmsg module to API dev:11
Mikael Berthe <mikael@lilotux.net>
parents: 12
diff changeset
   135
    return HOOK_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
10
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   136
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   137
  scr_log_print(LPRINT_NORMAL, "Looks like you're back...");
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   138
  scr_log_print(LPRINT_NORMAL, "I've got news for you, use /lastmsg to "
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   139
                "read your messages!");
13
efe544108ca1 Update lastmsg module to API dev:11
Mikael Berthe <mikael@lilotux.net>
parents: 12
diff changeset
   140
  return HOOK_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
10
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   141
}
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   142
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   143
/* Initialization */
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   144
static void lastmsg_init(void)
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   145
{
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   146
  /* Add command */
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   147
  cmd_add("lastmsg", "Display last missed messages", 0, 0, do_lastmsg, NULL);
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   148
12
3b30c879c8cc Update lastmsg module to API dev:8
Mikael Berthe <mikael@lilotux.net>
parents: 11
diff changeset
   149
  last_message_hid = hk_add_handler(last_message_hh, HOOK_POST_MESSAGE_IN,
3b30c879c8cc Update lastmsg module to API dev:8
Mikael Berthe <mikael@lilotux.net>
parents: 11
diff changeset
   150
                                    G_PRIORITY_DEFAULT_IDLE, NULL);
3b30c879c8cc Update lastmsg module to API dev:8
Mikael Berthe <mikael@lilotux.net>
parents: 11
diff changeset
   151
  last_status_hid  = hk_add_handler(last_status_hh, HOOK_MY_STATUS_CHANGE,
3b30c879c8cc Update lastmsg module to API dev:8
Mikael Berthe <mikael@lilotux.net>
parents: 11
diff changeset
   152
                                    G_PRIORITY_DEFAULT_IDLE, NULL);
10
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   153
}
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   154
11
573a48de8ee1 Update lastmsg module to API dev:6
Mikael Berthe <mikael@lilotux.net>
parents: 10
diff changeset
   155
/* Uninitialization */
10
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   156
static void lastmsg_uninit(void)
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   157
{
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   158
  /* Unregister command */
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   159
  cmd_del("lastmsg");
12
3b30c879c8cc Update lastmsg module to API dev:8
Mikael Berthe <mikael@lilotux.net>
parents: 11
diff changeset
   160
  hk_del_handler(HOOK_POST_MESSAGE_IN, last_message_hid);
3b30c879c8cc Update lastmsg module to API dev:8
Mikael Berthe <mikael@lilotux.net>
parents: 11
diff changeset
   161
  hk_del_handler(HOOK_MY_STATUS_CHANGE, last_status_hid);
10
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   162
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   163
  for (GSList *li = lastmsg_list; li ; li = g_slist_next(li)) {
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   164
    struct lastm_T *lastm_item = li->data;
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   165
    g_free(lastm_item->mucname);
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   166
    g_free(lastm_item->nickname);
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   167
    g_free(lastm_item->msg);
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   168
  }
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   169
  g_slist_free(lastmsg_list);
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   170
  lastmsg_list = NULL;
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   171
}
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   172
14f4f6dcc75a Add lastmsg module
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   173
/* vim: set expandtab cindent cinoptions=>2\:2(0:  For Vim users... */