--- a/hangouts_auth.c Thu Apr 28 22:59:02 2016 +1200
+++ b/hangouts_auth.c Fri Apr 29 19:08:58 2016 +1200
@@ -18,12 +18,78 @@
#include "hangouts_auth.h"
#include "hangouts_json.h"
#include "hangouts_connection.h"
#include "hangouts_conversation.h"
+ bitlbee_account_t *acc; +} bitlbee_im_connection; +static gpointer bitlbee_module; +static bitlbee_im_connection *(*bitlbee_purple_ic_by_pa)(PurpleAccount *); +static int (*bitlbee_set_setstr)(gpointer *, const char *, const char *); +static gboolean bitlbee_password_funcs_loaded = FALSE; +# define dlopen(filename, flag) GetModuleHandleA(filename) +# define dlsym(handle, symbol) GetProcAddress(handle, symbol) +# define dlclose(handle) FreeLibrary(handle) +save_bitlbee_password(PurpleAccount *account, const gchar *password) + bitlbee_account_t *acc; + bitlbee_im_connection *imconn; + if (bitlbee_password_funcs_loaded == FALSE) { + bitlbee_module = dlopen(NULL, 0); + g_return_if_fail(bitlbee_module); + bitlbee_purple_ic_by_pa = (gpointer) dlsym(bitlbee_module, "purple_ic_by_pa"); + bitlbee_set_setstr = (gpointer) dlsym(bitlbee_module, "set_setstr"); + bitlbee_password_funcs_loaded = TRUE; + imconn = bitlbee_purple_ic_by_pa(account); + bitlbee_set_setstr(&acc->set, "password", password ? password : ""); +hangouts_save_refresh_token_password(PurpleAccount *account, const gchar *password) + purple_account_set_password(account, password, NULL, NULL); + if (g_strcmp0(purple_core_get_ui(), "BitlBee") == 0) { + save_bitlbee_password(account, password); hangouts_oauth_refresh_token_cb(PurpleHttpConnection *http_conn, PurpleHttpResponse *response, gpointer user_data)
@@ -43,7 +109,7 @@
if (json_object_has_member(obj, "error")) {
if (g_strcmp0(json_object_get_string_member(obj, "error"), "invalid_grant") == 0) {
- purple_account_set_password(ha->account, NULL, NULL, NULL);
+ hangouts_save_refresh_token_password(ha->account, NULL); purple_connection_error(ha->pc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
json_object_get_string_member(obj, "error_description"));
@@ -109,14 +175,14 @@
ha->refresh_token = g_strdup(json_object_get_string_member(obj, "refresh_token"));
purple_account_set_remember_password(account, TRUE);
- purple_account_set_password(account, ha->refresh_token, NULL, NULL);
+ hangouts_save_refresh_token_password(account, ha->refresh_token); hangouts_auth_get_session_cookies(ha);
if (json_object_has_member(obj, "error")) {
if (g_strcmp0(json_object_get_string_member(obj, "error"), "invalid_grant") == 0) {
- purple_account_set_password(ha->account, NULL, NULL, NULL);
+ hangouts_save_refresh_token_password(ha->account, NULL); purple_connection_error(ha->pc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
json_object_get_string_member(obj, "error_description"));