gaim/gaim

4d9ea3462c35
Parents b7d392d68507
Children 3fdd702fb7dc
GaimWhiteboardUiOps is born and also some implementation and usage of such.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/gtkmain.c Fri Jul 22 17:25:16 2005 -0400
@@ -0,0 +1,728 @@
+/*
+ * gaim
+ *
+ * Gaim is the legal property of its developers, whose names are too numerous
+ * to list here. Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * 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 "internal.h"
+#include "gtkgaim.h"
+
+#include "account.h"
+#include "conversation.h"
+#include "core.h"
+#include "debug.h"
+#include "eventloop.h"
+#include "ft.h"
+#include "log.h"
+#include "notify.h"
+#include "prefs.h"
+#include "prpl.h"
+#include "pounce.h"
+#include "sound.h"
+#include "status.h"
+#include "util.h"
+#include "whiteboard.h"
+
+#include "gtkaccount.h"
+#include "gtkblist.h"
+#include "gtkconn.h"
+#include "gtkconv.h"
+#include "gtkdebug.h"
+#include "gtkdialogs.h"
+#include "gtkeventloop.h"
+#include "gtkft.h"
+#include "gtknotify.h"
+#include "gtkplugin.h"
+#include "gtkpounce.h"
+#include "gtkprefs.h"
+#include "gtkprivacy.h"
+#include "gtkrequest.h"
+#include "gtkroomlist.h"
+#include "gtksavedstatuses.h"
+#include "gtksound.h"
+#include "gtkutils.h"
+#include "gtkstock.h"
+#include "gtkwhiteboard.h"
+
+#if HAVE_SIGNAL_H
+# include <signal.h>
+#endif
+
+#include <getopt.h>
+
+#ifdef HAVE_STARTUP_NOTIFICATION
+# define SN_API_NOT_YET_FROZEN
+# include <libsn/sn-launchee.h>
+# include <gdk/gdkx.h>
+#endif
+
+#ifdef HAVE_STARTUP_NOTIFICATION
+static SnLauncheeContext *sn_context = NULL;
+static SnDisplay *sn_display = NULL;
+#endif
+
+/* TODO: Get this out of here? */
+int docklet_count = 0;
+
+#if HAVE_SIGNAL_H
+/*
+ * Lists of signals we wish to catch and those we wish to ignore.
+ * Each list terminated with -1
+ */
+static int catch_sig_list[] = {
+ SIGSEGV,
+ SIGHUP,
+ SIGINT,
+ SIGTERM,
+ SIGQUIT,
+ SIGCHLD,
+ -1
+};
+
+static int ignore_sig_list[] = {
+ SIGPIPE,
+ -1
+};
+#endif
+
+static int
+dologin_named(const char *name)
+{
+ GaimAccount *account;
+ char **names;
+ int i;
+ int ret = -1;
+
+ if (name != NULL) { /* list of names given */
+ names = g_strsplit(name, ",", 64);
+ for (i = 0; names[i] != NULL; i++) {
+ account = gaim_accounts_find(names[i], NULL);
+ if (account != NULL) { /* found a user */
+ ret = 0;
+ gaim_account_connect(account);
+ }
+ }
+ g_strfreev(names);
+ } else { /* no name given, use the first account */
+ account = (GaimAccount *)gaim_accounts_get_all()->data;
+ ret = 0;
+ gaim_account_connect(account);
+ }
+
+ return ret;
+}
+
+#if HAVE_SIGNAL_H
+static void
+clean_pid(void)
+{
+ int status;
+ pid_t pid;
+
+ do {
+ pid = waitpid(-1, &status, WNOHANG);
+ } while (pid != 0 && pid != (pid_t)-1);
+
+ if ((pid == (pid_t) - 1) && (errno != ECHILD)) {
+ char errmsg[BUFSIZ];
+ snprintf(errmsg, BUFSIZ, "Warning: waitpid() returned %d", pid);
+ perror(errmsg);
+ }
+}
+
+static void
+sighandler(int sig)
+{
+ switch (sig) {
+ case SIGHUP:
+ gaim_debug_warning("sighandler", "Caught signal %d\n", sig);
+ gaim_connections_disconnect_all();
+ break;
+ case SIGSEGV:
+#ifndef DEBUG
+ fprintf(stderr, "Gaim has segfaulted and attempted to dump a core file.\n"
+ "This is a bug in the software and has happened through\n"
+ "no fault of your own.\n\n"
+ "It is possible that this bug is already fixed in CVS.\n"
+ "If you can reproduce the crash, please notify the gaim\n"
+ "maintainers by reporting a bug at\n"
+ GAIM_WEBSITE "bug.php\n\n"
+ "Please make sure to specify what you were doing at the time,\n"
+ "and post the backtrace from the core file. If you do not know\n"
+ "how to get the backtrace, please get instructions at\n"
+ GAIM_WEBSITE "gdb.php. If you need further\n"
+ "assistance, please IM either SeanEgn or LSchiere and\n"
+ "they can help you.\n");
+#else
+ fprintf(stderr, "Hi, user. We need to talk.\n"
+ "I think something's gone wrong here. It's probably my fault.\n"
+ "No, really, it's not you... it's me... no no no, I think we get along well\n"
+ "it's just that.... well, I want to see other people. I... what?!? NO! I haven't\n"
+ "been cheating on you!! How many times do you want me to tell you?! And for the\n"
+ "last time, it's just a rash!\n");
+ /*g_on_error_query (g_get_prgname());*/
+#endif
+ abort();
+ break;
+ case SIGCHLD:
+ clean_pid();
+ signal(SIGCHLD, sighandler); /* restore signal catching on this one! */
+ break;
+ default:
+ gaim_debug_warning("sighandler", "Caught signal %d\n", sig);
+ gaim_connections_disconnect_all();
+
+ gaim_plugins_unload_all();
+
+ if (gtk_main_level())
+ gtk_main_quit();
+ exit(0);
+ }
+}
+#endif
+
+static int
+ui_main()
+{
+#ifndef _WIN32
+ GList *icons = NULL;
+ GdkPixbuf *icon = NULL;
+ char *icon_path;
+#endif
+
+ if (current_smiley_theme == NULL) {
+ smiley_theme_probe();
+ if (smiley_themes != NULL) {
+ struct smiley_theme *smile = smiley_themes->data;
+ load_smiley_theme(smile->path, TRUE);
+ }
+ }
+
+ gaim_gtk_blist_setup_sort_methods();
+
+#ifndef _WIN32
+ /* use the nice PNG icon for all the windows */
+ icon_path = g_build_filename(DATADIR, "pixmaps", "gaim", "icons", "online.png", NULL);
+ icon = gdk_pixbuf_new_from_file(icon_path, NULL);
+ g_free(icon_path);
+ if (icon) {
+ icons = g_list_append(icons,icon);
+ gtk_window_set_default_icon_list(icons);
+ g_object_unref(G_OBJECT(icon));
+ g_list_free(icons);
+ } else {
+ gaim_debug_error("ui_main",
+ "Failed to load the default window icon!\n");
+ }
+#endif
+
+ return 0;
+}
+
+static void
+debug_init(void)
+{
+ gaim_debug_set_ui_ops(gaim_gtk_debug_get_ui_ops());
+ gaim_gtk_debug_init();
+}
+
+static void
+gaim_gtk_ui_init(void)
+{
+ /* Set the UI operation structures. */
+ gaim_accounts_set_ui_ops(gaim_gtk_accounts_get_ui_ops());
+ gaim_conversations_set_win_ui_ops(gaim_gtk_conversations_get_win_ui_ops());
+ gaim_xfers_set_ui_ops(gaim_gtk_xfers_get_ui_ops());
+ gaim_blist_set_ui_ops(gaim_gtk_blist_get_ui_ops());
+ gaim_notify_set_ui_ops(gaim_gtk_notify_get_ui_ops());
+ gaim_privacy_set_ui_ops(gaim_gtk_privacy_get_ui_ops());
+ gaim_request_set_ui_ops(gaim_gtk_request_get_ui_ops());
+ gaim_sound_set_ui_ops(gaim_gtk_sound_get_ui_ops());
+ gaim_connections_set_ui_ops(gaim_gtk_connections_get_ui_ops());
+ gaim_whiteboard_set_ui_ops(gaim_gtk_whiteboard_get_ui_ops());
+
+ gaim_gtk_stock_init();
+ gaim_gtk_prefs_init();
+ gaim_gtk_account_init();
+ gaim_gtk_blist_init();
+ gaim_gtk_status_init();
+ gaim_gtk_conversations_init();
+ gaim_gtk_pounces_init();
+ gaim_gtk_privacy_init();
+ gaim_gtk_xfers_init();
+ gaim_gtk_roomlist_init();
+}
+
+static void
+gaim_gtk_quit(void)
+{
+ /* XXX? */
+ /* YYY is there an XXX here? */
+
+ /* captain's log, stardate... */
+ /* LOG system_log(log_quit, NULL, NULL, OPT_LOG_BUDDY_SIGNON | OPT_LOG_MY_SIGNON); */
+
+#ifdef USE_SM
+ /* unplug */
+ session_end();
+#endif
+
+ /* Save the plugins we have loaded for next time. */
+ gaim_gtk_plugins_save();
+
+ /* Uninit */
+ gaim_gtk_conversations_uninit();
+ gaim_gtk_status_uninit();
+ gaim_gtk_blist_uninit();
+ gaim_gtk_account_uninit();
+ gaim_gtk_xfers_uninit();
+ gaim_gtk_debug_uninit();
+
+ /* and end it all... */
+ gtk_main_quit();
+}
+
+static GaimCoreUiOps core_ops =
+{
+ gaim_gtk_prefs_init,
+ debug_init,
+ gaim_gtk_ui_init,
+ gaim_gtk_quit
+};
+
+static GaimCoreUiOps *
+gaim_gtk_core_get_ui_ops(void)
+{
+ return &core_ops;
+}
+
+static void
+show_usage(const char *name, gboolean terse)
+{
+ char *text;
+ char *text_conv;
+ GError *error = NULL;
+
+ if (terse) {
+ text = g_strdup_printf(_("Gaim %s. Try `%s -h' for more information.\n"), VERSION, name);
+ } else {
+ text = g_strdup_printf(_("Gaim %s\n"
+ "Usage: %s [OPTION]...\n\n"
+ " -a, --acct display account editor window\n"
+ " -c, --config=DIR use DIR for config files\n"
+ " -d, --debug print debugging messages to stdout\n"
+ " -h, --help display this help and exit\n"
+ " -n, --nologin don't automatically login\n"
+ " -l, --login[=NAME] automatically login (optional argument NAME specifies\n"
+ " account(s) to use, seperated by commas)\n"
+ " -v, --version display the current version and exit\n"), VERSION, name);
+ }
+
+ /* tries to convert 'text' to users locale */
+ text_conv = g_locale_from_utf8(text, -1, NULL, NULL, &error);
+ if (text_conv != NULL) {
+ puts(text_conv);
+ g_free(text_conv);
+ }
+ /* use 'text' as a fallback */
+ else {
+ g_warning("%s\n", error->message);
+ g_error_free(error);
+ puts(text);
+ }
+ g_free(text);
+}
+
+#ifdef HAVE_STARTUP_NOTIFICATION
+static void
+sn_error_trap_push(SnDisplay *display, Display *xdisplay)
+{
+ gdk_error_trap_push();
+}
+
+static void
+sn_error_trap_pop(SnDisplay *display, Display *xdisplay)
+{
+ gdk_error_trap_pop();
+}
+
+static void
+startup_notification_complete(void)
+{
+ Display *xdisplay;
+
+ xdisplay = GDK_DISPLAY();
+ sn_display = sn_display_new(xdisplay,
+ sn_error_trap_push,
+ sn_error_trap_pop);
+ sn_context =
+ sn_launchee_context_new_from_environment(sn_display,
+ DefaultScreen(xdisplay));
+
+ if (sn_context != NULL)
+ {
+ sn_launchee_context_complete(sn_context);
+ sn_launchee_context_unref(sn_context);
+
+ sn_display_unref(sn_display);
+ }
+}
+#endif /* HAVE_STARTUP_NOTIFICATION */
+
+#ifndef _WIN32
+static char *gaim_find_binary_location(void *symbol, void *data)
+{
+ static char *fullname = NULL;
+ static gboolean first = TRUE;
+
+ char *argv0 = data;
+ struct stat st;
+ char *basebuf, *linkbuf, *fullbuf;
+
+ if (!first)
+ /* We've already been through this. */
+ return strdup(fullname);
+
+ first = FALSE;
+
+ if (!argv0)
+ return NULL;
+
+
+ basebuf = g_find_program_in_path(argv0);
+
+ /* But we still need to deal with symbolic links */
+ g_lstat(basebuf, &st);
+ while ((st.st_mode & S_IFLNK) == S_IFLNK) {
+ linkbuf = g_malloc(1024);
+ readlink(basebuf, linkbuf, 1024);
+ if (linkbuf[0] == G_DIR_SEPARATOR) {
+ /* an absolute path */
+ fullbuf = g_strdup(linkbuf);
+ } else {
+ char *dirbuf = g_path_get_dirname(basebuf);
+ /* a relative path */
+ fullbuf = g_strdup_printf("%s%s%s",
+ dirbuf, G_DIR_SEPARATOR_S,
+ linkbuf);
+ g_free(dirbuf);
+ }
+ /* There's no memory leak here. Really! */
+ g_free(linkbuf);
+ g_free(basebuf);
+ basebuf = fullbuf;
+ g_lstat(basebuf, &st);
+ }
+
+ fullname = basebuf;
+ return strdup(fullname);
+}
+#endif /* #ifndef _WIN32 */
+
+/* FUCKING GET ME A TOWEL! */
+#ifdef _WIN32
+int gaim_main(HINSTANCE hint, int argc, char *argv[])
+#else
+int main(int argc, char *argv[])
+#endif
+{
+ gboolean opt_acct = FALSE;
+ gboolean opt_help = FALSE;
+ gboolean opt_login = FALSE;
+ gboolean opt_nologin = FALSE;
+ gboolean opt_version = FALSE;
+ char *opt_config_dir_arg = NULL;
+ char *opt_login_arg = NULL;
+ char *opt_session_arg = NULL;
+ int dologin_ret = -1;
+ char *search_path;
+#if HAVE_SIGNAL_H
+ int sig_indx; /* for setting up signal catching */
+ sigset_t sigset;
+ void (*prev_sig_disp)();
+#endif
+ int opt;
+ gboolean gui_check;
+ gboolean debug_enabled;
+#if HAVE_SIGNAL_H
+ char errmsg[BUFSIZ];
+#endif
+
+ struct option long_options[] = {
+ {"acct", no_argument, NULL, 'a'},
+ {"config", required_argument, NULL, 'c'},
+ {"debug", no_argument, NULL, 'd'},
+ {"help", no_argument, NULL, 'h'},
+ {"login", optional_argument, NULL, 'l'},
+ {"nologin", no_argument, NULL, 'n'},
+ {"session", required_argument, NULL, 's'},
+ {"version", no_argument, NULL, 'v'},
+ {0, 0, 0, 0}
+ };
+
+#ifdef DEBUG
+ debug_enabled = TRUE;
+#else
+ debug_enabled = FALSE;
+#endif
+
+#ifndef _WIN32
+ br_set_locate_fallback_func(gaim_find_binary_location, argv[0]);
+#endif
+#ifdef ENABLE_NLS
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ bind_textdomain_codeset(PACKAGE, "UTF-8");
+ textdomain(PACKAGE);
+#endif
+
+#if HAVE_SIGNAL_H
+ /* Let's not violate any PLA's!!!! */
+ /* jseymour: whatever the fsck that means */
+ /* Robot101: for some reason things like gdm like to block *
+ * useful signals like SIGCHLD, so we unblock all the ones we *
+ * declare a handler for. thanks JSeymour and Vann. */
+ if (sigemptyset(&sigset)) {
+ snprintf(errmsg, BUFSIZ, "Warning: couldn't initialise empty signal set");
+ perror(errmsg);
+ }
+ for(sig_indx = 0; catch_sig_list[sig_indx] != -1; ++sig_indx) {
+ if((prev_sig_disp = signal(catch_sig_list[sig_indx], sighandler)) == SIG_ERR) {
+ snprintf(errmsg, BUFSIZ, "Warning: couldn't set signal %d for catching",
+ catch_sig_list[sig_indx]);
+ perror(errmsg);
+ }
+ if(sigaddset(&sigset, catch_sig_list[sig_indx])) {
+ snprintf(errmsg, BUFSIZ, "Warning: couldn't include signal %d for unblocking",
+ catch_sig_list[sig_indx]);
+ perror(errmsg);
+ }
+ }
+ for(sig_indx = 0; ignore_sig_list[sig_indx] != -1; ++sig_indx) {
+ if((prev_sig_disp = signal(ignore_sig_list[sig_indx], SIG_IGN)) == SIG_ERR) {
+ snprintf(errmsg, BUFSIZ, "Warning: couldn't set signal %d to ignore",
+ ignore_sig_list[sig_indx]);
+ perror(errmsg);
+ }
+ }
+
+ if (sigprocmask(SIG_UNBLOCK, &sigset, NULL)) {
+ snprintf(errmsg, BUFSIZ, "Warning: couldn't unblock signals");
+ perror(errmsg);
+ }
+#endif
+
+ gui_check = gtk_init_check(&argc, &argv);
+ if (!gui_check) {
+ char *display = gdk_get_display();
+
+ printf("Gaim %s\n", VERSION);
+
+ g_warning("cannot open display: %s", display ? display : "unset");
+ g_free(display);
+
+ return 1;
+ }
+
+ /* scan command-line options */
+ opterr = 1;
+ while ((opt = getopt_long(argc, argv,
+#ifndef _WIN32
+ "ac:dhnl::s:v",
+#else
+ "ac:dhnl::v",
+#endif
+ long_options, NULL)) != -1) {
+ switch (opt) {
+ case 'a': /* account editor */
+ opt_acct = TRUE;
+ break;
+ case 'c': /* config dir */
+ g_free(opt_config_dir_arg);
+ opt_config_dir_arg = g_strdup(optarg);
+ break;
+ case 'd': /* debug */
+ debug_enabled = TRUE;
+ break;
+ case 'h': /* help */
+ opt_help = TRUE;
+ break;
+ case 'n': /* no autologin */
+ opt_nologin = TRUE;
+ break;
+ case 'l': /* login, option username */
+ opt_login = TRUE;
+ g_free(opt_login_arg);
+ if (optarg != NULL)
+ opt_login_arg = g_strdup(optarg);
+ break;
+ case 's': /* use existing session ID */
+ g_free(opt_session_arg);
+ opt_session_arg = g_strdup(optarg);
+ break;
+ case 'v': /* version */
+ opt_version = TRUE;
+ break;
+ case '?': /* show terse help */
+ default:
+ show_usage(argv[0], TRUE);
+ return 0;
+ break;
+ }
+ }
+
+ /* show help message */
+ if (opt_help) {
+ show_usage(argv[0], FALSE);
+ return 0;
+ }
+ /* show version message */
+ if (opt_version) {
+ printf("Gaim %s\n", VERSION);
+ return 0;
+ }
+
+ /* set a user-specified config directory */
+ if (opt_config_dir_arg != NULL) {
+ gaim_util_set_user_dir(opt_config_dir_arg);
+ }
+
+ /*
+ * We're done piddling around with command line arguments.
+ * Fire up this baby.
+ */
+
+ gaim_debug_set_enabled(debug_enabled);
+
+#ifdef _WIN32
+ wgaim_init(hint);
+#endif
+ gaim_core_set_ui_ops(gaim_gtk_core_get_ui_ops());
+ gaim_eventloop_set_ui_ops(gaim_gtk_eventloop_get_ui_ops());
+
+ /* Set plugin search directories */
+ gaim_plugins_add_search_path(LIBDIR);
+ search_path = g_build_filename(gaim_user_dir(), "plugins", NULL);
+ gaim_plugins_add_search_path(search_path);
+ g_free(search_path);
+
+ if (!gaim_core_init(GAIM_GTK_UI)) {
+ fprintf(stderr,
+ "Initialization of the Gaim core failed. Dumping core.\n"
+ "Please report this!\n");
+ abort();
+ }
+
+ /* TODO: Move blist loading into gaim_blist_init() */
+ gaim_set_blist(gaim_blist_new());
+ gaim_blist_load();
+
+ /* TODO: Move prefs loading into gaim_prefs_init() */
+ gaim_prefs_load();
+ gaim_prefs_update_old();
+ gaim_gtk_prefs_update_old();
+
+ /* load plugins we had when we quit */
+ gaim_plugins_load_saved("/gaim/gtk/plugins/loaded");
+
+ /* TODO: Move pounces loading into gaim_pounces_init() */
+ gaim_pounces_load();
+
+ ui_main();
+
+#ifdef USE_SM
+ session_init(argv[0], opt_session_arg, opt_config_dir_arg);
+#endif
+ if (opt_session_arg != NULL) {
+ g_free(opt_session_arg);
+ opt_session_arg = NULL;
+ }
+ if (opt_config_dir_arg != NULL) {
+ g_free(opt_config_dir_arg);
+ opt_config_dir_arg = NULL;
+ }
+
+ if (gaim_prefs_get_bool("/gaim/gtk/debug/enabled"))
+ gaim_gtk_debug_window_show();
+
+ gaim_blist_show();
+
+ if (opt_login) {
+ dologin_ret = dologin_named(opt_login_arg);
+ if (opt_login_arg != NULL) {
+ g_free(opt_login_arg);
+ opt_login_arg = NULL;
+ }
+ }
+
+ if (!opt_acct && opt_nologin)
+ {
+ /* TODO: Need to disable all accounts or set them all to offline */
+ }
+
+ if (opt_acct || (gaim_accounts_get_all() == NULL)) {
+ gaim_gtk_accounts_window_show();
+ }
+
+#ifdef HAVE_STARTUP_NOTIFICATION
+ startup_notification_complete();
+#endif
+
+ gaim_debug_register_category("sighandler");
+ gaim_debug_register_category("ui_main");
+
+ /* XXX These don't really belong here, but I don't have a better place for
+ * them right now */
+ gaim_debug_register_category("gtkimhtml");
+ gaim_debug_register_category("gtk_imhtml_tip");
+ gaim_debug_register_category("html clipboard");
+ /* #if 0'ed out for Windows stuff
+ gaim_debug_register_category("imhtml clipboard");
+ */
+ gaim_debug_register_category("imgstore");
+ gaim_debug_register_category("pluginpref");
+ gaim_debug_register_category("request");
+ gaim_debug_register_category("roomlist");
+ /* gtkutils.c */
+ gaim_debug_register_category("accels");
+ gaim_debug_register_category("gtkspell");
+ /* These are from util.c */
+ gaim_debug_register_category("build_dir");
+ gaim_debug_register_category("gaim_mkstemp");
+ gaim_debug_register_category("gaim_str_add_cr");
+ gaim_debug_register_category("gaim_url_fetch");
+ gaim_debug_register_category("gaim_utf8_strcasecmp");
+ gaim_debug_register_category("parse_content_len");
+ gaim_debug_register_category("program_is_valid");
+ gaim_debug_register_category("util");
+ /* These only show up once */
+ gaim_debug_register_category("gtknotify");
+ gaim_debug_register_category("gtksound");
+ gaim_debug_register_category("prpl");
+ gaim_debug_register_category("server");
+ gaim_debug_register_category("stringref");
+
+ gtk_main();
+
+#ifdef _WIN32
+ wgaim_cleanup();
+#endif
+
+ return 0;
+}
--- a/src/gtkwhiteboard.c Tue Jul 19 23:14:35 2005 -0400
+++ b/src/gtkwhiteboard.c Fri Jul 22 17:25:16 2005 -0400
@@ -27,18 +27,34 @@
// GLOBALS =============================================================================================
-//GList *buttonList = NULL;
+//GList *buttonList = NULL;
+
+int LastX; // Tracks last position of the mouse when drawing
+int LastY;
+int MotionCount; // Tracks how many brush motions made
+int BrushState = BRUSH_STATE_UP;
-int LastX; // Tracks last position of the mouse when drawing
-int LastY;
-int MotionCount; // Tracks how many brush motions made
-int BrushState = BRUSH_STATE_UP;
+static GaimWhiteboardUiOps ui_ops =
+{
+ gaim_gtk_whiteboard_create,
+ gaim_gtk_whiteboard_destroy,
+ gaim_gtk_whiteboard_draw_brush_point,
+ gaim_gtk_whiteboard_draw_brush_line
+};
// FUNCTIONS ============================================================================================
-GaimGtkWhiteboard *gaim_gtkwhiteboard_create( GaimWhiteboard *wb )
+GaimWhiteboardUiOps *gaim_gtk_whiteboard_get_ui_ops( void )
+{
+ return( &ui_ops );
+}
+
+// ------------------------------------------------------------------------------------------------------
+
+void gaim_gtk_whiteboard_create( GaimWhiteboard *wb )
{
//int i;
+ g_print( "gaim_gtk_whiteboard_create()\n" );
GtkWidget *window;
GtkWidget *drawing_area;
@@ -64,6 +80,10 @@
//GtkWidget *color_box[PALETTE_NUM_OF_COLORS];
GaimGtkWhiteboard *gtkwb = g_new0( GaimGtkWhiteboard, 1 );
+ gtkwb->wb = wb; // NOTE Pointer wrong address to link?
+ wb->ui_data = gtkwb;
+ g_print( "-->wb=%p\n", wb );
+ g_print( "-->ui_data=%p\n", wb->ui_data );
window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
gtkwb->window = window;
@@ -72,7 +92,7 @@
gtk_window_set_resizable( ( GtkWindow* )( window ), FALSE );
g_signal_connect( G_OBJECT( window ), "destroy",
- G_CALLBACK( gaim_gtkwhiteboard_exit ), ( gpointer )( gtkwb ) );
+ G_CALLBACK( gaim_gtk_whiteboard_exit ), ( gpointer )( gtkwb ) );
// Create vertical box to place palette above the canvas and controls
vbox_palette_above_canvas_and_controls = gtk_vbox_new( FALSE, 0 );
@@ -108,20 +128,20 @@
// Signals used to handle backing pixmap
g_signal_connect( G_OBJECT( drawing_area ), "expose_event",
- G_CALLBACK( gaim_gtkwhiteboard_expose_event ), ( gpointer )( gtkwb ) );
+ G_CALLBACK( gaim_gtk_whiteboard_expose_event ), ( gpointer )( gtkwb ) );
g_signal_connect( G_OBJECT( drawing_area ), "configure_event",
- G_CALLBACK( gaim_gtkwhiteboard_configure_event ), ( gpointer )( gtkwb ) );
+ G_CALLBACK( gaim_gtk_whiteboard_configure_event ), ( gpointer )( gtkwb ) );
// Event signals
g_signal_connect( G_OBJECT( drawing_area ), "button_press_event",
- G_CALLBACK( gaim_gtkwhiteboard_brush_down ), ( gpointer )( gtkwb ) );
+ G_CALLBACK( gaim_gtk_whiteboard_brush_down ), ( gpointer )( gtkwb ) );
g_signal_connect( G_OBJECT( drawing_area ), "motion_notify_event",
- G_CALLBACK( gaim_gtkwhiteboard_brush_motion ), ( gpointer )( gtkwb ) );
+ G_CALLBACK( gaim_gtk_whiteboard_brush_motion ), ( gpointer )( gtkwb ) );
g_signal_connect( G_OBJECT( drawing_area ), "button_release_event",
- G_CALLBACK( gaim_gtkwhiteboard_brush_up ), ( gpointer )( gtkwb ) );
+ G_CALLBACK( gaim_gtk_whiteboard_brush_up ), ( gpointer )( gtkwb ) );
gtk_widget_set_events( drawing_area, GDK_EXPOSURE_MASK |
GDK_LEAVE_NOTIFY_MASK |
@@ -142,7 +162,7 @@
gtk_widget_show( clear_button );
g_signal_connect( G_OBJECT( clear_button ), "clicked",
- G_CALLBACK( gaim_gtkwhiteboard_button_clear_press ), ( gpointer )( gtkwb ) );
+ G_CALLBACK( gaim_gtk_whiteboard_button_clear_press ), ( gpointer )( gtkwb ) );
// Add a save button
save_button = gtk_button_new_with_label( "Save" );
@@ -153,40 +173,47 @@
// Make all this (window) visible
gtk_widget_show( window );
- gaim_gtkwhiteboard_set_canvas_as_icon( gtkwb );
+ gaim_gtk_whiteboard_set_canvas_as_icon( gtkwb );
// TODO Specific protocol/whiteboard assignment here? Needs a UI Op?
// Set default brush size and color
//ds->brush_size = DOODLE_BRUSH_MEDIUM;
//ds->brush_color = 0; // black
-
- return( gtkwb );
}
// ------------------------------------------------------------------------------------------------------
-void gaim_gtkwhiteboard_destroy( GaimGtkWhiteboard *gtkwb )
+void gaim_gtk_whiteboard_destroy( GaimWhiteboard *wb )
{
+ g_print( "gaim_gtk_whiteboard_destroy()\n" );
+
+ GaimGtkWhiteboard *gtkwb = wb->ui_data;
+ g_print( "-->wb =%p\n", wb );
+ g_print( "-->ui_data=%p\n", wb->ui_data );
+ g_print( "-->gtkwb =%p\n", gtkwb );
+
// TODO Ask if user wants to save picture before the session is closed
// Clear pixmap memory before we remove this session from the Doodle session list
if( gtkwb->pixmap )
g_object_unref( gtkwb->pixmap );
+ if( gtkwb )
+ g_free( gtkwb );
+
// NOTE Correct order below? Will it break anything?
gaim_whiteboard_destroy( gtkwb->wb );
-
- if( gtkwb )
- g_free( gtkwb );
}
// ------------------------------------------------------------------------------------------------------
-void gaim_gtkwhiteboard_exit( GtkWidget *widget, gpointer data )
+void gaim_gtk_whiteboard_exit( GtkWidget *widget, gpointer data )
{
+ g_print( "gaim_gtk_whiteboard_exit()\n" );
+
GaimGtkWhiteboard *gtkwb = ( GaimGtkWhiteboard* )( data );
- gaim_gtkwhiteboard_destroy( gtkwb );
+ gaim_gtk_whiteboard_destroy( gtkwb->wb );
}
// ------------------------------------------------------------------------------------------------------
@@ -216,7 +243,7 @@
*/
// ------------------------------------------------------------------------------------------------------
-gboolean gaim_gtkwhiteboard_configure_event( GtkWidget *widget, GdkEventConfigure *event, gpointer data )
+gboolean gaim_gtk_whiteboard_configure_event( GtkWidget *widget, GdkEventConfigure *event, gpointer data )
{
GaimGtkWhiteboard *gtkwb = ( GaimGtkWhiteboard* )( data );
@@ -246,7 +273,7 @@
// ------------------------------------------------------------------------------------------------------
-gboolean gaim_gtkwhiteboard_expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer data )
+gboolean gaim_gtk_whiteboard_expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer data )
{
GaimGtkWhiteboard *gtkwb = ( GaimGtkWhiteboard* )( data );
GdkPixmap *pixmap = gtkwb->pixmap;
@@ -265,18 +292,18 @@
// ------------------------------------------------------------------------------------------------------
-gboolean gaim_gtkwhiteboard_brush_down( GtkWidget *widget, GdkEventButton *event, gpointer data )
+gboolean gaim_gtk_whiteboard_brush_down( GtkWidget *widget, GdkEventButton *event, gpointer data )
{
GaimGtkWhiteboard *gtkwb = ( GaimGtkWhiteboard* )( data );
GdkPixmap *pixmap = gtkwb->pixmap;
-
- GList *d_list = gtkwb->wb->draw_list;
+
+/* GList *d_list = gtkwb->wb->draw_list;
int *brush_color = NULL;
int *brush_size = NULL;
int *x0 = NULL;
int *y0 = NULL;
-
+*/
if( BrushState != BRUSH_STATE_UP )
{
// Potential double-click DOWN to DOWN?
@@ -294,7 +321,7 @@
if( event->button == 1 && pixmap != NULL )
{
- // Check if draw_list has contents; if so, clear it
+/* // Check if draw_list has contents; if so, clear it
if( d_list )
gaim_whiteboard_draw_list_destroy( d_list );
@@ -303,24 +330,24 @@
x0 = g_new0( int, 1 );
y0 = g_new0( int, 1 );
- //*brush_color = gtkwb->brush_color;
- //*brush_size = gtkwb->brush_size;
+ // *brush_color = gtkwb->brush_color;
+ // *brush_size = gtkwb->brush_size;
*x0 = event->x;
*y0 = event->y;
-
+*/
// Set tracking variables
- LastX = *x0;
- LastY = *y0;
+ LastX = event->x;//LastX = *x0;
+ LastY = event->y;//LastY = *y0;
MotionCount = 0;
-
+/*
d_list = g_list_append( d_list, ( gpointer )( brush_color ) );
d_list = g_list_append( d_list, ( gpointer )( brush_size ) );
d_list = g_list_append( d_list, ( gpointer )( x0 ) );
d_list = g_list_append( d_list, ( gpointer )( y0 ) );
-
- gaim_gtkwhiteboard_draw_brush_point( widget, gtkwb,
- event->x, event->y,
- 0,5 );//gtkwb->brush_color, gtkwb->brush_size ); NOTE temp const proto uiop
+*/
+ gaim_gtk_whiteboard_draw_brush_point( gtkwb->wb,
+ event->x, event->y,
+ 0,5 );//gtkwb->brush_color, gtkwb->brush_size ); NOTE temp const prot uiop
}
return( TRUE );
@@ -328,19 +355,19 @@
// ------------------------------------------------------------------------------------------------------
-gboolean gaim_gtkwhiteboard_brush_motion( GtkWidget *widget, GdkEventMotion *event, gpointer data )
+gboolean gaim_gtk_whiteboard_brush_motion( GtkWidget *widget, GdkEventMotion *event, gpointer data )
{
int x;
int y;
- int *dx;
- int *dy;
+// int *dx;
+// int *dy;
GdkModifierType state;
GaimGtkWhiteboard *gtkwb = ( GaimGtkWhiteboard* )( data );
GdkPixmap *pixmap = gtkwb->pixmap;
- GList *d_list = gtkwb->wb->draw_list;
-
+// GList *d_list = gtkwb->wb->draw_list;
+
//g_print( "BRUSH_MOTION | %s\n", ds->who );
if( event->is_hint )
@@ -363,15 +390,15 @@
return( FALSE );
}
BrushState = BRUSH_STATE_MOTION;
-
+/*
dx = g_new0( int, 1 );
dy = g_new0( int, 1 );
*dx = x - LastX;
*dy = y - LastY;
-
+*/
MotionCount++;
-
+/*
// NOTE 100 is a temporary constant for how many deltas/motions in a stroke (needs UI Ops?)
if( MotionCount == 100 )
{
@@ -391,8 +418,8 @@
int *x0 = g_new0( int, 1 );
int *y0 = g_new0( int, 1 );
- //*brush_color = gtkwb->brush_color;
- //*brush_size = gtkwb->brush_size;
+ // *brush_color = gtkwb->brush_color;
+ // *brush_size = gtkwb->brush_size;
*x0 = LastX;
*y0 = LastY;
@@ -415,11 +442,11 @@
d_list = g_list_append( d_list, ( gpointer )( dx ) );
d_list = g_list_append( d_list, ( gpointer )( dy ) );
}
-
- gaim_gtkwhiteboard_draw_brush_line( gtkwb->drawing_area, gtkwb,
- LastX, LastY,
- x, y,
- 0, 5 );//gtkwb->brush_color, gtkwb->brush_size ); temp const proto ui ops?
+*/
+ gaim_gtk_whiteboard_draw_brush_line( gtkwb->wb,
+ LastX, LastY,
+ x, y,
+ 0, 5 );//gtkwb->brush_color, gtkwb->brush_size ); temp const proto ui ops?
// Set tracking variables
LastX = x;
@@ -431,12 +458,12 @@
// ------------------------------------------------------------------------------------------------------
-gboolean gaim_gtkwhiteboard_brush_up( GtkWidget *widget, GdkEventButton *event, gpointer data )
+gboolean gaim_gtk_whiteboard_brush_up( GtkWidget *widget, GdkEventButton *event, gpointer data )
{
GaimGtkWhiteboard *gtkwb = ( GaimGtkWhiteboard* )( data );
GdkPixmap *pixmap = gtkwb->pixmap;
- GList *d_list = gtkwb->wb->draw_list;
+// GList *d_list = gtkwb->wb->draw_list;
//g_print( "BRUSH_UP | %s\n", ds->who );
@@ -452,7 +479,7 @@
if( event->button == 1 && pixmap != NULL )
{
- // If the brush was never moved, express two sets of two deltas
+/* // If the brush was never moved, express two sets of two deltas
// That's a 'point,' but not for Yahoo!
//if( ( event->x == LastX ) && ( event->y == LastY ) )
if( MotionCount == 0 )
@@ -476,11 +503,11 @@
//char* message = goodle_doodle_session_build_draw_string( drawList );
//yahoo_doodle_command_send_draw( ds->gc, ds->who, message );
-
- gaim_gtkwhiteboard_set_canvas_as_icon( gtkwb );
+*/
+ gaim_gtk_whiteboard_set_canvas_as_icon( gtkwb );
// The brush stroke is finished, clear the list for another one
- gaim_whiteboard_draw_list_destroy( d_list );
+// gaim_whiteboard_draw_list_destroy( d_list );
}
return( TRUE );
@@ -488,25 +515,28 @@
// ------------------------------------------------------------------------------------------------------
-void gaim_gtkwhiteboard_draw_brush_point( GtkWidget *widget, GaimGtkWhiteboard *gtkwb,
- int x, int y, int color, int size )
+// void gaim_gtk_whiteboard_draw_brush_point( GtkWidget *widget, GaimGtkWhiteboard *gtkwb,
+// int x, int y, int color, int size )
+void gaim_gtk_whiteboard_draw_brush_point( GaimWhiteboard *wb, int x, int y, int color, int size )
{
- GdkPixmap *pixmap = gtkwb->pixmap;
-
- //g_print( "goodle_doodle_session_draw_brush | %s\n", ds->who );
+ GaimGtkWhiteboard *gtkwb = wb->ui_data;
+ GtkWidget *widget = gtkwb->drawing_area;
+ GdkPixmap *pixmap = gtkwb->pixmap;
- GdkRectangle update_rect;
+ GdkRectangle update_rect;
update_rect.x = x - size / 2;
update_rect.y = y - size / 2;
update_rect.width = size;
update_rect.height = size;
+ //g_print( "goodle_doodle_session_draw_brush | %s\n", ds->who );
+
// Interpret and convert color
GdkGC *gfx_con = gdk_gc_new( pixmap );
GdkColor col;
- gaim_gtkwhiteboard_rgb24_to_rgb48( color, &col );
+ gaim_gtk_whiteboard_rgb24_to_rgb48( color, &col );
gdk_gc_set_rgb_fg_color( gfx_con, &col );
//gdk_gc_set_rgb_bg_color( gfx_con, &col );
@@ -541,9 +571,10 @@
// ------------------------------------------------------------------------------------------------------
// Uses Bresenham's algorithm (as provided by Wikipedia)
-void gaim_gtkwhiteboard_draw_brush_line( GtkWidget *widget, GaimGtkWhiteboard *gtkwb,
- int x0, int y0, int x1, int y1, int color, int size )
-{
+// void gaim_gtk_whiteboard_draw_brush_line( GtkWidget *widget, GaimGtkWhiteboard *gtkwb,
+// int x0, int y0, int x1, int y1, int color, int size )
+void gaim_gtk_whiteboard_draw_brush_line( GaimWhiteboard *wb, int x0, int y0, int x1, int y1, int color, int size )
+{
int temp;
int xstep;
@@ -577,9 +608,9 @@
ystep = -1;
if( steep )
- gaim_gtkwhiteboard_draw_brush_point( widget, gtkwb, y, x, color, size );
+ gaim_gtk_whiteboard_draw_brush_point( wb, y, x, color, size );
else
- gaim_gtkwhiteboard_draw_brush_point( widget, gtkwb, x, y, color, size );
+ gaim_gtk_whiteboard_draw_brush_point( wb, x, y, color, size );
while( x != x1 )
{
@@ -593,15 +624,15 @@
}
if( steep )
- gaim_gtkwhiteboard_draw_brush_point( widget, gtkwb, y, x, color, size );
+ gaim_gtk_whiteboard_draw_brush_point( wb, y, x, color, size );
else
- gaim_gtkwhiteboard_draw_brush_point( widget, gtkwb, x, y, color, size );
+ gaim_gtk_whiteboard_draw_brush_point( wb, x, y, color, size );
}
}
// ------------------------------------------------------------------------------------------------------
-void gaim_gtkwhiteboard_clear_canvas( GaimGtkWhiteboard *gtkwb )
+void gaim_gtk_whiteboard_clear_canvas( GaimGtkWhiteboard *gtkwb )
{
GdkPixmap *pixmap = gtkwb->pixmap;
GtkWidget *drawing_area = gtkwb->drawing_area;
@@ -619,21 +650,21 @@
// ------------------------------------------------------------------------------------------------------
-void gaim_gtkwhiteboard_button_clear_press( GtkWidget *widget, gpointer data )
+void gaim_gtk_whiteboard_button_clear_press( GtkWidget *widget, gpointer data )
{
GaimGtkWhiteboard *gtkwb = ( GaimGtkWhiteboard* )( data );
// Proto specific? UI Ops?
//goodle_send_command_clear( ds->gc, ds->who );
- gaim_gtkwhiteboard_clear_canvas( gtkwb );
+ gaim_gtk_whiteboard_clear_canvas( gtkwb );
- gaim_gtkwhiteboard_set_canvas_as_icon( gtkwb );
+ gaim_gtk_whiteboard_set_canvas_as_icon( gtkwb );
}
// ------------------------------------------------------------------------------------------------------
-void gaim_gtkwhiteboard_set_canvas_as_icon( GaimGtkWhiteboard *gtkwb )
+void gaim_gtk_whiteboard_set_canvas_as_icon( GaimGtkWhiteboard *gtkwb )
{
GdkPixbuf *pixbuf;
@@ -650,7 +681,7 @@
// ------------------------------------------------------------------------------------------------------
-void gaim_gtkwhiteboard_rgb24_to_rgb48( int color_rgb, GdkColor *color )
+void gaim_gtk_whiteboard_rgb24_to_rgb48( int color_rgb, GdkColor *color )
{
color->red = ( color_rgb >> 8 ) | 0xFF;
color->green = ( color_rgb & 0xFF00 ) | 0xFF;
--- a/src/gtkwhiteboard.h Tue Jul 19 23:14:35 2005 -0400
+++ b/src/gtkwhiteboard.h Fri Jul 22 17:25:16 2005 -0400
@@ -51,30 +51,32 @@
// PROTOTYPES ==========================================================================================
-GaimGtkWhiteboard *gaim_gtkwhiteboard_create( GaimWhiteboard *wb );
-void gaim_gtkwhiteboard_destroy( GaimGtkWhiteboard *gtkwb );
-void gaim_gtkwhiteboard_exit( GtkWidget *widget, gpointer data );
+GaimWhiteboardUiOps *gaim_gtk_whiteboard_get_ui_ops( void );
+
+void gaim_gtk_whiteboard_create( GaimWhiteboard *wb );
+void gaim_gtk_whiteboard_destroy( GaimWhiteboard *wb );
+void gaim_gtk_whiteboard_exit( GtkWidget *widget, gpointer data );
//void gaim_gtkwhiteboard_button_start_press( GtkButton *button, gpointer data );
-gboolean gaim_gtkwhiteboard_configure_event( GtkWidget *widget, GdkEventConfigure *event, gpointer data );
-gboolean gaim_gtkwhiteboard_expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer data );
+gboolean gaim_gtk_whiteboard_configure_event( GtkWidget *widget, GdkEventConfigure *event, gpointer data );
+gboolean gaim_gtk_whiteboard_expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer data );
-gboolean gaim_gtkwhiteboard_brush_down( GtkWidget *widget, GdkEventButton *event, gpointer data );
-gboolean gaim_gtkwhiteboard_brush_motion( GtkWidget *widget, GdkEventMotion *event, gpointer data );
-gboolean gaim_gtkwhiteboard_brush_up( GtkWidget *widget, GdkEventButton *event, gpointer data );
+gboolean gaim_gtk_whiteboard_brush_down( GtkWidget *widget, GdkEventButton *event, gpointer data );
+gboolean gaim_gtk_whiteboard_brush_motion( GtkWidget *widget, GdkEventMotion *event, gpointer data );
+gboolean gaim_gtk_whiteboard_brush_up( GtkWidget *widget, GdkEventButton *event, gpointer data );
-void gaim_gtkwhiteboard_draw_brush_point( GtkWidget *widget, GaimGtkWhiteboard *gtkwb,
- int x, int y, int color, int size );
-void gaim_gtkwhiteboard_draw_brush_line( GtkWidget *widget, GaimGtkWhiteboard *gtkwb,
- int x0, int y0, int x1, int y1, int color, int size );
+void gaim_gtk_whiteboard_draw_brush_point( GaimWhiteboard *wb,
+ int x, int y, int color, int size );
+void gaim_gtk_whiteboard_draw_brush_line( GaimWhiteboard *wb,
+ int x0, int y0, int x1, int y1, int color, int size );
-void gaim_gtkwhiteboard_clear_canvas( GaimGtkWhiteboard *gtkwb );
+void gaim_gtk_whiteboard_clear_canvas( GaimGtkWhiteboard *gtkwb );
-void gaim_gtkwhiteboard_button_clear_press( GtkWidget *widget, gpointer data );
+void gaim_gtk_whiteboard_button_clear_press( GtkWidget *widget, gpointer data );
-void gaim_gtkwhiteboard_set_canvas_as_icon( GaimGtkWhiteboard *gtkwb );
+void gaim_gtk_whiteboard_set_canvas_as_icon( GaimGtkWhiteboard *gtkwb );
-void gaim_gtkwhiteboard_rgb24_to_rgb48( int color_rgb, GdkColor *color );
+void gaim_gtk_whiteboard_rgb24_to_rgb48( int color_rgb, GdkColor *color );
#endif // _GAIM_GTKWHITEBOARD_H_
Binary file src/gtkwhiteboard.o has changed
--- a/src/protocols/yahoo/yahoo_doodle.c Tue Jul 19 23:14:35 2005 -0400
+++ b/src/protocols/yahoo/yahoo_doodle.c Fri Jul 22 17:25:16 2005 -0400
@@ -113,9 +113,6 @@
gaim_signal_connect( conv_handle, "deleting-conversation", plugin,
GAIM_CALLBACK( goodle_conv_destroyed ), NULL );
- // Make all active Yahoo accounts use the Goodle network packet handler
- goodle_set_goodle_functions( TRUE );
-
return( TRUE );
}
// ------------------------------------------------------------------------------------------------------
@@ -148,9 +145,6 @@
g_list_free( dsList );
dsList = NULL;
- // Return full packet handling to the original Yahoo plugin
- goodle_set_goodle_functions( FALSE );
-
return( TRUE );
}
// ------------------------------------------------------------------------------------------------------
@@ -284,13 +278,13 @@
void yahoo_doodle_command_got_request( GaimConnection *gc, char *from )
{
+ g_print( "-----------------------------------------------\n" );
+ g_print( "Got REQUEST (%s)\n", from );
+
GaimAccount *account = gaim_connection_get_account( gc );
// Only handle this if local client requested Doodle session (else local client would have sent one)
- GaimWhiteboard *wb = gaim_whiteboard_get( account, from );
-
- g_print( "-----------------------------------------------\n" );
- g_print( "Got REQUEST (%s)\n", from );
+ GaimWhiteboard *wb = gaim_whiteboard_get_session( account, from );
// If a session with the remote user doesn't exist
if( wb == NULL )
@@ -318,13 +312,13 @@
void yahoo_doodle_command_got_ready( GaimConnection *gc, char *from )
{
+ g_print( "-----------------------------------------------\n" );
+ g_print( "Got READY (%s)\n", from );
+
GaimAccount *account = gaim_connection_get_account( gc );
// Only handle this if local client requested Doodle session (else local client would have sent one)
- GaimWhiteboard *wb = gaim_whiteboard_get( account, from );
-
- g_print( "-----------------------------------------------\n" );
- g_print( "Got READY (%s)\n", from );
+ GaimWhiteboard *wb = gaim_whiteboard_get_session( account, from );
if( wb == NULL )
return;
@@ -332,7 +326,7 @@
if( wb->state == DOODLE_STATE_REQUESTING )
{
// TODO Check for active pixmap?
- //goodle_doodle_session_start( ds );
+ gaim_whiteboard_start( wb );
wb->state = DOODLE_STATE_ESTABLISHED;
@@ -345,8 +339,6 @@
// Ask whether to save picture too
//goodle_doodle_session_clear_canvas( ds );
-
- //goodle_doodle_session_set_canvas_as_icon( ds );
}
}
@@ -354,19 +346,19 @@
void yahoo_doodle_command_got_draw( GaimConnection *gc, char *from, char *message )
{
- GaimAccount *account = gaim_connection_get_account( gc );
-
- // Only handle this if local client requested Doodle session (else local client would have sent one)
- GaimWhiteboard *wb = gaim_whiteboard_get( account, from );
-
- if( wb == NULL )
- return;
-
g_print( "-----------------------------------------------\n" );
g_print( "Got DRAW (%s)\n", from );
g_print( "Draw Message: %s\n", message );
+ GaimAccount *account = gaim_connection_get_account( gc );
+
+ // Only handle this if local client requested Doodle session (else local client would have sent one)
+ GaimWhiteboard *wb = gaim_whiteboard_get_session( account, from );
+
+ if( wb == NULL )
+ return;
+
// TODO Functionalize
// Convert drawing packet message to an integer list
@@ -422,13 +414,13 @@
void yahoo_doodle_command_got_clear( GaimConnection *gc, char *from )
{
+ g_print( "-----------------------------------------------\n" );
+ g_print( "Got CLEAR (%s)\n", from );
+
GaimAccount *account = gaim_connection_get_account( gc );
// Only handle this if local client requested Doodle session (else local client would have sent one)
- GaimWhiteboard *wb = gaim_whiteboard_get( account, from );
-
- g_print( "-----------------------------------------------\n" );
- g_print( "Got CLEAR (%s)\n", from );
+ GaimWhiteboard *wb = gaim_whiteboard_get_session( account, from );
if( wb == NULL )
return;
@@ -438,8 +430,6 @@
// TODO Ask user whether to save the image before clearing it
//goodle_doodle_session_clear_canvas( ds );
-
- //goodle_doodle_session_set_canvas_as_icon( ds );
}
}
@@ -447,12 +437,12 @@
void yahoo_doodle_command_got_extra( GaimConnection *gc, char *from, char *message )
{
+ g_print( "-----------------------------------------------\n" );
+ g_print( "Got EXTRA (%s)\n", from );
+
// I do not like these 'extra' features, so I'll only handle them in one way,
// which is returning them with the command/packet to turn them off
- g_print( "-----------------------------------------------\n" );
- g_print( "Got EXTRA (%s)\n", from );
-
yahoo_doodle_command_send_extra( gc, from, DOODLE_EXTRA_NONE );
}
@@ -460,14 +450,14 @@
void yahoo_doodle_command_got_confirm( GaimConnection *gc, char *from )
{
+ g_print( "-----------------------------------------------\n" );
+ g_print( "Got CONFIRM (%s)\n", from );
+
// Get the doodle session
GaimAccount *account = gaim_connection_get_account( gc );
// Only handle this if local client requested Doodle session (else local client would have sent one)
- GaimWhiteboard *wb = gaim_whiteboard_get( account, from );
-
- g_print( "-----------------------------------------------\n" );
- g_print( "Got CONFIRM (%s)\n", from );
+ GaimWhiteboard *wb = gaim_whiteboard_get_session( account, from );
if( wb == NULL )
return;
@@ -481,7 +471,7 @@
// Check if this session wasn't already started before we start it (again?)
//if( ds->pixmap == NULL )
- // goodle_doodle_session_start( ds );
+ gaim_whiteboard_start( wb );
yahoo_doodle_command_send_confirm( gc, from );
}
@@ -493,7 +483,7 @@
// Check if this session wasn't already started before we start it (again?)
//if( ds->pixmap == NULL )
- // goodle_doodle_session_start( ds );
+ gaim_whiteboard_start( wb );
}
}
@@ -501,13 +491,13 @@
void yahoo_doodle_command_got_shutdown( GaimConnection *gc, char *from )
{
+ g_print( "-----------------------------------------------\n" );
+ g_print( "Got SHUTDOWN (%s)\n", from );
+
GaimAccount *account = gaim_connection_get_account( gc );
// Only handle this if local client requested Doodle session (else local client would have sent one)
- GaimWhiteboard *wb = gaim_whiteboard_get( account, from );
-
- g_print( "-----------------------------------------------\n" );
- g_print( "Got SHUTDOWN (%s)\n", from );
+ GaimWhiteboard *wb = gaim_whiteboard_get_session( account, from );
// TODO Ask if user wants to save picture before the session is closed
@@ -515,19 +505,19 @@
if( wb == NULL )
return;
else
- ;//gtk_widget_destroy( ds->window );
+ gaim_whiteboard_destroy( wb );
}
// ------------------------------------------------------------------------------------------------------
int yahoo_doodle_command_send_request( GaimConnection *gc, char *to )
{
+ g_print( "-----------------------------------------------\n" );
+ g_print( "Sent REQUEST (%s)\n", to );
+
struct yahoo_data *yd;
struct yahoo_packet *pkt;
- g_print( "-----------------------------------------------\n" );
- g_print( "Sent REQUEST (%s)\n", to );
-
yd = gc->proto_data;
// Make and send an acknowledge (ready) Doodle packet
@@ -550,11 +540,11 @@
int yahoo_doodle_command_send_ready( GaimConnection *gc, char *to )
{
+ g_print( "-----------------------------------------------\n" );
+ g_print( "Sent READY (%s)\n", to );
+
struct yahoo_data *yd;
struct yahoo_packet *pkt;
-
- g_print( "-----------------------------------------------\n" );
- g_print( "Sent READY (%s)\n", to );
yd = gc->proto_data;
@@ -578,11 +568,11 @@
void yahoo_doodle_command_send_draw( GaimConnection *gc, char *to, char *message )
{
+ g_print( "-----------------------------------------------\n" );
+ g_print( "Sent DRAW (%s)\n", to );
+
struct yahoo_data *yd;
struct yahoo_packet *pkt;
-
- g_print( "-----------------------------------------------\n" );
- g_print( "Sent DRAW (%s)\n", to );
yd = gc->proto_data;
@@ -604,11 +594,11 @@
void yahoo_doodle_command_send_clear( GaimConnection *gc, char *to )
{
+ g_print( "-----------------------------------------------\n" );
+ g_print( "Sent CLEAR (%s)\n", to );
+
struct yahoo_data *yd;
struct yahoo_packet *pkt;
-
- g_print( "-----------------------------------------------\n" );
- g_print( "Sent CLEAR (%s)\n", to );
yd = gc->proto_data;
@@ -630,11 +620,11 @@
void yahoo_doodle_command_send_extra( GaimConnection *gc, char *to, char *message )
{
+ g_print( "-----------------------------------------------\n" );
+ g_print( "Sent EXTRA (%s)\n", to );
+
struct yahoo_data *yd;
struct yahoo_packet *pkt;
-
- g_print( "-----------------------------------------------\n" );
- g_print( "Sent EXTRA (%s)\n", to );
yd = gc->proto_data;
@@ -656,11 +646,11 @@
void yahoo_doodle_command_send_confirm( GaimConnection *gc, char *to )
{
+ g_print( "-----------------------------------------------\n" );
+ g_print( "Sent CONFIRM (%s)\n", to );
+
struct yahoo_data *yd;
struct yahoo_packet *pkt;
-
- g_print( "-----------------------------------------------\n" );
- g_print( "Sent CONFIRM (%s)\n", to );
yd = gc->proto_data;
@@ -682,11 +672,11 @@
void yahoo_doodle_command_send_shutdown( GaimConnection *gc, char *to )
{
+ g_print( "-----------------------------------------------\n" );
+ g_print( "Sent SHUTDOWN (%s)\n", to );
+
struct yahoo_data *yd;
struct yahoo_packet *pkt;
-
- g_print( "-----------------------------------------------\n" );
- g_print( "Sent SHUTDOWN (%s)\n", to );
yd = gc->proto_data;
@@ -919,8 +909,6 @@
yahoo_doodle_command_send_clear( ds->gc, ds->who );
goodle_doodle_session_clear_canvas( ds );
-
- goodle_doodle_session_set_canvas_as_icon( ds );
}
// ------------------------------------------------------------------------------------------------------
--- a/src/whiteboard.c Tue Jul 19 23:14:35 2005 -0400
+++ b/src/whiteboard.c Fri Jul 22 17:25:16 2005 -0400
@@ -27,19 +27,29 @@
// DATATYPES ============================================================================================
-//static GaimWhiteboardOps *ui_ops = NULL;
-
// GLOBALS ==============================================================================================
-static GList *wbList = NULL;
+static GaimWhiteboardUiOps *whiteboard_ui_ops = NULL;
-gboolean auto_accept = TRUE;
+static GList *wbList = NULL;
+
+static gboolean auto_accept = TRUE;
// FUNCTIONS ============================================================================================
+void gaim_whiteboard_set_ui_ops( GaimWhiteboardUiOps *ops )
+{
+ whiteboard_ui_ops = ops;
+}
+
+// ------------------------------------------------------------------------------------------------------
+
GaimWhiteboard *gaim_whiteboard_create( GaimAccount *account, char *who, int state )
{
+ g_print( "gaim_whiteboard_create()\n" );
+
GaimWhiteboard *wb = g_new0( GaimWhiteboard, 1 );
+ g_print( "-->wb=%p\n", wb );
wb->account = account;
@@ -57,23 +67,41 @@
void gaim_whiteboard_destroy( GaimWhiteboard *wb )
{
+ g_print( "gaim_whiteboard_destroy()\n" );
+ g_print( "-->wb=%p\n", wb );
+
wbList = g_list_remove( wbList, wb );
wb->account = NULL;
g_free( wb->who );
+ g_print( "freed (wb->who)\n" );
wb->state = 0;
g_free( wb );
+ g_print( "freed (wb)\n" );
+}
+
+// ------------------------------------------------------------------------------------------------------
+
+void gaim_whiteboard_start( GaimWhiteboard *wb )
+{
+ g_print( "gaim_whiteboard_start()\n" );
+
+ // Create frontend for whiteboard
+ if( whiteboard_ui_ops && whiteboard_ui_ops->create )
+ whiteboard_ui_ops->create( wb );
}
// ------------------------------------------------------------------------------------------------------
// Looks through the list of whiteboard sessions for one that is between usernames 'me' and 'who'
// Returns a pointer to a matching whiteboard session; if none match, it returns NULL
-GaimWhiteboard *gaim_whiteboard_get( GaimAccount *account, char *who )
+GaimWhiteboard *gaim_whiteboard_get_session( GaimAccount *account, char *who )
{
+ g_print( "gaim_whiteboard_get_session()\n" );
+
GaimWhiteboard *wb = NULL;
GList *l = wbList;
@@ -85,7 +113,10 @@
if( !strcmp( gaim_account_get_username( wb->account ), gaim_account_get_username( account ) ) &&
!strcmp( wb->who, who ) )
+ {
+ g_print( "@Found whiteboard session\n" );
return( wb );
+ }
l = l->next;
}
@@ -115,19 +146,18 @@
// ------------------------------------------------------------------------------------------------------
-/*
-void gaim_whiteboard_draw_line( GaimWhiteBoard *board, int x1, int y1, int x2, int y2 )
+void gaim_whiteboard_draw_point( GaimWhiteboard *wb, int x, int y, int color, int size )
{
- if( ui_ops && ui_ops->draw_line )
- ui_ops->draw_line( board, x1, y1, x2, y2 );
+ if( whiteboard_ui_ops && whiteboard_ui_ops->draw_point )
+ whiteboard_ui_ops->draw_point( wb, x, y, color, size );
}
// ------------------------------------------------------------------------------------------------------
-void gaim_whiteboard_set_ui_ops( GaimWhiteboardOps *ops )
+void gaim_whiteboard_draw_line( GaimWhiteboard *wb, int x1, int y1, int x2, int y2, int color, int size )
{
- ui_ops = ops;
+ if( whiteboard_ui_ops && whiteboard_ui_ops->draw_line )
+ whiteboard_ui_ops->draw_line( wb, x1, y1, x2, y2, color, size );
}
// ------------------------------------------------------------------------------------------------------
-*/
--- a/src/whiteboard.h Tue Jul 19 23:14:35 2005 -0400
+++ b/src/whiteboard.h Fri Jul 22 17:25:16 2005 -0400
@@ -42,26 +42,31 @@
char *who; // Name of the remote user
void *proto_data; // Protocol specific data
- //void *gui_data; // Graphical user-interface data
+ void *ui_data; // Graphical user-interface data
GList *draw_list; // List of drawing elements/deltas to send
} GaimWhiteboard;
-/*
-typedef struct _GaimWhiteBoardOps
+
+typedef struct _GaimWhiteboardUiOps
{
- void ( *draw_line )( GaimWhiteboard *wb, int x1, int y1, int x2, int y2 );
-} GaimWhiteBoardOps;
-*/
+ void ( *create )( GaimWhiteboard *wb );
+ void ( *destroy )( GaimWhiteboard *wb );
+ void ( *draw_point )( GaimWhiteboard *wb, int x, int y, int color, int size );
+ void ( *draw_line )( GaimWhiteboard *wb, int x1, int y1, int x2, int y2, int color, int size );
+} GaimWhiteboardUiOps;
+
// PROTOTYPES ==========================================================================================
+void gaim_whiteboard_set_ui_ops( GaimWhiteboardUiOps *ops );
+
GaimWhiteboard *gaim_whiteboard_create( GaimAccount *account, char *who, int state );
void gaim_whiteboard_destroy( GaimWhiteboard *wb );
-GaimWhiteboard *gaim_whiteboard_get( GaimAccount *account, char *who );
+void gaim_whiteboard_start( GaimWhiteboard *wb );
+GaimWhiteboard *gaim_whiteboard_get_session( GaimAccount *account, char *who );
void gaim_whiteboard_draw_list_destroy( GList *d_list );
-//void gaim_whiteboard_draw_line( GaimWhiteboard *wb, int x1, int y1, int x2, int y2 );
-//void gaim_whiteboard_set_ops( GaimWhiteboardOps *ops );
+void gaim_whiteboard_draw_line( GaimWhiteboard *wb, int x1, int y1, int x2, int y2, int color, int size );
#endif // _GAIM_WHITEBOARD_H_
Binary file src/whiteboard.o has changed