00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "intl.h"
00023 #include <string.h>
00024 #include <stdlib.h>
00025 #include <sys/stat.h>
00026 #include <fcntl.h>
00027
00028 #include "globals.h"
00029 #include "value_pair.h"
00030 #include "util.h"
00031
00032
00033 void write_account_list()
00034 {
00035 FILE * fp;
00036 char buff2[1024];
00037 GList * l1;
00038
00039
00040
00041
00042
00043
00044
00045
00046 g_snprintf(buff2, 1024, "%saccounts", config_dir);
00047 if(!(fp = fdopen(creat(buff2,0700),"w")))
00048 return;
00049
00050
00051 for(l1 = accounts; l1; l1=l1->next )
00052 {
00053 eb_local_account * ela = (eb_local_account*)l1->data;
00054
00055
00056
00057
00058
00059
00060
00061 GList * config = eb_services[ela->service_id].sc->write_local_config(ela);
00062 fprintf(fp, "<ACCOUNT %s>\n", eb_services[ela->service_id].name);
00063 value_pair_print_values(config, fp, 1);
00064 fprintf( fp, "</ACCOUNT>\n" );
00065 }
00066
00067 fclose(fp);
00068 }
00069
00070
00071
00072
00073
00074 void write_contact_list()
00075 {
00076 FILE * fp;
00077 char buff2[1024];
00078 GList * l1;
00079 GList * l2;
00080 GList * l3;
00081
00082
00083
00084
00085
00086
00087
00088
00089 g_snprintf(buff2, 1024, "%scontacts", config_dir);
00090 if(!(fp = fdopen(creat(buff2,0700),"w")))
00091 return;
00092
00093
00094 for(l1 = groups; l1; l1=l1->next ) {
00095 fprintf(fp,"<GROUP>\n\tNAME=\"%s\"\n", ((grouplist*)l1->data)->name);
00096 for(l2 = ((grouplist*)l1->data)->members; l2; l2=l2->next ) {
00097 struct contact * c = (struct contact*)l2->data;
00098 char *strbuf = NULL;
00099 fprintf(fp, "\t<CONTACT>\n\t\tNAME=\"%s\"\n\t\tDEFAULT_PROTOCOL=\"%s\"\n\t\tLANGUAGE=\"%s\"\n",
00100 c->nick, eb_services[c->default_chatb].name, c->language);
00101 strbuf = escape_string(c->trigger.param);
00102 fprintf(fp, "\t\tTRIGGER_TYPE=\"%s\"\n\t\tTRIGGER_ACTION=\"%s\"\n\t\tTRIGGER_PARAM=\"%s\"\n",
00103 get_trigger_type_text(c->trigger.type),
00104 get_trigger_action_text(c->trigger.action),
00105 strbuf);
00106 g_free (strbuf);
00107
00108 for(l3 = ((struct contact*)l2->data)->accounts; l3; l3=l3->next) {
00109 eb_account * account = (eb_account*)l3->data;
00110 fprintf( fp, "\t\t<ACCOUNT %s>\n\t\t\tNAME=\"%s\"\n\t\t</ACCOUNT>\n",
00111 eb_services[account->service_id].name,
00112 account->handle );
00113
00114 }
00115 fprintf( fp, "\t</CONTACT>\n" );
00116 }
00117 fprintf( fp, "</GROUP>\n" );
00118 }
00119
00120 fclose(fp);
00121 }
00122
00123
00124
00125
00126
00127
00128
00129 int load_accounts()
00130 {
00131 FILE * fp;
00132 char buff2[1024];
00133 extern int accountparse();
00134 extern FILE * accountin;
00135
00136 g_snprintf(buff2, 1024, "%saccounts",config_dir);
00137
00138 if(!(fp = fopen(buff2,"r")))
00139 return 0;
00140 accounts = NULL;
00141
00142 accountin = fp;
00143 accountparse();
00144 eb_debug(DBG_CORE, "closing fp\n");
00145 fclose(fp);
00146 return accounts != NULL;
00147 }
00148
00149
00150
00151
00152
00153
00154 int load_contacts()
00155 {
00156 FILE * fp;
00157 char buff2[1024];
00158 extern int contactparse();
00159 extern FILE * contactin;
00160
00161 g_snprintf(buff2, 1024, "%scontacts",config_dir);
00162
00163 if(!(fp = fopen(buff2,"r")))
00164 return 0;
00165 contactin = fp;
00166 groups = NULL;
00167
00168 contactparse();
00169
00170 fclose(fp);
00171 return 1;
00172 }
00173
00174