Yattm - unified GTK instant-messaging client logo
   [Generated for version 0.2-17 - Mon Jan 6 19:01:23 GMT+1 2003]

Home - Main Page - Data Structures - File List - Data Fields - Globals

account.c File Reference

#include "intl.h"
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "globals.h"
#include "value_pair.h"
#include "util.h"

Include dependency graph for account.c:

Include dependency graph

Go to the source code of this file.

Functions

void write_account_list ()
void write_contact_list ()
int load_accounts ()
int load_contacts ()


Function Documentation

int load_accounts  
 

Definition at line 129 of file account.c.

References DBG_CORE, and eb_debug.

Referenced by main(), and ok_callback().

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 }

int load_contacts  
 

Definition at line 154 of file account.c.

Referenced by main(), and ok_callback().

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 }

void write_account_list  
 

Definition at line 33 of file account.c.

References local_account::service_id, and value_pair_print_values().

00034 {
00035     FILE * fp;
00036     char buff2[1024];
00037     GList * l1;
00038 
00039     /*
00040      * The contact list is a 3 dimensional linked list, at the top
00041      * level you have a list of groups, each group can have several
00042      * contacts, each contact can have several accounts.  Please see
00043      * the Nomenclature file in the docs directory for details
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         * This is the deal, what a protocol stores as account data is 
00057         * protocol specific, so you just query for the values you need to write
00058         * cool stuff :-)
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 }

void write_contact_list  
 

Definition at line 74 of file account.c.

References _trigger::action, contact::default_chatb, escape_string(), get_trigger_type_text(), account::handle, contact::language, contact::nick, _trigger::param, account::service_id, contact::trigger, and _trigger::type.

Referenced by add_button_callback(), add_unknown(), add_unknown_with_name(), drag_data_get(), eb_import_function(), eb_profile_function(), ignore_dialog_callback(), ok_callback(), remove_account_callback(), remove_contact_callback(), remove_group_callback(), and set_button_callback().

00075 {
00076     FILE * fp;
00077     char buff2[1024];
00078     GList * l1;
00079     GList * l2;
00080     GList * l3;
00081 
00082     /*
00083      * The contact list is a 3 dimensional linked list, at the top
00084      * level you have a list of groups, each group can have several
00085      * contacts, each contact can have several accounts.  Please see
00086      * the Nomenclature file in the docs directory for details
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 }


Contact: Andy Maloney     [Documentation generated by doxygen]