|
From: xevuz <xe...@us...> - 2007-07-12 13:54:33
|
Update of /cvsroot/chix/chix/src/lib In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv11276/src/lib Modified Files: chix.c chix_buddy.c chix_mesg.c chix_mesg.h chix_status.c Log Message: status/away fixes that introduces more bugs :) Index: chix_status.c =================================================================== RCS file: /cvsroot/chix/chix/src/lib/chix_status.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- chix_status.c 10 Jul 2007 16:46:26 -0000 1.7 +++ chix_status.c 12 Jul 2007 13:54:29 -0000 1.8 @@ -38,6 +38,7 @@ {"Away", 0}, {"Busy", 4}, {"Offline", 5}, + {"Unknown", -1}, }; static const char *_status_mood[] = Index: chix_mesg.h =================================================================== RCS file: /cvsroot/chix/chix/src/lib/chix_mesg.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- chix_mesg.h 25 Jul 2006 12:07:07 -0000 1.8 +++ chix_mesg.h 12 Jul 2007 13:54:29 -0000 1.9 @@ -61,6 +61,6 @@ int chix_mesg_instant (Chix_Client *cl, Chix_Packet *pkt); int chix_mesg_inbox (Chix_Client *cl, Chix_Packet *pkt); int chix_mesg_outbox (Chix_Client *cl, Chix_Packet *pkt); -int chix_mesg_box_new (Chix_Client *cl, Chix_Packet *pkt); +int chix_mesg_box_new (Chix_Client *cl, Chix_Packet *pkt, int type); #endif Index: chix_buddy.c =================================================================== RCS file: /cvsroot/chix/chix/src/lib/chix_buddy.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- chix_buddy.c 25 Jul 2006 12:07:07 -0000 1.21 +++ chix_buddy.c 12 Jul 2007 13:54:29 -0000 1.22 @@ -424,8 +424,6 @@ { Chix_Buddy *bud; - printf("blist_client()..........\n"); - bud = _chix_buddy_new(pkt); if (!bud) return 0; @@ -606,8 +604,11 @@ if (bud->online) { - bud->stat.away = chix_packet_get_int(pkt, KEY_STATUS_AWAY); - if (bud->stat.away > MAX_AWAY) return NULL; + int away = chix_packet_get_int(pkt, KEY_STATUS_AWAY); + if (away > MAX_AWAY) + chix_status_away_set_extern(&bud->stat, AWAY_UNKNOWN); + else + chix_status_away_set_intern(&bud->stat, away); } else bud->stat.away = AWAY_OFFLINE; bud->stat.mood = chix_packet_get_int(pkt, KEY_STATUS_MOOD); Index: chix_mesg.c =================================================================== RCS file: /cvsroot/chix/chix/src/lib/chix_mesg.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- chix_mesg.c 10 Jul 2007 16:46:26 -0000 1.14 +++ chix_mesg.c 12 Jul 2007 13:54:29 -0000 1.15 @@ -133,12 +133,6 @@ msg->time = _chix_mesg_time(chix_packet_get_ptr(pkt, KEY_MESG_TIME)); SET_TYPE(msg, MESG_TYPE); - printf("DEBUG: MESSAGE RECIEVED\n"); - printf("Time: %s\n", ctime(&msg->time)); - printf("From: %s\n", msg->buddy->alias); - printf("Mesg: %s\n", msg->mesg); - - chix_event_set(cl, msg, EVENT_MESG, 0,CHIX_FUNC_FREE(_chix_mesg_free)); return _chix_mesg_ack(cl, pkt); } @@ -153,7 +147,7 @@ box = chix_event_data_get(cl, pkt->seqn); if (!box) return 0; - msg = malloc(sizeof(Chix_Mesg)); + msg = calloc(1, sizeof(Chix_Mesg)); if (!msg) return 0; id = chix_packet_get_ptr(pkt, KEY_MESG_FROM); @@ -176,7 +170,7 @@ box = chix_event_data_get(cl, pkt->seqn); if (!box) return 0; - msg = malloc(sizeof(Chix_Mesg)); + msg = calloc(1, sizeof(Chix_Mesg)); if (!msg) return 0; id = chix_packet_get_ptr(pkt, KEY_MESG_TO); @@ -190,19 +184,23 @@ } CHIX_INTERN int -chix_mesg_box_new(Chix_Client *cl, Chix_Packet *pkt) +chix_mesg_box_new(Chix_Client *cl, Chix_Packet *pkt, int type) { Chix_Mesg_Box *box; Chix_Event *ev; - int type; + int ev_type; box = calloc(1, sizeof(Chix_Mesg_Box)); if (!box) return 0; SET_TYPE(box, MESG_BOX_TYPE); - type = chix_packet_get_int(pkt, KEY_LIST_TYPE); - ev = chix_event_set(cl, box, type, pkt->seqn, - CHIX_FUNC_FREE(_chix_mesg_box_free)); + if (type == VAL_INBOX) + ev_type = EVENT_INBOX; + else + ev_type = EVENT_OUTBOX; + + ev = chix_event_set(cl, box, ev_type, pkt->seqn, + CHIX_FUNC_FREE(_chix_mesg_box_free)); if (!ev) return 0; chix_event_freeze(ev); return 1; Index: chix.c =================================================================== RCS file: /cvsroot/chix/chix/src/lib/chix.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- chix.c 10 Jul 2007 16:46:25 -0000 1.24 +++ chix.c 12 Jul 2007 13:54:29 -0000 1.25 @@ -379,8 +379,8 @@ switch (chix_packet_get_int(pkt, KEY_LIST_TYPE)) { case VAL_BLIST: return chix_blist_new(cl, pkt); - case VAL_INBOX: return chix_mesg_box_new(cl, pkt); - case VAL_OUTBOX: return chix_mesg_box_new(cl, pkt); + case VAL_INBOX: return chix_mesg_box_new(cl, pkt, VAL_INBOX); + case VAL_OUTBOX: return chix_mesg_box_new(cl, pkt, VAL_OUTBOX); case VAL_SEARCH: return chix_info_result_new(cl, pkt); case VAL_CREDITS: return chix_clist_new(cl, pkt); default: break; @@ -440,8 +440,10 @@ * mobile phones? I dont think so. So we'll set either * Available or Offline here. */ - if (!bud->online) bud->stat.away = AWAY_OFFLINE; - else bud->stat.away = AWAY_AVAILABLE; + if (!bud->online) + chix_status_away_set_extern(&bud->stat, AWAY_OFFLINE); + else + chix_status_away_set_extern(&bud->stat, AWAY_AVAILABLE); chix_event_set(cl, bud, EVENT_BUDDY_NOTIFY, pkt->seqn, NULL); @@ -460,8 +462,8 @@ /* This get's called when the buddy changes status. */ - num = chix_packet_get_int(pkt, KEY_BUDDY_NUMBER); - bud = chix_blist_search_num(cl->blist, num); + num = chix_packet_get_int(pkt, KEY_BUDDY_NUMBER); + bud = chix_blist_search_num(cl->blist, num); type = chix_packet_get_int(pkt, KEY_STATUS_TYPE); if (type == VAL_STATUS_MOOD) |