mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Logins remembered in ~/.profanity
This commit is contained in:
parent
73ba46da0d
commit
4e23031c74
4
jabber.c
4
jabber.c
@ -28,6 +28,7 @@
|
||||
#include "contact_list.h"
|
||||
#include "windows.h"
|
||||
#include "util.h"
|
||||
#include "preferences.h"
|
||||
|
||||
#define PING_INTERVAL 120000 // 2 minutes
|
||||
|
||||
@ -221,6 +222,9 @@ static void _jabber_conn_handler(xmpp_conn_t * const conn,
|
||||
xmpp_stanza_set_name(pres, "presence");
|
||||
xmpp_send(conn, pres);
|
||||
xmpp_stanza_release(pres);
|
||||
|
||||
prefs_add_login(jid);
|
||||
|
||||
jabber_conn.conn_status = JABBER_CONNECTED;
|
||||
}
|
||||
else {
|
||||
|
@ -21,6 +21,8 @@
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
static GString *prefs_loc;
|
||||
@ -59,6 +61,47 @@ void prefs_set_flash(gboolean value)
|
||||
_save_prefs();
|
||||
}
|
||||
|
||||
void prefs_add_login(const char *jid)
|
||||
{
|
||||
gsize njids;
|
||||
gchar **jids =
|
||||
g_key_file_get_string_list(prefs, "connections", "logins", &njids, NULL);
|
||||
|
||||
// no logins remembered yet
|
||||
if (jids == NULL) {
|
||||
njids = 1;
|
||||
jids = (gchar**) g_malloc(sizeof(gchar *) * 2);
|
||||
jids[0] = g_strdup(jid);
|
||||
jids[1] = NULL;
|
||||
g_key_file_set_string_list(prefs, "connections", "logins",
|
||||
(const gchar * const *)jids, njids);
|
||||
_save_prefs();
|
||||
g_strfreev(jids);
|
||||
|
||||
return;
|
||||
} else {
|
||||
gsize i;
|
||||
for (i = 0; i < njids; i++) {
|
||||
if (strcmp(jid, jids[i]) == 0) {
|
||||
g_strfreev(jids);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// jid not found, add to the list
|
||||
jids = (gchar **) g_realloc(jids, (sizeof(gchar *) * (njids+2)));
|
||||
jids[njids] = g_strdup(jid);
|
||||
njids++;
|
||||
jids[njids] = NULL;
|
||||
g_key_file_set_string_list(prefs, "connections", "logins",
|
||||
(const gchar * const *)jids, njids);
|
||||
_save_prefs();
|
||||
g_strfreev(jids);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void _save_prefs(void)
|
||||
{
|
||||
gsize g_data_size;
|
||||
|
@ -31,5 +31,6 @@ gboolean prefs_get_beep(void);
|
||||
void prefs_set_beep(gboolean value);
|
||||
gboolean prefs_get_flash(void);
|
||||
void prefs_set_flash(gboolean value);
|
||||
void prefs_add_login(const char *jid);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user