@@ -544,8 +544,8 @@ static void remmina_profiles_get_data(RemminaFile *remminafile, gpointer user_da
544544 dmonth = g_strdup_printf ("%.2s" , pdata -> pdatestr + 4 );
545545 dday = g_strdup_printf ("%.2s" , pdata -> pdatestr + 6 );
546546 dd = g_date_time_new_local (g_ascii_strtoll (dyear , NULL , 0 ),
547- g_ascii_strtoll (dmonth , NULL , 0 ),
548- g_ascii_strtoll (dday , NULL , 0 ), 0 , 0 , 0.0 );
547+ g_ascii_strtoll (dmonth , NULL , 0 ),
548+ g_ascii_strtoll (dday , NULL , 0 ), 0 , 0 , 0.0 );
549549 g_free (dyear );
550550 g_free (dmonth );
551551 g_free (dday );
@@ -560,6 +560,7 @@ static void remmina_profiles_get_data(RemminaFile *remminafile, gpointer user_da
560560 g_hash_table_insert (pdata -> proto_count , g_strdup (pdata -> protocol ), GINT_TO_POINTER (count ));
561561 }
562562 g_hash_table_replace (pdata -> proto_count , g_strdup (pdata -> protocol ), GINT_TO_POINTER (count ));
563+ pdate = NULL ;
563564 if (g_hash_table_lookup_extended (pdata -> proto_date , pdata -> protocol , & kdo , & pdate )) {
564565
565566 ds = NULL ;
@@ -568,36 +569,53 @@ static void remmina_profiles_get_data(RemminaFile *remminafile, gpointer user_da
568569 smonth = g_strdup_printf ("%.2s" , (char * )pdate + 4 );
569570 sday = g_strdup_printf ("%.2s" , (char * )pdate + 6 );
570571 ds = g_date_time_new_local (g_ascii_strtoll (syear , NULL , 0 ),
571- g_ascii_strtoll (smonth , NULL , 0 ),
572- g_ascii_strtoll (sday , NULL , 0 ), 0 , 0 , 0.0 );
572+ g_ascii_strtoll (smonth , NULL , 0 ),
573+ g_ascii_strtoll (sday , NULL , 0 ), 0 , 0 , 0.0 );
573574 g_free (syear );
574575 g_free (smonth );
575576 g_free (sday );
576577 }
577578
579+ /** When both date in the has and in the profile are valid we compare the date */
578580 if (ds && dd ) {
579581 gint res = g_date_time_compare ( ds , dd );
582+ /** If the date in the hash less than the date in the profile, we take the latter */
580583 if (res < 0 ) {
584+ //remmina_log_printf("Date %s is newer than the one inside pdata->protocol for protocol %s\n", g_strdup(pdata->pdatestr), g_strdup(pdata->protocol));
581585 g_hash_table_replace (pdata -> proto_date , g_strdup (pdata -> protocol ), g_strdup (pdata -> pdatestr ));
582586 }
583587 g_date_time_unref (ds );
584588 }
589+ /** If the date in the hash is valid and the date in the profile is NULL we keep the first one */
585590 if (ds && !dd ) {
591+ g_date_time_unref (ds );
592+ }
593+ /** If the date in the hash is NOT valid and the date in the profile is valid we keep the latter */
594+ if (!ds && dd ) {
595+ //remmina_log_printf("Date %s inserted in pdata->protocol for protocol %s\n", g_strdup(pdata->pdatestr), g_strdup(pdata->protocol));
586596 g_hash_table_replace (pdata -> proto_date , g_strdup (pdata -> protocol ), g_strdup (pdata -> pdatestr ));
587597 g_date_time_unref (ds );
588598 }
589- if ((!ds && !dd ) && pdata -> pdatestr )
590- g_hash_table_insert (pdata -> proto_date , g_strdup (pdata -> protocol ), g_strdup (pdata -> pdatestr ));
599+ /** If both date are NULL, we insert NULL for that protocol */
600+ if ((!ds && !dd ) && pdata -> pdatestr ) {
601+ //remmina_log_printf("Date NULL inserted in pdata->protocol for protocol %s\n", g_strdup(pdata->protocol));
602+ g_hash_table_replace (pdata -> proto_date , g_strdup (pdata -> protocol ), NULL );
603+ }
591604 }else {
605+ /** If there is not the protocol in the hash, we add it */
606+ /** If the date in the profile is not NULL we use it */
592607 if (pdata -> pdatestr ) {
593- g_hash_table_insert (pdata -> proto_date , g_strdup (pdata -> protocol ), g_strdup (pdata -> pdatestr ));
608+ //remmina_log_printf("Date %s inserted in pdata->protocol for protocol %s\n", g_strdup(pdata->pdatestr), g_strdup(pdata->protocol));
609+ g_hash_table_replace (pdata -> proto_date , g_strdup (pdata -> protocol ), g_strdup (pdata -> pdatestr ));
594610 }else {
595- g_hash_table_insert (pdata -> proto_date , g_strdup (pdata -> protocol ), NULL );
611+ /** Otherwise we set it to NULL */
612+ //remmina_log_printf("We set %s protocol date to NULL\n", g_strdup(pdata->protocol));
613+ g_hash_table_replace (pdata -> proto_date , g_strdup (pdata -> protocol ), NULL );
596614 }
597615 }
616+ if (dd )
617+ g_date_time_unref (dd );
598618 }
599- if (dd )
600- g_date_time_unref (dd );
601619}
602620
603621/**
0 commit comments