mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Added desktop notifications for chat room invites
Use "/notify invite on|off"
This commit is contained in:
parent
9373f41fa4
commit
f099bf9a7c
@ -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);
|
||||
|
@ -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:
|
||||
|
@ -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,
|
||||
|
@ -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");
|
||||
|
@ -65,6 +65,19 @@ notify_typing(const char * const from)
|
||||
_notify(message, 10000, "Incoming message");
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user