#include "RxPlugin.h"
#include "XUrls.h"
#include "XAuth.h"
#include "XDpyName.h"
#include "Prefs.h"
#include <X11/StringDefs.h>
#include <limits.h>
#ifndef MAXHOSTNAMELEN
# define MAXHOSTNAMELEN 256
#endif
#ifdef XUSE_XTREGISTERWINDOW
extern void _XtRegisterWindow (Window window, Widget widget);
#define XtRegisterDrawable(d,win,wid) _XtRegisterWindow(win,wid)
extern void _XtUnregisterWindow (Window window, Widget widget);
#define UnregisterDrawable(win,wid) _XtUnregisterWindow(win,wid)
#else
#define UnregisterDrawable(win,wid) XtUnregisterDrawable(XtDisplay(wid),win)
#endif
#define DEFAULT_TIMEOUT 300
#define NO_TIMEOUT 0
static void
GetWindowGeometry(
Display* dpy,
Window win,
Position* x,
Position* y,
Dimension* width,
Dimension* height,
Dimension* border_width,
Colormap *cmap)
{
long mask;
XSizeHints* sizehints = XAllocSizeHints();
XWindowAttributes wattr;
if (XGetWindowAttributes (dpy, win, &wattr)) {
*x = wattr.x;
*y = wattr.y;
*width = wattr.width;
*height = wattr.height;
*border_width = wattr.border_width;
*cmap = wattr.colormap;
}
if (sizehints) {
XGetWMNormalHints (dpy, win, sizehints, &mask);
if (mask & (USPosition|PPosition)) {
*x = sizehints->x;
*y = sizehints->y;
*width = sizehints->width;
*height = sizehints->height;
XFree ((char*) sizehints);
return;
}
XFree ((char*) sizehints);
}
*x = 0;
*y = 0;
*width = 0;
*height = 0;
}
static Bool
IsInWinList(Window *list, int count, Window win)
{
int i;
for (i = 0; i < count; i++, list++)
if (*list == win)
return True;
return False;
}
#ifdef UNUSED
static void
AppendToWinList(Window **new_list, int *new_count,
Window *list, int count, Window win)
{
*new_count = count + 1;
*new_list = (Window*) malloc(sizeof(Window) * *new_count);
memcpy(*new_list, list, sizeof(Window) * count);
(*new_list)[count] = win;
}
#endif
static void
PrependToWinList(Window **new_list, int *new_count,
Window *list, int count, Window win)
{
*new_count = count + 1;
*new_list = (Window*) malloc(sizeof(Window) * *new_count);
(*new_list)[0] = win;
memcpy(*new_list + 1, list, sizeof(Window) * count);
}
static void
SetFirstWinList(Window *list, int count, Window win)
{
int i;
list += count - 1;
for (i = 0; i < count; i++, list--)
if (*list == win)
break;
if (i < count) {
for (i++; i < count; i++) {
list--;
list[1] = list[0];
}
*list = win;
}
}
static void
SetLastWinList(Window *list, int count, Window win)
{
if (*list == win) {
int i;
for (i = 0; i < count - 1; i++, list++)
list[0] = list[1];
*list = win;
}
}
static void
RemoveFromWinList(Window **wlist, int *count, Window win)
{
Window *list = *wlist;
int i;
for (i = 0; i < *count; i++, list++)
if (*list == win) {
(*count)--;
break;
}
for (; i < *count; i++, list++)
list[0] = list[1];
}
#ifdef UNUSED
static void
ConcatWinLists(Window **list, int *count,
Window *list1, int count1,
Window *list2, int count2)
{
*count = count1 + count2;
*list = (Window*) malloc(sizeof(Window) * *count);
memcpy(*list, list1, sizeof(Window) * count1);
memcpy(*list + count1, list2, sizeof(Window) * count2);
}
static void
SubstractWinLists(Window **wlist, int *count,
Window *list1, int count1)
{
Window *list = *wlist;
int i, j;
for (i = 0; i < *count; i++, list++)
if (*list == *list1)
break;
for (j = 0; j < count1 && i + j < *count; j++, list1++)
if (list[j] != *list1)
break;
*count -= j;
for (; i < *count; i++, list++)
list[0] = list[j];
}
#endif
static void
SetWMColormap(PluginInstance* This, Window win)
{
int i;
Colormap top_cmap;
Arg arg;
for (i = 0; i < This->nclient_windows; i++)
if ((This->client_windows[i].win = win))
break;
if (i == This->nclient_windows)
return;
XtSetArg(arg, XtNcolormap, &top_cmap);
XtGetValues(This->toplevel_widget, &arg, 1);
if (This->client_windows[i].colormap != top_cmap) {
Window *cur_list;
int cur_count = 0;
if (XGetWMColormapWindows(RxGlobal.dpy, XtWindow(This->toplevel_widget),
&cur_list, &cur_count) == True &&
cur_count != 0) {
if (IsInWinList(cur_list, cur_count, win)) {
SetFirstWinList(cur_list, cur_count, win);
XSetWMColormapWindows(RxGlobal.dpy,
XtWindow(This->toplevel_widget),
cur_list, cur_count);
} else {
Window *new_list;
int new_count;
PrependToWinList(&new_list, &new_count,
cur_list, cur_count, win);
XSetWMColormapWindows(RxGlobal.dpy,
XtWindow(This->toplevel_widget),
new_list, new_count);
free(new_list);
}
} else {
Window list[2];
list[0] = win;
list[1] = XtWindow(This->toplevel_widget);
XSetWMColormapWindows(RxGlobal.dpy, XtWindow(This->toplevel_widget),
list, 2);
}
if (cur_count != 0)
XFree(cur_list);
}
}
static void
UnsetWMColormap(PluginInstance* This, Window win)
{
Window *list;
int count = 0;
if (XGetWMColormapWindows(RxGlobal.dpy, XtWindow(This->toplevel_widget),
&list, &count) == True && count != 0) {
SetLastWinList(list, count, win);
XSetWMColormapWindows(RxGlobal.dpy, XtWindow(This->toplevel_widget),
list, count);
}
if (count != 0)
XFree(list);
}
static void
ResetWMColormap(PluginInstance* This, Window win)
{
Window *list;
int count = 0;
if (XGetWMColormapWindows(RxGlobal.dpy, XtWindow(This->toplevel_widget),
&list, &count) == True && count != 0) {
RemoveFromWinList(&list, &count, win);
if (count > 1)
XSetWMColormapWindows(RxGlobal.dpy, XtWindow(This->toplevel_widget),
list, count);
else {
Atom prop;
prop = XInternAtom (RxGlobal.dpy, "WM_COLORMAP_WINDOWS", False);
XDeleteProperty(RxGlobal.dpy, XtWindow(This->toplevel_widget), prop);
}
}
if (count != 0)
XFree(list);
}
void
SubstructureRedirectHandler (
Widget widget,
XtPointer client_data,
XEvent* event,
Boolean* cont)
{
windowrec* new_list;
PluginInstance* This = (PluginInstance*) client_data;
#ifdef PLUGIN_TRACE
fprintf (stderr, "%s\n", "SubstructureRedirectHandler");
fprintf (stderr, "This: 0x%x\n", This);
#endif
switch (event->type) {
case ConfigureRequest:
{
XWindowChanges config;
config.x = event->xconfigurerequest.x;
config.y = event->xconfigurerequest.y;
config.width = event->xconfigurerequest.width;
config.height = event->xconfigurerequest.height;
config.border_width = event->xconfigurerequest.border_width;
config.sibling = event->xconfigurerequest.above;
config.stack_mode = event->xconfigurerequest.detail;
#if 0
fprintf (stderr, "configuring at %dx%d+%d+%d\n",
config.width, config.height, config.x, config.y);
#endif
XConfigureWindow (RxGlobal.dpy,
event->xconfigurerequest.window,
event->xconfigurerequest.value_mask,
&config);
}
break;
case MapRequest:
RxpSetStatusWidget(This, RUNNING);
{
Window for_win;
int i;
if (XGetTransientForHint (RxGlobal.dpy, event->xmaprequest.window,
&for_win)) {
for (i = 0; i < This->nclient_windows; i++)
if (for_win == This->client_windows[i].win)
XMapWindow (RxGlobal.dpy, event->xmaprequest.window);
return;
}
}
new_list = (windowrec*)
NPN_MemAlloc (sizeof (windowrec) * (This->nclient_windows + 1));
if (new_list) {
Position x, y;
Dimension width, height;
Dimension border_width;
Colormap cmap;
int n;
Atom* wm_proto;
windowrec* wp;
Window destwin = XtWindow (This->plugin_widget);
This->nclient_windows++;
if (This->nclient_windows > 1)
memcpy ((void*) new_list, (void*) This->client_windows,
(This->nclient_windows - 1) * sizeof (windowrec));
if (This->client_windows)
NPN_MemFree (This->client_windows);
This->client_windows = new_list;
x = y = 0;
width = height = border_width = 0;
GetWindowGeometry (RxGlobal.dpy, event->xmaprequest.window,
&x, &y, &width, &height, &border_width, &cmap);
wp = &This->client_windows[This->nclient_windows - 1];
wp->win = event->xmaprequest.window;
wp->x = x; wp->y = y;
wp->width = width; wp->height = height;
wp->border_width = border_width;
wp->flags = RxpMapped;
wp->colormap = cmap;
if (XGetWMProtocols (RxGlobal.dpy, wp->win, &wm_proto, &n)) {
int i;
Atom* ap;
for (i = 0, ap = wm_proto; i < n; i++, ap++) {
if (*ap == RxGlobal.wm_delete_window)
wp->flags |= RxpWmDelWin;
}
if (wm_proto) XFree ((char*) wm_proto);
}
XSelectInput(RxGlobal.dpy, wp->win,
EnterWindowMask | LeaveWindowMask);
XtRegisterDrawable (RxGlobal.dpy, wp->win, This->plugin_widget);
XReparentWindow (RxGlobal.dpy, wp->win, destwin, wp->x, wp->y);
XMapWindow (RxGlobal.dpy, wp->win);
}
break;
}
}
void
RxpWmDelWinHandler (
Widget widget,
XtPointer client_data,
XEvent* event,
Boolean* cont)
{
PluginInstance* This = (PluginInstance*) client_data;
int i;
if (event == NULL ||
(event->type == ClientMessage &&
event->xclient.message_type == RxGlobal.wm_protocols &&
event->xclient.data.l[0] == RxGlobal.wm_delete_window)) {
for (i = 0; i < This->nclient_windows; i++) {
if (This->client_windows[i].flags & RxpWmDelWin) {
XClientMessageEvent ev;
ev.type = ClientMessage;
ev.window = This->client_windows[i].win;
ev.message_type = RxGlobal.wm_protocols;
ev.format = 32;
ev.data.l[0] = RxGlobal.wm_delete_window;
ev.data.l[1] = XtLastTimestampProcessed (XtDisplay (widget));
XSendEvent (RxGlobal.dpy, ev.window, FALSE, 0L, (XEvent*) &ev);
}
}
}
}
static void
StructureNotifyHandler (
Widget widget,
XtPointer client_data,
XEvent* event,
Boolean* cont)
{
PluginInstance* This = (PluginInstance*) client_data;
#ifdef PLUGIN_TRACE
fprintf (stderr, "%s\n", "StructureNotifyHandler");
#endif
switch (event->type) {
case ConfigureNotify:
case GravityNotify:
if (This->plugin_widget == NULL)
return;
{
int i;
Position x, y;
XConfigureEvent sendev;
XtTranslateCoords (This->plugin_widget, 0, 0, &x, &y);
for (i = 0; i < This->nclient_windows; i++) {
sendev.type = ConfigureNotify;
sendev.send_event = True;
sendev.event = sendev.window = This->client_windows[i].win;
sendev.x = x + This->client_windows[i].x;
sendev.y = y + This->client_windows[i].y;
sendev.width = This->client_windows[i].width;
sendev.height = This->client_windows[i].height;
sendev.border_width = This->client_windows[i].border_width;
sendev.above = None;
sendev.override_redirect = False;
if (!XSendEvent (RxGlobal.dpy, This->client_windows[i].win,
False, StructureNotifyMask,
(XEvent*) &sendev))
(void) fprintf (stderr, "%s\n", "XSendEvent Failed");
}
}
break;
default:
break;
}
}
static void
SubstructureNotifyHandler (
Widget widget,
XtPointer client_data,
XEvent* event,
Boolean* cont)
{
PluginInstance* This = (PluginInstance*) client_data;
#ifdef PLUGIN_TRACE
fprintf (stderr, "%s\n", "SubstructureNotifyHandler");
#endif
if (event->type == DestroyNotify) {
int i;
#ifdef PLUGIN_TRACE
fprintf (stderr, "%s\n", "DestroyNotify");
#endif
for (i = 0; i < This->nclient_windows; i++)
if (This->client_windows[i].win == event->xdestroywindow.window) {
This->nclient_windows--;
if (This->nclient_windows > 0) {
for (; i < This->nclient_windows; i++)
This->client_windows[i] = This->client_windows[i + 1];
} else {
RxpSetStatusWidget(This, WAITING);
}
ResetWMColormap(This, event->xdestroywindow.window);
UnregisterDrawable(event->xdestroywindow.window,
This->plugin_widget);
break;
}
}
}
static void
SetupStructureNotify (PluginInstance* This)
{
XtAddRawEventHandler (This->toplevel_widget,
StructureNotifyMask,
False,
StructureNotifyHandler,
(XtPointer) This);
XtAddRawEventHandler (This->toplevel_widget,
NoEventMask,
True,
RxpWmDelWinHandler,
(XtPointer) This);
#if 0
XmAddWMProtocolCallback (This->toplevel_widget,
RxGlobal.wm_delete_window,
RxpWmDelWinHandler,
(XtPointer) This);
#endif
}
static void
CrossingHandler (
Widget widget,
XtPointer client_data,
XEvent* event,
Boolean* cont)
{
PluginInstance* This = (PluginInstance*) client_data;
#ifdef PLUGIN_TRACE
fprintf (stderr, "%s: 0x%x\n", "CrossingHandler", event->xany.window);
#endif
if (event->xany.window != XtWindow(This->plugin_widget) &&
event->xcrossing.detail != NotifyInferior) {
if (event->type == EnterNotify) {
#ifdef PLUGIN_TRACE
fprintf (stderr, "%s\n", "EnterNotify");
#endif
SetWMColormap(This, event->xany.window);
} else if (event->type == LeaveNotify) {
#ifdef PLUGIN_TRACE
fprintf (stderr, "%s\n", "LeaveNotify");
#endif
UnsetWMColormap(This, event->xany.window);
}
}
}
void
RxpSetupPluginEventHandlers (PluginInstance* This)
{
int i;
XtAddEventHandler (This->plugin_widget,
StructureNotifyMask,
False,
StructureNotifyHandler,
(XtPointer) This);
XtAddEventHandler (This->plugin_widget,
SubstructureNotifyMask,
False,
SubstructureNotifyHandler,
(XtPointer) This);
XtAddRawEventHandler(This->plugin_widget,
SubstructureRedirectMask,
False,
SubstructureRedirectHandler,
(XtPointer) This);
XtRegisterDrawable (RxGlobal.dpy, This->app_group, This->plugin_widget);
XtAddRawEventHandler(This->plugin_widget,
EnterWindowMask | LeaveWindowMask,
False,
CrossingHandler,
(XtPointer) This);
for (i = 0; i < This->nclient_windows; i++) {
XtRegisterDrawable (RxGlobal.dpy,
This->client_windows[i].win, This->plugin_widget);
}
}
void
RxpTeardown (PluginInstance* This)
{
if (This->toplevel_widget != NULL) {
XtRemoveRawEventHandler (This->toplevel_widget,
StructureNotifyMask,
False,
StructureNotifyHandler,
(XtPointer) This);
XtRemoveRawEventHandler (This->toplevel_widget,
NoEventMask,
True,
RxpWmDelWinHandler,
(XtPointer) This);
#if 0
XmRemoveWMProtocolCallback (This->toplevel_widget,
RxGlobal.wm_delete_window,
RxpWmDelWinHandler,
(XtPointer) This);
#endif
}
}
static int
ProcessUIParams(PluginInstance* This,
Boolean trusted, Boolean use_fwp, Boolean use_lbx,
RxParams *in, RxReturnParams *out, char **x_ui_auth_ret)
{
XSecurityAuthorization dum;
int dummy;
char *display_name;
This->app_group = None;
if (out->embedded != RxFalse) {
if (RxGlobal.has_appgroup == RxUndef) {
if (XQueryExtension(RxGlobal.dpy, "XC-APPGROUP",
&dummy, &dummy, &dummy) &&
XagQueryVersion (RxGlobal.dpy, &dummy, &dummy))
RxGlobal.has_appgroup = RxTrue;
else
RxGlobal.has_appgroup = RxFalse;
}
if (RxGlobal.has_appgroup == RxTrue) {
Screen *scr;
Colormap cmap;
Arg arg;
XtSetArg(arg, XtNcolormap, &cmap);
XtGetValues(This->plugin_widget, &arg, 1);
scr = XtScreen(This->plugin_widget);
if (cmap == DefaultColormapOfScreen(scr)) {
XagCreateEmbeddedApplicationGroup (RxGlobal.dpy, None,
cmap,
BlackPixelOfScreen(scr),
WhitePixelOfScreen(scr),
&This->app_group);
} else {
XColor black, white;
Pixel pixels[2];
black.red = black.green = black.blue = 0;
XAllocColor(RxGlobal.dpy, cmap, &black);
white.red = white.green = white.blue = 65535;
XAllocColor(RxGlobal.dpy, cmap, &white);
XagCreateEmbeddedApplicationGroup (RxGlobal.dpy, None,
cmap,
pixels[0] = black.pixel,
pixels[1] = white.pixel,
&This->app_group);
XFreeColors(RxGlobal.dpy, cmap, pixels, 2, 0);
}
SetupStructureNotify (This);
RxpSetupPluginEventHandlers (This);
} else {
out->embedded = RxFalse;
fprintf(stderr, "Warning: Cannot perform embedding as \
requested, APPGROUP extension not supported\n");
}
}
if (in->x_ui_auth[0] != 0) {
GetXAuth(RxGlobal.dpy, in->x_ui_auth[0], in->x_ui_auth_data[0],
trusted, This->app_group, False, DEFAULT_TIMEOUT,
x_ui_auth_ret, &This->x_ui_auth_id, &dummy);
} else if (in->x_auth[0] != 0)
GetXAuth(RxGlobal.dpy, in->x_auth[0], in->x_auth_data[0],
trusted, This->app_group, False, DEFAULT_TIMEOUT,
x_ui_auth_ret, &This->x_ui_auth_id, &dummy);
if (RxGlobal.has_real_server == RxUndef) {
Display *rdpy = RxGlobal.dpy;
char *real_display = getenv("XREALDISPLAY");
RxGlobal.has_real_server = RxFalse;
if (real_display != NULL) {
rdpy = XOpenDisplay(real_display);
if (rdpy == NULL)
rdpy = RxGlobal.dpy;
else
RxGlobal.has_real_server = RxTrue;
}
if (XQueryExtension(rdpy, "LBX", &dummy, &dummy, &dummy))
RxGlobal.has_ui_lbx = RxTrue;
else
RxGlobal.has_ui_lbx = RxFalse;
if (rdpy != RxGlobal.dpy)
XCloseDisplay(rdpy);
}
if (RxGlobal.has_real_server == RxTrue)
display_name = getenv("XREALDISPLAY");
else
display_name = DisplayString(RxGlobal.dpy);
if (use_fwp == True && RxGlobal.has_ui_fwp == RxUndef) {
RxGlobal.fwp_dpyname = GetXFwpDisplayName(display_name);
if (RxGlobal.fwp_dpyname != NULL)
RxGlobal.has_ui_fwp = RxTrue;
else {
return 1;
}
}
if (use_fwp == True && RxGlobal.has_ui_fwp == RxTrue)
out->ui = GetXUrl(RxGlobal.fwp_dpyname, *x_ui_auth_ret, in->action);
else
out->ui = GetXUrl(display_name, *x_ui_auth_ret, in->action);
if (in->x_ui_lbx == RxTrue) {
if (use_lbx == True) {
if (RxGlobal.has_ui_lbx == RxTrue) {
out->x_ui_lbx = RxTrue;
if (in->x_ui_lbx_auth[0] != 0) {
GetXAuth(RxGlobal.dpy, in->x_ui_lbx_auth[0],
in->x_ui_lbx_auth_data[0],
trusted, None, False, DEFAULT_TIMEOUT,
&out->x_ui_lbx_auth, &dum, &dummy);
} else if (in->x_auth[0] != 0)
GetXAuth(RxGlobal.dpy, in->x_auth[0], in->x_auth_data[0],
trusted, None, False, DEFAULT_TIMEOUT,
&out->x_ui_lbx_auth, &dum, &dummy);
} else {
out->x_ui_lbx = RxFalse;
fprintf(stderr, "Warning: Cannot setup LBX as requested, \
LBX extension not supported\n");
}
} else
out->x_ui_lbx = RxFalse;
} else
out->x_ui_lbx = in->x_ui_lbx;
return 0;
}
static int
ProcessPrintParams(PluginInstance* This,
Boolean trusted, Boolean use_fwp, Boolean use_lbx,
RxParams *in, RxReturnParams *out, char *x_ui_auth)
{
char *auth = NULL;
XSecurityAuthorization dum;
int dummy;
if (RxGlobal.has_printer == RxUndef) {
RxGlobal.pdpy_name = GetXPrintDisplayName(&RxGlobal.printer_name);
if (RxGlobal.pdpy_name != NULL) {
RxGlobal.pdpy = XOpenDisplay(RxGlobal.pdpy_name);
if (RxGlobal.pdpy != NULL)
RxGlobal.has_printer = RxTrue;
else
RxGlobal.has_printer = RxFalse;
} else {
if (XQueryExtension(RxGlobal.dpy, "XpExtension",
&dummy, &dummy, &dummy)) {
RxGlobal.has_printer = RxTrue;
RxGlobal.pdpy = RxGlobal.dpy;
} else
RxGlobal.has_printer = RxFalse;
}
}
if (RxGlobal.has_printer == RxFalse) {
fprintf(stderr, "Warning: Cannot setup X printer as requested, \
no server found\n");
return 0;
}
if (RxGlobal.pdpy != RxGlobal.dpy || x_ui_auth == NULL) {
if (in->x_print_auth[0] != 0)
GetXAuth(RxGlobal.pdpy, in->x_print_auth[0],
in->x_print_auth_data[0],
trusted, None, False, NO_TIMEOUT,
&auth, &This->x_print_auth_id, &dummy);
else if (in->x_auth[0] != 0)
GetXAuth(RxGlobal.pdpy, in->x_auth[0], in->x_auth_data[0],
trusted, None, False, NO_TIMEOUT,
&auth, &This->x_print_auth_id, &dummy);
}
if (use_fwp == True && RxGlobal.has_print_fwp == RxUndef) {
RxGlobal.pfwp_dpyname = GetXFwpDisplayName(DisplayString(RxGlobal.pdpy));
if (RxGlobal.pfwp_dpyname != NULL)
RxGlobal.has_print_fwp = RxTrue;
else {
return 1;
}
}
if (use_fwp == True && RxGlobal.has_print_fwp == RxTrue)
out->print = GetXPrintUrl(RxGlobal.pfwp_dpyname,
RxGlobal.printer_name, auth,
in->action);
else
out->print = GetXPrintUrl(DisplayString(RxGlobal.pdpy),
RxGlobal.printer_name, auth,
in->action);
if (auth != NULL)
NPN_MemFree(auth);
if (in->x_print_lbx == RxTrue) {
if (use_lbx == True) {
if (RxGlobal.has_print_lbx == RxUndef) {
if (RxGlobal.pdpy == RxGlobal.dpy &&
RxGlobal.has_ui_lbx != RxUndef) {
RxGlobal.has_print_lbx = RxGlobal.has_ui_lbx;
} else {
if (XQueryExtension(RxGlobal.pdpy, "LBX",
&dummy, &dummy, &dummy))
RxGlobal.has_print_lbx = RxTrue;
else
RxGlobal.has_print_lbx = RxFalse;
}
}
if (RxGlobal.has_print_lbx == RxTrue) {
out->x_print_lbx = RxTrue;
if (RxGlobal.pdpy != RxGlobal.dpy) {
if (in->x_print_lbx_auth[0] != 0) {
GetXAuth(RxGlobal.pdpy, in->x_print_lbx_auth[0],
in->x_print_lbx_auth_data[0],
trusted, None, False, DEFAULT_TIMEOUT,
&out->x_print_lbx_auth, &dum, &dummy);
} else if (in->x_auth[0] != 0)
GetXAuth(RxGlobal.pdpy, in->x_auth[0],
in->x_auth_data[0],
trusted, None, False, DEFAULT_TIMEOUT,
&out->x_print_lbx_auth, &dum, &dummy);
}
} else {
out->x_print_lbx = RxFalse;
fprintf(stderr, "Warning: Cannot setup LBX as \
requested, LBX extension not supported\n");
}
} else
out->x_print_lbx = RxFalse;
} else
out->x_print_lbx = in->x_print_lbx;
return 0;
}
int
RxpProcessParams(PluginInstance* This, RxParams *in, RxReturnParams *out)
{
char *x_ui_auth = NULL;
char webserver[MAXHOSTNAMELEN];
Boolean trusted, use_fwp, use_lbx;
int return_value = 0;
#ifdef PLUGIN_TRACE
fprintf (stderr, "%s\n", "RxpProcessParams");
fprintf (stderr, "This: 0x%x\n", This);
#endif
memset(out, 0, sizeof(RxReturnParams));
out->x_ui_lbx = RxUndef;
out->x_print_lbx = RxUndef;
out->action = in->action;
if (in->embedded != RxUndef)
out->embedded = in->embedded;
else
out->embedded = RxUndef;
out->width = in->width;
out->height = in->height;
if (RxGlobal.get_prefs == True) {
GetPreferences(This->toplevel_widget, &RxGlobal.prefs);
RxGlobal.get_prefs = False;
}
ComputePreferences(&RxGlobal.prefs,
ParseHostname(in->action, webserver, MAXHOSTNAMELEN) ? webserver : NULL,
&trusted, &use_fwp, &use_lbx);
if (in->ui[0] == XUI)
return_value = ProcessUIParams(This, trusted, use_fwp, use_lbx,
in, out, &x_ui_auth);
if (in->print[0] == XPrint)
return_value = ProcessPrintParams(This, trusted, use_fwp, use_lbx,
in, out, x_ui_auth);
if (x_ui_auth != NULL)
NPN_MemFree(x_ui_auth);
return return_value;
}