/* X-Chat * Copyright (C) 1998 Peter Zelezny. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #include #include #include #ifdef HAVE_STRINGS_H #include #endif #ifdef WIN32 #define STDIN_FILENO 0 #define STDOUT_FILENO 1 #else #include #include #endif #include #include #include #include "../common/hexchat.h" #include "../common/hexchatc.h" #include "../common/cfgfiles.h" #include "../common/outbound.h" #include "../common/util.h" #include "../common/fe.h" #include "fe-text.h" static int done = FALSE; /* finished ? */ static void send_command (char *cmd) { handle_multiline (current_tab, cmd, TRUE, FALSE); } static gboolean handle_line (GIOChannel *channel, GIOCondition cond, gpointer data) { gchar *str_return; gsize length, terminator_pos; GError *error = NULL; GIOStatus result; result = g_io_channel_read_line(channel, &str_return, &length, &terminator_pos, &error); if (result == G_IO_STATUS_ERROR) { return FALSE; } else { send_command(str_return); g_free(str_return); return TRUE; } } static int done_intro = 0; void fe_new_window (struct session *sess, int focus) { char buf[512]; sess->gui = malloc (4); current_sess = sess; if (!sess->server->front_session) sess->server->front_session = sess; if (!sess->server->server_session) sess->server->server_session = sess; if (!current_tab || focus) current_tab = sess; if (done_intro) return; done_intro = 1; snprintf (buf, sizeof (buf), "\n" " \017HexChat-Text \00310"PACKAGE_VERSION"\n" " \017Running on \00310%s \017glib \00310%d.%d.%d\n" " \017This binary compiled \00310"__DATE__"\017\n", get_sys_str (1), glib_major_version, glib_minor_version, glib_micro_version); fe_print_text (sess, buf, 0); fe_print_text (sess, "\n\nCompiled in Features\0032:\017 " #ifdef USE_PLUGIN "Plugin " #endif #ifdef ENABLE_NLS "NLS " #endif #ifdef USE_OPENSSL "OpenSSL " #endif #ifdef USE_IPV6 "IPv6" #endif "\n\n", 0); fflush (stdout); fflush (stdin); } static int get_stamp_str (time_t tim, char *dest, int size) { return strftime (dest, size, prefs.hex_stamp_text_format, localtime (&tim)); } static int timecat (char *buf, time_t stamp) { char stampbuf[64]; /* set the stamp to the current time if not provided */ if (!stamp) stamp = time (0); get_stamp_str (stamp, stampbuf, sizeof (stampbuf)); strcat (buf, stampbuf); return strlen (stampbuf); } /* Windows doesn't handle ANSI codes in cmd.exe, need to not display them */ #ifndef WIN32 /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ static const short colconv[] = { 0, 7, 4, 2, 1, 3, 5, 11, 13, 12, 6, 16, 14, 15, 10, 7 }; void fe_print_text (struct session *sess, char *text, time_t stamp) { int dotime = FALSE; char num[8]; int reverse = 0, under = 0, bold = 0, comma, k, i = 0, j = 0, len = strlen (text); unsigned char *newtext = malloc (len + 1024); if (prefs.hex_stamp_text) { newtext[0] = 0; j += timecat (newtext, stamp); } while (i < len) { if (dotime && text[i] != 0) { dotime = FALSE; newtext[j] = 0; j += timecat (newtext, stamp); } switch (text[i]) { case 3: i++; if (!isdigit (text[i])) { newtext[j] = 27; j++; newtext[j] = '['; j++; newtext[j] = 'm'; j++; goto endloop; } k = 0; comma = FALSE; while (i < len) { if (text[i] >= '0' && text[i] <= '9' && k < 2) { num[k] = text[i]; k++; } else { int col, mirc; num[k] = 0; newtext[j] = 27; j++; newtext[j] = '['; j++; if (k == 0) { newtext[j] = 'm'; j++; } else { if (comma) col = 40; else col = 30; mirc = atoi (num); mirc = colconv[mirc]; if (mirc > 9) { mirc += 50; sprintf ((char *) &newtext[j], "%dm", mirc + col); } else { sprintf ((char *) &newtext[j], "%dm", mirc + col); } j = strlen (newtext); } switch (text[i]) { case ',': comma = TRUE; break; default: goto endloop; } k = 0; } i++; } break; /* don't actually want hidden text */ case '\010': /* hidden */ break; case '\026': /* REVERSE */ if (reverse) { reverse = FALSE; strcpy (&newtext[j], "\033[27m"); } else { reverse = TRUE; strcpy (&newtext[j], "\033[7m"); } j = strlen (newtext); break; case '\037': /* underline */ if (under) { under = FALSE; strcpy (&newtext[j], "\033[24m"); } else { under = TRUE; strcpy (&newtext[j], "\033[4m"); } j = strlen (newtext); break; case '\002': /* bold */ if (bold) { bold = FALSE; strcpy (&newtext[j], "\033[22m"); } else { bold = TRUE; strcpy (&newtext[j], "\033[1m"); } j = strlen (newtext); break; case '\007': if (!prefs.hex_input_filter_beep) { newtext[j] = text[i]; j++; } break; case '\017': /* reset all */ strcpy (&newtext[j], "\033[m"); j += 3; reverse = FALSE; bold = FALSE; under = FALSE; break; case '\t': newtext[j] = ' '; j++; break; case '\n': newtext[j] = '\r'; j++; if (prefs.hex_stamp_text) dotime = TRUE; default: newtext[j] = text[i]; j++; } i++; endloop: ; } /* make sure last character is a new line */ if (text[i-1] != '\n') newtext[j++] = '\n'; newtext[j] = 0; write (STDOUT_FILENO, newtext, j); free (newtext); } #else /* The win32 version for cmd.exe */ void fe_print_text (struct session *sess, char *text, time_t stamp) { int dotime = FALSE; int comma, k, i = 0, j = 0, len = strlen (text); unsigned char *newtext = malloc (len + 1024); if (prefs.hex_stamp_text) { newtext[0] = 0; j += timecat (newtext, stamp); } while (i < len) { if (dotime && text[i] != 0) { dotime = FALSE; newtext[j] = 0; j += timecat (newtext, stamp); } switch (text[i]) { case 3: i++; if (!isdigit (text[i])) { goto endloop; } k = 0; comma = FALSE; while (i < len) { if (text[i] >= '0' && text[i] <= '9' && k < 2) { k++; } else { switch (text[i]) { case ',': comma = TRUE; break; default: goto endloop; } k = 0; } i++; } break; /* don't actually want hidden text */ case '\010': /* hidden */ case '\026': /* REVERSE */ case '\037': /* underline */ case '\002': /* bold */ case '\017': /* reset all */ break; case '\007': if (!prefs.hex_input_filter_beep) { newtext[j] = text[i]; j++; } break; case '\t': newtext[j] = ' '; j++; break; case '\n': newtext[j] = '\r'; j++; if (prefs.hex_stamp_text) dotime = TRUE; default: newtext[j] = text[i]; j++; } i++; endloop: ; } /* make sure last character is a new line */ if (text[i-1] != '\n') newtext[j++] = '\n'; newtext[j] = 0; write (STDOUT_FILENO, newtext, j); free (newtext); } #endif void fe_timeout_remove (int tag) { g_source_remove (tag); } int fe_timeout_add (int interval, void *callback, void *userdata) { return g_timeout_add (interval, (GSourceFunc) callback, userdata); } void fe_input_remove (int tag) { g_source_remove (tag); } int fe_input_add (int sok, int flags, void *func, void *data) { int tag, type = 0; GIOChannel *channel; channel = g_io_channel_unix_new (sok); if (flags & FIA_READ) type |= G_IO_IN | G_IO_HUP | G_IO_ERR; if (flags & FIA_WRITE) type |= G_IO_OUT | G_IO_ERR; if (flags & FIA_EX) type |= G_IO_PRI; tag = g_io_add_watch (channel, type, (GIOFunc) func, d
/* X-Tray
 * Copyright (C) 2005 Michael Hotaling <Mike.Hotaling@SinisterDevelopments.com>
 *
 * X-Tray is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * X-Tray is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with X-Tray; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include <windows.h>
#include <winuser.h>
#include <stdio.h>
#include "utility.h"
#include "resource.h"
#include "sdAlerts.h"

int g_iAlerts = 0;

void sdSystemAlert(HINSTANCE hModule, UINT uiDialog, char *szMsg, char *szName, unsigned