changeset 229:e8ea7f37e28f

[gaim-migrate @ 239] One minor tweak to the buddy list cache. If we read a non-zero buddy list from TOC and there is not a cache yet, create it. committer: Tailor Script <tailor@pidgin.im>
author Syd Logan <slogan>
date Wed, 10 May 2000 08:29:02 +0000
parents f3b61c04f44e
children 83dd297aa363
files src/dialogs.c src/toc.c
diffstat 2 files changed, 25 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/dialogs.c	Wed May 10 07:41:25 2000 +0000
+++ b/src/dialogs.c	Wed May 10 08:29:02 2000 +0000
@@ -1938,7 +1938,27 @@
 
 #define PATHSIZE 1024
 
-/* if dummy is 0, save to ~/.gaimbdcache_screenname */
+/* see if a buddy list cache file for this user exists */
+
+gboolean
+bud_list_cache_exists( void )
+{
+	gboolean ret = FALSE;
+	char path[PATHSIZE];
+	char *file;
+	struct stat sbuf;
+	extern char g_screenname[];
+
+	file = getenv( "HOME" );
+	if ( file != (char *) NULL ) {
+	       	sprintf( path, "%s/.gaimbdcache_%s", file, g_screenname );
+		if ( !stat(path, &sbuf) ) 
+			ret = TRUE;
+	}
+	return ret;
+}
+
+/* if dummy is 0, save to ~/.gaimbdcache_screenname. Else, let user choose */
 
 void do_export(GtkWidget *w, void *dummy)
 {
@@ -2008,7 +2028,8 @@
 
 }
 
-/* if dummy is 0, then import from ~/.gaimbdcache_screenname */
+/* if dummy is 0, then import from ~/.gaimbdcache_screenname, else let user
+   choose */
 
 void do_import(GtkWidget *w, void *dummy)
 {
--- a/src/toc.c	Wed May 10 07:41:25 2000 +0000
+++ b/src/toc.c	Wed May 10 08:29:02 2000 +0000
@@ -900,5 +900,7 @@
 
 	if ( how_many == 0 ) {
 		do_import( (GtkWidget *) NULL, 0 );
+	} else if ( bud_list_cache_exists() == FALSE ) {
+		do_export( (GtkWidget *) NULL, 0 );	
 	}
  }