comparison src/protocols/jabber/jabber.c @ 3150:0097f5462ac2

[gaim-migrate @ 3166] Patches by Max Horn, Nathan Walp and Danny Colascione. Thanks, guys. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Mon, 15 Apr 2002 03:23:09 +0000
parents 1bd472b7f7a2
children fce1883cc608
comparison
equal deleted inserted replaced
3149:746a661b8bfe 3150:0097f5462ac2
892 { 892 {
893 char *to, *from, *type; 893 char *to, *from, *type;
894 struct buddy *b = NULL; 894 struct buddy *b = NULL;
895 jid who; 895 jid who;
896 char *buddy; 896 char *buddy;
897 xmlnode y; 897 xmlnode y,z;
898 char *show; 898 char *show;
899 int state = 0; 899 int state = 0;
900 GSList *resources; 900 GSList *resources;
901 char *res; 901 char *res;
902 struct conversation *cnv = NULL; 902 struct conversation *cnv = NULL;
903 struct jabber_chat *jc = NULL; 903 struct jabber_chat *jc = NULL;
904 time_t signon = time(NULL);
905
904 906
905 to = xmlnode_get_attrib(p->x, "to"); 907 to = xmlnode_get_attrib(p->x, "to");
906 from = xmlnode_get_attrib(p->x, "from"); 908 from = xmlnode_get_attrib(p->x, "from");
907 type = xmlnode_get_attrib(p->x, "type"); 909 type = xmlnode_get_attrib(p->x, "type");
910
911 z = xmlnode_get_tag(p->x, "x");
912
913 if(NSCHECK(z,NS_DELAY))
914 {
915 struct tm t;
916 char *timestamp = xmlnode_get_attrib(z,"stamp");
917 if(sscanf(timestamp,"%04d%02d%02dT%02d:%02d:%02d", &t.tm_year, &t.tm_mon, &t.tm_mday, &t.tm_hour, &t.tm_min, &t.tm_sec))
918 {
919 t.tm_year -= 1900;
920 t.tm_mon -= 1;
921 signon = mktime(&t) - timezone;
922 }
923 }
908 924
909 if ((y = xmlnode_get_tag(p->x, "show"))) { 925 if ((y = xmlnode_get_tag(p->x, "show"))) {
910 show = xmlnode_get_data(y); 926 show = xmlnode_get_data(y);
911 if (!show) { 927 if (!show) {
912 state = 0; 928 state = 0;
970 } else { 986 } else {
971 if (!resources) { 987 if (!resources) {
972 b->proto_data = g_slist_append(b->proto_data, g_strdup(res)); 988 b->proto_data = g_slist_append(b->proto_data, g_strdup(res));
973 } 989 }
974 990
975 serv_got_update(GJ_GC(gjc), buddy, 1, 0, 0, 0, state, 0); 991 serv_got_update(GJ_GC(gjc), buddy, 1, 0, b->signon ? b->signon : signon, b->idle, state, 0);
976 992
977 } 993 }
978 } else { 994 } else {
979 if (who->resource) { 995 if (who->resource) {
980 char *buf; 996 char *buf;
1131 * If the buddy's in a new group or his/her alias is changed... 1147 * If the buddy's in a new group or his/her alias is changed...
1132 */ 1148 */
1133 if(groupname && c_grp && strcmp(c_grp->name, groupname)) { 1149 if(groupname && c_grp && strcmp(c_grp->name, groupname)) {
1134 int present = b->present; /* save presence state */ 1150 int present = b->present; /* save presence state */
1135 int uc = b->uc; /* and away state (?) */ 1151 int uc = b->uc; /* and away state (?) */
1152 int idle = b->idle;
1153 int signon = b->signon;
1136 1154
1137 /* 1155 /*
1138 * seems rude, but it seems to be the only way... 1156 * seems rude, but it seems to be the only way...
1139 */ 1157 */
1140 remove_buddy(GJ_GC(gjc), c_grp, b); 1158 remove_buddy(GJ_GC(gjc), c_grp, b);
1141 b = add_buddy(GJ_GC(gjc), groupname, buddyname, 1159 b = add_buddy(GJ_GC(gjc), groupname, buddyname,
1142 name ? name : buddyname); 1160 name ? name : buddyname);
1143 do_export(GJ_GC(gjc)); 1161 do_export(GJ_GC(gjc));
1144 if(present) { 1162 if(present) {
1145 serv_got_update(GJ_GC(gjc), buddyname, 1, 0, 0, 0, uc, 0); 1163 serv_got_update(GJ_GC(gjc), buddyname, 1, 0, signon, idle, uc, 0);
1146 } 1164 }
1147 } else if(name != NULL && strcmp(b->show, name)) { 1165 } else if(name != NULL && strcmp(b->show, name)) {
1148 strncpy(b->show, name, BUDDY_ALIAS_MAXLEN); 1166 strncpy(b->show, name, BUDDY_ALIAS_MAXLEN);
1149 b->show[BUDDY_ALIAS_MAXLEN - 1] = '\0'; /* cheap safety feature */ 1167 b->show[BUDDY_ALIAS_MAXLEN - 1] = '\0'; /* cheap safety feature */
1150 handle_buddy_rename(b, buddyname); 1168 handle_buddy_rename(b, buddyname);