| Yattm - unified GTK instant-messaging client | ![]() |
| [Generated for version 0.2-17 - Mon Jan 6 19:01:23 GMT+1 2003] |
#include <gtk/gtk.h>#include <stdio.h>#include <time.h>#include "contact.h"#include "log_window.h"#include "service.h"Include dependency graph for chat_window.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
|
|
|
|
|
|
|
|
Definition at line 2155 of file chat_window.c. References account::account_contact, contact::chatwindow, eb_chat_window_new(), eb_restore_last_conv(), eb_update_window_title(), _chat_window::entry, find_suitable_local_account(), make_safe_filename(), NAME_MAX, contact::nick, _chat_window::notebook, _chat_window::notebook_child, _chat_window::perfered, account::service_id, set_tab_normal(), and _chat_window::window. Referenced by account_click().
02156 {
02157 struct contact * remote_contact = remote_account->account_contact;
02158 eb_local_account * account =find_suitable_local_account(NULL, remote_account->service_id);
02159
02160 if(!remote_contact->chatwindow || !remote_contact->chatwindow->window)
02161 {
02162 if(remote_contact->chatwindow)
02163 {
02164 g_free(remote_contact->chatwindow);
02165 }
02166
02167 remote_contact->chatwindow = eb_chat_window_new(account, remote_contact);
02168
02169 if(remote_contact->chatwindow)
02170 {
02171 gtk_widget_show(remote_contact->chatwindow->window);
02172 if (do_restore_last_conv)
02173 {
02174 gchar buff[NAME_MAX];
02175 make_safe_filename(buff, remote_contact->nick);
02176 eb_restore_last_conv(buff,remote_contact->chatwindow);
02177 }
02178 gdk_window_raise(remote_contact->chatwindow->window->window);
02179 gtk_window_set_focus (GTK_WINDOW
02180 (remote_contact->chatwindow->window),
02181 remote_contact->chatwindow->entry);
02182 }
02183 else /* Did they get denied because they're in the Unknown group? */
02184 return;
02185 }
02186 else if (remote_contact->chatwindow && remote_contact->chatwindow->window)
02187 {
02188 gdk_window_raise(remote_contact->chatwindow->window->window);
02189 gtk_window_set_focus (GTK_WINDOW
02190 (remote_contact->chatwindow->window),
02191 remote_contact->chatwindow->entry);
02192 }
02193
02194 eb_update_window_title(remote_contact->chatwindow, FALSE);
02195
02196 if (remote_contact->chatwindow->notebook != NULL)
02197 {
02198 int page_num = gtk_notebook_page_num(GTK_NOTEBOOK(remote_contact->chatwindow->notebook),
02199 remote_contact->chatwindow->notebook_child);
02200 /* no more icons in the tabs */
02201 /* gtk_widget_hide(remote_contact->chatwindow->talk_pixmap); */
02202 set_tab_normal(GTK_NOTEBOOK(remote_contact->chatwindow->notebook),
02203 remote_contact->chatwindow->notebook_child);
02204 gtk_notebook_set_page(GTK_NOTEBOOK(remote_contact->chatwindow->notebook),
02205 page_num);
02206
02207 } else {
02208 gdk_window_raise(remote_contact->chatwindow->window->window);
02209 gtk_window_set_focus(GTK_WINDOW(remote_contact->chatwindow->window),
02210 remote_contact->chatwindow->entry);
02211 }
02212
02213 remote_contact->chatwindow->perfered = remote_account;
02214 }
|
|
|
Definition at line 2097 of file chat_window.c. References contact::chatwindow, eb_chat_window_new(), eb_restore_last_conv(), _chat_window::entry, find_suitable_local_account(), find_suitable_remote_account(), make_safe_filename(), NAME_MAX, contact::nick, _chat_window::notebook, _chat_window::notebook_child, account::service_id, set_tab_normal(), and _chat_window::window. Referenced by console_session_get_command(), contact_click(), and pounce_contact().
02098 {
02099 eb_account *remote_account =
02100 find_suitable_remote_account (NULL, remote_contact);
02101 eb_local_account *account = NULL;
02102
02103 if (remote_account)
02104 account = find_suitable_local_account (NULL, remote_account->service_id);
02105
02106 if (!remote_contact->chatwindow || !remote_contact->chatwindow->window)
02107 {
02108 if (remote_contact->chatwindow)
02109 {
02110 g_free (remote_contact->chatwindow);
02111 }
02112
02113 remote_contact->chatwindow = eb_chat_window_new (account, remote_contact);
02114
02115 if (remote_contact->chatwindow)
02116 {
02117 gtk_widget_show (remote_contact->chatwindow->window);
02118 if (do_restore_last_conv)
02119 {
02120 gchar buff[NAME_MAX];
02121 make_safe_filename (buff, remote_contact->nick);
02122 eb_restore_last_conv (buff, remote_contact->chatwindow);
02123 }
02124 gdk_window_raise(remote_contact->chatwindow->window->window);
02125 gtk_window_set_focus (GTK_WINDOW
02126 (remote_contact->chatwindow->window),
02127 remote_contact->chatwindow->entry);
02128 }
02129
02130 } else {
02131 gdk_window_raise(remote_contact->chatwindow->window->window);
02132 gtk_window_set_focus (GTK_WINDOW
02133 (remote_contact->chatwindow->window),
02134 remote_contact->chatwindow->entry);
02135
02136 }
02137
02138 if (remote_contact->chatwindow->notebook != NULL)
02139 {
02140 int page_num =
02141 gtk_notebook_page_num (GTK_NOTEBOOK
02142 (remote_contact->chatwindow->notebook),
02143 remote_contact->chatwindow->notebook_child);
02144 /* no more icons in the tabs */
02145 /* gtk_widget_hide(remote_contact->chatwindow->talk_pixmap); */
02146
02147 set_tab_normal (GTK_NOTEBOOK (remote_contact->chatwindow->notebook),
02148 remote_contact->chatwindow->notebook_child);
02149
02150 gtk_notebook_set_page (GTK_NOTEBOOK
02151 (remote_contact->chatwindow->notebook), page_num);
02152 }
02153 }
|
|
||||||||||||
|
Definition at line 1871 of file chat_window.c. References _, account::account_contact, _chat_window::chat, contact::chatwindow, EXT_GTK_TEXT, and gtk_eb_html_add().
01872 {
01873 struct contact * remote_contact = remote->account_contact;
01874
01875 if(remote_contact->chatwindow)
01876 {
01877 gtk_eb_html_add(EXT_GTK_TEXT(remote_contact->chatwindow->chat),
01878 _("<b>Error: </b>"), 0,0,0);
01879 gtk_eb_html_add(EXT_GTK_TEXT(remote_contact->chatwindow->chat), message, 0,0,0);
01880 gtk_eb_html_add(EXT_GTK_TEXT(remote_contact->chatwindow->chat), "<br>", 0,0,0);
01881 }
01882 }
|
|
||||||||||||||||||||
|
Definition at line 1904 of file chat_window.c. References _, account::account_contact, local_account::alias, _chat_window::away_msg_sent, BUF_SIZE, _chat_window::chat, contact::chatwindow, DBG_CORE, eb_chat_window_new(), eb_debug, eb_log_message(), eb_restore_last_conv(), eb_smilify(), eb_update_window_title(), _chat_window::entry, EXT_GTK_TEXT, _chat_window::first_enabled, FIRSTMSG, _chat_window::fp, service_callbacks::get_color, service_callbacks::get_smileys, contact::group, gtk_eb_html_add(), incoming_message_filters, _chat_window::local_user, make_safe_filename(), _grouplist::name, NAME_MAX, contact::nick, _chat_window::notebook, _chat_window::notebook_child, _chat_window::perfered, play_sound(), RECEIVE, _chat_window::receive_enabled, RUN_SERVICE, service::sc, send_message(), set_tab_red(), _chat_window::sound_enabled, and _chat_window::window. Referenced by eb_parse_incomming_message().
01908 {
01909 struct contact * remote_contact = remote->account_contact;
01910 gchar buff[BUF_SIZE];
01911 gchar buff2[BUF_SIZE];
01912 struct tm * cur_time;
01913 time_t t;
01914 GList * filter_walk;
01915 gchar * message;
01916 gboolean firstmsg = FALSE; /* init to false so only play if
01917 * first msg is one received rather
01918 * than sent */
01919 #ifdef HAVE_ICONV_H
01920 /* 'BUF_SIZE*2' e.g. for 'Latin-x' to 'UTF-8',
01921 which is 1-byte to 2-byte recoding */
01922 char recode_buff[BUF_SIZE*2 + 1];
01923 #endif
01924
01925
01926 /* do we need to ignore this user? If so, do it BEFORE filters so they can't DoS us */
01927
01928 if(!strcasecmp(remote_contact->group->name, _("Ignore") ))
01929 return;
01930
01931 // Inbound filters here - Meredydd
01932 filter_walk=incoming_message_filters;
01933
01934 eb_debug(DBG_CORE, "Starting to run incoming filters\n");
01935
01936 message=strdup(o_message);
01937
01938 while(filter_walk!=NULL)
01939 {
01940 gchar * (*ofilter)(eb_local_account *, eb_account *, struct contact *, gchar *);
01941
01942 eb_debug(DBG_CORE, "Running an incoming filter\n");
01943 ofilter=(gchar *(*)(eb_local_account *, eb_account *, struct contact *, gchar *))filter_walk->data;
01944
01945 message=ofilter(account, remote, remote_contact, message);
01946 if(message==NULL) { return; } // Nothing to clean up (I think...)
01947
01948 filter_walk=g_list_next(filter_walk);
01949 }
01950
01951 eb_debug(DBG_CORE, "Finished incoming filters\n");
01952
01953 // end inbound filters
01954
01955
01956 message = eb_smilify(message, serv->sc->get_smileys());
01957
01958 if(!remote_contact->chatwindow || !remote_contact->chatwindow->window)
01959 {
01960 if(remote_contact->chatwindow)
01961 g_free(remote_contact->chatwindow);
01962
01963 remote_contact->chatwindow = eb_chat_window_new(account, remote_contact);
01964
01965 if (!remote_contact->chatwindow)
01966 /* this message is ignored */
01967 return;
01968
01969 gtk_widget_show(remote_contact->chatwindow->window);
01970 firstmsg = TRUE; /* chat window created by
01971 * receive msg, so set to true */
01972 if (do_restore_last_conv){
01973 gchar buff[NAME_MAX];
01974 make_safe_filename(buff, remote_contact->nick);
01975 eb_restore_last_conv(buff,remote_contact->chatwindow);
01976 }
01977 }
01978
01979 /*for now we will assume the identity that the person in question talked
01980 to us last as */
01981 remote_contact->chatwindow->local_user = account;
01982
01983 /*also specify that if possible, try to use the same account they used
01984 to last talk to us with */
01985 remote_contact->chatwindow->perfered = remote;
01986
01987 if (remote_contact->chatwindow->notebook != NULL) {
01988 /* no more icons in the tabs */
01989 /* gtk_widget_show(remote_contact->chatwindow->talk_pixmap); */
01990
01991 if (gtk_notebook_page_num(GTK_NOTEBOOK(remote_contact->chatwindow->notebook),
01992 remote_contact->chatwindow->notebook_child) != gtk_notebook_get_current_page(
01993 GTK_NOTEBOOK(remote_contact->chatwindow->notebook)))
01994 {
01995 set_tab_red(GTK_NOTEBOOK(remote_contact->chatwindow->notebook), remote_contact->chatwindow->notebook_child);
01996 }
01997
01998 } else {
01999 gdk_window_raise(remote_contact->chatwindow->window->window);
02000 gtk_window_set_focus(GTK_WINDOW(remote_contact->chatwindow->window),
02001 remote_contact->chatwindow->entry);
02002 }
02003
02004 eb_update_window_title(remote_contact->chatwindow, TRUE);
02005
02006 if(remote_contact->chatwindow->sound_enabled)
02007 {
02008 if (firstmsg)
02009 {
02010 if (remote_contact->chatwindow->first_enabled)
02011 {
02012 play_sound(FIRSTMSG);
02013 firstmsg = FALSE;
02014 }
02015 else
02016 {
02017 play_sound(RECEIVE);
02018 firstmsg = FALSE;
02019 }
02020 }
02021 else if (remote_contact->chatwindow->receive_enabled)
02022 play_sound(RECEIVE);
02023 }
02024
02025 /*for grab the focus*/
02026
02027 if(do_raise_window)
02028 {
02029 gdk_window_raise(remote_contact->chatwindow->window->window);
02030 // gtk_widget_grab_focus(remote_contact->chatwindow->entry);
02031 }
02032
02033 if (do_convo_timestamp)
02034 {
02035 gchar * color;
02036
02037 color=serv->sc->get_color(); // note do not free() afterwards, may be static
02038
02039 time(&t);
02040 cur_time = localtime(&t);
02041 g_snprintf(buff2, BUF_SIZE, "<FONT COLOR=\"#ff0000\">%d:%.2d:%.2d</FONT> <FONT COLOR=\"%s\">%s:</FONT>",
02042 cur_time->tm_hour, cur_time->tm_min,
02043 cur_time->tm_sec, color, remote_contact->nick);
02044 }
02045 else
02046 {
02047 g_snprintf(buff2, BUF_SIZE, "%s", remote_contact->nick);
02048 }
02049
02050 #ifdef HAVE_ICONV_H
02051 message = recode_if_needed(message, recode_buff, RECODE_TO_LOCAL);
02052 #endif
02053
02054 g_snprintf(buff, BUF_SIZE, "<B>%s </B>",buff2);
02055
02056 gtk_eb_html_add(EXT_GTK_TEXT(remote_contact->chatwindow->chat), buff,0,0,0);
02057 gtk_eb_html_add(EXT_GTK_TEXT(remote_contact->chatwindow->chat), message,do_ignore_back,do_ignore_fore,do_ignore_font);
02058 gtk_eb_html_add(EXT_GTK_TEXT(remote_contact->chatwindow->chat), "<BR>",0,0,0);
02059
02060 /* Log the message */
02061
02062 if(do_logging) eb_log_message(remote_contact->chatwindow->fp, buff, message);
02063
02064 /* If user's away and hasn't yet sent the away message in the last 5 minutes,
02065 send, display, & log his away message.
02066 We might want to give the option of whether or not to always send the message.*/
02067
02068 if(is_away && (time(NULL) - remote_contact->chatwindow->away_msg_sent) > 300)
02069 {
02070 send_message(NULL, remote_contact->chatwindow);
02071 RUN_SERVICE(account)->send_im(
02072 account,
02073 remote,
02074 gtk_entry_get_text(GTK_ENTRY(away_message)));
02075 time(&t);
02076 cur_time = localtime(&t);
02077 g_snprintf(buff, BUF_SIZE, "<FONT COLOR=\"#0000ff\"><B>%d:%.2d:%.2d %s: </B></FONT>",
02078 cur_time->tm_hour, cur_time->tm_min, cur_time->tm_sec,
02079 account->alias);
02080 gtk_eb_html_add(EXT_GTK_TEXT(remote_contact->chatwindow->chat), buff,0,0,0);
02081 gtk_eb_html_add(EXT_GTK_TEXT(remote_contact->chatwindow->chat),
02082 gtk_entry_get_text(GTK_ENTRY(away_message)),do_ignore_back,do_ignore_fore,do_ignore_font);
02083 gtk_eb_html_add(EXT_GTK_TEXT(remote_contact->chatwindow->chat), "<br>", 0,0,0);
02084
02085 /* Note that the time the last away message has been sent */
02086
02087 remote_contact->chatwindow->away_msg_sent = time(NULL);
02088
02089 /* Log it */
02090
02091 if(do_logging) eb_log_message(remote_contact->chatwindow->fp, buff,
02092 gtk_entry_get_text(GTK_ENTRY(away_message)));
02093 }
02094 free(message);
02095 }
|
|
||||||||||||
|
Definition at line 2409 of file chat_window.c. References contact::chatwindow, find_contact_by_handle(), account::handle, and _chat_window::status_label. Referenced by eb_update_status().
02411 {
02412 struct contact * remote_contact = find_contact_by_handle(remote->handle);
02413 char * tmp = NULL;
02414
02415 /* trim @.* part for User is typing */
02416 if (remote_contact == NULL || remote_contact->chatwindow == NULL) {
02417 gchar ** tmp_ct = NULL;
02418 if (strchr (remote->handle,'@') ) {
02419 tmp_ct = g_strsplit (remote->handle,"@",2);
02420 remote_contact = find_contact_by_handle(tmp_ct[0]);
02421 g_strfreev (tmp_ct);
02422 }
02423 }
02424
02425 if (remote_contact == NULL || remote_contact->chatwindow == NULL)
02426 return;
02427
02428 if (message != NULL && strlen(message) > 0)
02429 tmp = g_strdup_printf("%s", message);
02430 else
02431 tmp = g_strdup_printf(" ");
02432
02433 gtk_label_set_text( GTK_LABEL(remote_contact->chatwindow->status_label), tmp );
02434 g_free(tmp);
02435 }
|
|
||||||||||||
|
Definition at line 1884 of file chat_window.c. References _, BUF_SIZE, _chat_window::chat, contact::chatwindow, EXT_GTK_TEXT, gtk_eb_html_add(), and contact::nick. Referenced by contact_login(), and contact_logoff().
01885 {
01886 gchar buff[BUF_SIZE];
01887 time_t my_time = time(NULL);
01888 if(!c || !c->chatwindow)
01889 return;
01890
01891 if(!do_timestamp)
01892 {
01893 return;
01894 }
01895
01896 gtk_eb_html_add(EXT_GTK_TEXT(c->chatwindow->chat), "<hr>", 0,0,0);
01897 g_snprintf(buff, BUF_SIZE,_("<b>%s is logged %s @ %s.</b>"),
01898 c->nick, (online?_("in"):_("out")), g_strchomp(asctime(localtime(&my_time))));
01899 gtk_eb_html_add(EXT_GTK_TEXT(c->chatwindow->chat), buff, 0,0,0);
01900 gtk_eb_html_add(EXT_GTK_TEXT(c->chatwindow->chat), "<hr>", 0,0,0);
01901 }
|
|
||||||||||||
|
Definition at line 1320 of file chat_window.c. References _, add_unknown_callback(), _chat_window::allow_button, allow_offline_on_click(), allow_offline_on_toggle(), _chat_window::away_msg_sent, can_offline_message(), _chat_window::chat, chat_key_press(), chat_notebook_switch_callback(), chat_singleline_key_press(), close_tab_callback(), close_win(), _chat_window::contact, destroy_event(), eb_icon(), _chat_window::entry, EXT_GTK_TEXT, ext_gtk_text_new(), find_tabbed_chat_window(), _chat_window::first_enabled, _chat_window::fp, contact::group, gtk_eb_html_init(), gtkspell_attach(), gtkspell_running(), gtkspell_start(), handle_click(), handle_focus(), ignore_callback(), _chat_window::local_user, make_safe_filename(), _grouplist::name, NAME_MAX, contact::nick, _chat_window::notebook, _chat_window::notebook_child, _chat_window::perfered, _chat_window::receive_enabled, _chat_window::send_enabled, send_file(), send_message(), set_sound_on_click(), set_sound_on_toggle(), show_smileys_callback(), _chat_window::smiley_button, _chat_window::sound_button, _chat_window::sound_enabled, _chat_window::status_label, view_log_callback(), and _chat_window::window. Referenced by eb_chat_window_display_account(), eb_chat_window_display_contact(), and eb_chat_window_display_remote_message().
01321 {
01322 GtkWidget *vbox;
01323 GtkWidget *hbox;
01324 GtkWidget *scrollwindow;
01325 GtkWidget *toolbar;
01326 GtkWidget *add_button;
01327 GtkWidget *sendf_button;
01328 GtkWidget *send_button;
01329 GtkWidget *view_log_button;
01330 GtkWidget *close_button;
01331 GtkWidget *ignore_button;
01332 GtkWidget *iconwid;
01333 GdkPixmap *icon;
01334 GdkBitmap *mask;
01335 GtkAccelGroup *accel_group;
01336 GtkWidget *menu;
01337 GtkWidget *button;
01338 GtkWidget *separator;
01339 GtkWidget *resize_bar;
01340 gchar buff[NAME_MAX];
01341 chat_window *cw;
01342 chat_window *tab_cw;
01343 GtkPositionType pos;
01344 GtkWidget *contact_label;
01345
01346 if (do_ignore_unknown)
01347 {
01348 if (!strcmp(_("Unknown"), remote->group->name))
01349 return NULL;
01350 }
01351
01352 /* first we allocate room for the new chat window */
01353 cw = g_new0(chat_window,1);
01354 cw->contact = remote;
01355 cw->away_msg_sent = 0;
01356 cw->perfered = NULL;
01357 cw->local_user = NULL;
01358
01359 vbox = gtk_vbox_new(FALSE,0);
01360
01361 /* we're doing a tabbed chat */
01362 if (do_tabbed_chat) {
01363 /* look for an already open tabbed chat window */
01364 tab_cw = find_tabbed_chat_window();
01365 if (tab_cw == NULL) {
01366 /* none exists, create one */
01367 cw->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
01368 gtk_window_set_wmclass(GTK_WINDOW(cw->window), "yattm-chat", "Yattm");
01369 gtk_window_set_policy(GTK_WINDOW(cw->window), TRUE, TRUE, TRUE);
01370 gtk_widget_realize(cw->window);
01371
01372 cw->notebook = gtk_notebook_new();
01373
01374 /* Set tab orientation.... */
01375 pos = GTK_POS_BOTTOM;
01376 switch (do_tabbed_chat_orient)
01377 {
01378 case 1:
01379 pos = GTK_POS_TOP;
01380 break;;
01381
01382 case 2:
01383 pos = GTK_POS_LEFT;
01384 break;;
01385
01386 case 3:
01387 pos = GTK_POS_RIGHT;
01388 break;;
01389
01390 case 0:
01391 default:
01392 pos = GTK_POS_BOTTOM;
01393 break;;
01394 }
01395 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(cw->notebook), pos);
01396 /* End tab orientation */
01397
01398 gtk_notebook_set_scrollable(GTK_NOTEBOOK(cw->notebook), TRUE);
01399 gtk_container_add(GTK_CONTAINER(cw->window), cw->notebook);
01400
01401 /* setup a signal handler for the notebook to handle page switches */
01402 gtk_signal_connect(GTK_OBJECT(cw->notebook), "switch-page",
01403 GTK_SIGNAL_FUNC(chat_notebook_switch_callback),
01404 cw);
01405
01406
01407 gtk_widget_show(cw->notebook);
01408 } else {
01409 cw->window = tab_cw->window;
01410 cw->notebook = tab_cw->notebook;
01411 }
01412
01413 /* set up the text and close button */
01414 contact_label = gtk_label_new(remote->nick);
01415 gtk_widget_show(contact_label);
01416
01417 /* we use vbox as our child. */
01418 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
01419 cw->notebook_child = vbox;
01420 gtk_notebook_append_page(GTK_NOTEBOOK(cw->notebook), cw->notebook_child, contact_label);
01421 gtk_widget_show(cw->notebook_child);
01422 } else {
01423 /* setup like normal */
01424 cw->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
01425
01426 gtk_window_set_wmclass(GTK_WINDOW(cw->window), "yattm-chat", "Yattm");
01427 gtk_window_set_policy(GTK_WINDOW(cw->window), TRUE, TRUE, TRUE);
01428 gtk_widget_realize(cw->window);
01429
01430 cw->notebook = NULL;
01431 cw->notebook_child = NULL;
01432 gtk_container_add(GTK_CONTAINER(cw->window), vbox);
01433 gtk_widget_show(vbox);
01434 }
01435
01436 /* Next line allows making window smaller than orig. size */
01437 cw->chat = ext_gtk_text_new(NULL,NULL);
01438 gtk_eb_html_init(EXT_GTK_TEXT(cw->chat));
01439 scrollwindow = gtk_scrolled_window_new(NULL, EXT_GTK_TEXT(cw->chat)->vadj);
01440 /* gtk_widget_realize(cw->window); */
01441
01442 gtk_window_set_title(GTK_WINDOW(cw->window), remote->nick);
01443
01444 eb_icon(cw->window->window);
01445 gtk_widget_set_usize(scrollwindow, 375, 150);
01446 gtk_container_add(GTK_CONTAINER(scrollwindow), cw->chat);
01447 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwindow),
01448 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
01449 gtk_widget_show(scrollwindow);
01450
01451 /* Create the bar for resizing chat/window box */
01452
01453 /*Add stuff for multi-line*/
01454
01455 if(do_multi_line)
01456 {
01457 resize_bar = gtk_vpaned_new();
01458 gtk_paned_set_gutter_size(GTK_PANED(resize_bar), 20);
01459 gtk_paned_pack1(GTK_PANED(resize_bar), scrollwindow, TRUE, TRUE);
01460 gtk_widget_show(scrollwindow);
01461
01462 scrollwindow = gtk_scrolled_window_new(NULL, NULL);
01463 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrollwindow),
01464 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
01465
01466 cw->entry = gtk_text_new(NULL, NULL);
01467
01468 gtk_widget_set_usize(scrollwindow, 375, 50);
01469 gtk_container_add(GTK_CONTAINER(scrollwindow), cw->entry);
01470
01471 gtk_text_set_editable(GTK_TEXT(cw->entry), TRUE);
01472 gtk_text_set_word_wrap(GTK_TEXT(cw->entry), TRUE);
01473 gtk_text_set_line_wrap(GTK_TEXT(cw->entry), TRUE);
01474
01475 #ifdef HAVE_ISPELL
01476 if(do_spell_checking)
01477 {
01478 if(!gtkspell_running())
01479 {
01480 gchar *ispell_cmd[] = { "ispell", "-a", NULL };
01481 gtkspell_start(NULL, ispell_cmd);
01482 }
01483 gtkspell_attach(GTK_TEXT(cw->entry));
01484 }
01485 #endif
01486
01487 gtk_signal_connect(GTK_OBJECT(cw->entry), "key_press_event",
01488 GTK_SIGNAL_FUNC(chat_key_press),
01489 cw);
01490
01491 gtk_paned_pack2(GTK_PANED(resize_bar), scrollwindow, FALSE, FALSE);
01492 gtk_widget_show(scrollwindow);
01493 gtk_box_pack_start(GTK_BOX(vbox),resize_bar, TRUE, TRUE, 5);
01494 gtk_widget_show(resize_bar);
01495 }
01496
01497 /*Or not multi-line*/
01498
01499 else
01500 {
01501 cw->entry = gtk_entry_new();
01502 gtk_signal_connect(GTK_OBJECT(cw->entry), "key_press_event",
01503 GTK_SIGNAL_FUNC(chat_singleline_key_press),
01504 cw);
01505
01506 gtk_box_pack_start(GTK_BOX(vbox), scrollwindow, TRUE,TRUE, 5);
01507 gtk_box_pack_start(GTK_BOX(vbox), cw->entry, FALSE,FALSE, 5);
01508 }
01509
01510 gtk_container_set_border_width(GTK_CONTAINER(cw->window), do_tabbed_chat ? 2 : 5);
01511 /* gtk_container_add(GTK_CONTAINER(cw->window), vbox); */
01512
01513 gtk_signal_connect(GTK_OBJECT(cw->entry), "activate",
01514 GTK_SIGNAL_FUNC(send_message), cw);
01515
01516 gtk_signal_connect(GTK_OBJECT(vbox), "destroy",
01517 GTK_SIGNAL_FUNC(destroy_event), cw);
01518
01519 gtk_signal_connect(GTK_OBJECT(cw->chat), "button_press_event",
01520 GTK_SIGNAL_FUNC(handle_click), cw);
01521
01522 gtk_signal_connect(GTK_OBJECT(cw->window), "focus_in_event",
01523 GTK_SIGNAL_FUNC(handle_focus), cw);
01524
01525 hbox = gtk_hbox_new(FALSE, 0);
01526 gtk_widget_set_usize(hbox, 200, 25);
01527
01528 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS);
01529 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
01530 gtk_container_set_border_width(GTK_CONTAINER(toolbar), 0);
01531 gtk_toolbar_set_space_size(GTK_TOOLBAR(toolbar), 5);
01532
01533 /* Adding accelerators to windows*/
01534
01535 accel_group = gtk_accel_group_new();
01536 gtk_window_add_accel_group(GTK_WINDOW(cw->window), accel_group);
01537 menu = gtk_menu_new();
01538
01539 /* This is the same as handle_clicks, without showing the menu for
01540 accelerators to hopefully work better now.
01541 */
01542
01543 /*Add Contact Selection*/
01544
01545 if(!strcmp(cw->contact->group->name, _("Unknown")))
01546 {
01547 button = gtk_menu_item_new_with_label(_("Add Contact"));
01548 gtk_signal_connect(GTK_OBJECT(button), "activate",
01549 GTK_SIGNAL_FUNC(add_unknown_callback),
01550 cw);
01551 gtk_menu_append(GTK_MENU(menu), button);
01552 }
01553
01554 /*Allow Offline Messaging Selection*/
01555
01556 if(can_offline_message(cw->contact))
01557 {
01558 button = gtk_menu_item_new_with_label(_("Offline Messaging"));
01559 gtk_signal_connect(GTK_OBJECT(button), "activate",
01560 GTK_SIGNAL_FUNC(allow_offline_on_click),
01561 cw);
01562 gtk_widget_add_accelerator(button, "activate", accel_group,
01563 GDK_o, GDK_CONTROL_MASK,
01564 GTK_ACCEL_VISIBLE);
01565 gtk_menu_append(GTK_MENU(menu), button);
01566 }
01567
01568 /*Sound Selection*/
01569
01570 if (cw->sound_enabled)
01571 {
01572 button = gtk_menu_item_new_with_label(_("Disable Sounds"));
01573 }
01574 else
01575 {
01576 button = gtk_menu_item_new_with_label(_("Enable Sounds"));
01577 }
01578
01579 gtk_signal_connect(GTK_OBJECT(button), "activate",
01580 GTK_SIGNAL_FUNC(set_sound_on_click),
01581 cw);
01582 gtk_widget_add_accelerator(button, "activate", accel_group,
01583 GDK_s, GDK_CONTROL_MASK,
01584 GTK_ACCEL_VISIBLE);
01585 gtk_menu_append(GTK_MENU(menu), button);
01586
01587 /* Ignore button section */
01588
01589 button = gtk_menu_item_new_with_label(_("Ignore Contact"));
01590 gtk_signal_connect(GTK_OBJECT(button), "activate",
01591 GTK_SIGNAL_FUNC(ignore_callback), cw);
01592 gtk_widget_add_accelerator(button, "activate", accel_group,
01593 GDK_g, GDK_CONTROL_MASK,
01594 GTK_ACCEL_VISIBLE);
01595 gtk_menu_append(GTK_MENU(menu), button);
01596
01597 /*Send File Selection*/
01598
01599 button = gtk_menu_item_new_with_label(_("Send File"));
01600 gtk_signal_connect(GTK_OBJECT(button), "activate",
01601 GTK_SIGNAL_FUNC(send_file),
01602 cw);
01603 gtk_widget_add_accelerator(button, "activate", accel_group,
01604 GDK_t, GDK_CONTROL_MASK,
01605 GTK_ACCEL_VISIBLE);
01606 gtk_menu_append(GTK_MENU(menu), button);
01607
01608 /*Send Selection*/
01609
01610 button = gtk_menu_item_new_with_label(_("Send Message"));
01611 gtk_signal_connect(GTK_OBJECT(button), "activate",
01612 GTK_SIGNAL_FUNC(send_message),
01613 cw);
01614 gtk_widget_add_accelerator(button, "activate", accel_group,
01615 GDK_r, GDK_CONTROL_MASK,
01616 GTK_ACCEL_VISIBLE);
01617 gtk_menu_append(GTK_MENU(menu), button);
01618
01619 /*** MIZHI
01620 * view log file selection
01621 */
01622
01623 button = gtk_menu_item_new_with_label(_("View log"));
01624 gtk_signal_connect(GTK_OBJECT(button), "activate",
01625 GTK_SIGNAL_FUNC(view_log_callback),
01626 cw);
01627 gtk_widget_add_accelerator(button, "activate", accel_group,
01628 GDK_l, GDK_CONTROL_MASK,
01629 GTK_ACCEL_VISIBLE);
01630 gtk_menu_append(GTK_MENU(menu), button);
01631
01632 /*Close Selection*/
01633
01634 button = gtk_menu_item_new_with_label(_("Close"));
01635
01636 gtk_signal_connect(GTK_OBJECT(button), "activate",
01637 GTK_SIGNAL_FUNC(close_win),
01638 cw);
01639
01640 gtk_widget_add_accelerator(button, "activate", accel_group,
01641 GDK_q, GDK_CONTROL_MASK,
01642 GTK_ACCEL_VISIBLE);
01643 gtk_menu_append(GTK_MENU(menu), button);
01644
01645 /*This is we decide whether or not the add button should be displayed*/
01646
01647 if (!strcmp(cw->contact->group->name, _("Unknown")))
01648 {
01649 /*This is the add button*/
01650 icon = gdk_pixmap_create_from_xpm_d(cw->window->window, &mask, NULL, tb_book_red_xpm);
01651 iconwid = gtk_pixmap_new(icon , mask);
01652 gtk_widget_show(iconwid);
01653 add_button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
01654 _("Add"),
01655 _("Add Contact"),
01656 _("Add"),
01657 iconwid,
01658 GTK_SIGNAL_FUNC(add_unknown_callback),
01659 cw);
01660 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
01661 }
01662
01663 /*Decide whether the offline messaging button should be displayed*/
01664
01665 if(can_offline_message(remote))
01666 {
01667 icon = gdk_pixmap_create_from_xpm_d(cw->window->window, &mask, NULL, tb_edit_xpm);
01668 iconwid = gtk_pixmap_new(icon , mask);
01669 gtk_widget_show(iconwid);
01670 cw->allow_button = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
01671 GTK_TOOLBAR_CHILD_TOGGLEBUTTON,
01672 NULL,
01673 _("Allow"),
01674 _("Allow Offline Messaging CTRL+O"),
01675 _("Allow"),
01676 iconwid,
01677 GTK_SIGNAL_FUNC(allow_offline_on_toggle),
01678 cw);
01679 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
01680 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(cw->allow_button), FALSE);
01681 }
01682
01683 /* smileys */
01684 if(do_smiley == 1) {
01685 icon = gdk_pixmap_create_from_xpm_d(cw->window->window, &mask, NULL, smiley_button_xpm);
01686 iconwid = gtk_pixmap_new(icon, mask);
01687 gtk_widget_show(iconwid);
01688 cw->smiley_button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
01689 _("Smiley"),
01690 _("Insert Smiley"),
01691 _("Smiley"),
01692 iconwid,
01693 GTK_SIGNAL_FUNC(show_smileys_callback),
01694 cw);
01695 /*Create the separator for the toolbar*/
01696
01697 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
01698 separator = gtk_vseparator_new();
01699 gtk_widget_set_usize(GTK_WIDGET(separator), 0, 20);
01700 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), separator, NULL, NULL);
01701 gtk_widget_show(separator);
01702 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
01703 }
01704 /*This is the sound toggle button*/
01705
01706 icon = gdk_pixmap_create_from_xpm_d(cw->window->window, &mask, NULL, tb_volume_xpm);
01707 iconwid = gtk_pixmap_new(icon, mask);
01708 gtk_widget_show(iconwid);
01709 cw->sound_button = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
01710 GTK_TOOLBAR_CHILD_TOGGLEBUTTON,
01711 NULL,
01712 _("Sound"),
01713 _("Enable Sounds CTRL+S"),
01714 _("Sound"),
01715 iconwid,
01716 GTK_SIGNAL_FUNC(set_sound_on_toggle),
01717 cw);
01718 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
01719
01720 /*Toggle the sound button based on preferences*/
01721
01722 if (do_play_send)
01723 cw->send_enabled=TRUE;
01724
01725 if (do_play_receive)
01726 cw->receive_enabled = TRUE;
01727
01728 if (do_play_first)
01729 cw->first_enabled = TRUE;
01730
01731 if (do_play_send + do_play_receive + do_play_first > 0)
01732 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(cw->sound_button), TRUE);
01733 else
01734 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(cw->sound_button), FALSE);
01735
01736 /*Create the separator for the toolbar*/
01737
01738 separator = gtk_vseparator_new();
01739 gtk_widget_set_usize(GTK_WIDGET(separator), 0, 20);
01740 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), separator, NULL, NULL);
01741 gtk_widget_show(separator);
01742 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
01743
01744 /*** MIZHI
01745 * create the button for the log viewing functions
01746 */
01747
01748 icon = gdk_pixmap_create_from_xpm_d(cw->window->window, &mask, NULL, tb_search_xpm);
01749 iconwid = gtk_pixmap_new(icon, mask);
01750 gtk_widget_show(iconwid);
01751 view_log_button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
01752 "View",
01753 _("View Log CTRL+L"),
01754 "View",
01755 iconwid,
01756 GTK_SIGNAL_FUNC(view_log_callback),
01757 cw);
01758 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
01759
01760 /*This is the send file button*/
01761
01762 icon = gdk_pixmap_create_from_xpm_d(cw->window->window, &mask, NULL, tb_open_xpm);
01763 iconwid = gtk_pixmap_new(icon, mask);
01764 gtk_widget_show(iconwid);
01765 sendf_button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
01766 "sendf",
01767 _("Send File CTRL+T"),
01768 "sendf",
01769 iconwid,
01770 GTK_SIGNAL_FUNC(send_file),
01771 cw);
01772 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
01773
01774 /*This is the ignore button*/
01775
01776 icon = gdk_pixmap_create_from_xpm_d(cw->window->window, &mask, NULL, tb_no_xpm);
01777 iconwid = gtk_pixmap_new(icon, mask);
01778 gtk_widget_show(iconwid);
01779 ignore_button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
01780 "ignore",
01781 _("Ignore CTRL+G"),
01782 "ignore",
01783 iconwid,
01784 GTK_SIGNAL_FUNC(ignore_callback),
01785 cw);
01786 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
01787
01788 /*This is the send button*/
01789
01790 icon = gdk_pixmap_create_from_xpm_d(cw->window->window, &mask, NULL, tb_mail_send_xpm);
01791 iconwid = gtk_pixmap_new(icon, mask);
01792 gtk_widget_show(iconwid);
01793 send_button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
01794 "send",
01795 _("Send Message CTRL+R"),
01796 "send",
01797 iconwid,
01798 GTK_SIGNAL_FUNC(send_message),
01799 cw);
01800 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
01801
01802 /* Vertical separator */
01803
01804 separator = gtk_vseparator_new();
01805 gtk_widget_set_usize(GTK_WIDGET(separator), 0, 20);
01806 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), separator, NULL, NULL);
01807 gtk_widget_show(separator);
01808 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
01809
01810 /*This is the close button*/
01811
01812 icon = gdk_pixmap_create_from_xpm_d(cw->window->window, &mask, NULL, cancel_xpm);
01813 iconwid = gtk_pixmap_new(icon, mask);
01814 gtk_widget_show(iconwid);
01815
01816 if (do_tabbed_chat)
01817 {
01818 close_button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
01819 "close",
01820 _("Close CTRL+Q"),
01821 "close",
01822 iconwid,
01823 GTK_SIGNAL_FUNC(close_tab_callback),
01824 cw);
01825 } else {
01826
01827 close_button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
01828 "close",
01829 _("Close CTRL+Q"),
01830 "close",
01831 iconwid,
01832 GTK_SIGNAL_FUNC(close_win),
01833 cw);
01834 }
01835
01836 cw->status_label = gtk_label_new(" ");
01837 gtk_box_pack_start(GTK_BOX(hbox), cw->status_label, FALSE, FALSE, 0);
01838 gtk_widget_show(cw->status_label);
01839
01840 gtk_box_pack_end(GTK_BOX(hbox), toolbar, FALSE, FALSE, 0);
01841 gtk_widget_show(toolbar);
01842
01843 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
01844 gtk_widget_show(hbox);
01845
01846 make_safe_filename(buff, remote->nick);
01847
01848 if ((cw->fp = fopen(buff, "a")) == NULL)
01849 {
01850 perror(buff);
01851 do_logging=0;
01852 }
01853
01854 if(do_logging)
01855 {
01856 time_t my_time = time(NULL);
01857 fprintf(cw->fp, _("%sConversation started on %s %s\n"),
01858 (do_strip_html ? "" : "<HR WIDTH=\"100%%\"><P ALIGN=\"CENTER\"><B>"),
01859 g_strchomp(asctime(localtime(&my_time))), (do_strip_html?"":"</B></P>"));
01860 fflush(cw->fp);
01861 }
01862
01863 gtk_widget_show(cw->chat);
01864 gtk_widget_show(cw->entry);
01865 /* gtk_widget_show(vbox);
01866 gtk_widget_show(cw->notebook); */
01867
01868 return cw;
01869 }
|
|
||||||||||||||||
|
Definition at line 2227 of file chat_window.c. References strip_html(). Referenced by eb_chat_window_display_remote_message(), eb_log_status_changed(), and send_message().
02228 {
02229 gchar * my_name = strdup(buff);
02230 gchar * my_message = strdup(message);
02231
02232 /* Get rid of the HTML if the user doesn't want it */
02233
02234 if(do_strip_html)
02235 {
02236 strip_html(my_message);
02237 strip_html(my_name);
02238 }
02239
02240 /* Log the message, using the appropriate formatting */
02241
02242 fprintf(log_file, "%s %s %s %s\n",
02243 (do_strip_html ? "" : "<P>"), my_name, my_message, (do_strip_html ? "" : "</P>"));
02244 fflush(log_file);
02245
02246 free(my_message);
02247 free(my_name);
02248 }
|
|
||||||||||||
|
Definition at line 2216 of file chat_window.c. References account::account_contact, contact::chatwindow, eb_log_message(), _chat_window::fp, and account::handle. Referenced by buddy_update_status_and_log().
02217 {
02218 if(ea == NULL || ea->account_contact == NULL ||
02219 ea->account_contact->chatwindow == NULL ||
02220 ea->account_contact->chatwindow->fp == NULL)
02221 return;
02222
02223 eb_log_message(ea->account_contact->chatwindow->fp, ea->handle,
02224 ((status && status[0])?status:"Available"));
02225 }
|
|
||||||||||||
|
Definition at line 2250 of file chat_window.c. References _, BUF_SIZE, _chat_window::chat, _chat_window::contact, EXT_GTK_TEXT, gtk_eb_html_add(), contact::nick, and strip_html(). Referenced by eb_chat_window_display_account(), eb_chat_window_display_contact(), and eb_chat_window_display_remote_message().
02251 {
02252 FILE * fp;
02253 gchar buff[1024];
02254 gchar buff2[1024];
02255 gchar *buff3;
02256 gchar color[8];
02257 gchar name[512];
02258 gchar *token;
02259 long location = -1;
02260 long lastlocation = -1;
02261 long beforeget;
02262
02263 if ( (fp = fopen(file_name, "r")) == NULL)
02264 {
02265 //there must not be a list logfile...
02266 return;
02267 }
02268
02269
02270 /*find last conversation */
02271 while(!feof(fp))
02272 {
02273 beforeget = ftell(fp);
02274 fgets(buff, 1024, fp);
02275 if(feof(fp))
02276 {
02277 break;
02278 }
02279 g_strchomp(buff);
02280 if(!strncmp(buff,_("Conversation started"),strlen(_("Conversation started")))
02281 || !strncmp(buff,_("<HR WIDTH=\"100%\"><P ALIGN=\"CENTER\"><B>Conversation started"),strlen(_("<HR WIDTH=\"100%\"><P ALIGN=\"CENTER\"><B>Conversation started"))))
02282 {
02283 lastlocation = location;
02284 location = beforeget;
02285 }
02286 }
02287
02288 if(lastlocation == -1)
02289 {
02290 if(location == -1 || location == 0)
02291 {
02292 fclose(fp);
02293 return;
02294 }
02295 lastlocation = location;
02296 }
02297 fseek(fp,lastlocation, SEEK_SET);
02298
02299 /* now we display the log */
02300 while(!feof(fp))
02301 {
02302 fgets(buff,1024,fp);
02303 if(feof(fp))
02304 {
02305 break;
02306 }
02307 g_strchomp(buff);
02308
02309 if(buff[0] == '<') /*this is html*/
02310 {
02311
02312 if(!strncmp(buff,"<HR WIDTH=\"100%\">",
02313 strlen("<HR WIDTH=\"100%\">")))
02314 {
02315 gtk_eb_html_add(EXT_GTK_TEXT(cw->chat), buff+strlen("<HR WIDTH=\"100%\">"),0,0,0);
02316 }
02317 else
02318 {
02319 gtk_eb_html_add(EXT_GTK_TEXT(cw->chat), buff, 0,0,0);
02320 }
02321
02322
02323 gtk_eb_html_add(EXT_GTK_TEXT(cw->chat), "<br>",0,0,0);
02324
02325 if(strlen(buff) > 34 && !strncmp(buff+34,_("ended on"),8))
02326 {
02327 break;
02328 }
02329 }
02330 else if(!strncmp(buff,_("Conversation started"),strlen(_("Conversation started"))))
02331 {
02332 gtk_eb_html_add(EXT_GTK_TEXT(cw->chat), "<hr>", 0,0,0);
02333 gtk_eb_html_add(EXT_GTK_TEXT(cw->chat), buff, 0,0,0);
02334 gtk_eb_html_add(EXT_GTK_TEXT(cw->chat), "<br>",0,0,0);
02335
02336 }
02337 else if(!strncmp(buff,_("Conversation ended"),strlen(_("Conversation ended"))))
02338 {
02339
02340 gtk_eb_html_add(EXT_GTK_TEXT(cw->chat), buff,0,0,0);
02341 gtk_eb_html_add(EXT_GTK_TEXT(cw->chat), "<br>",0,0,0);
02342 gtk_eb_html_add(EXT_GTK_TEXT(cw->chat), "<hr>",0,0,0);
02343 break;
02344 }
02345 else
02346 {
02347 strip_html(buff); /*better safe than sorry */
02348 strcpy(buff2, buff);
02349
02350 token = strtok(buff2,":");
02351
02352 if(token && (strcmp(buff,token) != 0))
02353 {
02354 /* not happy with this if statement at all! */
02355 if(((strlen(token)==3)&&isdigit((int)token[1])&&isdigit(token[2]))
02356 || ((strlen(token)==2) && isdigit((int)token[1])))
02357 {
02358 /* we must have time stamps */
02359 /* allready have hours */
02360 token = strtok(NULL,":"); /*minutes*/
02361 if(token == NULL) /* we were wrong, this isn't a time stamp */
02362 {
02363 break; /* need to test this */
02364 }
02365 token = strtok(NULL,":"); /*seconds + name*/
02366
02367 if(token == NULL) /* we were wrong, this isn't a time stamp */
02368 break; /* need to test this */
02369 buff3 = token + strlen(token)+1; /* should be the end
02370 of the screen name */
02371 token+=3;
02372 }
02373 else
02374 {
02375 /* no time stamps */
02376 buff3 = buff2+strlen(token)+1;
02377 token++;
02378 }
02379 if( !strncmp(token,cw->contact->nick,strlen(cw->contact->nick)))
02380 {
02381 /* this is the other person */
02382
02383 strcpy(color,"#ff0000");
02384 }
02385 else
02386 {
02387 /* must be me */
02388 strcpy(color,"#0000ff");
02389 }
02390 strncpy(name,buff,buff3-buff2);
02391 name[buff3-buff2] = '\0';
02392 g_snprintf(buff, BUF_SIZE, "<FONT COLOR=\"%s\"><B>%s </B></FONT>",color, name);
02393 gtk_eb_html_add(EXT_GTK_TEXT(cw->chat), buff,0,0,0);
02394 gtk_eb_html_add(EXT_GTK_TEXT(cw->chat), buff3,0,0,0);
02395 gtk_eb_html_add(EXT_GTK_TEXT(cw->chat), "<br>",0,0,0);
02396 }
02397 else
02398 {
02399 /* hmm, no ':' must be a non start/blank line */
02400 gtk_eb_html_add(EXT_GTK_TEXT(cw->chat),buff2,0,0,0);
02401 gtk_eb_html_add(EXT_GTK_TEXT(cw->chat), "<br>",0,0,0);
02402 }
02403 }
02404 }
02405 fclose(fp);
02406
02407 }
|
|
||||||||||||
|
Definition at line 395 of file chat_window.c. References local_account::alias, _chat_window::away_msg_sent, BUF_SIZE, can_offline_message(), _chat_window::chat, local_account::connected, _chat_window::contact, convert_eol(), DBG_CORE, eb_debug, eb_log_message(), eb_smilify(), eb_update_window_title(), _chat_window::entry, EXT_GTK_TEXT, find_suitable_local_account(), find_suitable_remote_account(), _chat_window::fp, GET_CHAT_WINDOW, gtk_eb_html_add(), _chat_window::hist_pos, _chat_window::history, linkify(), _chat_window::local_user, _chat_window::notebook, _chat_window::notebook_child, outgoing_message_filters, _chat_window::perfered, play_sound(), RUN_SERVICE, SEND, _chat_window::send_enabled, contact::send_offline, serv_touch_idle(), account::service_id, local_account::service_id, set_tab_normal(), _chat_window::sound_enabled, and _chat_window::this_msg_in_history. Referenced by chat_key_press(), console_session_get_command(), eb_chat_window_display_remote_message(), eb_chat_window_new(), handle_click(), and pounce_contact().
00396 {
00397 chat_window * data = (chat_window*)d;
00398 gchar buff[BUF_SIZE];
00399 gchar buff2[BUF_SIZE];
00400 gchar * text, *o_text;
00401 gchar * link_message;
00402 gchar * temp_message;
00403 struct tm * cur_time;
00404 time_t t;
00405
00406 GList * filter_walk;
00407
00408 #ifdef HAVE_ICONV_H
00409 /* 'BUF_SIZE*2' e.g. for 'Latin-x' to 'UTF-8',
00410 which is 1-byte to 2-byte recoding */
00411 char recode_buff[BUF_SIZE*2 + 1];
00412 #endif
00413 GET_CHAT_WINDOW(data);
00414
00415 /*determine what is the best account to send to*/
00416 data->perfered= find_suitable_remote_account(data->perfered, data->contact);
00417
00418
00419 if(!data->perfered)
00420 {
00421 /*Eventually this will need to become a dialog box that pops up*/
00422
00423 if(data->contact->send_offline && can_offline_message(data->contact))
00424 {
00425 data->perfered = can_offline_message(data->contact);
00426 }
00427 else
00428 {
00429 gtk_eb_html_add(EXT_GTK_TEXT(data->chat), "<hr>", 0,0,0);
00430 gtk_eb_html_add(EXT_GTK_TEXT(data->chat), "<b>Cannot send message - user is offline.</b>", 0, 0, 0);
00431 gtk_eb_html_add(EXT_GTK_TEXT(data->chat), "<hr>", 0,0,0);
00432 return;
00433 }
00434 }
00435
00436 if(data->local_user && data->local_user->service_id != data->perfered->service_id)
00437 {
00438 data->local_user = NULL;
00439 }
00440
00441 if(data->local_user && !data->local_user->connected)
00442 {
00443 data->local_user = NULL;
00444 }
00445
00446 /*determine what is the best local account to use*/
00447
00448 if(!data->local_user)
00449 {
00450 data->local_user =
00451 find_suitable_local_account(data->local_user, data->perfered->service_id);
00452 }
00453
00454 if(!data->local_user) {
00455 return;
00456 }
00457
00458 eb_update_window_title(data, FALSE);
00459
00460 text = gtk_editable_get_chars(GTK_EDITABLE (data->entry), 0, -1);
00461
00462 if(strlen(text) == 0)
00463 return;
00464
00465 if(data->this_msg_in_history)
00466 {
00467 GList * node=NULL;
00468 GList * node2=NULL;
00469
00470 for(node=data->history; node!=NULL ; node=node->next)
00471 {
00472 node2=node;
00473 }
00474 free(node2->data);
00475 node2->data=strdup(text);
00476 data->this_msg_in_history=0;
00477 } else {
00478 data->history=g_list_append(data->history, strdup(text));
00479 data->hist_pos=NULL;
00480 }
00481
00482 temp_message = eb_smilify(strdup(text), RUN_SERVICE(data->local_user)->get_smileys());
00483 link_message = linkify(temp_message);
00484 g_free(temp_message);
00485
00486 eb_update_window_title(data, FALSE);
00487
00488 // Outbound filters here - Meredydd
00489 filter_walk=outgoing_message_filters;
00490
00491 eb_debug(DBG_CORE, "Starting to run outgoing filters\n");
00492
00493 while(filter_walk!=NULL)
00494 {
00495 gchar * (*ifilter)(eb_local_account *, eb_account *, struct contact *, gchar *);
00496
00497 eb_debug(DBG_CORE, "Running an outgoing filter\n");
00498
00499 ifilter=(gchar *(*)(eb_local_account *, eb_account *, struct contact *, gchar *))filter_walk->data;
00500
00501 text=ifilter(data->local_user, data->perfered, data->contact, text);
00502
00503 if(text==NULL) { return; } // Urgh, no cleanup, but it does it on strlen(text)==0 too
00504
00505 filter_walk=g_list_next(filter_walk);
00506 }
00507
00508 eb_debug(DBG_CORE, "Finished outgoing filters\n");
00509
00510 // end outbound filters
00511
00512 o_text = text;
00513 text = convert_eol(text);
00514 g_free(o_text);
00515
00516 #ifdef HAVE_ICONV_H
00517 if(!eb_services[data->perfered->service_id].can_iconvert)
00518 {
00519 RUN_SERVICE(data->local_user)->send_im(
00520 data->local_user,
00521 data->perfered,
00522 text);
00523 }
00524 else
00525 {
00526 RUN_SERVICE(data->local_user)->send_im(
00527 data->local_user,
00528 data->perfered,
00529 recode_if_needed(text, recode_buff, RECODE_TO_REMOTE) );
00530 }
00531 /* seems like variable 'text' is not used any more down
00532 the function, so we don't have to assign it (BTW it's freed in the end)*/
00533 #else
00534 RUN_SERVICE(data->local_user)->send_im(
00535 data->local_user,
00536 data->perfered,
00537 text);
00538 #endif
00539 serv_touch_idle();
00540
00541 if(data->sound_enabled && data->send_enabled)
00542 play_sound(SEND);
00543
00544 if (do_convo_timestamp)
00545 {
00546 time(&t);
00547 cur_time = localtime(&t);
00548 g_snprintf(buff2, BUF_SIZE, "%d:%.2d:%.2d %s", cur_time->tm_hour,
00549 cur_time->tm_min, cur_time->tm_sec,
00550 data->local_user->alias);
00551 }
00552 else
00553 {
00554 g_snprintf(buff2, BUF_SIZE, "%s", data->local_user->alias);
00555 }
00556
00557 g_snprintf(buff, BUF_SIZE, "<FONT COLOR=\"#0000ff\"><B>%s: </B></FONT>", buff2);
00558
00559 gtk_eb_html_add(EXT_GTK_TEXT(data->chat), buff, 1, 0, 0);
00560 gtk_eb_html_add(EXT_GTK_TEXT(data->chat), link_message, do_ignore_back, do_ignore_fore, do_ignore_font);
00561 gtk_eb_html_add(EXT_GTK_TEXT(data->chat), "<br>", 0, 0, 0);
00562
00563 /* If an away message had been sent to this person, reset the away message tracker */
00564 /* It's probably faster to just do the assignment all the time--the test
00565 is there for code clarity. */
00566
00567 if (data->away_msg_sent)
00568 {
00569 data->away_msg_sent = FALSE;
00570 }
00571
00572 /* Log the message */
00573
00574 if(do_logging) eb_log_message(data->fp, buff, link_message);
00575
00576 gtk_editable_delete_text(GTK_EDITABLE (data->entry), 0, -1);
00577 g_free(link_message);
00578 g_free(text);
00579
00580
00581 /* if using tabs, then turn off the chat icon */
00582 if (data->notebook != NULL) {
00583 /* no more icons in the tabs */
00584 /* gtk_widget_hide(data->talk_pixmap); */
00585 /* printf("chat icon is off... \n"); */
00586 set_tab_normal(GTK_NOTEBOOK(data->notebook), data->notebook_child);
00587 }
00588 }
|
|
|
Definition at line 110 of file chat_window.h. Referenced by eb_chat_window_display_remote_message(). |
|
|
Definition at line 109 of file chat_window.h. Referenced by send_message(). |