Changeset 644

Show
Ignore:
Timestamp:
07/26/05 22:00:46 (3 years ago)
Author:
jajcus
Message:

- user file format version marker
- workaround for buggy user files (wrong subscription) created by jggtrans 2.2.0
- fixed handling od pretty-formated XML files

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/users.c

    r642 r644  
    2323#include <time.h> 
    2424#include <locale.h> 
     25#include <stdlib.h> 
    2526#include "ggtrans.h" 
    2627#include "jabber.h" 
     
    155156        } 
    156157        xml=xmlnode_new_tag("user"); 
     158        tag=xmlnode_insert_tag(xml,"version"); 
     159        str=g_strdup_printf("%08x",USER_FILE_FORMAT_VERSION); 
     160        xmlnode_put_attrib(tag,"file_format",str); 
     161        g_free(str); 
    157162        tag=xmlnode_insert_tag(xml,"jid"); 
    158163        xmlnode_insert_cdata(tag,u->jid,-1); 
     
    253258char *status,*offline_status,*invisible_status; 
    254259int last_sys_msg=0,invisible=0,friends_only=0,ignore_unknown=0; 
     260unsigned int file_format_version=0; 
    255261User *u; 
    256262GList *contacts; 
     
    273279        } 
    274280        g_free(fn); 
     281        tag=xmlnode_get_tag(xml,"jid"); 
     282        if (tag!=NULL) { 
     283                p=xmlnode_get_data(tag); 
     284                if (p!=NULL) file_format_version=(unsigned int)strtol(p,NULL,16); 
     285        } 
    275286        tag=xmlnode_get_tag(xml,"jid"); 
    276287        if (tag!=NULL) ujid=xmlnode_get_data(tag); 
     
    333344 
    334345                for(t=xmlnode_get_firstchild(tag);t;t=xmlnode_get_nextsibling(t)){ 
    335                         if (!strcmp(xmlnode_get_name(t),"uin")){ 
     346                        char *node_name; 
     347                        node_name=xmlnode_get_name(t); 
     348                        if (!node_name) continue; 
     349                        if (!strcmp(node_name,"uin")){ 
    336350                                char *d; 
    337351                                int uin; 
     
    348362                                continue; 
    349363                        } 
    350                         if (!strcmp(xmlnode_get_name(t),"contact")){ 
     364                        if (!strcmp(node_name,"contact")){ 
    351365                                char *d; 
    352366                                int uin; 
     
    375389                                                        break; 
    376390                                                case 't': 
    377                                                         c->subscribe=SUB_TO; 
     391                                                        /* version 2.2.0 has a bug which causes 
     392                                                         * SUB_BOTH to be changed to SUB_TO 
     393                                                         * this will force resynchronisation with 
     394                                                         * user's roster. User will be asked for  
     395                                                         * subscription authorisation if the 
     396                                                         * subscription was really "to" 
     397                                                         */ 
     398                                                        if (file_format_version<=0x02020000) c->subscribe=SUB_UNDEFINED; 
     399                                                        else c->subscribe=SUB_TO; 
    378400                                                        break; 
    379401                                                case 'b': 
  • trunk/src/users.h

    r642 r644  
    2222 
    2323#include <libgadu.h> 
     24 
     25#define USER_FILE_FORMAT_VERSION 0x02020001U   /* first change after 2.2.0 */ 
    2426 
    2527typedef enum subscription_type_e {