ayttm-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Ayttm-commits] CVS: ayttm/src prefs.c,1.31.2.6,1.31.2.7 prefs.h,1.6.2.


From: Andy Maloney <address@hidden>
Subject: [Ayttm-commits] CVS: ayttm/src prefs.c,1.31.2.6,1.31.2.7 prefs.h,1.6.2.5,1.6.2.6
Date: Sat, 29 Mar 2003 14:33:36 -0500

Update of /cvsroot/ayttm/ayttm/src
In directory subversions:/tmp/cvs-serv595/src

Modified Files:
      Tag: new_prefs
        prefs.c prefs.h 
Log Message:
Variable name cleanup
Minor code formatting


Index: prefs.c
===================================================================
RCS file: /cvsroot/ayttm/ayttm/src/prefs.c,v
retrieving revision 1.31.2.6
retrieving revision 1.31.2.7
diff -u -r1.31.2.6 -r1.31.2.7
--- prefs.c     28 Mar 2003 18:04:36 -0000      1.31.2.6
+++ prefs.c     29 Mar 2003 19:33:34 -0000      1.31.2.7
@@ -55,11 +55,7 @@
 } ptr_list;
 
 
-static LList *s_global_prefs = NULL;
-
-static const int       length_contact_window_default = 256;
-static const int       width_contact_window_default = 150;
-static const int       font_size_default = 4;
+static LList           *s_global_prefs = NULL;
 
 
 static int s_compare_ptr_key( const void *a, const void *b )
@@ -74,20 +70,20 @@
 {
        const module_pref *pref = a;
        
-       if ( pref->name && !strcmp( pref->name, (const char *)b) )
+       if ( pref->file_name && !strcmp( pref->file_name, (const char *)b) )
                return( 0 );
                
        return( 1 );
 }
 
-static void s_AddPref( const char *key, void *data )
+static void s_add_pref( const char *key, void *data )
 {
-       ptr_list *PrefData = calloc( 1, sizeof( ptr_list ) );
+       ptr_list *pref_data = calloc( 1, sizeof( ptr_list ) );
        
-       strcpy( PrefData->key, key );
-       PrefData->value=(void *)data;
+       strcpy( pref_data->key, key );
+       pref_data->value=(void *)data;
        
-       s_global_prefs = l_list_append( s_global_prefs, PrefData );
+       s_global_prefs = l_list_append( s_global_prefs, pref_data );
 }
 
 static char    *s_strip_whitespace( char *inStr )
@@ -251,24 +247,24 @@
        
        for ( ; plugins; plugins = plugins->next )
        {
-               const eb_PLUGIN_INFO    *epi = plugins->data;
+               const eb_PLUGIN_INFO    *plugin_info = plugins->data;
                module_pref                             *pref_info = NULL;
                
                
-               if ( epi == NULL )
+               if ( plugin_info == NULL )
                        continue;
                
                pref_info = calloc( 1, sizeof( module_pref ) );
 
-               pref_info->type = PLUGIN_TYPE_TXT[epi->pi.type-1];
-               pref_info->brief_desc = s_strdup_allow_null( epi->pi.brief_desc 
);
-               pref_info->status = PLUGIN_STATUS_TXT[epi->status];
-               pref_info->version = s_strdup_allow_null( epi->pi.version );
-               pref_info->date = s_strdup_allow_null( epi->pi.date );
-               pref_info->name = s_strdup_allow_null( epi->name );
-               pref_info->status_desc = s_strdup_allow_null( epi->status_desc 
);
-               pref_info->service_name = s_strdup_allow_null( epi->service );
-               pref_info->pref_list = s_copy_input_list( epi->pi.prefs );
+               pref_info->module_type = 
PLUGIN_TYPE_TXT[plugin_info->pi.type-1];
+               pref_info->brief_desc = s_strdup_allow_null( 
plugin_info->pi.brief_desc );
+               pref_info->loaded_status = 
PLUGIN_STATUS_TXT[plugin_info->status];
+               pref_info->version = s_strdup_allow_null( 
plugin_info->pi.version );
+               pref_info->date = s_strdup_allow_null( plugin_info->pi.date );
+               pref_info->file_name = s_strdup_allow_null( plugin_info->name );
+               pref_info->status_desc = s_strdup_allow_null( 
plugin_info->status_desc );
+               pref_info->service_name = s_strdup_allow_null( 
plugin_info->service );
+               pref_info->pref_list = s_copy_input_list( plugin_info->pi.prefs 
);
                        
                module_prefs_list = l_list_append( module_prefs_list, 
pref_info);
        }
@@ -289,7 +285,7 @@
                free( (void *)pref_info->brief_desc );
                free( (void *)pref_info->version );
                free( (void *)pref_info->date );
-               free( (void *)pref_info->name );
+               free( (void *)pref_info->file_name );
                free( (void *)pref_info->status_desc );
                free( (void *)pref_info->service_name );
                
@@ -304,7 +300,6 @@
        if ( ioPrefs == NULL )
                return;
                
-       // clean up memory
        s_destroy_module_prefs_list( ioPrefs->module.module_info );
        free( ioPrefs );
 }
@@ -321,6 +316,7 @@
 
        master_prefs = GetPref( plugin_info->name );
        master_prefs = value_pair_remove( master_prefs, "load" );
+       
        current_prefs = eb_input_to_value_pair( plugin_info->pi.prefs );
 
        if ( plugin_info->status == PLUGIN_LOADED )
@@ -331,7 +327,9 @@
        master_prefs = value_pair_update( master_prefs, current_prefs );
        SetPref( plugin_info->name, master_prefs );
        value_pair_print_values( master_prefs, fp, 2 );
+       
        fprintf( fp, "\tend\n" );
+       
        value_pair_free( current_prefs );
 }
 
@@ -350,7 +348,7 @@
                        NOTE that this will hopefully be solved by changing the 
way prefs are
                        applied to plugins
                */
-               plugin_info = FindPluginByName( the_prefs->name );
+               plugin_info = FindPluginByName( the_prefs->file_name );
                
                if ( plugin_info != NULL )
                {
@@ -410,8 +408,8 @@
        iSetLocalPref( "do_spell_checking", 0 );
        cSetLocalPref( "spell_dictionary", "" );
        
-       iSetLocalPref( "length_contact_window", length_contact_window_default );
-       iSetLocalPref( "width_contact_window", width_contact_window_default );
+       iSetLocalPref( "length_contact_window", 256 );
+       iSetLocalPref( "width_contact_window", 150 );
        
        /* logging */
        iSetLocalPref( "do_logging", 1 );
@@ -439,7 +437,7 @@
        iSetLocalPref( "do_ignore_font", 1 );
        iSetLocalPref( "do_smiley", 1 );
        
-       /* NOTE that the way these defaults are stored is GTK-specific */
+       /* NOTE that the way the defaults for accelerators are stored is likely 
GTK-specific */
        cSetLocalPref( "accel_prev_tab", "<Control>Left" );
        cSetLocalPref( "accel_next_tab", "<Control>Right" );
 
@@ -542,7 +540,7 @@
                
                if ( !strcasecmp( param, "plugins" ) )
                        pref_type = PLUGIN_PREF;
-               else if( !strcasecmp( param, "connections" ) )
+               else if ( !strcasecmp( param, "connections" ) )
                        pref_type = SERVICE_PREF;
                        
                if ( pref_type != CORE_PREF )
@@ -608,7 +606,6 @@
                                                        eb_debug(DBG_CORE, 
"Freeing old_session_prefs\n");
                                                        value_pair_free( 
old_session_prefs );
                                                }
-                                               
                                                break;
                                        }
                                        else
@@ -631,7 +628,7 @@
                                                        val[strlen(val)-1] = 
'\0';
                                                }
                                                
-                                               eb_debug(DBG_CORE,"Adding %s:%s 
to session_prefs\n", param, val);
+                                               eb_debug( DBG_CORE, "Adding 
%s:%s to session_prefs\n", param, val );
                                                session_prefs = value_pair_add( 
session_prefs, param, val );
                                        }
                                }
@@ -670,11 +667,12 @@
        char            buff[bufferLen];
        char            file[bufferLen];
        FILE            *fp = NULL;
-        
+
+
        snprintf( buff, bufferLen, "%sprefs.tmp", config_dir );
        snprintf( file, bufferLen, "%sprefs", config_dir );
         
-       fp = fopen(buff, "w");
+       fp = fopen( buff, "w" );
        
        /* general */
     fprintf( fp, "do_login_on_startup=%d\n", 
iGetLocalPref("do_login_on_startup") );
@@ -720,7 +718,6 @@
        fprintf( fp, "do_smiley=%d\n", iGetLocalPref("do_smiley" ) );
        fprintf( fp, "accel_next_tab=%s\n", cGetLocalPref("accel_next_tab") );
        fprintf( fp, "accel_prev_tab=%s\n", cGetLocalPref("accel_prev_tab") );
-       fprintf( fp, "end\n" );
 
         /* sound */
        fprintf( fp, "do_no_sound_when_away=%d\n", 
iGetLocalPref("do_no_sound_when_away") );
@@ -753,7 +750,6 @@
        fprintf( fp, "modules_path=%s\n", cGetLocalPref("modules_path") );
        fprintf( fp, "plugins\n" );
        l_list_foreach( GetPref(EB_PLUGIN_LIST), s_write_module_prefs, fp );
-        
        fprintf( fp, "end\n" );
        
        fclose( fp );
@@ -831,7 +827,7 @@
        /* modules */
        prefs->module.module_info = s_create_module_prefs_list();
        
-       prefs_window_create( prefs );
+       ayttm_prefs_window_create( prefs );
 }
 
 module_pref    *ayttm_prefs_find_module_by_name( const struct prefs *inPrefs, 
const char *inName )
@@ -839,6 +835,7 @@
        LList   *module_list = NULL;
        LList   *search_result =NULL;
        
+       
        if ( (inPrefs == NULL) || (inName == NULL) )
                return( NULL );
        
@@ -903,7 +900,7 @@
        cSetLocalPref( "SendFilename", inPrefs->sound.SendFilename );
        cSetLocalPref( "ReceiveFilename", inPrefs->sound.ReceiveFilename );
        cSetLocalPref( "FirstMsgFilename", inPrefs->sound.FirstMsgFilename );
-               
+       
        fSetLocalPref( "SoundVolume", inPrefs->sound.SoundVolume );
 
        /* advanced */
@@ -944,37 +941,40 @@
 /* Find old pref data, and replace with new, returning old data */
 void   *SetPref( const char *key, void *data )
 {
-       ptr_list        *PrefData = NULL;
+       ptr_list        *pref_data = NULL;
        void            *old_data = NULL;
-       LList           *ListData = l_list_find_custom( s_global_prefs, key, 
s_compare_ptr_key );
+       LList           *list_data = l_list_find_custom( s_global_prefs, key, 
s_compare_ptr_key );
+
 
-       if ( !ListData )
+       if ( !list_data )
        {
-               s_AddPref( key, data );
+               s_add_pref( key, data );
                
                return( NULL );
        }
        
-       PrefData = (ptr_list *)ListData->data;
-       old_data = PrefData->value;
-       PrefData->value=data;
+       pref_data = (ptr_list *)list_data->data;
+       old_data = pref_data->value;
+       pref_data->value=data;
        
        return( old_data );
 }
 
 void   *GetPref( const char *key )
 {
-       ptr_list        *PrefData = NULL;
-       LList           *ListData = l_list_find_custom( s_global_prefs, key, 
s_compare_ptr_key );
+       ptr_list        *pref_data = NULL;
+       LList           *list_data = l_list_find_custom( s_global_prefs, key, 
s_compare_ptr_key );
 
-       if( !ListData )
+
+       if ( !list_data )
                return( NULL );
                
-       PrefData = ListData->data;
-       if ( !PrefData )
+       pref_data = list_data->data;
+       
+       if ( !pref_data )
                return( NULL );
                
-       return( PrefData->value );
+       return( pref_data->value );
 }
 
 void   cSetLocalPref( const char *key, char *data )
@@ -982,8 +982,11 @@
        char    newkey[MAX_PREF_NAME_LEN];
        char    *oldvalue = NULL;
 
+
        snprintf( newkey, MAX_PREF_NAME_LEN, "Local::%s", key );
+       
        oldvalue = SetPref( newkey, strdup(data) );
+       
        if ( oldvalue )
                free( oldvalue );
 }
@@ -992,6 +995,7 @@
 {
        char    value[MAX_PREF_LEN];
 
+
        snprintf( value, MAX_PREF_LEN, "%i", data );
        cSetLocalPref( key, value );
 }
@@ -1000,6 +1004,7 @@
 {
        char    value[MAX_PREF_LEN];
 
+
        snprintf( value, MAX_PREF_LEN, "%f", data );
        cSetLocalPref( key, value );
 }
@@ -1009,8 +1014,11 @@
        char    newkey[MAX_PREF_NAME_LEN];
        char    *value = NULL;
 
+
        snprintf( newkey, MAX_PREF_NAME_LEN, "Local::%s", key );
+       
        value = (char *)GetPref( newkey );
+       
        if ( !value )
                value="";
                
@@ -1020,6 +1028,7 @@
 float  fGetLocalPref( const char *key )
 {
        float   value = 0.0;
+       
 
        value = atof( cGetLocalPref( key ) );
        
@@ -1030,6 +1039,7 @@
 {
        int     value = 0;
 
+
        value = atoi( cGetLocalPref( key ) );
        
        return( value );
@@ -1042,6 +1052,9 @@
        const int       buffer_size = 256;
        char            buff[buffer_size];
        char            *val = value_pair_get_value( pairs, "SCREEN_NAME" );
+       
+
+       assert( val != NULL );
        
        snprintf( buff, buffer_size, "%s:%s", service, val );
        

Index: prefs.h
===================================================================
RCS file: /cvsroot/ayttm/ayttm/src/prefs.h,v
retrieving revision 1.6.2.5
retrieving revision 1.6.2.6
diff -u -r1.6.2.5 -r1.6.2.6
--- prefs.h     28 Mar 2003 18:04:36 -0000      1.6.2.5
+++ prefs.h     29 Mar 2003 19:33:34 -0000      1.6.2.6
@@ -38,12 +38,12 @@
 
 typedef struct
 {
-       const char              *type;
+       const char              *module_type;
        const char              *brief_desc;
-       const char              *status;
+       const char              *loaded_status;
        const char              *version;
        const char              *date;
-       const char              *name;
+       const char              *file_name;
        const char              *status_desc;
        const char              *service_name;
        





reply via email to

[Prev in Thread] Current Thread [Next in Thread]