/** * Processes the error of a #SteamApiReq. * * @param sata The #SteamData. * @param req The #SteamApiReq. * @param logout TRUE to logout, otherwise FALSE. * * @return TRUE if an error exists, otherwise FALSE. **/ static gboolean steam_req_error(SteamData *sata, SteamApiReq *req, gboolean logout) { if (req->err == NULL) return FALSE; if (g_error_matches(req->err, STEAM_API_ERROR, STEAM_API_ERROR_EXPRIED)) { STEAM_UTIL_DEBUGLN("Relogging on due to expired session"); steam_http_free_reqs(req->api->http); req = steam_api_req_new(req->api, steam_cb_relogon, sata); steam_api_req_logon(req); return TRUE; } if (g_error_matches(req->err, STEAM_HTTP_ERROR, STEAM_HTTP_ERROR_CLOSED)) { STEAM_UTIL_DEBUGLN("Request (%p) forcefully closed", req->req); /* Ignore closed HTTP connections */ return TRUE; } STEAM_UTIL_DEBUGLN("Error: %s", req->err->message); imcb_error(sata->ic, "%s", req->err->message); if (logout) { STEAM_UTIL_DEBUGLN("Reconnecting due to error"); imc_logout(sata->ic, logout); } return TRUE; }
/** * Frees all memory used by a #SteamHttp. * * @param http The #SteamHttp. **/ void steam_http_free(SteamHttp *http) { if (G_UNLIKELY(http == NULL)) return; steam_http_free_reqs(http); g_hash_table_destroy(http->reqs); g_hash_table_destroy(http->cookies); g_free(http->agent); g_free(http); }
/** * Implements #prpl->logout(). This logs an account out. * * @param ic The #im_connection. **/ static void steam_logout(struct im_connection *ic) { SteamData *sata = ic->proto_data; SteamApiReq *req; steam_http_free_reqs(sata->api->http); if (ic->flags & BEE_USER_ONLINE) { req = steam_api_req_new(sata->api, steam_cb_logoff, sata); steam_api_req_logoff(req); } else { steam_data_free(sata); } }