[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Ayttm-commits] CVS: ayttm/src Makefile.am,1.7,1.8 browser.c,1.6,1.7 ch
From: |
Colin Leroy <address@hidden> |
Subject: |
[Ayttm-commits] CVS: ayttm/src Makefile.am,1.7,1.8 browser.c,1.6,1.7 chat_room.c,1.26,1.27 |
Date: |
Tue, 14 Jan 2003 07:03:14 -0500 |
Update of /cvsroot/ayttm/ayttm/src
In directory subversions:/tmp/cvs-serv32472/src
Modified Files:
Makefile.am browser.c chat_room.c
Log Message:
Clean old buggy netscape code
Mozilla is now the default browser
Index: Makefile.am
===================================================================
RCS file: /cvsroot/ayttm/ayttm/src/Makefile.am,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Makefile.am 14 Jan 2003 10:51:56 -0000 1.7
+++ Makefile.am 14 Jan 2003 12:03:12 -0000 1.8
@@ -19,7 +19,7 @@
nomodule.h file_select.h extgtktext.h contact_actions.h \
smileys.h intl.h account_parser.h contact_parser.h crash.h
-EXTRA_DIST =
+EXTRA_DIST = openurl.sh
CFLAGS = @CFLAGS@ $(EB_CFLAGS) -I$(top_srcdir) -I$(top_srcdir)/libproxy \
$(GNOME_INCLUDEDIR)
@@ -30,7 +30,7 @@
localedir = $(datadir)/locale
DEFS = @DEFS@ -DLOCALEDIR=\"$(localedir)\" -D_REENTRANT
-bin_SCRIPTS =
+bin_SCRIPTS =
defaults.h: Makefile
@rm -f defaults.h >/dev/null 2>&1;
Index: browser.c
===================================================================
RCS file: /cvsroot/ayttm/ayttm/src/browser.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- browser.c 10 Jan 2003 23:43:56 -0000 1.6
+++ browser.c 14 Jan 2003 12:03:12 -0000 1.7
@@ -55,568 +55,47 @@
};
#ifndef _WIN32
-gint web_browser = BROWSER_NETSCAPE;
-
-
-
-
-
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-
-
-// static const char *progname = "Yattm"; // Nobody uses this
-static const char *expected_mozilla_version = "1.1";
-
-#define MOZILLA_VERSION_PROP "_MOZILLA_VERSION"
-#define MOZILLA_LOCK_PROP "_MOZILLA_LOCK"
-#define MOZILLA_COMMAND_PROP "_MOZILLA_COMMAND"
-#define MOZILLA_RESPONSE_PROP "_MOZILLA_RESPONSE"
-
-static GdkAtom XA_MOZILLA_VERSION = 0;
-static GdkAtom XA_MOZILLA_LOCK = 0;
-static GdkAtom XA_MOZILLA_COMMAND = 0;
-static GdkAtom XA_MOZILLA_RESPONSE = 0;
-
-
-static int netscape_lock;
-
-
-static Window
-VirtualRootWindowOfScreen(screen)
- Screen *screen;
-{
- static Screen *save_screen = (Screen *)0;
- static Window root = (Window)0;
-
- if (screen != save_screen) {
- Display *dpy = DisplayOfScreen(screen);
- Atom __SWM_VROOT = None;
- unsigned int i;
- Window rootReturn, parentReturn, *children;
- unsigned int numChildren;
-
- root = RootWindowOfScreen(screen);
-
- /* go look for a virtual root */
- __SWM_VROOT = XInternAtom(dpy, "__SWM_VROOT", False);
- if (XQueryTree(dpy, root, &rootReturn, &parentReturn,
- &children, &numChildren)) {
- for (i = 0; i < numChildren; i++) {
- Atom actual_type;
- int actual_format;
- unsigned long nitems, bytesafter;
- Window *newRoot = (Window *)0;
-
- if (XGetWindowProperty(dpy, children[i],
- __SWM_VROOT, 0, 1, False, XA_WINDOW,
- &actual_type, &actual_format,
- &nitems, &bytesafter,
- (unsigned char **) &newRoot) == Success
- && newRoot) {
- root = *newRoot;
- break;
- }
- }
- if (children)
- XFree((char *)children);
- }
-
- save_screen = screen;
- }
-
- return root;
-}
-
-/* The following code is Copyright (C) 1989 X Consortium */
-
-static Window TryChildren();
-
-/* Find a window with WM_STATE, else return win itself, as per ICCCM */
-
-static Window GClientWindow (dpy, win)
- Display *dpy;
- Window win;
-{
- Atom WM_STATE;
- Atom type = None;
- int format;
- unsigned long nitems, after;
- unsigned char *data;
- Window inf;
-
- WM_STATE = XInternAtom(dpy, "WM_STATE", True);
- if (!WM_STATE)
- return win;
- XGetWindowProperty(dpy, win, WM_STATE, 0, 0, False, AnyPropertyType,
- &type, &format, &nitems, &after, &data);
- if (type)
- return win;
- inf = TryChildren(dpy, win, WM_STATE);
- if (!inf)
- inf = win;
- return inf;
-}
-
-static
-Window TryChildren (dpy, win, WM_STATE)
- Display *dpy;
- Window win;
- Atom WM_STATE;
-{
- Window root, parent;
- Window *children;
- unsigned int nchildren;
- unsigned int i;
- Atom type = None;
- int format;
- unsigned long nitems, after;
- unsigned char *data;
- Window inf = 0;
-
- if (!XQueryTree(dpy, win, &root, &parent, &children, &nchildren))
- return 0;
- for (i = 0; !inf && (i < nchildren); i++) {
- XGetWindowProperty(dpy, children[i], WM_STATE, 0, 0, False,
- AnyPropertyType, &type, &format, &nitems,
- &after, &data);
- if (type)
- inf = children[i];
- }
- for (i = 0; !inf && (i < nchildren); i++)
- inf = TryChildren(dpy, children[i], WM_STATE);
- if (children) XFree((char *)children);
- return inf;
-}
-
-/* END X Consortium code */
-
-
-static void mozilla_remote_init_atoms()
-{
- if (!XA_MOZILLA_VERSION)
- XA_MOZILLA_VERSION = gdk_atom_intern(MOZILLA_VERSION_PROP, 0);
- if (!XA_MOZILLA_LOCK)
- XA_MOZILLA_LOCK = gdk_atom_intern(MOZILLA_LOCK_PROP, 0);
- if (! XA_MOZILLA_COMMAND)
- XA_MOZILLA_COMMAND = gdk_atom_intern(MOZILLA_COMMAND_PROP, 0);
- if (! XA_MOZILLA_RESPONSE)
- XA_MOZILLA_RESPONSE = gdk_atom_intern(MOZILLA_RESPONSE_PROP, 0);
-}
-
-static GdkWindow *mozilla_remote_find_window()
-{
- int i;
- Window root =
VirtualRootWindowOfScreen(DefaultScreenOfDisplay(gdk_display));
- Window root2, parent, *kids;
- unsigned int nkids;
- Window result = 0;
- Window tenative = 0;
- unsigned char *tenative_version = 0;
-
- if (!XQueryTree (gdk_display, root, &root2, &parent, &kids, &nkids))
- {
- }
-
- /* root != root2 is possible with virtual root WMs. */
-
- if (!(kids && nkids)) {
- return NULL;
- }
-
- for (i = nkids-1; i >= 0; i--)
- {
- Atom type;
- int format;
- unsigned long nitems, bytesafter;
- unsigned char *version = 0;
- Window w = GClientWindow (gdk_display, kids[i]);
- int status = XGetWindowProperty (gdk_display, w,
XA_MOZILLA_VERSION,
- 0, (65536 / sizeof (long)),
- False, XA_STRING,
- &type, &format, &nitems,
&bytesafter,
- &version);
- if (! version)
- continue;
- if (strcmp ((char *) version, expected_mozilla_version) &&
- !tenative)
- {
- tenative = w;
- tenative_version = version;
- continue;
- }
- g_free (version);
- if (status == Success && type != None)
- {
- result = w;
- break;
- }
- }
-
- if (result && tenative)
- {
- g_free (tenative_version);
- return gdk_window_foreign_new(result);
- }
- else if (tenative)
- {
- g_free (tenative_version);
- return gdk_window_foreign_new(tenative);
- }
- else if (result)
- {
- return gdk_window_foreign_new(result);
- }
- else
- {
- return NULL;
- }
-}
-
-
-static char *lock_data = 0;
-
-static void mozilla_remote_obtain_lock (GdkWindow *window)
-{
- Bool locked = False;
-
- if (!lock_data) {
- lock_data = (char *)g_malloc (255);
- sprintf (lock_data, "pid%d@", getpid ());
- if (gethostname (lock_data + strlen (lock_data), 100)) {
- return;
- }
- }
-
- do {
- int result;
- GdkAtom actual_type;
- gint actual_format;
- gint nitems;
- unsigned char *data = 0;
-
- result = gdk_property_get (window, XA_MOZILLA_LOCK,
- XA_STRING, 0,
- (65536 / sizeof (long)), 0,
- &actual_type, &actual_format,
- &nitems, &data);
- if (result != Success || actual_type == None)
- {
- /* It's not now locked - lock it. */
-
- gdk_property_change(window,
XA_MOZILLA_LOCK, XA_STRING,
- 8, PropModeReplace,
- (unsigned char *) lock_data,
- strlen (lock_data));
- locked = True;
- }
-
- if (!locked) {
- /* Then just fuck it. */
- if (data)
- g_free(data);
- return;
- }
- if (data)
- g_free(data);
- } while (!locked);
-}
-
-
-static void mozilla_remote_free_lock (GdkWindow *window)
-{
- int result = 0;
- GdkAtom actual_type;
- gint actual_format;
- gint nitems;
- unsigned char *data = 0;
-
-
- result = gdk_property_get(window, XA_MOZILLA_LOCK, XA_STRING,
- 0, (65536 / sizeof (long)),
- 1, &actual_type, &actual_format,
- &nitems, &data);
- if (result != Success)
- {
- return;
- }
- else if (!data || !*data)
- {
- return;
- }
- else if (strcmp ((char *) data, lock_data))
- {
- return;
- }
-
- if (data)
- g_free(data);
-}
-
-
-static int
-mozilla_remote_command (GdkWindow *window, const char *command,
- Bool raise_p)
-{
- int result = 0;
- Bool done = False;
- char *new_command = 0;
-
- /* The -noraise option is implemented by passing a "noraise" argument
- to each command to which it should apply.
- */
- if (!raise_p)
- {
- char *close;
- new_command = (char *) malloc (strlen (command) + 20);
- strcpy (new_command, command);
- close = strrchr (new_command, ')');
- if (close)
- strcpy (close, ", noraise)");
- else
- strcat (new_command, "(noraise)");
- command = new_command;
- }
-
-
- gdk_property_change(window, XA_MOZILLA_COMMAND, XA_STRING, 8,
- GDK_PROP_MODE_REPLACE, (unsigned char *) command,
- strlen (command));
-
- while (!done) {
- GdkEvent *event;
-
- event = gdk_event_get();
-
- if (!event)
- continue;
-
- if (event->any.window != window) {
- gtk_main_do_event(event);
- continue;
- }
-
- if (event->type == GDK_DESTROY &&
- event->any.window == window) {
-
- /* Print to warn user...*/
- result = 6;
- goto DONE;
- } else if (event->type == GDK_PROPERTY_NOTIFY &&
- event->property.state == GDK_PROPERTY_NEW_VALUE &&
- event->property.window == window &&
- event->property.atom == XA_MOZILLA_RESPONSE) {
- GdkAtom actual_type;
- gint actual_format, nitems;
- unsigned char *data = 0;
-
- result = gdk_property_get (window, XA_MOZILLA_RESPONSE,
- XA_STRING, 0,
- (65536 / sizeof (long)),
- 1,
- &actual_type, &actual_format,
- &nitems, &data);
-
-
- if (result == Success && data && *data) {
- }
-
- if (result != Success) {
- result = 6;
- done = True;
- } else if (!data || strlen((char *) data) < 5) {
- result = 6;
- done = True;
- } else if (*data == '1') { /* positive preliminary
reply */
- } else if (!strncmp ((char *)data, "200", 3)) {
- result = 0;
- done = True;
- } else if (*data == '2') {
- result = 0;
- done = True;
- } else if (*data == '3') {
- result = 3;
- done = True;
- } else if (*data == '4' || *data == '5') {
- result = (*data - '0');
- done = True;
- } else {
- result = 6;
- done = True;
- }
-
- if (data)
- g_free(data);
- }
- else if (event->type == GDK_PROPERTY_NOTIFY &&
- event->property.window == window &&
- event->property.state == GDK_PROPERTY_DELETE &&
- event->property.atom == XA_MOZILLA_COMMAND) {
- }
- gdk_event_free(event);
- }
-
-DONE:
-
- if (new_command)
- g_free (new_command);
-
- return result;
-}
-
-
-gint check_netscape(char *msg)
-{
- int status;
- GdkWindow *window;
-
- mozilla_remote_init_atoms ();
- window = mozilla_remote_find_window();
-
- if (window) {
-
- XSelectInput(gdk_display, ((GdkWindowPrivate *)window)->xwindow,
- (PropertyChangeMask|StructureNotifyMask));
-
-
- mozilla_remote_obtain_lock(window);
-
- status = mozilla_remote_command(window, msg, False);
-
- if (status != 6)
- mozilla_remote_free_lock(window);
-
- gtk_timeout_add(1000, (GtkFunction)clean_pid, NULL);
-
- netscape_lock = 0;
-
- g_free(msg);
- return FALSE;
- } else
- return TRUE;
-}
-
-
-static void netscape_command(char *command)
-{
- int status;
- pid_t pid;
- GdkWindow *window;
-
- if (netscape_lock)
- return;
-
- netscape_lock = 1;
-
-
-
- mozilla_remote_init_atoms();
- window = mozilla_remote_find_window();
-
- if (window) {
-
- XSelectInput(gdk_display, ((GdkWindowPrivate *)window)->xwindow,
- (PropertyChangeMask|StructureNotifyMask));
-
- mozilla_remote_obtain_lock(window);
-
- status = mozilla_remote_command(window, command, False);
-
- if (status != 6)
- mozilla_remote_free_lock(window);
-
- netscape_lock = 0;
+gint web_browser = BROWSER_NETSCAPE;
- } else {
- pid = fork();
- if (pid == 0) {
- char *args[2];
- int e;
-
- args[0] = g_strdup("netscape");
- args[1] = NULL;
- e = execvp(args[0], args);
-
- _exit(0);
- } else {
- char *tmp = g_strdup(command);
- gtk_timeout_add(200, (GtkFunction)check_netscape, tmp);
- }
- }
-
-}
-
void open_url(GtkWidget *w, char *url) {
- if (web_browser == BROWSER_NETSCAPE) {
- char *command = g_malloc(1024);
-
- g_snprintf(command, 1024, "OpenURL(%s)", url);
-
- netscape_command(command);
- g_free(command);
- } else if (web_browser == BROWSER_KFM) {
- pid_t pid;
-
- pid = fork();
-
- if (pid == 0) {
- char *args[4];
-
- args[0] = g_strdup("kfmclient");
- args[1] = g_strdup("openURL");
- args[2] = url;;
- args[3] = NULL;
-
- execvp(args[0], args);
- _exit(0);
- } else {
- gtk_timeout_add(1000, (GtkFunction)clean_pid, NULL);
- }
- }
-}
-
-void add_bookmark(GtkWidget *w, char *url) {
- if (web_browser == BROWSER_NETSCAPE) {
- char *command = g_malloc(1024);
-
- g_snprintf(command, 1024, "AddBookmark(%s)", url);
-
- netscape_command(command);
- g_free(command);
- }
+ open_url_nw(w,url);
}
void open_url_nw(GtkWidget *w, char *url) {
- const char *alternate_browser = cGetLocalPref("alternate_browser");
-
- if ( iGetLocalPref("use_alternate_browser") &&
(strlen(alternate_browser) > 0)) {
- char *command = g_malloc(1024);
- const char *url_pos = strstr(alternate_browser, "%s");
- /*
- * if alternate_browser contains a %s, then we put
- * the url in place of the %s, else, put the url
- * at the end.
- */
- if(url_pos) {
- int pre_len = url_pos-alternate_browser;
- strncpy(command, alternate_browser, pre_len);
- command[pre_len] = 0;
- strncat(command, url, 1024 - pre_len);
- strncat(command, url_pos+2, 1024 - strlen(command));
- strncat(command, " &", 1024 - strlen(command));
- } else
- g_snprintf(command, 1024, "%s \"%s\" &",
alternate_browser, url);
- eb_debug(DBG_CORE, "launching %s\n", command);
- system(command);
- g_free(command);
- } else if (web_browser == BROWSER_NETSCAPE) {
- char *command = g_malloc(1024);
- g_snprintf(command, 1024, "OpenURL(%s, new-window)", url);
-
- netscape_command(command);
- g_free(command);
+ char *browser = NULL;
+ char *command = g_malloc(1024);
+ char *url_pos = NULL;
+ char *esc_url = g_strdup_printf("\"%s\"", url);
+
+ if (iGetLocalPref("use_alternate_browser"))
+ browser = cGetLocalPref("alternate_browser");
+ else
+ browser = "mozilla %s";
+
+ if (!browser || (strlen(browser) == 0)) {
+ browser = "mozilla %s";
+ }
+ url_pos = strstr(browser, "%s");
+ /*
+ * if alternate_browser contains a %s, then we put
+ * the url in place of the %s, else, put the url
+ * at the end.
+ */
+ if(url_pos) {
+ int pre_len = url_pos-browser;
+ strncpy(command, browser, pre_len);
+ command[pre_len] = 0;
+ strncat(command, esc_url, 1024 - pre_len);
+ strncat(command, url_pos+2, 1024 - strlen(command));
+ strncat(command, " &", 1024 - strlen(command));
+ g_free(esc_url);
+ } else {
+ g_snprintf(command, 1024, "%s \"%s\" &", browser, url);
}
+ eb_debug(DBG_CORE, "launching %s\n", command);
+ system(command);
+ g_free(command);
}
#else
@@ -624,10 +103,9 @@
#include <process.h>
gint web_browser = BROWSER_INTERNAL;
-void add_bookmark(GtkWidget *w, char *url) {
-}
-
void open_url_nw(GdkWindow *w, char *url) {
+ if (!w)
+ return;
ShellExecute(GDK_DRAWABLE_XID(w),"open",url,NULL,"C:\\",0);
}
Index: chat_room.c
===================================================================
RCS file: /cvsroot/ayttm/ayttm/src/chat_room.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- chat_room.c 13 Jan 2003 16:16:14 -0000 1.26
+++ chat_room.c 14 Jan 2003 12:03:12 -0000 1.27
@@ -496,10 +496,6 @@
gtk_signal_connect( GTK_OBJECT(join_chat_window), "destroy",
GTK_SIGNAL_FUNC(join_chat_destroy), NULL );
}
-
-
-
-
static void destroy(GtkWidget * widget, gpointer data)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Ayttm-commits] CVS: ayttm/src Makefile.am,1.7,1.8 browser.c,1.6,1.7 chat_room.c,1.26,1.27,
Colin Leroy <address@hidden> <=
- Prev by Date:
[Ayttm-commits] CVS: ayttm ChangeLog,1.101,1.102 configure.in,1.99,1.100
- Next by Date:
[Ayttm-commits] CVS: ayttm/src Makefile.am,1.8,1.9
- Previous by thread:
[Ayttm-commits] CVS: ayttm ChangeLog,1.101,1.102 configure.in,1.99,1.100
- Next by thread:
[Ayttm-commits] CVS: ayttm/src Makefile.am,1.8,1.9
- Index(es):