Mercurial > pidgin
comparison src/log.c @ 7443:df50bd14e161
[gaim-migrate @ 8048]
whitespace
committer: Tailor Script <tailor@pidgin.im>
| author | Luke Schierer <lschiere@pidgin.im> |
|---|---|
| date | Thu, 06 Nov 2003 02:46:07 +0000 |
| parents | d42289ecf0ce |
| children | 0e7a835e2433 |
comparison
equal
deleted
inserted
replaced
| 7442:d42289ecf0ce | 7443:df50bd14e161 |
|---|---|
| 255 g_dir_close(dir); | 255 g_dir_close(dir); |
| 256 return list; | 256 return list; |
| 257 } | 257 } |
| 258 | 258 |
| 259 #if 0 /* Maybe some other time. */ | 259 #if 0 /* Maybe some other time. */ |
| 260 /**************** | 260 /**************** |
| 261 ** XML LOGGER ** | 261 ** XML LOGGER ** |
| 262 ****************/ | 262 ****************/ |
| 263 | 263 |
| 264 static const char *str_from_msg_type (GaimMessageFlags type) | 264 static const char *str_from_msg_type (GaimMessageFlags type) |
| 265 { | 265 { |
| 266 | 266 |
| 267 return ""; | 267 return ""; |
| 268 | 268 |
| 269 } | 269 } |
| 270 | 270 |
| 271 static void xml_logger_write(GaimLog *log, | 271 static void xml_logger_write(GaimLog *log, |
| 272 GaimMessageFlags type, | 272 GaimMessageFlags type, |
| 273 const char *from, time_t time, const char *message) | 273 const char *from, time_t time, const char *message) |
| 274 { | 274 { |
| 275 char date[64]; | 275 char date[64]; |
| 276 char *xhtml = NULL; | 276 char *xhtml = NULL; |
| 277 if (!log->logger_data) { | 277 if (!log->logger_data) { |
| 285 (gaim_find_prpl(gaim_account_get_protocol(log->account)))->list_icon(log->account, NULL); | 285 (gaim_find_prpl(gaim_account_get_protocol(log->account)))->list_icon(log->account, NULL); |
| 286 char *dir; | 286 char *dir; |
| 287 FILE *file; | 287 FILE *file; |
| 288 | 288 |
| 289 strftime(date, sizeof(date), "%F.%H%M%S.xml", localtime(&log->time)); | 289 strftime(date, sizeof(date), "%F.%H%M%S.xml", localtime(&log->time)); |
| 290 | 290 |
| 291 dir = g_build_filename(ud, "logs", NULL); | 291 dir = g_build_filename(ud, "logs", NULL); |
| 292 mkdir (dir, S_IRUSR | S_IWUSR | S_IXUSR); | 292 mkdir (dir, S_IRUSR | S_IWUSR | S_IXUSR); |
| 293 g_free(dir); | 293 g_free(dir); |
| 294 dir = g_build_filename(ud, "logs", | 294 dir = g_build_filename(ud, "logs", |
| 295 prpl, NULL); | 295 prpl, NULL); |
| 296 mkdir (dir, S_IRUSR | S_IWUSR | S_IXUSR); | 296 mkdir (dir, S_IRUSR | S_IWUSR | S_IXUSR); |
| 297 g_free(dir); | 297 g_free(dir); |
| 298 dir = g_build_filename(ud, "logs", | 298 dir = g_build_filename(ud, "logs", |
| 299 prpl, guy, NULL); | 299 prpl, guy, NULL); |
| 300 mkdir (dir, S_IRUSR | S_IWUSR | S_IXUSR); | 300 mkdir (dir, S_IRUSR | S_IWUSR | S_IXUSR); |
| 301 g_free(dir); | 301 g_free(dir); |
| 302 dir = g_build_filename(ud, "logs", | 302 dir = g_build_filename(ud, "logs", |
| 303 prpl, guy, gaim_normalize(log->account, log->name), NULL); | 303 prpl, guy, gaim_normalize(log->account, log->name), NULL); |
| 304 mkdir (dir, S_IRUSR | S_IWUSR | S_IXUSR); | 304 mkdir (dir, S_IRUSR | S_IWUSR | S_IXUSR); |
| 305 | 305 |
| 306 char *filename = g_build_filename(dir, date, NULL); | 306 char *filename = g_build_filename(dir, date, NULL); |
| 307 g_free(dir); | 307 g_free(dir); |
| 308 | 308 |
| 309 file = fopen(dir, "r"); | 309 file = fopen(dir, "r"); |
| 310 if(!file) | 310 if(!file) |
| 311 mkdir(dir, S_IRUSR | S_IWUSR | S_IXUSR); | 311 mkdir(dir, S_IRUSR | S_IWUSR | S_IXUSR); |
| 312 else | 312 else |
| 313 fclose(file); | 313 fclose(file); |
| 314 | 314 |
| 315 log->logger_data = fopen(filename, "a"); | 315 log->logger_data = fopen(filename, "a"); |
| 316 if (!log->logger_data) { | 316 if (!log->logger_data) { |
| 317 gaim_debug(GAIM_DEBUG_ERROR, "log", "Could not create log file %s\n", filename); | 317 gaim_debug(GAIM_DEBUG_ERROR, "log", "Could not create log file %s\n", filename); |
| 318 return; | 318 return; |
| 319 } | 319 } |
| 320 fprintf(log->logger_data, "<?xml version='1.0' encoding='UTF-8' ?>\n" | 320 fprintf(log->logger_data, "<?xml version='1.0' encoding='UTF-8' ?>\n" |
| 321 "<?xml-stylesheet href='file:///usr/src/web/htdocs/log-stylesheet.xsl' type='text/xml' ?>\n"); | 321 "<?xml-stylesheet href='file:///usr/src/web/htdocs/log-stylesheet.xsl' type='text/xml' ?>\n"); |
| 322 | 322 |
| 323 strftime(date, sizeof(date), "%F %T", localtime(&log->time)); | 323 strftime(date, sizeof(date), "%F %T", localtime(&log->time)); |
| 324 fprintf(log->logger_data, "<conversation time='%s' screenname='%s' protocol='%s'>\n", | 324 fprintf(log->logger_data, "<conversation time='%s' screenname='%s' protocol='%s'>\n", |
| 325 date, log->name, prpl); | 325 date, log->name, prpl); |
| 326 } | 326 } |
| 327 | 327 |
| 328 strftime(date, sizeof(date), "%T", localtime(&time)); | 328 strftime(date, sizeof(date), "%T", localtime(&time)); |
| 329 gaim_markup_html_to_xhtml(message, &xhtml, NULL); | 329 gaim_markup_html_to_xhtml(message, &xhtml, NULL); |
| 330 if (from) | 330 if (from) |
| 331 fprintf(log->logger_data, "<message %s %s from='%s' time='%s'>%s</message>\n", | 331 fprintf(log->logger_data, "<message %s %s from='%s' time='%s'>%s</message>\n", |
| 332 str_from_msg_type(type), | 332 str_from_msg_type(type), |
| 333 type & GAIM_MESSAGE_SEND ? "direction='sent'" : | 333 type & GAIM_MESSAGE_SEND ? "direction='sent'" : |
| 334 type & GAIM_MESSAGE_RECV ? "direction='received'" : "", | 334 type & GAIM_MESSAGE_RECV ? "direction='received'" : "", |
| 335 from, date, xhtml); | 335 from, date, xhtml); |
| 336 else | 336 else |
| 337 fprintf(log->logger_data, "<message %s %s time='%s'>%s</message>\n", | 337 fprintf(log->logger_data, "<message %s %s time='%s'>%s</message>\n", |
| 338 str_from_msg_type(type), | 338 str_from_msg_type(type), |
| 339 type & GAIM_MESSAGE_SEND ? "direction='sent'" : | 339 type & GAIM_MESSAGE_SEND ? "direction='sent'" : |
| 340 type & GAIM_MESSAGE_RECV ? "direction='received'" : "", | 340 type & GAIM_MESSAGE_RECV ? "direction='received'" : "", |
| 341 date, xhtml); | 341 date, xhtml): |
| 342 fflush(log->logger_data); | 342 fflush(log->logger_data); |
| 343 g_free(xhtml); | 343 g_free(xhtml); |
| 344 } | 344 } |
| 345 | 345 |
| 346 static void xml_logger_finalize(GaimLog *log) | 346 static void xml_logger_finalize(GaimLog *log) |
| 347 { | 347 { |
| 348 if (log->logger_data) { | 348 if (log->logger_data) { |
| 349 fprintf(log->logger_data, "</conversation>\n"); | 349 fprintf(log->logger_data, "</conversation>\n"); |
| 350 fclose(log->logger_data); | 350 fclose(log->logger_data); |
| 351 log->logger_data = NULL; | 351 log->logger_data = NULL; |
| 352 } | 352 } |
| 353 } | 353 } |
| 354 | 354 |
| 355 static GList *xml_logger_list(const char *sn, GaimAccount *account) | 355 static GList *xml_logger_list(const char *sn, GaimAccount *account) |
| 356 { | 356 { |
| 357 return log_lister_common(sn, account, ".xml", &xml_logger); | 357 return log_lister_common(sn, account, ".xml", &xml_logger); |
| 358 } | 358 } |
| 359 | 359 |
