equal
deleted
inserted
replaced
514 |
514 |
515 postlogin(); |
515 postlogin(); |
516 } |
516 } |
517 |
517 |
518 void gotmessage(char *type, const char *from, const char *body, |
518 void gotmessage(char *type, const char *from, const char *body, |
519 const char *enc) |
519 const char *enc, time_t timestamp) |
520 { |
520 { |
521 char *jid; |
521 char *jid; |
522 char *buffer = utf8_decode(body); |
522 char *buffer = utf8_decode(body); |
523 |
523 |
524 /* |
524 /* |
529 scr_LogPrint("There is an extra part in message (resource?): %s", r); |
529 scr_LogPrint("There is an extra part in message (resource?): %s", r); |
530 //scr_LogPrint("Msg from <%s>, type=%s", jidtodisp(from), type); |
530 //scr_LogPrint("Msg from <%s>, type=%s", jidtodisp(from), type); |
531 */ |
531 */ |
532 |
532 |
533 jid = jidtodisp(from); |
533 jid = jidtodisp(from); |
534 hk_message_in(jid, 0, buffer); |
534 hk_message_in(jid, timestamp, buffer); |
535 g_free(jid); |
535 g_free(jid); |
536 free(buffer); |
536 free(buffer); |
537 } |
537 } |
538 |
538 |
539 void statehandler(jconn conn, int state) |
539 void statehandler(jconn conn, int state) |
594 |
594 |
595 switch (packet->type) { |
595 switch (packet->type) { |
596 case JPACKET_MESSAGE: |
596 case JPACKET_MESSAGE: |
597 { |
597 { |
598 char *tmp = NULL; |
598 char *tmp = NULL; |
|
599 time_t timestamp = 0; |
|
600 |
599 x = xmlnode_get_tag(packet->x, "body"); |
601 x = xmlnode_get_tag(packet->x, "body"); |
600 p = xmlnode_get_data(x); if (p) body = p; |
602 p = xmlnode_get_data(x); if (p) body = p; |
601 |
603 |
602 if ((x = xmlnode_get_tag(packet->x, "subject")) != NULL) |
604 if ((x = xmlnode_get_tag(packet->x, "subject")) != NULL) |
603 if ((p = xmlnode_get_data(x)) != NULL) { |
605 if ((p = xmlnode_get_data(x)) != NULL) { |
620 enc = p; |
622 enc = p; |
621 break; |
623 break; |
622 } |
624 } |
623 } |
625 } |
624 |
626 |
|
627 // Timestamp? |
|
628 if ((x = xmlnode_get_tag(packet->x, "x")) != NULL) { |
|
629 if ((p = xmlnode_get_attrib(x, "stamp")) != NULL) { |
|
630 struct tm tstamp; |
|
631 memset(&tstamp, 0, sizeof(tstamp)); |
|
632 if (strptime(p, "%Y%m%dT%H:%M:%S", &tstamp)) |
|
633 timestamp = mktime(&tstamp) - timezone; |
|
634 } |
|
635 } |
|
636 |
625 if (from && body) |
637 if (from && body) |
626 gotmessage(type, from, body, enc); |
638 gotmessage(type, from, body, enc, timestamp); |
627 if (tmp) |
639 if (tmp) |
628 g_free(tmp); |
640 g_free(tmp); |
629 } |
641 } |
630 break; |
642 break; |
631 |
643 |