Commit 67d64540 authored by Andrea Schaefer's avatar Andrea Schaefer

Merge branch 'modem-connect' into 'master'

Enable SMS account notifications after initial connect

See merge request !113
parents 828e143a 1b36749b
Pipeline #32942 passed with stages
in 4 minutes and 26 seconds
......@@ -5,4 +5,5 @@ build
arm
arm-build
.zanata-cache/
.vscode
.#*
......@@ -23,6 +23,8 @@
static GHashTable *auto_reconns = NULL;
static gboolean sms_notifications = FALSE;
static gboolean chatty_connection_sign_on (gpointer data);
static void chatty_connection_account_spinner (PurpleAccount *account, gboolean spin);
......@@ -42,7 +44,6 @@ cb_sms_modem_added (int status)
info = g_new0 (ChattyAutoRecon, 1);
g_hash_table_insert (auto_reconns, account, info);
}
info->delay = g_random_int_range (INITIAL_RECON_DELAY_MIN,
......@@ -160,20 +161,31 @@ chatty_connection_connected (PurpleConnection *gc)
PurpleAccount *account;
char *message;
const char *user_name;
const char *protocol_id;
int sms_match;
account = purple_connection_get_account (gc);
user_name = purple_account_get_username (account),
protocol_id = purple_account_get_protocol_id (account);
sms_match = !g_strcmp0 (protocol_id, "prpl-mm-sms");
chatty_connection_account_spinner (account, FALSE);
if (g_hash_table_contains (auto_reconns, account)) {
message = g_strdup_printf ("Account %s reconnected", user_name);
chatty_notify_show_notification (NULL, message, CHATTY_NOTIFY_ACCOUNT_CONNECTED, NULL);
if (!sms_match || (sms_match && sms_notifications)) {
chatty_notify_show_notification (NULL, message, CHATTY_NOTIFY_ACCOUNT_CONNECTED, NULL);
}
g_free (message);
}
if (sms_match) {
sms_notifications = TRUE;
}
chatty_dialogs_update_connection_status ();
g_hash_table_remove (auto_reconns, account);
......@@ -290,9 +302,11 @@ chatty_connection_report_disconnect_reason (PurpleConnection *gc,
if (!g_strcmp0 (protocol_id, "prpl-mm-sms")) {
// the SMS account gets included in auto_reconns
// in the 'cb_sms_modem_added' callback
message = g_strdup_printf ("SMS disconnected: %s", text);
chatty_notify_show_notification (user_name, message, CHATTY_NOTIFY_ACCOUNT_GENERIC, NULL);
g_free (message);
if (sms_notifications) {
message = g_strdup_printf ("SMS disconnected: %s", text);
chatty_notify_show_notification (user_name, message, CHATTY_NOTIFY_ACCOUNT_GENERIC, NULL);
g_free (message);
}
return;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment