comparison src/dialogs.c @ 7431:643cbc9a6035

[gaim-migrate @ 8036] This is good enough for CVS. This is new logging. It centers around the highly modular "GaimLogLogger," which controls how to write the log. Currently I only have the plain text logger. I wrote the beginning of an XML logger, but decided I didn't think it was that great an idea. Plugins can implement loggers themselves, so you can have, like, an SQL logger or something. The default logger writes to a file unique to the conversation, and they're saved on disk in a heirarchical fashion: ~/.gaim/logs/aim/seanegn/robflynn-date.log would be a conversation I had with Rob on date. What doesn't work: System logging The search button in the log viewer. Oh, chats probably don't log either, I didn't test. You can only log in plain text right now. Obviously, it's not done yet. But you can play around with it, and give it some love. I'll get back to it tomorrow after school, maybe. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Wed, 05 Nov 2003 06:15:49 +0000
parents fd17af0b7df1
children 357eb1c39b72
comparison
equal deleted inserted replaced
7430:783eea64614c 7431:643cbc9a6035
901 901
902 gtk_widget_show_all(b->window); 902 gtk_widget_show_all(b->window);
903 } 903 }
904 904
905 905
906 /*------------------------------------------------------------------------*/
907 /* Functions Called To Add A Log */
908 /*------------------------------------------------------------------------*/
909
910 void cancel_log(GtkWidget *widget, GaimConversation *c)
911 {
912 GaimGtkConversation *gtkconv;
913
914 gtkconv = GAIM_GTK_CONVERSATION(c);
915
916 if (gtkconv->toolbar.log) {
917 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkconv->toolbar.log),
918 FALSE);
919 }
920
921 dialogwindows = g_list_remove(dialogwindows, gtkconv->dialogs.log);
922 gtk_widget_destroy(gtkconv->dialogs.log);
923 gtkconv->dialogs.log = NULL;
924 }
925
926 void do_log(GtkWidget *w, GaimConversation *c)
927 {
928 GaimGtkConversation *gtkconv;
929 struct log_conversation *l;
930 const char *file;
931 char path[PATHSIZE];
932
933 gtkconv = GAIM_GTK_CONVERSATION(c);
934
935 if (!find_log_info(c->name)) {
936 file = gtk_file_selection_get_filename(
937 GTK_FILE_SELECTION(gtkconv->dialogs.log));
938
939 strncpy(path, file, PATHSIZE - 1);
940
941 if (gaim_gtk_check_if_dir(path, GTK_FILE_SELECTION(gtkconv->dialogs.log)))
942 return;
943
944 l = (struct log_conversation *)g_new0(struct log_conversation, 1);
945 strcpy(l->name, gaim_conversation_get_name(c));
946 strcpy(l->filename, file);
947 log_conversations = g_list_append(log_conversations, l);
948
949 if (c != NULL)
950 gaim_conversation_set_logging(c, TRUE);
951 }
952
953 cancel_log(NULL, c);
954 }
955
956 void show_log_dialog(GaimConversation *c)
957 {
958 GaimGtkConversation *gtkconv;
959 char *buf = g_malloc(BUF_LEN);
960
961 gtkconv = GAIM_GTK_CONVERSATION(c);
962
963 if (!gtkconv->dialogs.log) {
964 gtkconv->dialogs.log = gtk_file_selection_new(_("Log Conversation"));
965
966 gtk_file_selection_hide_fileop_buttons(
967 GTK_FILE_SELECTION(gtkconv->dialogs.log));
968
969 g_snprintf(buf, BUF_LEN - 1, "%s" G_DIR_SEPARATOR_S "%s.log",
970 gaim_home_dir(), gaim_normalize(c->account, c->name));
971 g_object_set_data(G_OBJECT(gtkconv->dialogs.log), "dialog_type",
972 "log dialog");
973 gtk_file_selection_set_filename(GTK_FILE_SELECTION(gtkconv->dialogs.log),
974 buf);
975 g_signal_connect(G_OBJECT(gtkconv->dialogs.log), "delete_event",
976 G_CALLBACK(delete_event_dialog), c);
977 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(gtkconv->dialogs.log)->ok_button), "clicked",
978 G_CALLBACK(do_log), c);
979 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(gtkconv->dialogs.log)->cancel_button), "clicked",
980 G_CALLBACK(cancel_log), c);
981 }
982
983 g_free(buf);
984
985 gtk_widget_show(gtkconv->dialogs.log);
986 gdk_window_raise(gtkconv->dialogs.log->window);
987 }
988
989 /*------------------------------------------------------*/ 906 /*------------------------------------------------------*/
990 /* Link Dialog */ 907 /* Link Dialog */
991 /*------------------------------------------------------*/ 908 /*------------------------------------------------------*/
992 909
993 void cancel_link(GtkWidget *widget, GaimConversation *c) 910 void cancel_link(GtkWidget *widget, GaimConversation *c)
2096 x = g_object_get_data(win, "name"); 2013 x = g_object_get_data(win, "name");
2097 if (x) 2014 if (x)
2098 g_free(x); 2015 g_free(x);
2099 } 2016 }
2100 2017
2101 void conv_show_log(GtkWidget *w, gpointer data)
2102 {
2103 char *name = g_strdup(data);
2104 show_log(name);
2105 g_free(name);
2106 }
2107
2108 void chat_show_log(GtkWidget *w, gpointer data)
2109 {
2110 char *name = g_strdup_printf("%s.chat", (char*)data);
2111 show_log(name);
2112 g_free(name);
2113 }
2114 2018
2115 static void 2019 static void
2116 url_clicked_cb(GtkWidget *widget, const char *uri) 2020 url_clicked_cb(GtkWidget *widget, const char *uri)
2117 { 2021 {
2118 gaim_notify_uri(NULL, uri); 2022 gaim_notify_uri(NULL, uri);