Permalink
Browse files

poprawki

  • Loading branch information...
darkjames
darkjames committed Oct 21, 2008
1 parent 49621b0 commit 04157522378531f3d10dc8f6dcd1b40007c3325c
Showing with 41 additions and 21 deletions.
  1. +1 −1 Makefile
  2. +17 −3 protocol.c
  3. +1 −0 protocol.h
  4. +22 −17 usg.c
@@ -12,5 +12,5 @@ dirs:
touch passwd

clean:
rm -f *.o core *~
rm -f usg *.o core *~

@@ -263,7 +263,6 @@ static int gg_notify_handler(client_t *c, void *data, uint32_t len) {

static int gg_notify_end_handler(client_t *c, void *data, uint32_t len) {
struct gg_notify *n = data;
list_t l;
int i;

printf("received notify list from %d\n", c->uin);
@@ -293,6 +292,11 @@ static int gg_notify_add_handler(client_t *c, void *data, uint32_t len) {
if (len < sizeof(struct gg_add_remove))
return -1;

if (c->state != STATE_LOGIN_OK) {
printf("gg_notify_add_handler() c->state = %d\n", c->state);
return -3;
}

printf("adding notify on %d for %d\n", ar->uin, c->uin);

if (ar->uin == 0) {
@@ -314,11 +318,21 @@ static int gg_notify_add_handler(client_t *c, void *data, uint32_t len) {
}

static int gg_notify_remove_handler(client_t *c, void *data, uint32_t len) {
struct gg_add_remove *ar = data;
struct gg_add_remove *ar = (struct gg_add_remove *) data;
list_t l;

if (len < sizeof(struct gg_add_remove))
return -1;

if (c->state != STATE_LOGIN_OK) {
printf("gg_notify_remove_handler() c->state = %d\n", c->state);
return -3;
}

printf("removing notify from %d for %d\n", c->uin, ar->uin);

/* XXX, tak samo czy moze wystepowac wiecej niz 1 numerek w pakiecie? */

for (l = c->friends; l; l = l->next) {
friend_t *f = l->data;

@@ -440,7 +454,7 @@ static const gg_handlers[] =
{ GG_NOTIFY_LAST, gg_notify_end_handler },
{ GG_LIST_EMPTY, gg_list_empty_handler },
{ GG_ADD_NOTIFY, gg_notify_add_handler }, /* ok */
{ GG_REMOVE_NOTIFY, gg_notify_remove_handler },
{ GG_REMOVE_NOTIFY, gg_notify_remove_handler }, /* ok */

/* statusy.. */
{ GG_NEW_STATUS, gg_new_status_handler },
@@ -115,6 +115,7 @@ struct gg_login70 {
#define GG_STATUS_INVISIBLE_DESCR 0x0016 /* niewidoczny z opisem (4.9) */

#define GG_STATUS_FRIENDS_MASK 0x8000 /* tylko dla znajomych (4.6) */
#define GG_STATUS_VOICE_MASK 0x20000 /* czy ma wlaczone audio (7.7) */

struct gg_new_status {
uint32_t status; /* na jaki zmieniæ? */
39 usg.c
@@ -114,18 +114,16 @@ static void gg77_status_write(client_t *ten, client_t *c) {
h.type = GG_STATUS77;
h.length = sizeof(s) + ((c->status_descr) ? strlen(c->status_descr) : 0);

memset(&s, 0, sizeof(s));

if (status == GG_STATUS_INVISIBLE)
status = GG_STATUS_NOT_AVAIL;

if (status == GG_STATUS_INVISIBLE_DESCR)
status = GG_STATUS_NOT_AVAIL_DESCR;

/* XXX, remote_ip, remote_port */

s.uin = c->uin;
s.status = status;
s.remote_ip = c->ip; /* XXX */
s.remote_port = c->port; /* XXX */
s.version = c->version;
s.image_size = c->image_size;
s.dunno1 = 0x00; /* ? */
@@ -148,22 +146,24 @@ client_t *get_client(client_t *c, int uin) {
/* je¶li nie jest po³±czony, zobacz, czy nie zostawi³ opisu */
if (!(f = find_client(uin))) {
static client_t dummy;
static char buf[100];

char fbuf[100];
FILE *fd;

memset(&dummy, 0, sizeof(dummy));

f = &dummy;
f->status = GG_STATUS_NOT_AVAIL;
f->uin = uin;
f->status = GG_STATUS_NOT_AVAIL;
f->status_descr = NULL;

snprintf(buf, sizeof(buf), "reasons/%d", uin);
snprintf(fbuf, sizeof(fbuf), "reasons/%d", uin);

if ((fd = fopen(buf, "r"))) {
if (fgets(buf, sizeof(buf), fd)) {
if ((fd = fopen(fbuf, "r"))) {
static char descr_buf[300];

if (fgets(descr_buf, sizeof(descr_buf), fd)) {
f->status = GG_STATUS_NOT_AVAIL_DESCR;
f->status_descr = buf;
f->status_descr = descr_buf;
}
fclose(fd);
}
@@ -188,28 +188,33 @@ static void gg77_notify_reply_data(client_t *ten, int uid) {
if (c->status == GG_STATUS_NOT_AVAIL_DESCR || c->status == GG_STATUS_INVISIBLE_DESCR) {
ten->status_write(ten, c);
return;

}

h.type = GG_NOTIFY_REPLY77;
h.length = sizeof(n) + ((c->status_descr) ? strlen(c->status_descr) : 0);
h.length = sizeof(n) + ((c->status_descr) ? 1+strlen(c->status_descr)+1 : 0);

n.uin = c->uin;
n.status = c->status;
n.remote_ip = c->ip;
n.remote_port = c->port;
n.image_size = c->image_size;
n.version = c->version;
n.image_size = c->image_size;
n.dunno1 = 0x00; /* ? */
n.dunno2 = c->port; /* ? */
n.dunno2 = 0x00; /* ? */

write_client(ten, &h, sizeof(h));
write_client(ten, &n, sizeof(n));
if (c->status_descr)
if (c->status_descr) {
unsigned char ile = strlen(c->status_descr);
unsigned char nul = '\0';

write_client(c, &ile, 1);
write_client(c, c->status_descr, strlen(c->status_descr));
write_client(c, &nul, 1);
}
}

static void gg77_notify_reply(client_t *c, int uid) {
client_t *a;
list_t l;

if (!uid) {

0 comments on commit 0415752

Please sign in to comment.