[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Ayttm-commits] CVS: ayttm/src prefs.c,1.31,1.31.2.1
From: |
Andy Maloney <address@hidden> |
Subject: |
[Ayttm-commits] CVS: ayttm/src prefs.c,1.31,1.31.2.1 |
Date: |
Sat, 22 Mar 2003 19:31:01 -0500 |
Update of /cvsroot/ayttm/ayttm/src
In directory subversions:/tmp/cvs-serv30389/src
Modified Files:
Tag: new_prefs
prefs.c
Log Message:
prefs.[ch] now handles all reading and writing of prefs
Replace GList with LList
Index: prefs.c
===================================================================
RCS file: /cvsroot/ayttm/ayttm/src/prefs.c,v
retrieving revision 1.31
retrieving revision 1.31.2.1
diff -u -r1.31 -r1.31.2.1
--- prefs.c 22 Mar 2003 11:48:25 -0000 1.31
+++ prefs.c 23 Mar 2003 00:30:59 -0000 1.31.2.1
@@ -31,16 +31,29 @@
#include "value_pair.h"
#include "globals.h"
#include "dialog.h"
+#include "defaults.h"
+#include "libproxy/libproxy.h"
+#include "prefs_window.h"
+enum {
+ CORE_PREF,
+ PLUGIN_PREF,
+ SERVICE_PREF
+};
+
typedef struct _ptr_list
{
- char key[MAX_PREF_NAME_LEN+1];
- void *value;
+ char key[MAX_PREF_NAME_LEN+1];
+ void *value;
} ptr_list;
-static GList *s_global_prefs = NULL;
+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 int compare_ptr_key(gconstpointer a, gconstpointer b)
@@ -50,22 +63,475 @@
return(1);
}
-static void AddPref(char *key, void *data)
+static void AddPref( const char *key, void *data )
{
- ptr_list *PrefData = g_new0(ptr_list, 1);
+ ptr_list *PrefData = calloc( 1, sizeof(ptr_list) );
- strcpy(PrefData->key, key);
+ strcpy( PrefData->key, key );
PrefData->value=(void *)data;
- s_global_prefs = g_list_append(s_global_prefs, PrefData);
- return;
+
+ s_global_prefs = l_list_append( s_global_prefs, PrefData );
+}
+
+
+void ayttm_prefs_init( void )
+{
+ /* set default prefs */
+
+ /* general */
+ iSetLocalPref( "do_login_on_startup", 0 );
+ iSetLocalPref( "do_ayttm_debug", 0 );
+ iSetLocalPref( "do_ayttm_debug_html", 0 );
+ iSetLocalPref( "do_plugin_debug", 0 );
+ iSetLocalPref( "do_noautoresize", 0 );
+ iSetLocalPref( "use_alternate_browser", 0 );
+ cSetLocalPref( "alternate_browser", "" );
+
+ iSetLocalPref( "do_spell_checking", 0 );
+ cSetLocalPref( "spell_dictionary", "" );
+
+ /* logging */
+ iSetLocalPref( "do_logging", 1 );
+ iSetLocalPref( "do_strip_html", 0 );
+ iSetLocalPref( "do_restore_last_conv", 0 );
+
+ /* layout */
+ iSetLocalPref( "do_tabbed_chat", 0 );
+ iSetLocalPref( "do_tabbed_chat_orient", 0 ); /* Tab Orientation: 0
=> bottom, 1 => top, 2=> left, 3 => right */
+
+ /* chat */
+ iSetLocalPref( "do_typing_notify", 1 );
+ iSetLocalPref( "do_send_typing_notify", 1 );
+ iSetLocalPref( "do_escape_close", 1 );
+ iSetLocalPref( "do_convo_timestamp", 1 );
+ iSetLocalPref( "do_enter_send", 1 );
+ iSetLocalPref( "do_ignore_unknown", 0 );
+ iSetLocalPref( "FontSize", 4 );
+ iSetLocalPref( "do_multi_line", 1 );
+ iSetLocalPref( "do_raise_window", 0 );
+ iSetLocalPref( "do_send_idle_time", 0 );
+ iSetLocalPref( "do_timestamp", 1 );
+ iSetLocalPref( "do_ignore_fore", 1 );
+ iSetLocalPref( "do_ignore_back", 1 );
+ iSetLocalPref( "do_ignore_font", 1 );
+ iSetLocalPref( "do_smiley", 1 );
+
+// g_prefs.chat.accel_prev_tab = { GDK_Left, GDK_CONTROL_MASK };
+// g_prefs.chat.accel_next_tab = { GDK_Right, GDK_CONTROL_MASK };
+
+ /* modules */
+ cSetLocalPref( "modules_path", MODULE_DIR );
+
+ /* sound */
+ iSetLocalPref( "do_no_sound_when_away", 0 );
+ iSetLocalPref( "do_no_sound_for_ignore", 1 );
+ iSetLocalPref( "do_online_sound", 1 );
+ iSetLocalPref( "do_play_send", 1 );
+ iSetLocalPref( "do_play_first", 1 );
+ iSetLocalPref( "do_play_receive", 1 );
+
+ cSetLocalPref( "BuddyArriveFilename", BuddyArriveDefault );
+ cSetLocalPref( "BuddyAwayFilename", BuddyLeaveDefault );
+ cSetLocalPref( "BuddyLeaveFilename", BuddyLeaveDefault );
+ cSetLocalPref( "SendFilename", SendDefault );
+ cSetLocalPref( "ReceiveFilename", ReceiveDefault );
+ cSetLocalPref( "FirstMsgFilename", ReceiveDefault );
+
+ fSetLocalPref( "SoundVolume", 0.0 );
+
+ /* advanced */
+ iSetLocalPref( "proxy_type", 0 );
+ cSetLocalPref( "proxy_host", "" );
+ iSetLocalPref( "proxy_port", 3128 );
+ iSetLocalPref( "do_proxy_auth", 0 );
+ cSetLocalPref( "proxy_user", "" );
+ cSetLocalPref( "proxy_password", "" );
+
+ iSetLocalPref( "use_recoding", 0 );
+ cSetLocalPref( "local_encoding", "" );
+ cSetLocalPref( "remote_encoding", "" );
+}
+
+void ayttm_prefs_read( void )
+{
+ const int bufferLen = 1024;
+ char buff[bufferLen];
+ int pref_type=0;
+ FILE *fp = NULL;
+ char *param = buff;
+ char *val = buff;
+
+ /* Set some default values */
+ iSetLocalPref( "length_contact_window", length_contact_window_default );
+ iSetLocalPref( "width_contact_window", width_contact_window_default );
+
+ snprintf( buff, bufferLen, "%sprefs",config_dir );
+
+ fp = fopen( buff, "r" );
+
+ if ( fp == NULL )
+ {
+ printf( "Creating prefs file [%s]\n", buff );
+ ayttm_prefs_write();
+ return;
+ }
+
+ while ( !feof( fp ) )
+ {
+ fgets(buff, bufferLen, fp);
+ param=buff;
+ if(feof(fp))
+ break;
+ g_strstrip(param);
+ pref_type=CORE_PREF;
+ if(!strcasecmp(buff, "plugins"))
+ pref_type=PLUGIN_PREF;
+ else if(!strcasecmp(buff, "connections"))
+ pref_type=SERVICE_PREF;
+ if(pref_type!=CORE_PREF)
+ {
+ for(;;)
+ {
+ int id=-1;
+ char *plugin_name=NULL;
+ LList * session_prefs = NULL;
+ LList *osession_prefs = NULL;
+ fgets(buff, bufferLen, fp);
+ param=buff;
+ g_strstrip(param);
+ if(!strcasecmp(param, "end"))
+ {
+ break;
+ }
+ switch(pref_type) {
+ case PLUGIN_PREF:
+ plugin_name=strdup(param);
+ break;
+ case SERVICE_PREF:
+ id = get_service_id(param);
+ break;
+ default:
+ break;
+ }
+
+ for(;;)
+ {
+ fgets(buff, bufferLen, fp);
+ param=buff;
+ g_strstrip(param);
+ if(!strcasecmp(param, "end"))
+ {
+ switch(pref_type) {
+ case PLUGIN_PREF:
+ osession_prefs =
SetPref(plugin_name, session_prefs);
+ if(osession_prefs)
+ {
+
eb_debug(DBG_CORE, "Freeing osession_prefs\n");
+
value_pair_free(osession_prefs);
+ }
+ free(plugin_name);
+ break;
+ case SERVICE_PREF:
+ osession_prefs =
SetPref(get_service_name(id), session_prefs);
+ if(osession_prefs)
+ {
+
eb_debug(DBG_CORE, "Freeing osession_prefs\n");
+
value_pair_free(osession_prefs);
+ }
+ break;
+ default:
+ eb_debug(DBG_CORE,
"Error! We're not supposed to ever get here!\n");
+ break;
+ }
+ break;
+ }
+ else
+ {
+ val=param;
+
+ while(*val != 0 && *val !='=')
+ val++;
+ if(*val=='=')
+ {
+ *val='\0';
+ val++;
+ }
+
+ /*
+ * if quoted strip off the quotes
+ */
+
+ if(*val == '"')
+ {
+ val++;
+ val[strlen(val)-1] =
'\0';
+ }
+ eb_debug(DBG_CORE,"Adding %s:%s
to session_prefs\n", param, val);
+ session_prefs =
value_pair_add(session_prefs, param, val);
+ }
+ }
+ }
+ continue;
+ } /* if(pref_type != CORE_PREF) */
+ val=param;
+
+ while(*val != 0 && *val !='=')
+ val++;
+ if(*val=='=')
+ {
+ *val='\0';
+ val++;
+ }
+ cSetLocalPref(param, val);
+ }
+
+ fclose(fp);
+
+ proxy_set_proxy(iGetLocalPref("proxy_type"),
cGetLocalPref("proxy_host"), iGetLocalPref("proxy_port"));
+ proxy_set_auth(iGetLocalPref("do_proxy_auth"),
cGetLocalPref("proxy_user"), cGetLocalPref("proxy_password"));
+}
+
+void ayttm_prefs_write( void )
+{
+ const int bufferLen = 1024;
+ 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");
+
+ /* general */
+ fprintf( fp,"do_login_on_startup=%d\n",
iGetLocalPref("do_login_on_startup") );
+ fprintf( fp,"do_ayttm_debug=%d\n", iGetLocalPref("do_ayttm_debug") );
+ fprintf( fp,"do_ayttm_debug_html=%d\n",
iGetLocalPref("do_ayttm_debug_html") );
+ fprintf( fp,"do_plugin_debug=%d\n", iGetLocalPref("do_ayttm_debug") );
+ fprintf( fp,"length_contact_window=%d\n",
iGetLocalPref("length_contact_window") );
+ fprintf( fp,"width_contact_window=%d\n",
iGetLocalPref("width_contact_window") );
+#ifdef HAVE_ISPELL
+ fprintf( fp,"do_spell_checking=%d\n", iGetLocalPref("do_spell_checking") );
+ fprintf( fp,"spell_dictionary=%s\n", cGetLocalPref("spell_dictionary")
);
+#endif
+ fprintf( fp,"do_noautoresize=%d\n", iGetLocalPref("do_noautoresize") ) ;
+ fprintf( fp,"use_alternate_browser=%d\n",
iGetLocalPref("use_alternate_browser") );
+ fprintf( fp,"alternate_browser=%s\n",
cGetLocalPref("alternate_browser") );
+
+ /* logging */
+ fprintf( fp, "do_logging=%d\n", iGetLocalPref("do_logging") );
+ fprintf( fp, "do_strip_html=%d\n", iGetLocalPref("do_strip_html") );
+ fprintf( fp, "do_restore_last_conv=%d\n",
iGetLocalPref("do_restore_last_conv") );
+
+ /* layout */
+ fprintf( fp, "do_tabbed_chat=%d\n", iGetLocalPref("do_tabbed_chat") );
+ fprintf( fp, "do_tabbed_chat_orient=%d\n",
iGetLocalPref("do_tabbed_chat_orient") );
+
+ /* chat */
+ fprintf( fp,"do_typing_notify=%d\n", iGetLocalPref("do_typing_notify")
);
+ fprintf( fp,"do_send_typing_notify=%d\n",
iGetLocalPref("do_send_typing_notify") );
+ fprintf( fp,"do_escape_close=%d\n", iGetLocalPref("do_escape_close") );
+ fprintf( fp,"do_convo_timestamp=%d\n",
iGetLocalPref("do_convo_timestamp") );
+ fprintf( fp,"do_enter_send=%d\n", iGetLocalPref("do_enter_send") );
+ fprintf( fp,"do_ignore_unknown=%d\n",
iGetLocalPref("do_ignore_unknown") );
+ fprintf( fp,"FontSize=%d\n", iGetLocalPref("FontSize") );
+ fprintf( fp,"do_multi_line=%d\n", iGetLocalPref("do_multi_line") );
+ fprintf( fp,"do_raise_window=%d\n", iGetLocalPref("do_raise_window") );
+ fprintf( fp,"do_send_idle_time=%d\n",
iGetLocalPref("do_send_idle_time") );
+ fprintf( fp,"do_timestamp=%d\n", iGetLocalPref("do_timestamp") );
+ fprintf( fp,"do_ignore_fore=%d\n", iGetLocalPref("do_ignore_fore") );
+ fprintf( fp,"do_ignore_back=%d\n", iGetLocalPref("do_ignore_back") );
+ fprintf( fp,"do_ignore_font=%d\n", iGetLocalPref("do_ignore_font") );
+ fprintf( fp,"do_smiley=%d\n", iGetLocalPref("do_smiley" ) );
+// fprintf( fp,"accel_next_tab=%s\n", ptr );
+// fprintf( fp,"accel_prev_tab=%s\n", ptr );
+
+ /* modules */
+ fprintf( fp, "modules_path=%s\n", cGetLocalPref("modules_path") );
+
+ /* sound */
+ fprintf( fp, "do_no_sound_when_away=%d\n",
iGetLocalPref("do_no_sound_when_away") );
+ fprintf( fp, "do_no_sound_for_ignore=%d\n",
iGetLocalPref("do_no_sound_for_ignore") );
+ fprintf( fp, "do_online_sound=%d\n", iGetLocalPref("do_online_sound") );
+ fprintf( fp, "do_play_send=%d\n", iGetLocalPref("do_play_send") );
+ fprintf( fp, "do_play_first=%d\n", iGetLocalPref("do_play_first") );
+ fprintf( fp, "do_play_receive=%d\n", iGetLocalPref("do_play_receive") );
+ fprintf( fp, "BuddyArriveFilename=%s\n",
cGetLocalPref("BuddyArriveFilename") );
+ fprintf( fp, "BuddyAwayFilename=%s\n",
cGetLocalPref("BuddyAwayFilename"));
+ fprintf( fp, "BuddyLeaveFilename=%s\n",
cGetLocalPref("BuddyLeaveFilename") );
+ fprintf( fp, "SendFilename=%s\n", cGetLocalPref("SendFilename") );
+ fprintf( fp, "ReceiveFilename=%s\n", cGetLocalPref("ReceiveFilename") );
+ fprintf( fp, "FirstMsgFilename=%s\n", cGetLocalPref("FirstMsgFilename")
);
+ fprintf( fp, "SoundVolume=%f\n", fGetLocalPref("SoundVolume") );
+
+ /* advanced */
+ fprintf( fp, "proxy_type=%d\n", iGetLocalPref("proxy_type") );
+ fprintf( fp, "proxy_host=%s\n", cGetLocalPref("proxy_host") );
+ fprintf( fp, "proxy_port=%d\n", iGetLocalPref("proxy_port") );
+ fprintf( fp, "do_proxy_auth=%d\n", iGetLocalPref("do_proxy_auth") );
+ fprintf( fp, "proxy_user=%s\n", cGetLocalPref("proxy_user") );
+ fprintf( fp, "proxy_password=%s\n", cGetLocalPref("proxy_password") );
+
+ fprintf( fp, "use_recoding=%d\n", iGetLocalPref("use_recoding") );
+ fprintf( fp, "local_encoding=%s\n", cGetLocalPref("local_encoding") );
+ fprintf( fp, "remote_encoding=%s\n", cGetLocalPref("remote_encoding") );
+
+ fprintf( fp, "end\n" );
+ fclose( fp );
+
+ rename( buff, file );
+
+ ayttm_prefs_read();
+}
+
+void ayttm_prefs_show_window( void )
+{
+ struct prefs prefs;
+
+
+ /* general prefs */
+ prefs.general.do_login_on_startup =
iGetLocalPref("do_login_on_startup");
+ prefs.general.do_ayttm_debug = iGetLocalPref("do_ayttm_debug");
+ prefs.general.use_alternate_browser =
iGetLocalPref("use_alternate_browser");
+ strncpy( prefs.general.alternate_browser,
cGetLocalPref("alternate_browser"), MAX_PREF_LEN );
+
+ prefs.general.do_spell_checking =
iGetLocalPref("do_spell_checking");
+ strncpy( prefs.general.spell_dictionary,
cGetLocalPref("spell_dictionary"), MAX_PREF_LEN );
+
+ /* logging prefs */
+ prefs.logging.do_logging = iGetLocalPref("do_logging");
+ prefs.logging.do_restore_last_conv =
iGetLocalPref("do_restore_last_conv");
+
+ /* layout prefs */
+ prefs.layout.do_tabbed_chat = iGetLocalPref("do_tabbed_chat");
+ prefs.layout.do_tabbed_chat_orient =
iGetLocalPref("do_tabbed_chat_orient");
+
+ /* chat prefs */
+ prefs.chat.do_ignore_unknown = iGetLocalPref("do_ignore_unknown");
+ prefs.chat.font_size = iGetLocalPref("FontSize");
+ prefs.chat.do_raise_window = iGetLocalPref("do_raise_window");
+ prefs.chat.do_send_idle_time = iGetLocalPref("do_send_idle_time");
+ prefs.chat.do_ignore_fore = iGetLocalPref("do_ignore_fore");
+ prefs.chat.do_ignore_back = iGetLocalPref("do_ignore_back");
+ prefs.chat.do_ignore_font = iGetLocalPref("do_ignore_font");
+
+// gtk_accelerator_parse(cGetLocalPref("accel_next_tab"),
&(accel_next_tab.keyval), &(accel_next_tab.modifiers));
+// gtk_accelerator_parse(cGetLocalPref("accel_prev_tab"),
&(accel_prev_tab.keyval), &(accel_prev_tab.modifiers));
+
+ /* modules */
+ strncpy( prefs.module.modules_path, cGetLocalPref("modules_path"),
MAX_PREF_LEN );
+
+ /* sound prefs */
+ prefs.sound.do_no_sound_when_away =
iGetLocalPref("do_no_sound_when_away");
+ prefs.sound.do_no_sound_for_ignore=
iGetLocalPref("do_no_sound_for_ignore");
+ prefs.sound.do_online_sound = iGetLocalPref("do_online_sound");
+ prefs.sound.do_play_send = iGetLocalPref("do_play_send");
+ prefs.sound.do_play_first = iGetLocalPref("do_play_first");
+ prefs.sound.do_play_receive = iGetLocalPref("do_play_receive");
+
+ strncpy( prefs.sound.BuddyArriveFilename,
cGetLocalPref("BuddyArriveFilename"), MAX_PREF_LEN );
+ strncpy( prefs.sound.BuddyAwayFilename,
cGetLocalPref("BuddyAwayFilename"), MAX_PREF_LEN );
+ strncpy( prefs.sound.BuddyLeaveFilename,
cGetLocalPref("BuddyLeaveFilename"), MAX_PREF_LEN );
+ strncpy( prefs.sound.SendFilename, cGetLocalPref("SendFilename"),
MAX_PREF_LEN );
+ strncpy( prefs.sound.ReceiveFilename, cGetLocalPref("ReceiveFilename"),
MAX_PREF_LEN );
+ strncpy( prefs.sound.FirstMsgFilename,
cGetLocalPref("FirstMsgFilename"), MAX_PREF_LEN );
+
+ prefs.sound.SoundVolume = fGetLocalPref("SoundVolume");
+
+ /* advanced */
+ prefs.advanced.proxy_type = iGetLocalPref("proxy_type");
+ strncpy( prefs.advanced.proxy_host, cGetLocalPref("proxy_host"),
MAX_PREF_LEN );
+ prefs.advanced.proxy_port = iGetLocalPref("proxy_port");
+ prefs.advanced.do_proxy_auth = iGetLocalPref("do_proxy_auth");
+ strncpy( prefs.advanced.proxy_user, cGetLocalPref("proxy_user"),
MAX_PREF_LEN );
+ strncpy( prefs.advanced.proxy_password,
cGetLocalPref("proxy_password"), MAX_PREF_LEN );
+
+ prefs.advanced.use_recoding = iGetLocalPref("use_recoding");
+ strncpy( prefs.advanced.local_encoding,
cGetLocalPref("local_encoding"), MAX_PREF_LEN );
+ strncpy( prefs.advanced.remote_encoding,
cGetLocalPref("remote_encoding"), MAX_PREF_LEN );
+
+ prefs_window_create( prefs );
+}
+
+void ayttm_prefs_set( const struct prefs inPrefs )
+{
+ /* general */
+ iSetLocalPref( "do_login_on_startup",
inPrefs.general.do_login_on_startup );
+ iSetLocalPref( "do_ayttm_debug", inPrefs.general.do_ayttm_debug );
+ iSetLocalPref( "do_plugin_debug", inPrefs.general.do_ayttm_debug );
+ iSetLocalPref( "use_alternate_browser",
inPrefs.general.use_alternate_browser );
+ cSetLocalPref( "alternate_browser", (char
*)inPrefs.general.alternate_browser );
+
+ iSetLocalPref( "do_spell_checking", inPrefs.general.do_spell_checking );
+ cSetLocalPref( "spell_dictionary", (char
*)inPrefs.general.spell_dictionary );
+
+ /* logging */
+ iSetLocalPref( "do_logging", inPrefs.logging.do_logging );
+ iSetLocalPref( "do_restore_last_conv",
inPrefs.logging.do_restore_last_conv );
+
+ /* layout */
+ iSetLocalPref( "do_tabbed_chat", inPrefs.layout.do_tabbed_chat );
+ iSetLocalPref( "do_tabbed_chat_orient",
inPrefs.layout.do_tabbed_chat_orient );
+
+ /* chat */
+ iSetLocalPref( "do_ignore_unknown", inPrefs.chat.do_ignore_unknown );
+ iSetLocalPref( "FontSize", inPrefs.chat.font_size );
+ iSetLocalPref( "do_raise_window", inPrefs.chat.do_raise_window );
+ iSetLocalPref( "do_send_idle_time", inPrefs.chat.do_send_idle_time );
+ iSetLocalPref( "do_ignore_fore", inPrefs.chat.do_ignore_fore );
+ iSetLocalPref( "do_ignore_back", inPrefs.chat.do_ignore_back );
+ iSetLocalPref( "do_ignore_font", inPrefs.chat.do_ignore_font );
+
+// g_prefs.chat.accel_prev_tab = { GDK_Left, GDK_CONTROL_MASK };
+// g_prefs.chat.accel_next_tab = { GDK_Right, GDK_CONTROL_MASK };
+
+ /* modules */
+ cSetLocalPref( "modules_path", (char *)inPrefs.module.modules_path );
+
+ /* sound */
+ iSetLocalPref( "do_no_sound_when_away",
inPrefs.sound.do_no_sound_when_away );
+ iSetLocalPref( "do_no_sound_for_ignore",
inPrefs.sound.do_no_sound_for_ignore );
+ iSetLocalPref( "do_online_sound", inPrefs.sound.do_online_sound );
+ iSetLocalPref( "do_play_send", inPrefs.sound.do_play_send );
+ iSetLocalPref( "do_play_first", inPrefs.sound.do_play_first );
+ iSetLocalPref( "do_play_receive", inPrefs.sound.do_play_receive );
+
+ cSetLocalPref( "BuddyArriveFilename", (char
*)inPrefs.sound.BuddyArriveFilename );
+ cSetLocalPref( "BuddyAwayFilename", (char
*)inPrefs.sound.BuddyAwayFilename );
+ cSetLocalPref( "BuddyLeaveFilename", (char
*)inPrefs.sound.BuddyLeaveFilename );
+ cSetLocalPref( "SendFilename", (char *)inPrefs.sound.SendFilename );
+ cSetLocalPref( "ReceiveFilename", (char *)inPrefs.sound.ReceiveFilename
);
+ cSetLocalPref( "FirstMsgFilename", (char
*)inPrefs.sound.FirstMsgFilename );
+
+ fSetLocalPref( "SoundVolume", inPrefs.sound.SoundVolume );
+
+ /* advanced */
+ iSetLocalPref( "proxy_type", inPrefs.advanced.proxy_type );
+ cSetLocalPref( "proxy_host", (char *)inPrefs.advanced.proxy_host );
+ iSetLocalPref( "proxy_port", inPrefs.advanced.proxy_port );
+ iSetLocalPref( "do_proxy_auth", inPrefs.advanced.do_proxy_auth );
+ cSetLocalPref( "proxy_user", (char *)inPrefs.advanced.proxy_user );
+ cSetLocalPref( "proxy_password", (char
*)inPrefs.advanced.proxy_password );
+
+ iSetLocalPref( "use_recoding", inPrefs.advanced.use_recoding );
+ cSetLocalPref( "local_encoding", (char
*)inPrefs.advanced.local_encoding );
+ cSetLocalPref( "remote_encoding", (char
*)inPrefs.advanced.remote_encoding );
+
+ ayttm_prefs_write();
+
+ if ( inPrefs.advanced.proxy_type != 0 )
+ {
+ proxy_set_proxy(iGetLocalPref("proxy_type"),
cGetLocalPref("proxy_host"), iGetLocalPref("proxy_port"));
+ proxy_set_auth(iGetLocalPref("do_proxy_auth"),
cGetLocalPref("proxy_user"), cGetLocalPref("proxy_password"));
+ }
}
/* Find old pref data, and replace with new, returning old data */
-void *SetPref(char *key, void *data)
+void *SetPref( const char *key, void *data )
{
ptr_list *PrefData = NULL;
void *old_data = NULL;
- GList *ListData = g_list_find_custom(s_global_prefs, key,
compare_ptr_key);
+ LList *ListData = l_list_find_custom(s_global_prefs, key,
compare_ptr_key);
if (!ListData)
{
@@ -78,10 +544,10 @@
return(old_data);
}
-void *GetPref(char *key)
+void *GetPref(const char *key)
{
ptr_list *PrefData = NULL;
- GList *ListData = g_list_find_custom(s_global_prefs, key,
compare_ptr_key);
+ LList *ListData = l_list_find_custom(s_global_prefs, key,
compare_ptr_key);
if(!ListData)
return(NULL);
@@ -91,49 +557,49 @@
return(PrefData->value);
}
-void cSetLocalPref(char *key, char *data)
+void cSetLocalPref(const char *key, char *data)
{
char newkey[MAX_PREF_NAME_LEN];
char *oldvalue = NULL;
- g_snprintf(newkey, MAX_PREF_NAME_LEN, "Local::%s", key);
+ snprintf(newkey, MAX_PREF_NAME_LEN, "Local::%s", key);
oldvalue = SetPref(newkey, strdup(data));
if(oldvalue)
g_free(oldvalue);
return;
}
-void iSetLocalPref(char *key, int data)
+void iSetLocalPref(const char *key, int data)
{
char value[MAX_PREF_LEN];
- g_snprintf(value, MAX_PREF_LEN, "%i", data);
+ snprintf(value, MAX_PREF_LEN, "%i", data);
cSetLocalPref(key, value);
return;
}
-void fSetLocalPref(char *key, float data)
+void fSetLocalPref(const char *key, float data)
{
char value[MAX_PREF_LEN];
- g_snprintf(value, MAX_PREF_LEN, "%f", data);
+ snprintf(value, MAX_PREF_LEN, "%f", data);
cSetLocalPref(key, value);
return;
}
-char *cGetLocalPref(char *key)
+char *cGetLocalPref(const char *key)
{
char newkey[MAX_PREF_NAME_LEN];
char *value = NULL;
- g_snprintf( newkey, MAX_PREF_NAME_LEN, "Local::%s", key );
+ snprintf( newkey, MAX_PREF_NAME_LEN, "Local::%s", key );
value = (char *)GetPref(newkey);
if(!value)
value="";
return(value);
}
-float fGetLocalPref(char *key)
+float fGetLocalPref(const char *key)
{
float value = 0.0;
@@ -141,7 +607,7 @@
return(value);
}
-int iGetLocalPref(char *key)
+int iGetLocalPref(const char *key)
{
int value = 0;
@@ -157,8 +623,8 @@
char buff[buffer_size];
char *val = value_pair_get_value(pairs, "SCREEN_NAME");
- g_snprintf(buff, buffer_size, "%s:%s", service, val);
- g_free(val);
+ snprintf(buff, buffer_size, "%s:%s", service, val);
+ free(val);
SetPref(buff, pairs);
}
@@ -180,11 +646,11 @@
continue;
}
eb_debug(DBG_CORE, "Account: handle:%s service: %s\n",
oela->handle, get_service_name(oela->service_id));
- g_snprintf(buff, buffer_size, "%s:%s",
get_service_name(oela->service_id), oela->handle);
+ snprintf(buff, buffer_size, "%s:%s",
get_service_name(oela->service_id), oela->handle);
account_pairs = GetPref(buff);
nela =
eb_services[oela->service_id].sc->read_local_account_config(account_pairs);
if(!nela) {
- g_snprintf(buff2, buffer_size, _("Unable to create
account for %s.\nCheck your config file."), buff);
+ snprintf(buff2, buffer_size, _("Unable to create
account for %s.\nCheck your config file."), buff);
do_error_dialog(buff2, _("Invalid account"));
oela->service_id=get_service_id("NO SERVICE");
}
@@ -192,9 +658,9 @@
nela->service_id = oela->service_id;
node->data=nela;
//FIXME: This should probably be left to the service to
clean up, though at this point, it may not exist
- g_free(oela->handle);
- g_free(oela->protocol_local_account_data);
- g_free(oela);
+ free(oela->handle);
+ free(oela->protocol_local_account_data);
+ free(oela);
}
node = node->next;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Ayttm-commits] CVS: ayttm/src prefs.c,1.31,1.31.2.1,
Andy Maloney <address@hidden> <=
- Prev by Date:
[Ayttm-commits] CVS: ayttm/src main.c,1.24,1.24.2.1 prefs.h,1.6,1.6.2.1 prefs_window.c,1.5,1.5.2.1 prefs_window.h,1.1,1.1.2.1 status.c,1.67,1.67.2.1
- Next by Date:
Re: [Ayttm-commits] CVS: ayttm/src globals.h,1.11,1.11.2.1
- Previous by thread:
[Ayttm-commits] CVS: ayttm/src main.c,1.24,1.24.2.1 prefs.h,1.6,1.6.2.1 prefs_window.c,1.5,1.5.2.1 prefs_window.h,1.1,1.1.2.1 status.c,1.67,1.67.2.1
- Next by thread:
[Ayttm-commits] CVS: ayttm/modules/msn2/libmsn2 msn_bittybits.C,1.6,1.7 msn_core.C,1.42,1.43
- Index(es):