(purple) Adhere to user setting 'offline' status
This commit is contained in:
parent
a712d89c76
commit
71433599e4
|
@ -170,6 +170,21 @@ PurpleApp::ImMessage(BMessage* msg)
|
||||||
{
|
{
|
||||||
PurpleAccount* account = _AccountFromMessage(msg);
|
PurpleAccount* account = _AccountFromMessage(msg);
|
||||||
UserStatus status = (UserStatus)msg->FindInt32("status");
|
UserStatus status = (UserStatus)msg->FindInt32("status");
|
||||||
|
|
||||||
|
switch (status) {
|
||||||
|
case STATUS_ONLINE:
|
||||||
|
if (purple_account_is_disconnected(account)) {
|
||||||
|
purple_account_set_enabled(account, PURPLE_UI_ID, true);
|
||||||
|
purple_account_connect(account);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case STATUS_OFFLINE: {
|
||||||
|
SendMessage(account, BMessage(PURPLE_SHUTDOWN_ADDON));
|
||||||
|
purple_account_disconnect(account);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PurpleStatusPrimitive prim = cardie_status_to_purple(status);
|
PurpleStatusPrimitive prim = cardie_status_to_purple(status);
|
||||||
const char* primId = purple_primitive_get_id_from_type(prim);
|
const char* primId = purple_primitive_get_id_from_type(prim);
|
||||||
|
|
||||||
|
@ -981,7 +996,7 @@ static PurpleConnectionUiOps _ui_op_connection =
|
||||||
{
|
{
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
ui_op_disconnected,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -1135,6 +1150,11 @@ signal_account_signed_on(PurpleAccount* account)
|
||||||
send_own_info(account);
|
send_own_info(account);
|
||||||
load_account_buddies(account);
|
load_account_buddies(account);
|
||||||
|
|
||||||
|
BMessage status(IM_MESSAGE);
|
||||||
|
status.AddInt32("im_what", IM_OWN_STATUS_SET);
|
||||||
|
status.AddInt32("status", (int32)STATUS_ONLINE);
|
||||||
|
((PurpleApp*)be_app)->SendMessage(account, status);
|
||||||
|
|
||||||
((PurpleApp*)be_app)->fUserNicks.AddItem(username, display);
|
((PurpleApp*)be_app)->fUserNicks.AddItem(username, display);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1422,6 +1442,21 @@ ui_op_input_add(gint fd, PurpleInputCondition condition,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
ui_op_disconnected(PurpleConnection* conn)
|
||||||
|
{
|
||||||
|
PurpleAccount* account = purple_connection_get_account(conn);
|
||||||
|
const PurpleConnectionErrorInfo* err
|
||||||
|
= purple_account_get_current_error(account);
|
||||||
|
if (!err) {
|
||||||
|
BMessage status(IM_MESSAGE);
|
||||||
|
status.AddInt32("im_what", IM_OWN_STATUS_SET);
|
||||||
|
status.AddInt32("status", (int32)STATUS_OFFLINE);
|
||||||
|
((PurpleApp*)be_app)->SendMessage(account, status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ui_op_report_disconnect_reason(PurpleConnection* conn,
|
ui_op_report_disconnect_reason(PurpleConnection* conn,
|
||||||
PurpleConnectionError reason, const char* text)
|
PurpleConnectionError reason, const char* text)
|
||||||
|
|
|
@ -166,6 +166,7 @@ private:
|
||||||
PurpleInputFunction function, gpointer data);
|
PurpleInputFunction function, gpointer data);
|
||||||
|
|
||||||
// Connection ui ops
|
// Connection ui ops
|
||||||
|
static void ui_op_disconnected(PurpleConnection* conn);
|
||||||
static void ui_op_report_disconnect_reason(PurpleConnection* conn,
|
static void ui_op_report_disconnect_reason(PurpleConnection* conn,
|
||||||
PurpleConnectionError reason, const char* text);
|
PurpleConnectionError reason, const char* text);
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,6 @@ connect_thread(void* data)
|
||||||
BMessage* msg = new BMessage(receive_message());
|
BMessage* msg = new BMessage(receive_message());
|
||||||
switch (msg->what) {
|
switch (msg->what) {
|
||||||
case PURPLE_SHUTDOWN_ADDON: {
|
case PURPLE_SHUTDOWN_ADDON: {
|
||||||
protocol->Shutdown();
|
|
||||||
BMessage* disabled = new BMessage(IM_MESSAGE);
|
BMessage* disabled = new BMessage(IM_MESSAGE);
|
||||||
disabled->AddInt32("im_what", IM_PROTOCOL_DISABLE);
|
disabled->AddInt32("im_what", IM_PROTOCOL_DISABLE);
|
||||||
protocol->SendMessage(disabled);
|
protocol->SendMessage(disabled);
|
||||||
|
@ -235,17 +234,17 @@ PurpleProtocol::UpdateSettings(BMessage* msg)
|
||||||
msg->what = PURPLE_CONNECT_ACCOUNT;
|
msg->what = PURPLE_CONNECT_ACCOUNT;
|
||||||
_SendPrplMessage(msg);
|
_SendPrplMessage(msg);
|
||||||
|
|
||||||
thread_id thread = spawn_thread(connect_thread, "fly_away_little_bird",
|
fBirdThread = spawn_thread(connect_thread, "god_has_abandoned_us",
|
||||||
B_NORMAL_PRIORITY, (void*)this);
|
B_NORMAL_PRIORITY, (void*)this);
|
||||||
|
|
||||||
if (thread < B_OK)
|
if (fBirdThread < B_OK)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
BMessage* account = new BMessage(PURPLE_REGISTER_THREAD);
|
BMessage* account = new BMessage(PURPLE_REGISTER_THREAD);
|
||||||
account->AddInt64("thread_id", thread);
|
account->AddInt64("thread_id", fBirdThread);
|
||||||
_SendPrplMessage(account);
|
_SendPrplMessage(account);
|
||||||
|
|
||||||
resume_thread(thread);
|
resume_thread(fBirdThread);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ resource app_version {
|
||||||
variety = B_APPV_ALPHA,
|
variety = B_APPV_ALPHA,
|
||||||
internal = 0,
|
internal = 0,
|
||||||
|
|
||||||
short_info = "Libpurple add-on for Cardie",
|
short_info = "Cardie libpurple add-on",
|
||||||
long_info = "©2021 Jaidyn Levesque"
|
long_info = "©2021 Jaidyn Levesque"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Ŝarĝante…
Reference in New Issue