(purple) Automatically reconnect disconnected account
This commit is contained in:
parent
e698d412a8
commit
20c6b9fc30
|
@ -948,6 +948,22 @@ static PurpleEventLoopUiOps _ui_op_eventloops =
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static PurpleConnectionUiOps _ui_op_connection =
|
||||||
|
{
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
ui_op_report_disconnect_reason,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
static PurpleRequestUiOps _ui_op_request =
|
static PurpleRequestUiOps _ui_op_request =
|
||||||
{
|
{
|
||||||
ui_op_request_input,
|
ui_op_request_input,
|
||||||
|
@ -986,6 +1002,7 @@ void
|
||||||
init_ui_ops()
|
init_ui_ops()
|
||||||
{
|
{
|
||||||
purple_eventloop_set_ui_ops(&_ui_op_eventloops);
|
purple_eventloop_set_ui_ops(&_ui_op_eventloops);
|
||||||
|
purple_connections_set_ui_ops(&_ui_op_connection);
|
||||||
purple_request_set_ui_ops(&_ui_op_request);
|
purple_request_set_ui_ops(&_ui_op_request);
|
||||||
purple_notify_set_ui_ops(&_ui_op_notify);
|
purple_notify_set_ui_ops(&_ui_op_notify);
|
||||||
}
|
}
|
||||||
|
@ -1001,10 +1018,6 @@ init_signals()
|
||||||
|
|
||||||
purple_signal_connect(purple_accounts_get_handle(), "account-signed-on",
|
purple_signal_connect(purple_accounts_get_handle(), "account-signed-on",
|
||||||
&handle, PURPLE_CALLBACK(signal_account_signed_on), NULL);
|
&handle, PURPLE_CALLBACK(signal_account_signed_on), NULL);
|
||||||
purple_signal_connect(purple_accounts_get_handle(), "account-signed-off",
|
|
||||||
&handle, PURPLE_CALLBACK(signal_account_signed_off), NULL);
|
|
||||||
purple_signal_connect(purple_accounts_get_handle(), "account-disabled",
|
|
||||||
&handle, PURPLE_CALLBACK(signal_account_disabled), NULL);
|
|
||||||
purple_signal_connect(purple_accounts_get_handle(), "account-error-changed",
|
purple_signal_connect(purple_accounts_get_handle(), "account-error-changed",
|
||||||
&handle, PURPLE_CALLBACK(signal_account_error_changed), NULL);
|
&handle, PURPLE_CALLBACK(signal_account_error_changed), NULL);
|
||||||
purple_signal_connect(purple_accounts_get_handle(), "account-status-changed",
|
purple_signal_connect(purple_accounts_get_handle(), "account-status-changed",
|
||||||
|
@ -1066,21 +1079,6 @@ signal_account_signed_on(PurpleAccount* account)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
signal_account_signed_off(PurpleAccount* account)
|
|
||||||
{
|
|
||||||
signal_account_disabled(account);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
signal_account_disabled(PurpleAccount* account)
|
|
||||||
{
|
|
||||||
BMessage disabled(PURPLE_SHUTDOWN_ADDON);
|
|
||||||
((PurpleApp*)be_app)->SendMessage(account, disabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
signal_account_error_changed(PurpleAccount* account,
|
signal_account_error_changed(PurpleAccount* account,
|
||||||
const PurpleConnectionErrorInfo* old_error,
|
const PurpleConnectionErrorInfo* old_error,
|
||||||
|
@ -1325,6 +1323,26 @@ ui_op_input_add(gint fd, PurpleInputCondition condition,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
ui_op_report_disconnect_reason(PurpleConnection* conn,
|
||||||
|
PurpleConnectionError reason, const char* text)
|
||||||
|
{
|
||||||
|
PurpleAccount* account = purple_connection_get_account(conn);
|
||||||
|
PurpleStatus* status = purple_account_get_active_status(account);
|
||||||
|
|
||||||
|
if (purple_connection_error_is_fatal(reason) == false)
|
||||||
|
if (purple_status_is_online(status))
|
||||||
|
purple_account_connect(account);
|
||||||
|
else
|
||||||
|
((PurpleApp*)be_app)->SendMessage(account,
|
||||||
|
BMessage(PURPLE_SHUTDOWN_ADDON));
|
||||||
|
else {
|
||||||
|
BMessage disabled(PURPLE_SHUTDOWN_ADDON);
|
||||||
|
((PurpleApp*)be_app)->SendMessage(account, disabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void*
|
static void*
|
||||||
ui_op_request_input(const char* title, const char* primary,
|
ui_op_request_input(const char* title, const char* primary,
|
||||||
const char* secondary, const char* default_value, gboolean multiline,
|
const char* secondary, const char* default_value, gboolean multiline,
|
||||||
|
|
|
@ -122,8 +122,6 @@ private:
|
||||||
|
|
||||||
// Account signals
|
// Account signals
|
||||||
static void signal_account_signed_on(PurpleAccount* account);
|
static void signal_account_signed_on(PurpleAccount* account);
|
||||||
static void signal_account_signed_off(PurpleAccount* account);
|
|
||||||
static void signal_account_disabled(PurpleAccount* account);
|
|
||||||
static void signal_account_error_changed(PurpleAccount* account,
|
static void signal_account_error_changed(PurpleAccount* account,
|
||||||
const PurpleConnectionErrorInfo* old_error,
|
const PurpleConnectionErrorInfo* old_error,
|
||||||
const PurpleConnectionErrorInfo* current_error);
|
const PurpleConnectionErrorInfo* current_error);
|
||||||
|
@ -163,6 +161,10 @@ private:
|
||||||
PurpleInputCondition condition,
|
PurpleInputCondition condition,
|
||||||
PurpleInputFunction function, gpointer data);
|
PurpleInputFunction function, gpointer data);
|
||||||
|
|
||||||
|
// Connection ui ops
|
||||||
|
static void ui_op_report_disconnect_reason(PurpleConnection* conn,
|
||||||
|
PurpleConnectionError reason, const char* text);
|
||||||
|
|
||||||
// Request ui ops
|
// Request ui ops
|
||||||
static void* ui_op_request_input(const char* title,
|
static void* ui_op_request_input(const char* title,
|
||||||
const char* primary, const char* secondary,
|
const char* primary, const char* secondary,
|
||||||
|
|
Ŝarĝante…
Reference in New Issue