[Commits] [SCM] claws branch, gtk3, updated. 3.99.0-85-gb56c85f8f

wwp at claws-mail.org wwp at claws-mail.org
Fri Apr 16 09:59:08 CEST 2021


The branch, gtk3 has been updated
       via  b56c85f8f8952cec1b83d60e7990a43c7f32902f (commit)
      from  cfb0306394764264727798eb6bdd821ad79b03a8 (commit)

Summary of changes:
 src/prefs_account.c | 92 +++++++++++++++++++++++++----------------------------
 1 file changed, 44 insertions(+), 48 deletions(-)


- Log -----------------------------------------------------------------
commit b56c85f8f8952cec1b83d60e7990a43c7f32902f
Author: wwp <subscript at free.fr>
Date:   Fri Apr 16 09:56:29 2021 +0200

    Make sure we remove leading and trailing spaces from the OAuth2
    authorization code (when setting the Authorize button sensitivity
    as well as when making use of the authcode value).
    A bit of code reformatting.

diff --git a/src/prefs_account.c b/src/prefs_account.c
index aeaa1ab4a..29fa68b09 100644
--- a/src/prefs_account.c
+++ b/src/prefs_account.c
@@ -2369,8 +2369,7 @@ static void oauth2_create_widget_func(PrefsPage * _page,
 			 G_CALLBACK(prefs_account_oauth2_set_sensitivity), NULL);
 	g_signal_connect(G_OBJECT(oauth2_authcode_entry), "changed", 
 			 G_CALLBACK(prefs_account_oauth2_set_auth_sensitivity), NULL);
-	gtk_widget_set_sensitive(GTK_WIDGET(oauth2_authorise_btn),
-				 gtk_entry_get_text_length(GTK_ENTRY(oauth2_authcode_entry)) > 0);
+	prefs_account_oauth2_set_auth_sensitivity();
 
 	if (new_account) {
 		prefs_set_dialog_to_default(oauth2_param);
@@ -5069,12 +5068,11 @@ static void prefs_account_oauth2_provider_set_optmenu(PrefParam *pparam)
 
 static void prefs_account_oauth2_set_auth_sensitivity(void)
 {
-  const gchar *authcode = gtk_entry_get_text ((GtkEntry *)oauth2_page.oauth2_authcode_entry);
-  
-  if(strlen(authcode) == 0)
-    gtk_widget_set_sensitive(oauth2_page.oauth2_authorise_btn, FALSE);
-  else
-    gtk_widget_set_sensitive(oauth2_page.oauth2_authorise_btn, TRUE);
+	const gchar *authcode = gtk_entry_get_text((GtkEntry *)oauth2_page.oauth2_authcode_entry);
+	gchar *trim_text = g_strdup(authcode);
+	g_strstrip(trim_text);
+	gtk_widget_set_sensitive(oauth2_page.oauth2_authorise_btn, (*trim_text != 0));
+	g_free(trim_text);
 }
 
 static void prefs_account_oauth2_set_sensitivity(void)
@@ -5134,6 +5132,8 @@ static void prefs_account_oauth2_obtain_tokens(GtkButton *button, gpointer data)
 	Oauth2Service service;
         OAUTH2Data *OAUTH2Data = g_malloc(sizeof(* OAUTH2Data));
 	const gchar *authcode = gtk_entry_get_text ((GtkEntry *)oauth2_page.oauth2_authcode_entry);
+	gchar *trim_text = g_strdup(authcode);
+	g_strstrip(trim_text);
 	gint ret;
 
 	oauth2_init (OAUTH2Data);
@@ -5146,49 +5146,45 @@ static void prefs_account_oauth2_obtain_tokens(GtkButton *button, gpointer data)
 	}
 
 	service = combobox_get_active_data(GTK_COMBO_BOX(optmenu));
-	ret = oauth2_obtain_tokens (service, OAUTH2Data, authcode);
+	ret = oauth2_obtain_tokens (service, OAUTH2Data, trim_text);
 	
-	if(ret){
-	  g_free(OAUTH2Data);
-	  return;
+	if(!ret){
+	    if(OAUTH2Data->refresh_token != NULL){
+	      passwd_store_set_account(tmp_ac_prefs.account_id,
+				       PWS_ACCOUNT_OAUTH2_REFRESH,
+				       OAUTH2Data->refresh_token,
+				       FALSE);
+	      log_message(LOG_PROTOCOL, "OAUTH2 refresh token stored\n");
+	    }
+
+	    if(OAUTH2Data->access_token != NULL){
+	      passwd_store_set_account(tmp_ac_prefs.account_id,
+				       PWS_ACCOUNT_RECV,
+				       OAUTH2Data->access_token,
+				       FALSE);
+
+	      passwd_store_set_account(tmp_ac_prefs.account_id,
+				       PWS_ACCOUNT_SEND,
+				       OAUTH2Data->access_token,
+				       FALSE);
+	      log_message(LOG_PROTOCOL, "OAUTH2 access token stored\n");
+
+	      gtk_entry_set_text(GTK_ENTRY(basic_page.pass_entry), OAUTH2Data->access_token);
+	      gtk_entry_set_text(GTK_ENTRY(send_page.smtp_pass_entry), OAUTH2Data->access_token);
+	    }
+
+	    if(OAUTH2Data->expiry_str != NULL){
+	      passwd_store_set_account(tmp_ac_prefs.account_id,
+				       PWS_ACCOUNT_OAUTH2_EXPIRY,
+				       OAUTH2Data->expiry_str,
+				       FALSE);
+	      log_message(LOG_PROTOCOL, "OAUTH2 access token expiry stored\n");
+	    }
+
+	    tmp_ac_prefs.oauth2_date = g_get_real_time () / G_USEC_PER_SEC;
 	}
-
-	if(OAUTH2Data->refresh_token != NULL){
-	  passwd_store_set_account(tmp_ac_prefs.account_id,
-				   PWS_ACCOUNT_OAUTH2_REFRESH,
-				   OAUTH2Data->refresh_token,
-				   FALSE);
-	  log_message(LOG_PROTOCOL, "OAUTH2 refresh token stored\n");
-	}
-
-	if(OAUTH2Data->access_token != NULL){
-	  passwd_store_set_account(tmp_ac_prefs.account_id,
-				   PWS_ACCOUNT_RECV,
-				   OAUTH2Data->access_token,
-				   FALSE);
-	  
-	  passwd_store_set_account(tmp_ac_prefs.account_id,
-				   PWS_ACCOUNT_SEND,
-				   OAUTH2Data->access_token,
-				   FALSE);
-	  log_message(LOG_PROTOCOL, "OAUTH2 access token stored\n");
-	  
-	  gtk_entry_set_text(GTK_ENTRY(basic_page.pass_entry), OAUTH2Data->access_token);
-	  gtk_entry_set_text(GTK_ENTRY(send_page.smtp_pass_entry), OAUTH2Data->access_token);
-	}
-
-	if(OAUTH2Data->expiry_str != NULL){
-	  passwd_store_set_account(tmp_ac_prefs.account_id,
-				   PWS_ACCOUNT_OAUTH2_EXPIRY,
-				   OAUTH2Data->expiry_str,
-				   FALSE);
-	  log_message(LOG_PROTOCOL, "OAUTH2 access token expiry stored\n");
-	}
-
-	tmp_ac_prefs.oauth2_date = g_get_real_time () / G_USEC_PER_SEC;
-
+	g_free(trim_text);
 	g_free(OAUTH2Data);
-
 }
 
 static void prefs_account_set_autochk_interval_to_widgets(PrefParam *pparam)

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list