about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/command/command.c18
-rw-r--r--src/config/preferences.c3
-rw-r--r--src/config/preferences.h1
-rw-r--r--src/ui/console.c10
-rw-r--r--src/ui/notifier.c13
-rw-r--r--src/ui/notifier.h1
6 files changed, 45 insertions, 1 deletions
diff --git a/src/command/command.c b/src/command/command.c
index adb831f4..6cbfdac9 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -499,11 +499,14 @@ static struct cmd_t setting_commands[] =
           "        : use 0 to disable.",
           "typing  : Notifications when contacts are typing.",
           "        : on|off",
+          "invite  : Notifications for chat room invites.",
+          "        : on|off",
           "",
           "Example : /notify message on (enable message notifications)",
           "Example : /notify remind 10  (remind every 10 seconds)",
           "Example : /notify remind 0   (switch off reminders)",
           "Example : /notify typing on  (enable typing notifications)",
+          "Example : /notify invite on  (enable chat room invite notifications)",
           NULL } } },
 
     { "/flash",
@@ -783,6 +786,7 @@ cmd_init(void)
     autocomplete_add(notify_ac, strdup("message"));
     autocomplete_add(notify_ac, strdup("typing"));
     autocomplete_add(notify_ac, strdup("remind"));
+    autocomplete_add(notify_ac, strdup("invite"));
     autocomplete_add(notify_ac, strdup("status"));
 
     sub_ac = autocomplete_new();
@@ -2487,7 +2491,7 @@ _cmd_set_notify(gchar **args, struct cmd_help_t help)
 
     // bad kind
     if ((strcmp(kind, "message") != 0) && (strcmp(kind, "typing") != 0) &&
-            (strcmp(kind, "remind") != 0)) {
+            (strcmp(kind, "remind") != 0) && (strcmp(kind, "invite") != 0)) {
         cons_show("Usage: %s", help.usage);
 
     // set message setting
@@ -2514,6 +2518,18 @@ _cmd_set_notify(gchar **args, struct cmd_help_t help)
             cons_show("Usage: /notify typing on|off");
         }
 
+    // set invite setting
+    } else if (strcmp(kind, "invite") == 0) {
+        if (strcmp(value, "on") == 0) {
+            cons_show("Chat room invite notifications enabled.");
+            prefs_set_boolean(PREF_NOTIFY_INVITE, TRUE);
+        } else if (strcmp(value, "off") == 0) {
+            cons_show("Chat room invite notifications disabled.");
+            prefs_set_boolean(PREF_NOTIFY_INVITE, FALSE);
+        } else {
+            cons_show("Usage: /notify invite on|off");
+        }
+
     // set remind setting
     } else if (strcmp(kind, "remind") == 0) {
         gint period = atoi(value);
diff --git a/src/config/preferences.c b/src/config/preferences.c
index 1abab5f6..d6d37234 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -299,6 +299,7 @@ _get_group(preference_t pref)
             return "chatstates";
         case PREF_NOTIFY_TYPING:
         case PREF_NOTIFY_MESSAGE:
+        case PREF_NOTIFY_INVITE:
             return "notifications";
         case PREF_CHLOG:
             return "logging";
@@ -344,6 +345,8 @@ _get_key(preference_t pref)
             return "typing";
         case PREF_NOTIFY_MESSAGE:
             return "message";
+        case PREF_NOTIFY_INVITE:
+            return "invite";
         case PREF_CHLOG:
             return "chlog";
         case PREF_AUTOAWAY_CHECK:
diff --git a/src/config/preferences.h b/src/config/preferences.h
index 70254e25..bdfe7a95 100644
--- a/src/config/preferences.h
+++ b/src/config/preferences.h
@@ -50,6 +50,7 @@ typedef enum {
     PREF_OUTTYPE,
     PREF_NOTIFY_TYPING,
     PREF_NOTIFY_MESSAGE,
+    PREF_NOTIFY_INVITE,
     PREF_CHLOG,
     PREF_AUTOAWAY_CHECK,
     PREF_AUTOAWAY_MODE,
diff --git a/src/ui/console.c b/src/ui/console.c
index e2d561cd..36358635 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -34,6 +34,7 @@
 #include "config/preferences.h"
 #include "contact_list.h"
 #include "config/theme.h"
+#include "ui/notifier.h"
 #include "ui/window.h"
 #include "ui/ui.h"
 
@@ -675,6 +676,10 @@ cons_show_room_invite(const char * const invitor, const char * const room,
 
     cons_show("Type \"/join %s\" to accept the invitation", display_room);
 
+    if (prefs_get_boolean(PREF_NOTIFY_INVITE)) {
+        notify_invite(invitor, room);
+    }
+
     jid_destroy(room_jid);
     g_string_free(default_service, TRUE);
 
@@ -897,6 +902,11 @@ cons_show_desktop_prefs(void)
     else
         cons_show("Composing (/notify typing)       : OFF");
 
+    if (prefs_get_boolean(PREF_NOTIFY_INVITE))
+        cons_show("Room invites (/notify invite)    : ON");
+    else
+        cons_show("Room invites (/notify invite)    : OFF");
+
     gint remind_period = prefs_get_notify_remind();
     if (remind_period == 0) {
         cons_show("Reminder period (/notify remind) : OFF");
diff --git a/src/ui/notifier.c b/src/ui/notifier.c
index 3f2b9688..5bf4defb 100644
--- a/src/ui/notifier.c
+++ b/src/ui/notifier.c
@@ -66,6 +66,19 @@ notify_typing(const char * const from)
 }
 
 void
+notify_invite(const char * const from, const char * const room)
+{
+    GString *message = g_string_new("Room invite\nfrom: ");
+    g_string_append(message, from);
+    g_string_append(message, "\nto: ");
+    g_string_append(message, room);
+
+    _notify(message->str, 10000, "Incoming message");
+
+    g_string_free(message, FALSE);
+}
+
+void
 notify_message(const char * const short_from)
 {
     char message[strlen(short_from) + 1 + 10];
diff --git a/src/ui/notifier.h b/src/ui/notifier.h
index a12dfa54..60b2e337 100644
--- a/src/ui/notifier.h
+++ b/src/ui/notifier.h
@@ -26,3 +26,4 @@ void notifier_uninit(void);
 void notify_typing(const char * const from);
 void notify_message(const char * const short_from);
 void notify_remind(void);
+void notify_invite(const char * const from, const char * const room);