Mercurial > pidgin
changeset 8577:599d6ac9bbfe
[gaim-migrate @ 9326]
a jabber tweak i forgot to commit
a fix for logging times wrt daylight savings time
re-fix html logging timestamp sizes, after the syslog merge
a cosmetic change to the log window
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Sun, 04 Apr 2004 18:27:45 +0000 |
parents | ddbcef747dc7 |
children | 089a3400b2aa |
files | src/gtklog.c src/gtkprefs.c src/log.c src/protocols/jabber/jutil.c src/protocols/jabber/jutil.h src/protocols/jabber/message.c src/protocols/jabber/presence.c src/util.c src/util.h |
diffstat | 9 files changed, 137 insertions(+), 133 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gtklog.c Sun Apr 04 15:08:26 2004 +0000 +++ b/src/gtklog.c Sun Apr 04 18:27:45 2004 +0000 @@ -301,15 +301,13 @@ gtk_tree_view_append_column (GTK_TREE_VIEW(lv->treeview), col); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (lv->treeview), FALSE); gtk_container_add (GTK_CONTAINER (sw), lv->treeview); - - gtk_widget_set_size_request(lv->treeview, 170, 200); populate_log_tree(lv); sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (lv->treeview)); g_signal_connect (G_OBJECT (sel), "changed", G_CALLBACK (log_select_cb), lv); - + /* Viewer ************/ vbox = gtk_vbox_new(FALSE, 6); gtk_paned_add2(GTK_PANED(pane), vbox);
--- a/src/gtkprefs.c Sun Apr 04 15:08:26 2004 +0000 +++ b/src/gtkprefs.c Sun Apr 04 18:27:45 2004 +0000 @@ -206,8 +206,16 @@ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_widget_show(label); +#if 0 /* GTK_CHECK_VERSION(2,4,0) */ + if(type == GAIM_PREF_INT) + model = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); + else if(type == GAIM_PREF_STRING) + model = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING); + dropdown = gtk_combo_box_new_with_model(model); +#else dropdown = gtk_option_menu_new(); menu = gtk_menu_new(); +#endif gtk_label_set_mnemonic_widget(GTK_LABEL(label), dropdown);
--- a/src/log.c Sun Apr 04 15:08:26 2004 +0000 +++ b/src/log.c Sun Apr 04 18:27:45 2004 +0000 @@ -307,39 +307,13 @@ return NULL; } while ((filename = g_dir_read_name(dir))) { - if (gaim_str_has_suffix(filename, ext)) { - const char *l = filename; - struct tm time; + if (gaim_str_has_suffix(filename, ext) && + strlen(filename) == 17 + strlen(ext)) { GaimLog *log; struct generic_logger_data *data; - char d[5]; - - strncpy(d, l, 4); - d[4] = '\0'; - time.tm_year = atoi(d) - 1900; - l = l + 5; - - strncpy(d, l, 2); - d[2] = '\0'; - time.tm_mon = atoi(d) - 1; - l = l + 3; + time_t stamp = gaim_str_to_time(filename, FALSE); - strncpy(d, l, 2); - time.tm_mday = atoi(d); - l = l + 3; - - strncpy(d, l, 2); - time.tm_hour = atoi(d); - l = l + 2; - - strncpy(d, l, 2); - time.tm_min = atoi(d); - l = l + 2; - - strncpy(d, l, 2); - time.tm_sec = atoi(d); - l = l + 2; - log = gaim_log_new(GAIM_LOG_IM, screenname, account, mktime(&time)); + log = gaim_log_new(GAIM_LOG_IM, screenname, account, stamp); log->logger = logger; log->logger_data = data = g_new0(struct generic_logger_data, 1); data->path = g_build_filename(path, filename, NULL); @@ -524,36 +498,36 @@ gaim_markup_html_to_xhtml(message, &msg_fixed, NULL); - if(log->type == GAIM_LOG_SYSTEM){ - strftime(date, sizeof(date), "%c", localtime(&time)); - fprintf(data->file, "---- %s @ %s ----<br/>\n", msg_fixed, date); - } else { - strftime(date, sizeof(date), "%H:%M:%S", localtime(&time)); - if (type & GAIM_MESSAGE_SYSTEM) - fprintf(data->file, "(%s)<b> %s</b><br/>\n", date, msg_fixed); - else if (type & GAIM_MESSAGE_WHISPER) - fprintf(data->file, "<font color=\"#6C2585\">(%s)<b> %s:</b></font> %s<br/>\n", - date, from, msg_fixed); - else if (type & GAIM_MESSAGE_AUTO_RESP) { - if (type & GAIM_MESSAGE_SEND) - fprintf(data->file, _("<font color=\"#16569E\">(%s) <b>%s <AUTO-REPLY>:</b></font> %s<br/>\n"), date, from, msg_fixed); - else if (type & GAIM_MESSAGE_RECV) - fprintf(data->file, _("<font color=\"#A82F2F\">(%s) <b>%s <AUTO-REPLY>:</b></font> %s<br/>\n"), date, from, msg_fixed); - } else if (type & GAIM_MESSAGE_RECV) { - if(gaim_message_meify(msg_fixed, -1)) - fprintf(data->file, "<font color=\"#6C2585\">(%s) <b>***%s</b></font> <font sml=\"%s\">%s</font><br/>\n", - date, from, gc->prpl->info->name, msg_fixed); - else - fprintf(data->file, "<font color=\"#A82F2F\">(%s) <b>%s:</b></font> <font sml=\"%s\">%s</font><br/>\n", - date, from, gc->prpl->info->name, msg_fixed); - } else if (type & GAIM_MESSAGE_SEND) { - if(gaim_message_meify(msg_fixed, -1)) - fprintf(data->file, "<font color=\"#6C2585\">(%s) <b>***%s</b></font> <font sml=\"%s\">%s</font><br/>\n", - date, from, gc->prpl->info->name, msg_fixed); - else - fprintf(data->file, "<font color=\"#16569E\">(%s) <b>%s:</b></font> <font sml=\"%s\">%s</font><br/>\n", - date, from, gc->prpl->info->name, msg_fixed); - } + if(log->type == GAIM_LOG_SYSTEM){ + strftime(date, sizeof(date), "%c", localtime(&time)); + fprintf(data->file, "---- %s @ %s ----<br/>\n", msg_fixed, date); + } else { + strftime(date, sizeof(date), "%H:%M:%S", localtime(&time)); + if (type & GAIM_MESSAGE_SYSTEM) + fprintf(data->file, "<font size=\"2\">(%s)</font><b> %s</b><br/>\n", date, msg_fixed); + else if (type & GAIM_MESSAGE_WHISPER) + fprintf(data->file, "<font color=\"#6C2585\"><font size=\"2\">(%s)</font><b> %s:</b></font> %s<br/>\n", + date, from, msg_fixed); + else if (type & GAIM_MESSAGE_AUTO_RESP) { + if (type & GAIM_MESSAGE_SEND) + fprintf(data->file, _("<font color=\"#16569E\"><font size=\"2\">(%s)</font> <b>%s <AUTO-REPLY>:</b></font> %s<br/>\n"), date, from, msg_fixed); + else if (type & GAIM_MESSAGE_RECV) + fprintf(data->file, _("<font color=\"#A82F2F\"><font size=\"2\">(%s)</font> <b>%s <AUTO-REPLY>:</b></font> %s<br/>\n"), date, from, msg_fixed); + } else if (type & GAIM_MESSAGE_RECV) { + if(gaim_message_meify(msg_fixed, -1)) + fprintf(data->file, "<font color=\"#6C2585\"><font size=\"2\">(%s)</font> <b>***%s</b></font> <font sml=\"%s\">%s</font><br/>\n", + date, from, gc->prpl->info->name, msg_fixed); + else + fprintf(data->file, "<font color=\"#A82F2F\"><font size=\"2\">(%s)</font> <b>%s:</b></font> <font sml=\"%s\">%s</font><br/>\n", + date, from, gc->prpl->info->name, msg_fixed); + } else if (type & GAIM_MESSAGE_SEND) { + if(gaim_message_meify(msg_fixed, -1)) + fprintf(data->file, "<font color=\"#6C2585\"><font size=\"2\">(%s)</font> <b>***%s</b></font> <font sml=\"%s\">%s</font><br/>\n", + date, from, gc->prpl->info->name, msg_fixed); + else + fprintf(data->file, "<font color=\"#16569E\"><font size=\"2\">(%s)</font> <b>%s:</b></font> <font sml=\"%s\">%s</font><br/>\n", + date, from, gc->prpl->info->name, msg_fixed); + } } g_free(msg_fixed);
--- a/src/protocols/jabber/jutil.c Sun Apr 04 15:08:26 2004 +0000 +++ b/src/protocols/jabber/jutil.c Sun Apr 04 18:27:45 2004 +0000 @@ -26,73 +26,6 @@ #include "presence.h" #include "jutil.h" -time_t str_to_time(const char *timestamp) -{ - struct tm t; - time_t retval = 0; - char buf[32]; - char *c; - int tzoff = 0; - - time(&retval); - localtime_r(&retval, &t); - - snprintf(buf, sizeof(buf), "%s", timestamp); - c = buf; - - /* 4 digit year */ - if(!sscanf(c, "%04d", &t.tm_year)) return 0; - c+=4; - if(*c == '-') - c++; - - t.tm_year -= 1900; - - /* 2 digit month */ - if(!sscanf(c, "%02d", &t.tm_mon)) return 0; - c+=2; - if(*c == '-') - c++; - - t.tm_mon -= 1; - - /* 2 digit day */ - if(!sscanf(c, "%02d", &t.tm_mday)) return 0; - c+=2; - if(*c == 'T') { /* we have more than a date, keep going */ - c++; /* skip the "T" */ - - /* 2 digit hour */ - if(sscanf(c, "%02d:%02d:%02d", &t.tm_hour, &t.tm_min, &t.tm_sec)) { - int tzhrs, tzmins; - c+=8; - if(*c == '.') /* dealing with precision we don't care about */ - c += 4; - - if((*c == '+' || *c == '-') && - sscanf(c+1, "%02d:%02d", &tzhrs, &tzmins)) { - tzoff = tzhrs*60*60 + tzmins*60; - if(*c == '+') - tzoff *= -1; - } - -#ifdef HAVE_TM_GMTOFF - tzoff += t.tm_gmtoff; -#else -# ifdef HAVE_TIMEZONE - tzset(); /* making sure */ - tzoff -= timezone; -# endif -#endif - } - } - retval = mktime(&t); - - retval += tzoff; - - return retval; -} - const char *jabber_get_state_string(int s) { switch(s) { case JABBER_STATE_AWAY:
--- a/src/protocols/jabber/jutil.h Sun Apr 04 15:08:26 2004 +0000 +++ b/src/protocols/jabber/jutil.h Sun Apr 04 18:27:45 2004 +0000 @@ -39,7 +39,6 @@ char *jabber_get_resource(const char *jid); char *jabber_get_bare_jid(const char *jid); -time_t str_to_time(const char *timestamp); const char *jabber_get_state_string(int state); const char *jabber_normalize(const GaimAccount *account, const char *in);
--- a/src/protocols/jabber/message.c Sun Apr 04 15:08:26 2004 +0000 +++ b/src/protocols/jabber/message.c Sun Apr 04 18:27:45 2004 +0000 @@ -304,7 +304,7 @@ } else if(xmlns && !strcmp(xmlns, "jabber:x:delay")) { const char *timestamp = xmlnode_get_attrib(child, "stamp"); if(timestamp) - jm->sent = str_to_time(timestamp); + jm->sent = gaim_str_to_time(timestamp, TRUE); } else if(xmlns && !strcmp(xmlns, "jabber:x:conference") && jm->type != JABBER_MESSAGE_GROUPCHAT_INVITE) { const char *jid = xmlnode_get_attrib(child, "jid");
--- a/src/protocols/jabber/presence.c Sun Apr 04 15:08:26 2004 +0000 +++ b/src/protocols/jabber/presence.c Sun Apr 04 18:27:45 2004 +0000 @@ -39,7 +39,12 @@ { JabberChat *chat = val; xmlnode *presence = user_data; - char *chat_full_jid = g_strdup_printf("%s@%s/%s", chat->room, chat->server, + char *chat_full_jid; + + if(!chat->conv) + return; + + chat_full_jid = g_strdup_printf("%s@%s/%s", chat->room, chat->server, chat->handle); xmlnode_set_attrib(presence, "to", chat_full_jid);
--- a/src/util.c Sun Apr 04 15:08:26 2004 +0000 +++ b/src/util.c Sun Apr 04 18:27:45 2004 +0000 @@ -427,6 +427,83 @@ return mktime(&tm); } +time_t +gaim_str_to_time(const char *timestamp, gboolean utc) +{ + struct tm t; + time_t retval = 0; + char buf[32]; + char *c; + int tzoff = 0; + + time(&retval); + localtime_r(&retval, &t); + + snprintf(buf, sizeof(buf), "%s", timestamp); + c = buf; + + /* 4 digit year */ + if(!sscanf(c, "%04d", &t.tm_year)) return 0; + c+=4; + if(*c == '-') + c++; + + t.tm_year -= 1900; + + /* 2 digit month */ + if(!sscanf(c, "%02d", &t.tm_mon)) return 0; + c+=2; + if(*c == '-') + c++; + + t.tm_mon -= 1; + + + /* 2 digit day */ + if(!sscanf(c, "%02d", &t.tm_mday)) return 0; + c+=2; + if(*c == 'T' || *c == '.') { /* we have more than a date, keep going */ + c++; /* skip the "T" */ + + /* 2 digit hour */ + if(sscanf(c, "%02d:%02d:%02d", &t.tm_hour, &t.tm_min, &t.tm_sec) == 3 || + sscanf(c, "%02d%02d%02d", &t.tm_hour, &t.tm_min, &t.tm_sec) == 3) { + int tzhrs, tzmins; + c+=8; + if(*c == '.') /* dealing with precision we don't care about */ + c += 4; + + if((*c == '+' || *c == '-') && + sscanf(c+1, "%02d:%02d", &tzhrs, &tzmins)) { + tzoff = tzhrs*60*60 + tzmins*60; + if(*c == '+') + tzoff *= -1; + } + + if(tzoff || utc) { + +#ifdef HAVE_TM_GMTOFF + tzoff += t.tm_gmtoff; +#else +# ifdef HAVE_TIMEZONE + tzset(); /* making sure */ + tzoff -= timezone; +# endif +#endif + } + } + } + + t.tm_isdst = -1; + + retval = mktime(&t); + + retval += tzoff; + + return retval; +} + + /************************************************************************** * Markup Functions
--- a/src/util.h Sun Apr 04 15:08:26 2004 +0000 +++ b/src/util.h Sun Apr 04 18:27:45 2004 +0000 @@ -183,6 +183,16 @@ time_t gaim_time_build(int year, int month, int day, int hour, int min, int sec); +/** + * Parses a timestamp in jabber or ISO8601 format and returns a time_t. + * + * @param timestamp The timestamp + * @param utc Assume UTC if no timezone specified + * + * @return A time_t. + */ +time_t gaim_str_to_time(const char *timestamp, gboolean utc); + /*@}*/