summaryrefslogtreecommitdiffstats
path: root/ksirc/puke
diff options
context:
space:
mode:
Diffstat (limited to 'ksirc/puke')
-rw-r--r--ksirc/puke/HOWTO-PUKE.pod325
-rw-r--r--ksirc/puke/Makefile.am43
-rw-r--r--ksirc/puke/commands-handler.pl61
-rw-r--r--ksirc/puke/commands-perl.pl605
-rw-r--r--ksirc/puke/commands.h1052
-rw-r--r--ksirc/puke/controller.cpp974
-rw-r--r--ksirc/puke/controller.h211
-rwxr-xr-xksirc/puke/convert_commands.pl13
-rw-r--r--ksirc/puke/dcc_progress.pm55
-rw-r--r--ksirc/puke/dcc_status.pm525
-rw-r--r--ksirc/puke/load_all.pm14
-rw-r--r--ksirc/puke/palistbox.cpp156
-rw-r--r--ksirc/puke/palistbox.h35
-rw-r--r--ksirc/puke/palistbox.pm117
-rw-r--r--ksirc/puke/pbase.pm265
-rw-r--r--ksirc/puke/pboxlayout.pm201
-rw-r--r--ksirc/puke/pbutton.cpp157
-rw-r--r--ksirc/puke/pbutton.h40
-rw-r--r--ksirc/puke/pbutton.pm79
-rw-r--r--ksirc/puke/pframe.cpp84
-rw-r--r--ksirc/puke/pframe.h28
-rw-r--r--ksirc/puke/pframe.pm57
-rw-r--r--ksirc/puke/pkfiledialog-cmd.h56
-rw-r--r--ksirc/puke/pkfiledialog.cpp123
-rw-r--r--ksirc/puke/pkfiledialog.h31
-rw-r--r--ksirc/puke/pkfiledialog.pm76
-rw-r--r--ksirc/puke/plabel.cpp127
-rw-r--r--ksirc/puke/plabel.h34
-rw-r--r--ksirc/puke/plabel.pm105
-rw-r--r--ksirc/puke/playout.cpp157
-rw-r--r--ksirc/puke/playout.h42
-rw-r--r--ksirc/puke/plined.cpp153
-rw-r--r--ksirc/puke/plined.h33
-rw-r--r--ksirc/puke/plined.pm84
-rw-r--r--ksirc/puke/plistbox.cpp224
-rw-r--r--ksirc/puke/plistbox.h37
-rw-r--r--ksirc/puke/plistbox.pm196
-rw-r--r--ksirc/puke/pmenudta.cpp79
-rw-r--r--ksirc/puke/pmenudta.h57
-rw-r--r--ksirc/puke/pmenudta.pm60
-rw-r--r--ksirc/puke/pmessage.h38
-rw-r--r--ksirc/puke/pobject.cpp138
-rw-r--r--ksirc/puke/pobject.h134
-rw-r--r--ksirc/puke/pobjfinder-cmd.h32
-rw-r--r--ksirc/puke/pobjfinder.cpp86
-rw-r--r--ksirc/puke/pobjfinder.h33
-rw-r--r--ksirc/puke/pobjfinder.pm89
-rw-r--r--ksirc/puke/ppopmenu.cpp120
-rw-r--r--ksirc/puke/ppopmenu.h36
-rw-r--r--ksirc/puke/ppopmenu.pm65
-rw-r--r--ksirc/puke/pprogress.cpp133
-rw-r--r--ksirc/puke/pprogress.h32
-rw-r--r--ksirc/puke/pprogress.pm86
-rw-r--r--ksirc/puke/ppushbt.cpp70
-rw-r--r--ksirc/puke/ppushbt.h33
-rw-r--r--ksirc/puke/ppushbt.pm30
-rw-r--r--ksirc/puke/ptabdialog.cpp101
-rw-r--r--ksirc/puke/ptabdialog.h41
-rw-r--r--ksirc/puke/ptabdialog.pm49
-rw-r--r--ksirc/puke/ptablevw.cpp76
-rw-r--r--ksirc/puke/ptablevw.h33
-rw-r--r--ksirc/puke/ptablevw.pm57
-rw-r--r--ksirc/puke/puke.pl225
-rw-r--r--ksirc/puke/pwidget.cpp492
-rw-r--r--ksirc/puke/pwidget.h45
-rw-r--r--ksirc/puke/pwidget.pm231
-rw-r--r--ksirc/puke/small.pl65
-rw-r--r--ksirc/puke/test.pl63
-rwxr-xr-xksirc/puke/tester.pl28
-rw-r--r--ksirc/puke/user_monitor.ks440
-rw-r--r--ksirc/puke/widgethdlr.h3
71 files changed, 9875 insertions, 0 deletions
diff --git a/ksirc/puke/HOWTO-PUKE.pod b/ksirc/puke/HOWTO-PUKE.pod
new file mode 100644
index 00000000..cf44e77e
--- /dev/null
+++ b/ksirc/puke/HOWTO-PUKE.pod
@@ -0,0 +1,325 @@
+=head1 OVERVIEW
+
+This document describes how to write puke addons and additional
+widgets. It assumes a good knowledge of C++, perl and X/Qt workings
+under Linux.
+
+=head1 1. Description and Background
+
+=over 6
+
+Puke's a generic protocol allowing dsirc to communicate with ksirc.
+Communications works over a unix domain socket between multiple
+client dsirc process's to a single ksirc process. All communications
+is done via a variable length message with the following layout:
+
+=begin text
+
+struct PukeMessage {
+unsigned int iHeader;
+int iCommand;
+int iWinId;
+int iArg;
+int iTextSize;
+char *cArg;
+}
+
+=end text
+
+None of the fields except for iCommand, iWinId and iHeader have any restrictions
+on their content and may contain arbitrary values. iCommand and iWinId must
+contain an int and it used by ksirc to determine the destination and
+handler of the actual command. (and of course it's meaning). iHeader is a
+fixed pattern used to identify the start of a header message should it loose
+syncronization. The current pattern used it 2863311530, which is:
+10101010101010101010101010101010.
+
+=item Internal handling by kSirc:
+
+Messages are received by a generic handler, PukeController where the message
+is passed to the iWinId's messageDipatcher for final processing. The
+iWinId of 1 through 10 are reserved for internal use, and 1 is
+currently set at the window ID for the PukeController itself.
+
+Connect a signal to PukeControllers writeBuffer (signal's generally
+called outputMessage) and pass the fd and PukeMessage to be sent to
+the client. No parsing of the output message is done.
+
+=item Internal handling by dsirc:
+
+All received messages are handled by an internal callback methods. 3
+sets of callbacks are checked for handlers in the following order:
+
+$PUKE_HANDLER{$cmd}{$winid}
+$PUKE_HANDLER{-$cmd}{$winid}
+$PUKE_DEF_HANDLER{$cmd}
+
+If no handler is found an error is printed.
+
+Output is handled by the PukeSendMessage function. PBase defines an
+alternate routine sendMessage which should be a lot friendlier.
+
+=head1 2. How to create a new widget
+
+There are 2 parts to creating a widget, the C++ code and the
+supporting perl5-oop object.
+
+=head2 2.1 C++ Widget code
+
+The C++ code must be able to hand all required settings and messages
+for the widget. Each new widget iherites it's parent and so forth
+allowing for a nice oop layout. The widget structure the author is
+following is the same as Qt's. Their seems to work well, why
+re-invent the wheel?
+
+=item 2.1.1 General Layout, etc
+
+Figure where your new widget goes in the heirachy. If it's a simple
+Qt widget, I recommend using their existing layout. Man pages list
+what widgets inherit what.
+
+The general idea behind the widget layout should be to be to provide
+all the functionality of the widget to dsirc perl script. Incoming
+messages are handled via the messageHandler and ALL messages should
+return an ACK with current state info.
+
+New widgets are created as shared objects and loaded on the fly. This
+means you don't need to recompile ksirc to use new widgets etc.
+
+Generally you'll have to inherit PWidget at a minimum.
+
+Functions you HAVE TO overrite:
+
+B<1. createWidget>
+
+This function creates a new widget of your type and returns a
+*PWidget.
+
+B<2. messageHandler>
+
+This function receives ALL your commands.
+
+B<3. widget() and setWidget(YourWidget *)>
+
+These set and return your widget.
+
+
+If you care about inheritance, which you should, all these functions
+should be virtual. (Since we are using pointers to PWidget's
+everywhere, it's a good bet you want your children's overriden
+functions called, not yours)
+
+The structure internally will have to hold a local copy of the widget,
+and connect to it's destroy signal so you can know when it has been
+destroyed.
+
+=item 2.1.2 createWidget
+
+createWidget is defined as:
+
+PWidget *createWidget(widgetId *pwi, PWidget *parent);
+
+It is called everytime a new widget of yours is required. The
+widgetId will be the identifier for your widget and must be kept for
+all future commands. PWidget::setWidgetId(pwi) should be called to
+set the widget id. The *parent is the parent of the current widget.
+Generally PWidget->widget() is passed to the contructor of your
+widget. If it's 0, there is no parent. Simeplfied code for a the
+PFrame is:
+
+=begin text
+
+extern "C" {
+PWidget *createWidget(widgetId *pwi, PWIdget *parent);
+}
+
+PWidget *createWidget(widgetId *pwi, PWIdget *parent){
+ QFrame *f;
+ PFrame *pf = new PFrame(parent);
+ if(parent != 0){
+ f = new QFrame(parent->widget());
+ }
+ else{
+ f = new QPFrame();
+ }
+ pf->setWidget(f);
+ pf->setWidgetId(pwi);
+ return pf;
+}
+
+=end text
+
+Note: you have to check parent for null since calling NULL->widget()
+results in Bad Things (tm).
+
+=item 2.1.3 messageHandler
+
+This receives all commands, etc. It should process required commands,
+if a command is unkown pass it to the parent. PFrame example:
+
+=begin text
+
+class PFrame : public PWidget
+...
+void messageHandler(int fd, PukeMessage *pm);
+...
+
+void PFrame::messageHandler(int fd, PukeMessage *pm) {
+ PukeMessage pmRet;
+ switch(pm->iCommand){
+ case PUKE_QFRAME_SET_FRAME:
+ widget()->setFrameStyle(pm->iArg);
+ pmRet.iCommand = PUKE_QFRAME_SET_FRAME_ACK;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = widget()->frameStyle();
+ pmRet.cArg[0] = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ default:
+ PWidget::messageHandler(fd, pm);
+ }
+}
+
+=end text
+
+=item 2.1.4 widget and setWidget
+
+Both these functions should be overriden and return your widget type,
+and set your widget. For setWidget you should connect required
+signals and eventFilters you are using.
+
+Make sure to call the parents setWidget in setWidget so it can connect
+filters etc.
+
+BEWARE: You might get the widget into setWidget being null (from the
+destructor).
+
+Another PFrame example (APE ;) ):
+
+=begin text
+void PFrame::setWidget(QFrame *_f)
+{
+ frame = _f;
+ PWidget::setWidget(_f);
+
+}
+
+
+QFrame *PFrame::widget()
+{
+ return frame;
+}
+
+=end text
+
+=item 2.1.5 Destructor
+
+Ok, unfortunaly since we have this internal widget floating arround
+the destructor has to a little maigc.
+
+Call the destructor as such:
+
+delete widget();
+setWidget(0);
+
+This will clear the widget from now and all parents and delete it.
+you never want it deleted twice. (deleting 0 won't hurt)
+
+=head2 2.2 The Perl code
+
+Most of the perl oop is pretty straight forward, command simply issue
+a require sendMessage and off everything goes. There's one problem.
+
+You can't get information back on the current read cycle. Huh? I can
+hear most people saying. It means say someone wanted to do $widget =
+$widget->height() and you didn't have the height information locally,
+there's no way to get the information and return it to them. Why? You
+issue a sendMessage(...) but until dsirc returns to the main select()
+loop, we never know there's more to read. We can't return to the main
+select loop until we return from our current function. What does this
+mean? We have to store all the information locally.
+
+This also brings up another intresting aspect. Sometimes a widget may
+depend on a prior command before it can complete. This is the purpose
+of canRun function, and onNext. It's use will have to be explained
+latter.
+
+To help with this problem, pbase.pm sets up a fairly complicated set
+of message and event queues. Be warned when you issue a sendMessage,
+it might not get sent right away.
+
+I'll provide example bellow of how I've done certain functions, this
+is certainly not the only way to do it. Feel free to use any format
+you like aslong as it get's the job done.
+
+Ok, so how do we do this?
+
+=item 2.2.1 Perl oop? where do I start?
+
+Read the perltoot and perlobj man pages.
+
+=item 2.2.2 What to inherit etc.
+
+You probably want to inherit the same object as your C function does.
+At very least you'll want to inherit PWidget.
+
+=item 2.2.3 new and DESTROY
+
+Your new function should look something like (APE?):
+
+=begin text
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new($class, @_);
+
+ $self->{widgetType} = $::PWIDGET_FRAME;
+
+ if($class eq 'PFrame'){
+ $self->create();
+ }
+
+ return $self;
+}
+
+=end text
+
+$self is the blessed variable and it returned from the super class.
+You should always do it this way. Setting widgetType defines the type
+of widget, and needs to be set before calling create.
+
+If we are creating an object of our own class we call create() which
+acutally sends out the correct creation messages, etc. You can
+override the create function, but do be warned it might not be a good
+idea. Make sure you understand what and how it does it first!
+
+=item 2.2.4 sendMessage
+
+sendMessage is the main form of communicating with kSirc. Generable
+arguments are:
+
+=begin text
+
+sendMessage('iCommand' => command number,
+ 'iArg' => interger argument,
+ 'cArg' => character string,
+ 'CallBack' => pointer to sub, generally sub{...}
+ );
+
+=end text
+
+You'll note it's a hash so order doesn't count. The callback is a 1
+shot call back (should be) so don't count on it getting hit twice.
+The call back's first argument will be a \%ARGS with the return
+arguments.
+
+=item 2.2.5 Final notes on perl
+
+Most of the function calls will just send out messages, etc. For call
+backs the general form I've found works well is: sub {$self->blah()}.
+
+=head1 3. Interfacing with the kSirc's main windows and functions
+
+NOT implemented yet.
+
+=back
diff --git a/ksirc/puke/Makefile.am b/ksirc/puke/Makefile.am
new file mode 100644
index 00000000..de25d641
--- /dev/null
+++ b/ksirc/puke/Makefile.am
@@ -0,0 +1,43 @@
+KDE_CXXFLAGS = $(USE_RTTI) $(USE_EXCEPTIONS) -UQT_NO_ASCII_CAST
+
+INCLUDES= $(all_includes)
+
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libpuke.la
+
+libpuke_la_SOURCES = pwidget.cpp pobject.cpp \
+ playout.cpp controller.cpp pframe.cpp \
+ plined.cpp pbutton.cpp ppushbt.cpp \
+ pprogress.cpp ptablevw.cpp plistbox.cpp \
+ plabel.cpp pmenudta.cpp ppopmenu.cpp \
+ palistbox.cpp ptabdialog.cpp \
+ pkfiledialog.cpp pobjfinder.cpp
+
+$(srcdir)/HOWTO-PUKE.txt: HOWTO-PUKE.pod
+ pod2text $(srcdir)/HOWTO-PUKE.pod > HOWTO-PUKE.txt
+
+# no install headers
+
+noinst_HEADERS = \
+ commands.h plined.h pwidget.h widgethdlr.h \
+ controller.h pframe.h pmessage.h HOWTO-PUKE.pod \
+ commands-handler.pl pboxlayout.pm pwidget.pm \
+ commands-perl.pl pframe.pm test.pl convert_commands.pl \
+ plined.pm tester.pl pbase.pm puke.pl ppushbt.h \
+ pbutton.h pprogress.h ptablevw.h plistbox.h \
+ plabel.h pobject.h playout.h pmenudta.h ppopmenu.h \
+ palistbox.h ptabdialog.h
+
+# Datafiles to install / uninstall : *.pl *.pm
+perl_DATA = commands-handler.pl commands-perl.pl convert_commands.pl \
+ puke.pl small.pl test.pl tester.pl \
+ dcc_progress.pm dcc_status.pm load_all.pm \
+ palistbox.pm pbase.pm pboxlayout.pm pbutton.pm pframe.pm \
+ pkfiledialog.pm plabel.pm plined.pm plistbox.pm pmenudta.pm \
+ ppopmenu.pm pprogress.pm ppushbt.pm ptabdialog.pm ptablevw.pm \
+ pwidget.pm pobjfinder.pm
+
+# Where to install them
+perldir = $(kde_datadir)/ksirc
+
diff --git a/ksirc/puke/commands-handler.pl b/ksirc/puke/commands-handler.pl
new file mode 100644
index 00000000..191353cf
--- /dev/null
+++ b/ksirc/puke/commands-handler.pl
@@ -0,0 +1,61 @@
+sub puke_invalid_cmd {
+ print "*E* Puke: Invalid command 0 ack'ed\n";
+ #
+ # Stop waiting, things are messed up
+ #
+ $wait = 0;
+}
+$PUKE_DEF_HANDLER{"$PUKE_INVALID"} = \&puke_invalid_cmd;
+
+
+#sub puke_widget_create_ack {
+# my %ARG = %{$_[0]};
+#
+# $ARG{cArg} =~ /^(.{8,8})/;
+# my $string = $1;
+#
+# if($PUKE_CREATOR{$string}){
+# &{$PUKE_CREATOR{$string}}(%ARG); # added %ARG
+# }
+# else {
+# print "*E* Widget created: $string but no handler\n";
+# }
+#}
+
+#$PUKE_DEF_HANDLER{"$PUKE_WIDGET_CREATE_ACK"} = \&puke_widget_create_ack;
+#$PUKE_DEF_HANDLER{"$PUKE_LAYOUT_NEW_ACK"} = \&puke_widget_create_ack;
+
+
+# By default we ignore all the EVENT's we get sent at us.
+
+$PUKE_DEF_HANDLER{"$PUKE_WIDGET_EVENT_NONE"} = sub {};
+$PUKE_DEF_HANDLER{"$PUKE_WIDGET_EVENT_TIME"} = sub {};
+$PUKE_DEF_HANDLER{$PUKE_WIDGET_EVENT_MOUSEBUTTONPRESS} = sub {};
+$PUKE_DEF_HANDLER{$PUKE_WIDGET_EVENT_MOUSEBUTTONRELEASE} = sub {};
+$PUKE_DEF_HANDLER{$PUKE_WIDGET_EVENT_MOUSEDBLCLICK} = sub {};
+$PUKE_DEF_HANDLER{$PUKE_WIDGET_EVENT_MOUSEMOVE} = sub {};
+$PUKE_DEF_HANDLER{$PUKE_WIDGET_EVENT_KEYPRESS} = sub {};
+$PUKE_DEF_HANDLER{$PUKE_WIDGET_EVENT_KEYRELEASE} = sub {};
+$PUKE_DEF_HANDLER{$PUKE_WIDGET_EVENT_KEYPRESS} = sub {};
+$PUKE_DEF_HANDLER{$PUKE_WIDGET_EVENT_FOCUSIN} = sub {};
+$PUKE_DEF_HANDLER{$PUKE_WIDGET_EVENT_FOCUSOUT} = sub {};
+$PUKE_DEF_HANDLER{"$PUKE_WIDGET_EVENT_ENTER"} = sub {};
+$PUKE_DEF_HANDLER{$PUKE_WIDGET_EVENT_LEAVE} = sub {};
+$PUKE_DEF_HANDLER{$PUKE_WIDGET_EVENT_PAINT} = sub {};
+$PUKE_DEF_HANDLER{$PUKE_WIDGET_EVENT_MOVE} = sub {};
+$PUKE_DEF_HANDLER{$PUKE_WIDGET_EVENT_RESIZE} = sub {};
+$PUKE_DEF_HANDLER{$PUKE_WIDGET_EVENT_CREATE} = sub {};
+$PUKE_DEF_HANDLER{$PUKE_WIDGET_EVENT_DESTORY} = sub {};
+$PUKE_DEF_HANDLER{$PUKE_WIDGET_EVENT_SHOW} = sub {};
+$PUKE_DEF_HANDLER{$PUKE_WIDGET_EVENT_HIDE} = sub {};
+$PUKE_DEF_HANDLER{$PUKE_WIDGET_EVENT_CLOSE} = sub {};
+$PUKE_DEF_HANDLER{$PUKE_WIDGET_EVENT_TIMER} = sub {};
+
+$PUKE_DEF_HANDLER{$PUKE_WIDGET_RESIZE_ACK} = sub {};
+$PUKE_DEF_HANDLER{$PUKE_WIDGET_REPAINT_ACK} = sub {};
+$PUKE_DEF_HANDLER{$PUKE_WIDGET_MOVE_ACK} = sub {};
+$PUKE_DEF_HANDLER{$PUKE_WIDGET_SHOW_ACK} = sub {};
+$PUKE_DEF_HANDLER{$PUKE_WIDGET_HIDE_ACK} = sub {};
+
+$PUKE_DEF_HANDLER{$PUKE_LINED_SET_TEXT_ACK} = sub {};
+1;
diff --git a/ksirc/puke/commands-perl.pl b/ksirc/puke/commands-perl.pl
new file mode 100644
index 00000000..1499daa9
--- /dev/null
+++ b/ksirc/puke/commands-perl.pl
@@ -0,0 +1,605 @@
+$PUKE_INVALID = 0;
+$PUKE_NAME2NUM{'PUKE_INVALID'} = 0;
+$PUKE_NUM2NAME{'0'} = 'PUKE_INVALID';
+$PUKE_SETUP = 1;
+$PUKE_NAME2NUM{'PUKE_SETUP'} = 1;
+$PUKE_NUM2NAME{'1'} = 'PUKE_SETUP';
+$PUKE_SETUP_ACK = -1;
+$PUKE_NAME2NUM{'PUKE_SETUP_ACK'} = -1;
+$PUKE_NUM2NAME{'-1'} = 'PUKE_SETUP_ACK';
+$PUKE_ECHO = 5;
+$PUKE_NAME2NUM{'PUKE_ECHO'} = 5;
+$PUKE_NUM2NAME{'5'} = 'PUKE_ECHO';
+$PUKE_ECHO_ACK = -5;
+$PUKE_NAME2NUM{'PUKE_ECHO_ACK'} = -5;
+$PUKE_NUM2NAME{'-5'} = 'PUKE_ECHO_ACK';
+$PUKE_EVENT_UNKOWN = -999;
+$PUKE_NAME2NUM{'PUKE_EVENT_UNKOWN'} = -999;
+$PUKE_NUM2NAME{'-999'} = 'PUKE_EVENT_UNKOWN';
+$PUKE_DUMPTREE = 997;
+$PUKE_NAME2NUM{'PUKE_DUMPTREE'} = 997;
+$PUKE_NUM2NAME{'997'} = 'PUKE_DUMPTREE';
+$PUKE_DUMPTREE_ACK = -997;
+$PUKE_NAME2NUM{'PUKE_DUMPTREE_ACK'} = -997;
+$PUKE_NUM2NAME{'-997'} = 'PUKE_DUMPTREE_ACK';
+$PUKE_RELEASEWIDGET = 996;
+$PUKE_NAME2NUM{'PUKE_RELEASEWIDGET'} = 996;
+$PUKE_NUM2NAME{'996'} = 'PUKE_RELEASEWIDGET';
+$PUKE_RELEASEWIDGET_ACK = -996;
+$PUKE_NAME2NUM{'PUKE_RELEASEWIDGET_ACK'} = -996;
+$PUKE_NUM2NAME{'-996'} = 'PUKE_RELEASEWIDGET_ACK';
+$PUKE_FETCHWIDGET = 998;
+$PUKE_NAME2NUM{'PUKE_FETCHWIDGET'} = 998;
+$PUKE_NUM2NAME{'998'} = 'PUKE_FETCHWIDGET';
+$PUKE_FETCHWIDGET_ACK = -998;
+$PUKE_NAME2NUM{'PUKE_FETCHWIDGET_ACK'} = -998;
+$PUKE_NUM2NAME{'-998'} = 'PUKE_FETCHWIDGET_ACK';
+$PUKE_WIDGET_CREATE = 1000;
+$PUKE_NAME2NUM{'PUKE_WIDGET_CREATE'} = 1000;
+$PUKE_NUM2NAME{'1000'} = 'PUKE_WIDGET_CREATE';
+$PUKE_WIDGET_CREATE_ACK = -1000;
+$PUKE_NAME2NUM{'PUKE_WIDGET_CREATE_ACK'} = -1000;
+$PUKE_NUM2NAME{'-1000'} = 'PUKE_WIDGET_CREATE_ACK';
+$PUKE_WIDGET_DELETE = 1001;
+$PUKE_NAME2NUM{'PUKE_WIDGET_DELETE'} = 1001;
+$PUKE_NUM2NAME{'1001'} = 'PUKE_WIDGET_DELETE';
+$PUKE_WIDGET_DELETE_ACK = -1001;
+$PUKE_NAME2NUM{'PUKE_WIDGET_DELETE_ACK'} = -1001;
+$PUKE_NUM2NAME{'-1001'} = 'PUKE_WIDGET_DELETE_ACK';
+$PUKE_WIDGET_SHOW = 1002;
+$PUKE_NAME2NUM{'PUKE_WIDGET_SHOW'} = 1002;
+$PUKE_NUM2NAME{'1002'} = 'PUKE_WIDGET_SHOW';
+$PUKE_WIDGET_SHOW_ACK = -1002;
+$PUKE_NAME2NUM{'PUKE_WIDGET_SHOW_ACK'} = -1002;
+$PUKE_NUM2NAME{'-1002'} = 'PUKE_WIDGET_SHOW_ACK';
+$PUKE_WIDGET_HIDE = 1003;
+$PUKE_NAME2NUM{'PUKE_WIDGET_HIDE'} = 1003;
+$PUKE_NUM2NAME{'1003'} = 'PUKE_WIDGET_HIDE';
+$PUKE_WIDGET_HIDE_ACK = -1003;
+$PUKE_NAME2NUM{'PUKE_WIDGET_HIDE_ACK'} = -1003;
+$PUKE_NUM2NAME{'-1003'} = 'PUKE_WIDGET_HIDE_ACK';
+$PUKE_WIDGET_REPAINT = 1005;
+$PUKE_NAME2NUM{'PUKE_WIDGET_REPAINT'} = 1005;
+$PUKE_NUM2NAME{'1005'} = 'PUKE_WIDGET_REPAINT';
+$PUKE_WIDGET_REPAINT_ACK = -1005;
+$PUKE_NAME2NUM{'PUKE_WIDGET_REPAINT_ACK'} = -1005;
+$PUKE_NUM2NAME{'-1005'} = 'PUKE_WIDGET_REPAINT_ACK';
+$PUKE_WIDGET_UPDATE = 1010;
+$PUKE_NAME2NUM{'PUKE_WIDGET_UPDATE'} = 1010;
+$PUKE_NUM2NAME{'1010'} = 'PUKE_WIDGET_UPDATE';
+$PUKE_WIDGET_UPDATE_ACK = -1010;
+$PUKE_NAME2NUM{'PUKE_WIDGET_UPDATE_ACK'} = -1010;
+$PUKE_NUM2NAME{'-1010'} = 'PUKE_WIDGET_UPDATE_ACK';
+$PUKE_WIDGET_RESIZE = 1015;
+$PUKE_NAME2NUM{'PUKE_WIDGET_RESIZE'} = 1015;
+$PUKE_NUM2NAME{'1015'} = 'PUKE_WIDGET_RESIZE';
+$PUKE_WIDGET_RESIZE_ACK = -1015;
+$PUKE_NAME2NUM{'PUKE_WIDGET_RESIZE_ACK'} = -1015;
+$PUKE_NUM2NAME{'-1015'} = 'PUKE_WIDGET_RESIZE_ACK';
+$PUKE_WIDGET_EVENT_NONE = -1020;
+$PUKE_NAME2NUM{'PUKE_WIDGET_EVENT_NONE'} = -1020;
+$PUKE_NUM2NAME{'-1020'} = 'PUKE_WIDGET_EVENT_NONE';
+$PUKE_WIDGET_EVENT_TIMER = -1021;
+$PUKE_NAME2NUM{'PUKE_WIDGET_EVENT_TIMER'} = -1021;
+$PUKE_NUM2NAME{'-1021'} = 'PUKE_WIDGET_EVENT_TIMER';
+$PUKE_WIDGET_EVENT_MOUSEBUTTONPRESS = -1022;
+$PUKE_NAME2NUM{'PUKE_WIDGET_EVENT_MOUSEBUTTONPRESS'} = -1022;
+$PUKE_NUM2NAME{'-1022'} = 'PUKE_WIDGET_EVENT_MOUSEBUTTONPRESS';
+$PUKE_WIDGET_EVENT_MOUSEBUTTONRELEASE = -1023;
+$PUKE_NAME2NUM{'PUKE_WIDGET_EVENT_MOUSEBUTTONRELEASE'} = -1023;
+$PUKE_NUM2NAME{'-1023'} = 'PUKE_WIDGET_EVENT_MOUSEBUTTONRELEASE';
+$PUKE_WIDGET_EVENT_MOUSEDBLCLICK = -1024;
+$PUKE_NAME2NUM{'PUKE_WIDGET_EVENT_MOUSEDBLCLICK'} = -1024;
+$PUKE_NUM2NAME{'-1024'} = 'PUKE_WIDGET_EVENT_MOUSEDBLCLICK';
+$PUKE_WIDGET_EVENT_MOUSEMOVE = -1025;
+$PUKE_NAME2NUM{'PUKE_WIDGET_EVENT_MOUSEMOVE'} = -1025;
+$PUKE_NUM2NAME{'-1025'} = 'PUKE_WIDGET_EVENT_MOUSEMOVE';
+$PUKE_WIDGET_EVENT_KEYPRESS = -1026;
+$PUKE_NAME2NUM{'PUKE_WIDGET_EVENT_KEYPRESS'} = -1026;
+$PUKE_NUM2NAME{'-1026'} = 'PUKE_WIDGET_EVENT_KEYPRESS';
+$PUKE_WIDGET_EVENT_KEYRELEASE = -1027;
+$PUKE_NAME2NUM{'PUKE_WIDGET_EVENT_KEYRELEASE'} = -1027;
+$PUKE_NUM2NAME{'-1027'} = 'PUKE_WIDGET_EVENT_KEYRELEASE';
+$PUKE_WIDGET_EVENT_FOCUSIN = -1028;
+$PUKE_NAME2NUM{'PUKE_WIDGET_EVENT_FOCUSIN'} = -1028;
+$PUKE_NUM2NAME{'-1028'} = 'PUKE_WIDGET_EVENT_FOCUSIN';
+$PUKE_WIDGET_EVENT_FOCUSOUT = -1029;
+$PUKE_NAME2NUM{'PUKE_WIDGET_EVENT_FOCUSOUT'} = -1029;
+$PUKE_NUM2NAME{'-1029'} = 'PUKE_WIDGET_EVENT_FOCUSOUT';
+$PUKE_WIDGET_EVENT_ENTER = -1030;
+$PUKE_NAME2NUM{'PUKE_WIDGET_EVENT_ENTER'} = -1030;
+$PUKE_NUM2NAME{'-1030'} = 'PUKE_WIDGET_EVENT_ENTER';
+$PUKE_WIDGET_EVENT_LEAVE = -1031;
+$PUKE_NAME2NUM{'PUKE_WIDGET_EVENT_LEAVE'} = -1031;
+$PUKE_NUM2NAME{'-1031'} = 'PUKE_WIDGET_EVENT_LEAVE';
+$PUKE_WIDGET_EVENT_PAINT = -1032;
+$PUKE_NAME2NUM{'PUKE_WIDGET_EVENT_PAINT'} = -1032;
+$PUKE_NUM2NAME{'-1032'} = 'PUKE_WIDGET_EVENT_PAINT';
+$PUKE_WIDGET_EVENT_MOVE = -1033;
+$PUKE_NAME2NUM{'PUKE_WIDGET_EVENT_MOVE'} = -1033;
+$PUKE_NUM2NAME{'-1033'} = 'PUKE_WIDGET_EVENT_MOVE';
+$PUKE_WIDGET_EVENT_RESIZE = -1034;
+$PUKE_NAME2NUM{'PUKE_WIDGET_EVENT_RESIZE'} = -1034;
+$PUKE_NUM2NAME{'-1034'} = 'PUKE_WIDGET_EVENT_RESIZE';
+$PUKE_WIDGET_EVENT_CREATE = -1035 ;
+$PUKE_NAME2NUM{'PUKE_WIDGET_EVENT_CREATE'} = -1035 ;
+$PUKE_NUM2NAME{'-1035 '} = 'PUKE_WIDGET_EVENT_CREATE';
+$PUKE_WIDGET_EVENT_DESTROY = -1036;
+$PUKE_NAME2NUM{'PUKE_WIDGET_EVENT_DESTROY'} = -1036;
+$PUKE_NUM2NAME{'-1036'} = 'PUKE_WIDGET_EVENT_DESTROY';
+$PUKE_WIDGET_EVENT_SHOW = -1037 ;
+$PUKE_NAME2NUM{'PUKE_WIDGET_EVENT_SHOW'} = -1037 ;
+$PUKE_NUM2NAME{'-1037 '} = 'PUKE_WIDGET_EVENT_SHOW';
+$PUKE_WIDGET_EVENT_HIDE = -1038 ;
+$PUKE_NAME2NUM{'PUKE_WIDGET_EVENT_HIDE'} = -1038 ;
+$PUKE_NUM2NAME{'-1038 '} = 'PUKE_WIDGET_EVENT_HIDE';
+$PUKE_WIDGET_EVENT_CLOSE = -1039 ;
+$PUKE_NAME2NUM{'PUKE_WIDGET_EVENT_CLOSE'} = -1039 ;
+$PUKE_NUM2NAME{'-1039 '} = 'PUKE_WIDGET_EVENT_CLOSE';
+$PUKE_WIDGET_MOVE = 1050;
+$PUKE_NAME2NUM{'PUKE_WIDGET_MOVE'} = 1050;
+$PUKE_NUM2NAME{'1050'} = 'PUKE_WIDGET_MOVE';
+$PUKE_WIDGET_MOVE_ACK = -1050;
+$PUKE_NAME2NUM{'PUKE_WIDGET_MOVE_ACK'} = -1050;
+$PUKE_NUM2NAME{'-1050'} = 'PUKE_WIDGET_MOVE_ACK';
+$PUKE_WIDGET_LOAD = 1055;
+$PUKE_NAME2NUM{'PUKE_WIDGET_LOAD'} = 1055;
+$PUKE_NUM2NAME{'1055'} = 'PUKE_WIDGET_LOAD';
+$PUKE_WIDGET_LOAD_ACK = -1055;
+$PUKE_NAME2NUM{'PUKE_WIDGET_LOAD_ACK'} = -1055;
+$PUKE_NUM2NAME{'-1055'} = 'PUKE_WIDGET_LOAD_ACK';
+$PUKE_WIDGET_UNLOAD = 1060;
+$PUKE_NAME2NUM{'PUKE_WIDGET_UNLOAD'} = 1060;
+$PUKE_NUM2NAME{'1060'} = 'PUKE_WIDGET_UNLOAD';
+$PUKE_WIDGET_UNLOAD_ACK = -1060;
+$PUKE_NAME2NUM{'PUKE_WIDGET_UNLOAD_ACK'} = -1060;
+$PUKE_NUM2NAME{'-1060'} = 'PUKE_WIDGET_UNLOAD_ACK';
+$PUKE_WIDGET_SETMINSIZE = 1065;
+$PUKE_NAME2NUM{'PUKE_WIDGET_SETMINSIZE'} = 1065;
+$PUKE_NUM2NAME{'1065'} = 'PUKE_WIDGET_SETMINSIZE';
+$PUKE_WIDGET_SETMINSIZE_ACK = -1065;
+$PUKE_NAME2NUM{'PUKE_WIDGET_SETMINSIZE_ACK'} = -1065;
+$PUKE_NUM2NAME{'-1065'} = 'PUKE_WIDGET_SETMINSIZE_ACK';
+$PUKE_WIDGET_SETMAXSIZE = 1070;
+$PUKE_NAME2NUM{'PUKE_WIDGET_SETMAXSIZE'} = 1070;
+$PUKE_NUM2NAME{'1070'} = 'PUKE_WIDGET_SETMAXSIZE';
+$PUKE_WIDGET_SETMAXSIZE_ACK = -1070;
+$PUKE_NAME2NUM{'PUKE_WIDGET_SETMAXSIZE_ACK'} = -1070;
+$PUKE_NUM2NAME{'-1070'} = 'PUKE_WIDGET_SETMAXSIZE_ACK';
+$PUKE_WIDGET_SETCAPTION = 1075;
+$PUKE_NAME2NUM{'PUKE_WIDGET_SETCAPTION'} = 1075;
+$PUKE_NUM2NAME{'1075'} = 'PUKE_WIDGET_SETCAPTION';
+$PUKE_WIDGET_SETCAPTION_ACK = -1075;
+$PUKE_NAME2NUM{'PUKE_WIDGET_SETCAPTION_ACK'} = -1075;
+$PUKE_NUM2NAME{'-1075'} = 'PUKE_WIDGET_SETCAPTION_ACK';
+$PUKE_WIDGET_GET_BACKGROUND_COLOUR = 1080;
+$PUKE_NAME2NUM{'PUKE_WIDGET_GET_BACKGROUND_COLOUR'} = 1080;
+$PUKE_NUM2NAME{'1080'} = 'PUKE_WIDGET_GET_BACKGROUND_COLOUR';
+$PUKE_WIDGET_GET_BACKGROUND_COLOUR_ACK = -1080;
+$PUKE_NAME2NUM{'PUKE_WIDGET_GET_BACKGROUND_COLOUR_ACK'} = -1080;
+$PUKE_NUM2NAME{'-1080'} = 'PUKE_WIDGET_GET_BACKGROUND_COLOUR_ACK';
+$PUKE_WIDGET_SET_BACKGROUND_COLOUR = 1085;
+$PUKE_NAME2NUM{'PUKE_WIDGET_SET_BACKGROUND_COLOUR'} = 1085;
+$PUKE_NUM2NAME{'1085'} = 'PUKE_WIDGET_SET_BACKGROUND_COLOUR';
+$PUKE_WIDGET_SET_BACKGROUND_COLOUR_ACK = -1085;
+$PUKE_NAME2NUM{'PUKE_WIDGET_SET_BACKGROUND_COLOUR_ACK'} = -1085;
+$PUKE_NUM2NAME{'-1085'} = 'PUKE_WIDGET_SET_BACKGROUND_COLOUR_ACK';
+$PUKE_WIDGET_SET_BACKGROUND_PIXMAP = 1086;
+$PUKE_NAME2NUM{'PUKE_WIDGET_SET_BACKGROUND_PIXMAP'} = 1086;
+$PUKE_NUM2NAME{'1086'} = 'PUKE_WIDGET_SET_BACKGROUND_PIXMAP';
+$PUKE_WIDGET_SET_BACKGROUND_PIXMAP_ACK = -1086;
+$PUKE_NAME2NUM{'PUKE_WIDGET_SET_BACKGROUND_PIXMAP_ACK'} = -1086;
+$PUKE_NUM2NAME{'-1086'} = 'PUKE_WIDGET_SET_BACKGROUND_PIXMAP_ACK';
+$PUKE_WIDGET_SET_BACKGROUND_MODE = 1087;
+$PUKE_NAME2NUM{'PUKE_WIDGET_SET_BACKGROUND_MODE'} = 1087;
+$PUKE_NUM2NAME{'1087'} = 'PUKE_WIDGET_SET_BACKGROUND_MODE';
+$PUKE_WIDGET_SET_BACKGROUND_MODE_ACK = -1087;
+$PUKE_NAME2NUM{'PUKE_WIDGET_SET_BACKGROUND_MODE_ACK'} = -1087;
+$PUKE_NUM2NAME{'-1087'} = 'PUKE_WIDGET_SET_BACKGROUND_MODE_ACK';
+$PUKE_WIDGET_SET_ENABLED = 1090;
+$PUKE_NAME2NUM{'PUKE_WIDGET_SET_ENABLED'} = 1090;
+$PUKE_NUM2NAME{'1090'} = 'PUKE_WIDGET_SET_ENABLED';
+$PUKE_WIDGET_SET_ENABLED_ACK = -1090;
+$PUKE_NAME2NUM{'PUKE_WIDGET_SET_ENABLED_ACK'} = -1090;
+$PUKE_NUM2NAME{'-1090'} = 'PUKE_WIDGET_SET_ENABLED_ACK';
+$PUKE_WIDGET_RECREATE = 1091;
+$PUKE_NAME2NUM{'PUKE_WIDGET_RECREATE'} = 1091;
+$PUKE_NUM2NAME{'1091'} = 'PUKE_WIDGET_RECREATE';
+$PUKE_WIDGET_RECREATE_ACK = -1091;
+$PUKE_NAME2NUM{'PUKE_WIDGET_RECREATE_ACK'} = -1091;
+$PUKE_NUM2NAME{'-1091'} = 'PUKE_WIDGET_RECREATE_ACK';
+$PUKE_QFRAME_SET_FRAME = 1100;
+$PUKE_NAME2NUM{'PUKE_QFRAME_SET_FRAME'} = 1100;
+$PUKE_NUM2NAME{'1100'} = 'PUKE_QFRAME_SET_FRAME';
+$PUKE_QFRAME_SET_FRAME_ACK = -1100;
+$PUKE_NAME2NUM{'PUKE_QFRAME_SET_FRAME_ACK'} = -1100;
+$PUKE_NUM2NAME{'-1100'} = 'PUKE_QFRAME_SET_FRAME_ACK';
+$PUKE_QFRAME_SET_LINEWIDTH = 1105;
+$PUKE_NAME2NUM{'PUKE_QFRAME_SET_LINEWIDTH'} = 1105;
+$PUKE_NUM2NAME{'1105'} = 'PUKE_QFRAME_SET_LINEWIDTH';
+$PUKE_QFRAME_SET_LINEWIDTH_ACK = -1105;
+$PUKE_NAME2NUM{'PUKE_QFRAME_SET_LINEWIDTH_ACK'} = -1105;
+$PUKE_NUM2NAME{'-1105'} = 'PUKE_QFRAME_SET_LINEWIDTH_ACK';
+$PUKE_LINED_SET_MAXLENGTH = 1200;
+$PUKE_NAME2NUM{'PUKE_LINED_SET_MAXLENGTH'} = 1200;
+$PUKE_NUM2NAME{'1200'} = 'PUKE_LINED_SET_MAXLENGTH';
+$PUKE_LINED_SET_MAXLENGTH_ACK = -1200;
+$PUKE_NAME2NUM{'PUKE_LINED_SET_MAXLENGTH_ACK'} = -1200;
+$PUKE_NUM2NAME{'-1200'} = 'PUKE_LINED_SET_MAXLENGTH_ACK';
+$PUKE_LINED_SET_ECHOMODE = 1205;
+$PUKE_NAME2NUM{'PUKE_LINED_SET_ECHOMODE'} = 1205;
+$PUKE_NUM2NAME{'1205'} = 'PUKE_LINED_SET_ECHOMODE';
+$PUKE_LINED_SET_ECHOMODE_ACK = -1205;
+$PUKE_NAME2NUM{'PUKE_LINED_SET_ECHOMODE_ACK'} = -1205;
+$PUKE_NUM2NAME{'-1205'} = 'PUKE_LINED_SET_ECHOMODE_ACK';
+$PUKE_LINED_SET_TEXT = 1210;
+$PUKE_NAME2NUM{'PUKE_LINED_SET_TEXT'} = 1210;
+$PUKE_NUM2NAME{'1210'} = 'PUKE_LINED_SET_TEXT';
+$PUKE_LINED_SET_TEXT_ACK = -1210;
+$PUKE_NAME2NUM{'PUKE_LINED_SET_TEXT_ACK'} = -1210;
+$PUKE_NUM2NAME{'-1210'} = 'PUKE_LINED_SET_TEXT_ACK';
+$PUKE_LINED_GET_TEXT = 1215;
+$PUKE_NAME2NUM{'PUKE_LINED_GET_TEXT'} = 1215;
+$PUKE_NUM2NAME{'1215'} = 'PUKE_LINED_GET_TEXT';
+$PUKE_LINED_GET_TEXT_ACK = -1215;
+$PUKE_NAME2NUM{'PUKE_LINED_GET_TEXT_ACK'} = -1215;
+$PUKE_NUM2NAME{'-1215'} = 'PUKE_LINED_GET_TEXT_ACK';
+$PUKE_LINED_RETURN_PRESSED = 1220;
+$PUKE_NAME2NUM{'PUKE_LINED_RETURN_PRESSED'} = 1220;
+$PUKE_NUM2NAME{'1220'} = 'PUKE_LINED_RETURN_PRESSED';
+$PUKE_LINED_RETURN_PRESSED_ACK = -1220;
+$PUKE_NAME2NUM{'PUKE_LINED_RETURN_PRESSED_ACK'} = -1220;
+$PUKE_NUM2NAME{'-1220'} = 'PUKE_LINED_RETURN_PRESSED_ACK';
+$PUKE_BUTTON_SET_TEXT = 1300;
+$PUKE_NAME2NUM{'PUKE_BUTTON_SET_TEXT'} = 1300;
+$PUKE_NUM2NAME{'1300'} = 'PUKE_BUTTON_SET_TEXT';
+$PUKE_BUTTON_SET_TEXT_ACK = -1300;
+$PUKE_NAME2NUM{'PUKE_BUTTON_SET_TEXT_ACK'} = -1300;
+$PUKE_NUM2NAME{'-1300'} = 'PUKE_BUTTON_SET_TEXT_ACK';
+$PUKE_BUTTON_SET_PIXMAP = 1305;
+$PUKE_NAME2NUM{'PUKE_BUTTON_SET_PIXMAP'} = 1305;
+$PUKE_NUM2NAME{'1305'} = 'PUKE_BUTTON_SET_PIXMAP';
+$PUKE_BUTTON_SET_PIXMAP_ACK = -1305;
+$PUKE_NAME2NUM{'PUKE_BUTTON_SET_PIXMAP_ACK'} = -1305;
+$PUKE_NUM2NAME{'-1305'} = 'PUKE_BUTTON_SET_PIXMAP_ACK';
+$PUKE_BUTTON_SET_AUTORESIZE = 1310;
+$PUKE_NAME2NUM{'PUKE_BUTTON_SET_AUTORESIZE'} = 1310;
+$PUKE_NUM2NAME{'1310'} = 'PUKE_BUTTON_SET_AUTORESIZE';
+$PUKE_BUTTON_SET_AUTORESIZE_ACK = -1310;
+$PUKE_NAME2NUM{'PUKE_BUTTON_SET_AUTORESIZE_ACK'} = -1310;
+$PUKE_NUM2NAME{'-1310'} = 'PUKE_BUTTON_SET_AUTORESIZE_ACK';
+$PUKE_BUTTON_PRESSED = 1350;
+$PUKE_NAME2NUM{'PUKE_BUTTON_PRESSED'} = 1350;
+$PUKE_NUM2NAME{'1350'} = 'PUKE_BUTTON_PRESSED';
+$PUKE_BUTTON_PRESSED_ACK = -1350;
+$PUKE_NAME2NUM{'PUKE_BUTTON_PRESSED_ACK'} = -1350;
+$PUKE_NUM2NAME{'-1350'} = 'PUKE_BUTTON_PRESSED_ACK';
+$PUKE_BUTTON_RELEASED = 1351;
+$PUKE_NAME2NUM{'PUKE_BUTTON_RELEASED'} = 1351;
+$PUKE_NUM2NAME{'1351'} = 'PUKE_BUTTON_RELEASED';
+$PUKE_BUTTON_RELEASED_ACK = -1351;
+$PUKE_NAME2NUM{'PUKE_BUTTON_RELEASED_ACK'} = -1351;
+$PUKE_NUM2NAME{'-1351'} = 'PUKE_BUTTON_RELEASED_ACK';
+$PUKE_BUTTON_CLICKED = 1352;
+$PUKE_NAME2NUM{'PUKE_BUTTON_CLICKED'} = 1352;
+$PUKE_NUM2NAME{'1352'} = 'PUKE_BUTTON_CLICKED';
+$PUKE_BUTTON_CLICKED_ACK = -1352;
+$PUKE_NAME2NUM{'PUKE_BUTTON_CLICKED_ACK'} = -1352;
+$PUKE_NUM2NAME{'-1352'} = 'PUKE_BUTTON_CLICKED_ACK';
+$PUKE_BUTTON_TOGGLED = 1353;
+$PUKE_NAME2NUM{'PUKE_BUTTON_TOGGLED'} = 1353;
+$PUKE_NUM2NAME{'1353'} = 'PUKE_BUTTON_TOGGLED';
+$PUKE_BUTTON_TOGGLED_ACK = -1353;
+$PUKE_NAME2NUM{'PUKE_BUTTON_TOGGLED_ACK'} = -1353;
+$PUKE_NUM2NAME{'-1353'} = 'PUKE_BUTTON_TOGGLED_ACK';
+$PUKE_KSPROGRESS_SET_RANGE = 1400;
+$PUKE_NAME2NUM{'PUKE_KSPROGRESS_SET_RANGE'} = 1400;
+$PUKE_NUM2NAME{'1400'} = 'PUKE_KSPROGRESS_SET_RANGE';
+$PUKE_KSPROGRESS_SET_RANGE_ACK = -1400;
+$PUKE_NAME2NUM{'PUKE_KSPROGRESS_SET_RANGE_ACK'} = -1400;
+$PUKE_NUM2NAME{'-1400'} = 'PUKE_KSPROGRESS_SET_RANGE_ACK';
+$PUKE_KSPROGRESS_SET_TOPTEXT = 1410;
+$PUKE_NAME2NUM{'PUKE_KSPROGRESS_SET_TOPTEXT'} = 1410;
+$PUKE_NUM2NAME{'1410'} = 'PUKE_KSPROGRESS_SET_TOPTEXT';
+$PUKE_KSPROGRESS_SET_TOPTEXT_ACK = -1410;
+$PUKE_NAME2NUM{'PUKE_KSPROGRESS_SET_TOPTEXT_ACK'} = -1410;
+$PUKE_NUM2NAME{'-1410'} = 'PUKE_KSPROGRESS_SET_TOPTEXT_ACK';
+$PUKE_KSPROGRESS_SET_BOTTEXT = 1415;
+$PUKE_NAME2NUM{'PUKE_KSPROGRESS_SET_BOTTEXT'} = 1415;
+$PUKE_NUM2NAME{'1415'} = 'PUKE_KSPROGRESS_SET_BOTTEXT';
+$PUKE_KSPROGRESS_SET_BOTTEXT_ACK = -1415;
+$PUKE_NAME2NUM{'PUKE_KSPROGRESS_SET_BOTTEXT_ACK'} = -1415;
+$PUKE_NUM2NAME{'-1415'} = 'PUKE_KSPROGRESS_SET_BOTTEXT_ACK';
+$PUKE_KSPROGRESS_SET_VALUE = 1420;
+$PUKE_NAME2NUM{'PUKE_KSPROGRESS_SET_VALUE'} = 1420;
+$PUKE_NUM2NAME{'1420'} = 'PUKE_KSPROGRESS_SET_VALUE';
+$PUKE_KSPROGRESS_SET_VALUE_ACK = -1420;
+$PUKE_NAME2NUM{'PUKE_KSPROGRESS_SET_VALUE_ACK'} = -1420;
+$PUKE_NUM2NAME{'-1420'} = 'PUKE_KSPROGRESS_SET_VALUE_ACK';
+$PUKE_KSPROGRESS_CANCEL = 1425;
+$PUKE_NAME2NUM{'PUKE_KSPROGRESS_CANCEL'} = 1425;
+$PUKE_NUM2NAME{'1425'} = 'PUKE_KSPROGRESS_CANCEL';
+$PUKE_KSPROGRESS_CANCEL_ACK = -1425;
+$PUKE_NAME2NUM{'PUKE_KSPROGRESS_CANCEL_ACK'} = -1425;
+$PUKE_NUM2NAME{'-1425'} = 'PUKE_KSPROGRESS_CANCEL_ACK';
+$PUKE_LISTBOX_INSERT = 1600;
+$PUKE_NAME2NUM{'PUKE_LISTBOX_INSERT'} = 1600;
+$PUKE_NUM2NAME{'1600'} = 'PUKE_LISTBOX_INSERT';
+$PUKE_LISTBOX_INSERT_ACK = -1600;
+$PUKE_NAME2NUM{'PUKE_LISTBOX_INSERT_ACK'} = -1600;
+$PUKE_NUM2NAME{'-1600'} = 'PUKE_LISTBOX_INSERT_ACK';
+$PUKE_LISTBOX_INSERT_SORT = 1605;
+$PUKE_NAME2NUM{'PUKE_LISTBOX_INSERT_SORT'} = 1605;
+$PUKE_NUM2NAME{'1605'} = 'PUKE_LISTBOX_INSERT_SORT';
+$PUKE_LISTBOX_INSERT_SORT_ACK = -1605;
+$PUKE_NAME2NUM{'PUKE_LISTBOX_INSERT_SORT_ACK'} = -1605;
+$PUKE_NUM2NAME{'-1605'} = 'PUKE_LISTBOX_INSERT_SORT_ACK';
+$PUKE_LISTBOX_INSERT_PIXMAP = 1610;
+$PUKE_NAME2NUM{'PUKE_LISTBOX_INSERT_PIXMAP'} = 1610;
+$PUKE_NUM2NAME{'1610'} = 'PUKE_LISTBOX_INSERT_PIXMAP';
+$PUKE_LISTBOX_INSERT_PIXMAP_ACK = -1610;
+$PUKE_NAME2NUM{'PUKE_LISTBOX_INSERT_PIXMAP_ACK'} = -1610;
+$PUKE_NUM2NAME{'-1610'} = 'PUKE_LISTBOX_INSERT_PIXMAP_ACK';
+$PUKE_LISTBOX_HIGHLIGHT = 1615;
+$PUKE_NAME2NUM{'PUKE_LISTBOX_HIGHLIGHT'} = 1615;
+$PUKE_NUM2NAME{'1615'} = 'PUKE_LISTBOX_HIGHLIGHT';
+$PUKE_LISTBOX_HIGHLIGHT_ACK = -1615;
+$PUKE_NAME2NUM{'PUKE_LISTBOX_HIGHLIGHT_ACK'} = -1615;
+$PUKE_NUM2NAME{'-1615'} = 'PUKE_LISTBOX_HIGHLIGHT_ACK';
+$PUKE_LISTBOX_REMOVE = 1620;
+$PUKE_NAME2NUM{'PUKE_LISTBOX_REMOVE'} = 1620;
+$PUKE_NUM2NAME{'1620'} = 'PUKE_LISTBOX_REMOVE';
+$PUKE_LISTBOX_REMOVE_ACK = -1620;
+$PUKE_NAME2NUM{'PUKE_LISTBOX_REMOVE_ACK'} = -1620;
+$PUKE_NUM2NAME{'-1620'} = 'PUKE_LISTBOX_REMOVE_ACK';
+$PUKE_LISTBOX_GETTEXT = 1625;
+$PUKE_NAME2NUM{'PUKE_LISTBOX_GETTEXT'} = 1625;
+$PUKE_NUM2NAME{'1625'} = 'PUKE_LISTBOX_GETTEXT';
+$PUKE_LISTBOX_GETTEXT_ACK = -1625 ;
+$PUKE_NAME2NUM{'PUKE_LISTBOX_GETTEXT_ACK'} = -1625 ;
+$PUKE_NUM2NAME{'-1625 '} = 'PUKE_LISTBOX_GETTEXT_ACK';
+$PUKE_LISTBOX_CLEAR = 1630;
+$PUKE_NAME2NUM{'PUKE_LISTBOX_CLEAR'} = 1630;
+$PUKE_NUM2NAME{'1630'} = 'PUKE_LISTBOX_CLEAR';
+$PUKE_LISTBOX_CLEAR_ACK = -1630;
+$PUKE_NAME2NUM{'PUKE_LISTBOX_CLEAR_ACK'} = -1630;
+$PUKE_NUM2NAME{'-1630'} = 'PUKE_LISTBOX_CLEAR_ACK';
+$PUKE_LISTBOX_SET_SCROLLBAR = 1635;
+$PUKE_NAME2NUM{'PUKE_LISTBOX_SET_SCROLLBAR'} = 1635;
+$PUKE_NUM2NAME{'1635'} = 'PUKE_LISTBOX_SET_SCROLLBAR';
+$PUKE_LISTBOX_SET_SCROLLBAR_ACK = -1635;
+$PUKE_NAME2NUM{'PUKE_LISTBOX_SET_SCROLLBAR_ACK'} = -1635;
+$PUKE_NUM2NAME{'-1635'} = 'PUKE_LISTBOX_SET_SCROLLBAR_ACK';
+$PUKE_LISTBOX_SET_AUTO_SCROLLBAR = 1636;
+$PUKE_NAME2NUM{'PUKE_LISTBOX_SET_AUTO_SCROLLBAR'} = 1636;
+$PUKE_NUM2NAME{'1636'} = 'PUKE_LISTBOX_SET_AUTO_SCROLLBAR';
+$PUKE_LISTBOX_SET_AUTO_SCROLLBAR_ACK = -1636;
+$PUKE_NAME2NUM{'PUKE_LISTBOX_SET_AUTO_SCROLLBAR_ACK'} = -1636;
+$PUKE_NUM2NAME{'-1636'} = 'PUKE_LISTBOX_SET_AUTO_SCROLLBAR_ACK';
+$PUKE_LISTBOX_HIGHLIGHTED = 1690;
+$PUKE_NAME2NUM{'PUKE_LISTBOX_HIGHLIGHTED'} = 1690;
+$PUKE_NUM2NAME{'1690'} = 'PUKE_LISTBOX_HIGHLIGHTED';
+$PUKE_LISTBOX_HIGHLIGHTED_ACK = -1690;
+$PUKE_NAME2NUM{'PUKE_LISTBOX_HIGHLIGHTED_ACK'} = -1690;
+$PUKE_NUM2NAME{'-1690'} = 'PUKE_LISTBOX_HIGHLIGHTED_ACK';
+$PUKE_LISTBOX_SELECTED = 1690;
+$PUKE_NAME2NUM{'PUKE_LISTBOX_SELECTED'} = 1690;
+$PUKE_NUM2NAME{'1690'} = 'PUKE_LISTBOX_SELECTED';
+$PUKE_LISTBOX_SELECTED_ACK = -1690;
+$PUKE_NAME2NUM{'PUKE_LISTBOX_SELECTED_ACK'} = -1690;
+$PUKE_NUM2NAME{'-1690'} = 'PUKE_LISTBOX_SELECTED_ACK';
+$PUKE_LABEL_SETTEXT = 1700;
+$PUKE_NAME2NUM{'PUKE_LABEL_SETTEXT'} = 1700;
+$PUKE_NUM2NAME{'1700'} = 'PUKE_LABEL_SETTEXT';
+$PUKE_LABEL_SETTEXT_ACK = -1700;
+$PUKE_NAME2NUM{'PUKE_LABEL_SETTEXT_ACK'} = -1700;
+$PUKE_NUM2NAME{'-1700'} = 'PUKE_LABEL_SETTEXT_ACK';
+$PUKE_LABEL_SETPIXMAP = 1705;
+$PUKE_NAME2NUM{'PUKE_LABEL_SETPIXMAP'} = 1705;
+$PUKE_NUM2NAME{'1705'} = 'PUKE_LABEL_SETPIXMAP';
+$PUKE_LABEL_SETPIXMAP_ACK = -1705;
+$PUKE_NAME2NUM{'PUKE_LABEL_SETPIXMAP_ACK'} = -1705;
+$PUKE_NUM2NAME{'-1705'} = 'PUKE_LABEL_SETPIXMAP_ACK';
+$PUKE_LABEL_SETMOVIE = 1710;
+$PUKE_NAME2NUM{'PUKE_LABEL_SETMOVIE'} = 1710;
+$PUKE_NUM2NAME{'1710'} = 'PUKE_LABEL_SETMOVIE';
+$PUKE_LABEL_SETMOVIE_ACK = -1710;
+$PUKE_NAME2NUM{'PUKE_LABEL_SETMOVIE_ACK'} = -1710;
+$PUKE_NUM2NAME{'-1710'} = 'PUKE_LABEL_SETMOVIE_ACK';
+$PUKE_LABEL_SETALIGNMENT = 1715;
+$PUKE_NAME2NUM{'PUKE_LABEL_SETALIGNMENT'} = 1715;
+$PUKE_NUM2NAME{'1715'} = 'PUKE_LABEL_SETALIGNMENT';
+$PUKE_LABEL_SETALIGNMENT_ACK = -1715;
+$PUKE_NAME2NUM{'PUKE_LABEL_SETALIGNMENT_ACK'} = -1715;
+$PUKE_NUM2NAME{'-1715'} = 'PUKE_LABEL_SETALIGNMENT_ACK';
+$PUKE_MENUDATA_INSERT_TEXT = 1800;
+$PUKE_NAME2NUM{'PUKE_MENUDATA_INSERT_TEXT'} = 1800;
+$PUKE_NUM2NAME{'1800'} = 'PUKE_MENUDATA_INSERT_TEXT';
+$PUKE_MENUDATA_INSERT_TEXT_ACK = -1800;
+$PUKE_NAME2NUM{'PUKE_MENUDATA_INSERT_TEXT_ACK'} = -1800;
+$PUKE_NUM2NAME{'-1800'} = 'PUKE_MENUDATA_INSERT_TEXT_ACK';
+$PUKE_MENUDATA_INSERT_PIXMAP = 1801;
+$PUKE_NAME2NUM{'PUKE_MENUDATA_INSERT_PIXMAP'} = 1801;
+$PUKE_NUM2NAME{'1801'} = 'PUKE_MENUDATA_INSERT_PIXMAP';
+$PUKE_MENUDATA_INSERT_PIXMAP_ACK = -1801;
+$PUKE_NAME2NUM{'PUKE_MENUDATA_INSERT_PIXMAP_ACK'} = -1801;
+$PUKE_NUM2NAME{'-1801'} = 'PUKE_MENUDATA_INSERT_PIXMAP_ACK';
+$PUKE_POPUPMENU_ACTIVATED = 1805;
+$PUKE_NAME2NUM{'PUKE_POPUPMENU_ACTIVATED'} = 1805;
+$PUKE_NUM2NAME{'1805'} = 'PUKE_POPUPMENU_ACTIVATED';
+$PUKE_POPUPMENU_ACTIVATED_ACK = -1805;
+$PUKE_NAME2NUM{'PUKE_POPUPMENU_ACTIVATED_ACK'} = -1805;
+$PUKE_NUM2NAME{'-1805'} = 'PUKE_POPUPMENU_ACTIVATED_ACK';
+$PUKE_POPUPMENU_POPUP_CURRENT = 1810;
+$PUKE_NAME2NUM{'PUKE_POPUPMENU_POPUP_CURRENT'} = 1810;
+$PUKE_NUM2NAME{'1810'} = 'PUKE_POPUPMENU_POPUP_CURRENT';
+$PUKE_POPUPMENU_POPUP_CURRENT_ACK = -1810;
+$PUKE_NAME2NUM{'PUKE_POPUPMENU_POPUP_CURRENT_ACK'} = -1810;
+$PUKE_NUM2NAME{'-1810'} = 'PUKE_POPUPMENU_POPUP_CURRENT_ACK';
+$PUKE_MENUDATA_REMOVE_ITEM = 1815;
+$PUKE_NAME2NUM{'PUKE_MENUDATA_REMOVE_ITEM'} = 1815;
+$PUKE_NUM2NAME{'1815'} = 'PUKE_MENUDATA_REMOVE_ITEM';
+$PUKE_MENUDATA_REMOVE_ITEM_ACK = -1815;
+$PUKE_NAME2NUM{'PUKE_MENUDATA_REMOVE_ITEM_ACK'} = -1815;
+$PUKE_NUM2NAME{'-1815'} = 'PUKE_MENUDATA_REMOVE_ITEM_ACK';
+$PUKE_ALISTBOX_ISTOP = 1900;
+$PUKE_NAME2NUM{'PUKE_ALISTBOX_ISTOP'} = 1900;
+$PUKE_NUM2NAME{'1900'} = 'PUKE_ALISTBOX_ISTOP';
+$PUKE_ALISTBOX_ISTOP_ACK = -1900;
+$PUKE_NAME2NUM{'PUKE_ALISTBOX_ISTOP_ACK'} = -1900;
+$PUKE_NUM2NAME{'-1900'} = 'PUKE_ALISTBOX_ISTOP_ACK';
+$PUKE_ALISTBOX_SMALL_HIGHLIGHT = 1905;
+$PUKE_NAME2NUM{'PUKE_ALISTBOX_SMALL_HIGHLIGHT'} = 1905;
+$PUKE_NUM2NAME{'1905'} = 'PUKE_ALISTBOX_SMALL_HIGHLIGHT';
+$PUKE_ALISTBOX_SMALL_HIGHLIGHT_ACK = -1905;
+$PUKE_NAME2NUM{'PUKE_ALISTBOX_SMALL_HIGHLIGHT_ACK'} = -1905;
+$PUKE_NUM2NAME{'-1905'} = 'PUKE_ALISTBOX_SMALL_HIGHLIGHT_ACK';
+$PUKE_ALISTBOX_BIG_HIGHLIGHT = 1910;
+$PUKE_NAME2NUM{'PUKE_ALISTBOX_BIG_HIGHLIGHT'} = 1910;
+$PUKE_NUM2NAME{'1910'} = 'PUKE_ALISTBOX_BIG_HIGHLIGHT';
+$PUKE_ALISTBOX_BIG_HIGHLIGHT_ACK = -1910;
+$PUKE_NAME2NUM{'PUKE_ALISTBOX_BIG_HIGHLIGHT_ACK'} = -1910;
+$PUKE_NUM2NAME{'-1910'} = 'PUKE_ALISTBOX_BIG_HIGHLIGHT_ACK';
+$PUKE_ALISTBOX_FIND_NICK = 1915;
+$PUKE_NAME2NUM{'PUKE_ALISTBOX_FIND_NICK'} = 1915;
+$PUKE_NUM2NAME{'1915'} = 'PUKE_ALISTBOX_FIND_NICK';
+$PUKE_ALISTBOX_FIND_NICK_ACK = -1915;
+$PUKE_NAME2NUM{'PUKE_ALISTBOX_FIND_NICK_ACK'} = -1915;
+$PUKE_NUM2NAME{'-1915'} = 'PUKE_ALISTBOX_FIND_NICK_ACK';
+$PUKE_TABDIALOG_ADDTAB = 2001;
+$PUKE_NAME2NUM{'PUKE_TABDIALOG_ADDTAB'} = 2001;
+$PUKE_NUM2NAME{'2001'} = 'PUKE_TABDIALOG_ADDTAB';
+$PUKE_TABDIALOG_ADDTAB_ACK = -2001;
+$PUKE_NAME2NUM{'PUKE_TABDIALOG_ADDTAB_ACK'} = -2001;
+$PUKE_NUM2NAME{'-2001'} = 'PUKE_TABDIALOG_ADDTAB_ACK';
+$PUKE_KSIRCLISTBOX_TOBOTTOM = 2100;
+$PUKE_NAME2NUM{'PUKE_KSIRCLISTBOX_TOBOTTOM'} = 2100;
+$PUKE_NUM2NAME{'2100'} = 'PUKE_KSIRCLISTBOX_TOBOTTOM';
+$PUKE_KSIRCLISTBOX_TOBOTTOM_ACK = -2100;
+$PUKE_NAME2NUM{'PUKE_KSIRCLISTBOX_TOBOTTOM_ACK'} = -2100;
+$PUKE_NUM2NAME{'-2100'} = 'PUKE_KSIRCLISTBOX_TOBOTTOM_ACK';
+$PWIDGET_OBJECT = 1;
+$PUKE_NAME2NUM{'PWIDGET_OBJECT'} = 1;
+$PUKE_NUM2NAME{'1'} = 'PWIDGET_OBJECT';
+$PWIDGET_WIDGET = 2;
+$PUKE_NAME2NUM{'PWIDGET_WIDGET'} = 2;
+$PUKE_NUM2NAME{'2'} = 'PWIDGET_WIDGET';
+$PWIDGET_FRAME = 3;
+$PUKE_NAME2NUM{'PWIDGET_FRAME'} = 3;
+$PUKE_NUM2NAME{'3'} = 'PWIDGET_FRAME';
+$PWIDGET_LINED = 4;
+$PUKE_NAME2NUM{'PWIDGET_LINED'} = 4;
+$PUKE_NUM2NAME{'4'} = 'PWIDGET_LINED';
+$PWIDGET_BUTTON = 5;
+$PUKE_NAME2NUM{'PWIDGET_BUTTON'} = 5;
+$PUKE_NUM2NAME{'5'} = 'PWIDGET_BUTTON';
+$PWIDGET_PUSHBT = 6;
+$PUKE_NAME2NUM{'PWIDGET_PUSHBT'} = 6;
+$PUKE_NUM2NAME{'6'} = 'PWIDGET_PUSHBT';
+$PWIDGET_KSPROGRESS = 7;
+$PUKE_NAME2NUM{'PWIDGET_KSPROGRESS'} = 7;
+$PUKE_NUM2NAME{'7'} = 'PWIDGET_KSPROGRESS';
+$PWIDGET_TABLEVW = 8;
+$PUKE_NAME2NUM{'PWIDGET_TABLEVW'} = 8;
+$PUKE_NUM2NAME{'8'} = 'PWIDGET_TABLEVW';
+$PWIDGET_LISTBOX = 9;
+$PUKE_NAME2NUM{'PWIDGET_LISTBOX'} = 9;
+$PUKE_NUM2NAME{'9'} = 'PWIDGET_LISTBOX';
+$PWIDGET_LABEL = 10;
+$PUKE_NAME2NUM{'PWIDGET_LABEL'} = 10;
+$PUKE_NUM2NAME{'10'} = 'PWIDGET_LABEL';
+$POBJECT_LAYOUT = 11;
+$PUKE_NAME2NUM{'POBJECT_LAYOUT'} = 11;
+$PUKE_NUM2NAME{'11'} = 'POBJECT_LAYOUT';
+$PWIDGET_MENUDATA = 12;
+$PUKE_NAME2NUM{'PWIDGET_MENUDATA'} = 12;
+$PUKE_NUM2NAME{'12'} = 'PWIDGET_MENUDATA';
+$PWIDGET_POPMENU = 13;
+$PUKE_NAME2NUM{'PWIDGET_POPMENU'} = 13;
+$PUKE_NUM2NAME{'13'} = 'PWIDGET_POPMENU';
+$PWIDGET_ALISTBOX = 14;
+$PUKE_NAME2NUM{'PWIDGET_ALISTBOX'} = 14;
+$PUKE_NUM2NAME{'14'} = 'PWIDGET_ALISTBOX';
+$PWIDGET_KSIRCLISTBOX = 15;
+$PUKE_NAME2NUM{'PWIDGET_KSIRCLISTBOX'} = 15;
+$PUKE_NUM2NAME{'15'} = 'PWIDGET_KSIRCLISTBOX';
+$PWIDGET_TABDIALOG = 16;
+$PUKE_NAME2NUM{'PWIDGET_TABDIALOG'} = 16;
+$PUKE_NUM2NAME{'16'} = 'PWIDGET_TABDIALOG';
+$PWIDGET_KFILEDIALOG = 17;
+$PUKE_NAME2NUM{'PWIDGET_KFILEDIALOG'} = 17;
+$PUKE_NUM2NAME{'17'} = 'PWIDGET_KFILEDIALOG';
+$PWIDGET_OBJFINDER = 18;
+$PUKE_NAME2NUM{'PWIDGET_OBJFINDER'} = 18;
+$PUKE_NUM2NAME{'18'} = 'PWIDGET_OBJFINDER';
+$PUKE_LAYOUT_NEW = 11000;
+$PUKE_NAME2NUM{'PUKE_LAYOUT_NEW'} = 11000;
+$PUKE_NUM2NAME{'11000'} = 'PUKE_LAYOUT_NEW';
+$PUKE_LAYOUT_NEW_ACK = -11000;
+$PUKE_NAME2NUM{'PUKE_LAYOUT_NEW_ACK'} = -11000;
+$PUKE_NUM2NAME{'-11000'} = 'PUKE_LAYOUT_NEW_ACK';
+$PUKE_LAYOUT_ADDLAYOUT = 11005;
+$PUKE_NAME2NUM{'PUKE_LAYOUT_ADDLAYOUT'} = 11005;
+$PUKE_NUM2NAME{'11005'} = 'PUKE_LAYOUT_ADDLAYOUT';
+$PUKE_LAYOUT_ADDLAYOUT_ACK = -11005;
+$PUKE_NAME2NUM{'PUKE_LAYOUT_ADDLAYOUT_ACK'} = -11005;
+$PUKE_NUM2NAME{'-11005'} = 'PUKE_LAYOUT_ADDLAYOUT_ACK';
+$PUKE_LAYOUT_ADDWIDGET = 11010;
+$PUKE_NAME2NUM{'PUKE_LAYOUT_ADDWIDGET'} = 11010;
+$PUKE_NUM2NAME{'11010'} = 'PUKE_LAYOUT_ADDWIDGET';
+$PUKE_LAYOUT_ADDWIDGET_ACK = -11010;
+$PUKE_NAME2NUM{'PUKE_LAYOUT_ADDWIDGET_ACK'} = -11010;
+$PUKE_NUM2NAME{'-11010'} = 'PUKE_LAYOUT_ADDWIDGET_ACK';
+$PUKE_LAYOUT_ADDSTRUT = 11015;
+$PUKE_NAME2NUM{'PUKE_LAYOUT_ADDSTRUT'} = 11015;
+$PUKE_NUM2NAME{'11015'} = 'PUKE_LAYOUT_ADDSTRUT';
+$PUKE_LAYOUT_ADDSTRUT_ACK = -11015;
+$PUKE_NAME2NUM{'PUKE_LAYOUT_ADDSTRUT_ACK'} = -11015;
+$PUKE_NUM2NAME{'-11015'} = 'PUKE_LAYOUT_ADDSTRUT_ACK';
+$PUKE_LAYOUT_ACTIVATE = 11020;
+$PUKE_NAME2NUM{'PUKE_LAYOUT_ACTIVATE'} = 11020;
+$PUKE_NUM2NAME{'11020'} = 'PUKE_LAYOUT_ACTIVATE';
+$PUKE_LAYOUT_ACTIVATE_ACK = -11020;
+$PUKE_NAME2NUM{'PUKE_LAYOUT_ACTIVATE_ACK'} = -11020;
+$PUKE_NUM2NAME{'-11020'} = 'PUKE_LAYOUT_ACTIVATE_ACK';
+$PUKE_CONTROLLER = 1;
+$PUKE_NAME2NUM{'PUKE_CONTROLLER'} = 1;
+$PUKE_NUM2NAME{'1'} = 'PUKE_CONTROLLER';
+$PUKE_KBFD_SET_PATH = 2200;
+$PUKE_NAME2NUM{'PUKE_KBFD_SET_PATH'} = 2200;
+$PUKE_NUM2NAME{'2200'} = 'PUKE_KBFD_SET_PATH';
+$PUKE_BFD_SET_PATH_ACK = -2200;
+$PUKE_NAME2NUM{'PUKE_BFD_SET_PATH_ACK'} = -2200;
+$PUKE_NUM2NAME{'-2200'} = 'PUKE_BFD_SET_PATH_ACK';
+$PUKE_KBFD_SET_FILTER = 2201;
+$PUKE_NAME2NUM{'PUKE_KBFD_SET_FILTER'} = 2201;
+$PUKE_NUM2NAME{'2201'} = 'PUKE_KBFD_SET_FILTER';
+$PUKE_KBFD_SET_FILTER_ACK = -2201;
+$PUKE_NAME2NUM{'PUKE_KBFD_SET_FILTER_ACK'} = -2201;
+$PUKE_NUM2NAME{'-2201'} = 'PUKE_KBFD_SET_FILTER_ACK';
+$PUKE_KBFD_SET_SELECTION = 2202;
+$PUKE_NAME2NUM{'PUKE_KBFD_SET_SELECTION'} = 2202;
+$PUKE_NUM2NAME{'2202'} = 'PUKE_KBFD_SET_SELECTION';
+$PUKE_KBFD_SET_SELECTION_ACK = -2202;
+$PUKE_NAME2NUM{'PUKE_KBFD_SET_SELECTION_ACK'} = -2202;
+$PUKE_NUM2NAME{'-2202'} = 'PUKE_KBFD_SET_SELECTION_ACK';
+$PUKE_KBFD_FILE_SELECTED = 2203;
+$PUKE_NAME2NUM{'PUKE_KBFD_FILE_SELECTED'} = 2203;
+$PUKE_NUM2NAME{'2203'} = 'PUKE_KBFD_FILE_SELECTED';
+$PUKE_KBFD_FILE_SELECTED_ACK = -2203;
+$PUKE_NAME2NUM{'PUKE_KBFD_FILE_SELECTED_ACK'} = -2203;
+$PUKE_NUM2NAME{'-2203'} = 'PUKE_KBFD_FILE_SELECTED_ACK';
+$PUKE_OBJFINDER_ALLOBJECTS = 2300;
+$PUKE_NAME2NUM{'PUKE_OBJFINDER_ALLOBJECTS'} = 2300;
+$PUKE_NUM2NAME{'2300'} = 'PUKE_OBJFINDER_ALLOBJECTS';
+$PUKE_OBJFINDER_ALLOBJECTS_ACK = -2300;
+$PUKE_NAME2NUM{'PUKE_OBJFINDER_ALLOBJECTS_ACK'} = -2300;
+$PUKE_NUM2NAME{'-2300'} = 'PUKE_OBJFINDER_ALLOBJECTS_ACK';
+$PUKE_OBJFINDER_NEWOBJECT = 2301;
+$PUKE_NAME2NUM{'PUKE_OBJFINDER_NEWOBJECT'} = 2301;
+$PUKE_NUM2NAME{'2301'} = 'PUKE_OBJFINDER_NEWOBJECT';
+$PUKE_OBJFINDER_NEWOBJECT_ACK = -2301;
+$PUKE_NAME2NUM{'PUKE_OBJFINDER_NEWOBJECT_ACK'} = -2301;
+$PUKE_NUM2NAME{'-2301'} = 'PUKE_OBJFINDER_NEWOBJECT_ACK';
+
+1;
diff --git a/ksirc/puke/commands.h b/ksirc/puke/commands.h
new file mode 100644
index 00000000..3e45d8ba
--- /dev/null
+++ b/ksirc/puke/commands.h
@@ -0,0 +1,1052 @@
+
+// 0 is special "invalid character"
+// Value > 0 indicates from dsirc -> ksirc
+// Value < 0 indicates from ksirc -> dsirc
+
+// Desc: INVALID command
+// iWinId: not defined
+// iArg: not defined
+// cArg: not defined
+#define PUKE_INVALID 0
+
+// Desc: associantes server name with fd.
+// iWinId: not defined, but pass unchanged
+// iArg: not defined
+// cArg: name of the server
+#define PUKE_SETUP 1
+
+// Desc: replies to make sure association was valid
+// iWinId: not defined, but pass unchanged
+// iArg: size of Message
+// cArg: not defined
+#define PUKE_SETUP_ACK -1
+
+
+// Desc: sends the ack back. Used for doing actions after returning to select.
+// iWinId: window id
+// iArg: not defined
+// cArg: not define
+#define PUKE_ECHO 5
+
+// Desc: sends the ack back. Used for doing actions after returning to select.
+// iWinId: window id
+// iArg: not defined
+// cArg: not define
+#define PUKE_ECHO_ACK -5
+
+
+// From ksirc to sirc, event command unkown.
+// There should be somewhere better for this!!!
+
+#define PUKE_EVENT_UNKOWN -999
+
+// Dumps object tree
+// iWinId: puke controller
+// iArg: not defined
+// cArg: undef
+#define PUKE_DUMPTREE 997
+
+// Desc: dump object tree ack
+// iWinId: undef
+// iArg: undef
+// cArg: undef
+#define PUKE_DUMPTREE_ACK -997
+
+// Release a widget without delete'ing it, used after fetching a widget
+// iWinId: window id
+// iArg: undef
+// cArg: undef
+#define PUKE_RELEASEWIDGET 996
+
+// Desc: release ack
+// iWinId: window id
+// iArg: undef
+// cArg: undef
+#define PUKE_RELEASEWIDGET_ACK -996
+
+
+// Fetch widgets
+// Desc: get widget from parent
+// iWinId: not defined
+// iArg: not defined
+// cArg: 2 feilds, tab sperated, must be returned unchanged. 1. random string. 3. Object Name.
+#define PUKE_FETCHWIDGET 998
+
+// Desc: Fetch widget ack
+// iWinId: new widget id
+// iArg: not defined
+// cArg: 2 feilds, tab sperated, must be returned unchanged. 1. random string. 3. Object Name.
+#define PUKE_FETCHWIDGET_ACK -998
+
+
+// Widget commands starts at 1000 and end at 10000
+
+// Desc: create new widget
+// iWinId: parent widget id
+// iArg: widget type as defined by PWIDGET_*
+// cArg: Must be return unchanged
+#define PUKE_WIDGET_CREATE 1000
+
+// Desc: ack for newly created new widget
+// iWinId: new widget Id, 0 if failed
+// iArg: widget type as defined by PWIDGET_*
+// cArg: Returned unchanged
+#define PUKE_WIDGET_CREATE_ACK -1000
+
+
+// Desc: shows requested widget
+// iWinId: widget to show
+// iArg: not defined
+// cArg: not define
+#define PUKE_WIDGET_DELETE 1001
+
+// Desc: ack for show requested widget
+// iWinId: widget to show
+// iArg: not defined
+// cArg: not define
+#define PUKE_WIDGET_DELETE_ACK -1001
+
+// Desc: shows requested widget
+// iWinId: widget to show
+// iArg: not defined
+// cArg: not define
+#define PUKE_WIDGET_SHOW 1002
+
+// Desc: ack for show requested widget
+// iWinId: widget to show
+// iArg: not defined
+// cArg: not define
+#define PUKE_WIDGET_SHOW_ACK -1002
+
+// Desc: hidess requested widget
+// iWinId: widget to hide
+// iArg: not defined
+// cArg: not define
+#define PUKE_WIDGET_HIDE 1003
+
+// Desc: ack for hide requested widget
+// iWinId: widget to hide
+// iArg: not defined
+// cArg: not define
+#define PUKE_WIDGET_HIDE_ACK -1003
+
+// Desc: repaint widget
+// iWinId: widget to repaint
+// iArg: erase, 0 for false, 1 for true
+// cArg: no defines
+#define PUKE_WIDGET_REPAINT 1005
+
+// Desc: repaint widget ack
+// iWinId: widget to repaint
+// iArg: not defined
+// cArg: not defined
+#define PUKE_WIDGET_REPAINT_ACK -1005
+
+// Desc: update widget on next event loop
+// iWinId: widget to repaint
+// iArg: erase, 0 for false, 1 for true
+// cArg: no defines
+#define PUKE_WIDGET_UPDATE 1010
+
+// Desc: repaint widget ack
+// iWinId: widget to repaint
+// iArg: not defined
+// cArg: not defined
+#define PUKE_WIDGET_UPDATE_ACK -1010
+
+// Desc: resize the widget
+// iWinId: widget to repaint
+// iArg: width in the low 16 bit, height in next 16 bits
+// cArg: not defined
+#define PUKE_WIDGET_RESIZE 1015
+
+// Desc: repaint widget ack
+// iWinId: widget to repaint
+// iArg: new widget in lower 16 bit, new height in lower 16 bits
+// cArg: not defined
+#define PUKE_WIDGET_RESIZE_ACK -1015
+
+// -1020 to -1040 defines QEvent types
+// All arguments are 0 unless otherwise stated
+#define PUKE_WIDGET_EVENT_NONE -1020
+// iArg: timerId
+#define PUKE_WIDGET_EVENT_TIMER -1021
+// All EVENT_MOUSE are:
+// cArg: cast to int[25], int[0] = x(), int[1] = y(), int[2] = button()
+// int[3] = state()
+#define PUKE_WIDGET_EVENT_MOUSEBUTTONPRESS -1022
+#define PUKE_WIDGET_EVENT_MOUSEBUTTONRELEASE -1023
+#define PUKE_WIDGET_EVENT_MOUSEDBLCLICK -1024
+#define PUKE_WIDGET_EVENT_MOUSEMOVE -1025
+// All EVENT_KEY
+// cArg: cast to int[25], int[0] = key(), int[1] = ascii(), int[2] = state()
+#define PUKE_WIDGET_EVENT_KEYPRESS -1026
+#define PUKE_WIDGET_EVENT_KEYRELEASE -1027
+// All EVENT_FOCUS
+// cArg[0] = gotFocus()
+// cArg[1] = lostFocus()
+#define PUKE_WIDGET_EVENT_FOCUSIN -1028
+#define PUKE_WIDGET_EVENT_FOCUSOUT -1029
+#define PUKE_WIDGET_EVENT_ENTER -1030
+#define PUKE_WIDGET_EVENT_LEAVE -1031
+// Paint event
+#define PUKE_WIDGET_EVENT_PAINT -1032
+// cArg: int[0] = pos()->x() int[1] = pos->y()
+// int[2] = oldPos->x() int[3] = oldPos->y()
+#define PUKE_WIDGET_EVENT_MOVE -1033
+// cArg: int[0] = size()->width() int[1] = size()->height()
+// int[2] = oldSize()->width() int[3] = oldSize()->height()
+#define PUKE_WIDGET_EVENT_RESIZE -1034
+#define PUKE_WIDGET_EVENT_CREATE -1035
+#define PUKE_WIDGET_EVENT_DESTROY -1036
+#define PUKE_WIDGET_EVENT_SHOW -1037
+#define PUKE_WIDGET_EVENT_HIDE -1038
+#define PUKE_WIDGET_EVENT_CLOSE -1039
+
+// Desc: move widget
+// iWinId: widget id
+// iArg: new location, lower short is x, upper short is y
+// cArg: not define
+#define PUKE_WIDGET_MOVE 1050
+
+// Desc: move widget
+// iWinId: widget id
+// iArg: new location, lower short is x, upper short is y
+// cArg: not define
+#define PUKE_WIDGET_MOVE_ACK -1050
+
+// Desc: open and load library file
+// iWinid: not defined
+// iArg: type of widget
+// cArg: file name
+#define PUKE_WIDGET_LOAD 1055
+
+// Desc: ack the open library file
+// iWinid: not defined
+// iArg: widget number
+// cArg: not defined
+#define PUKE_WIDGET_LOAD_ACK -1055
+
+// Desc: unload library file
+// iWinid: not define
+// iArg: type of widget to unload
+// cArg: no define
+#define PUKE_WIDGET_UNLOAD 1060
+
+// Desc: ack open and load library file
+// iWinid: not defined
+// iArg: not defined
+// cArg: no defined
+#define PUKE_WIDGET_UNLOAD_ACK -1060
+
+// Desc: set's a a minimum size
+// iWinid: window id
+// iArg: 2 ints, lower is width , upper is height
+// cArg: not define
+#define PUKE_WIDGET_SETMINSIZE 1065
+
+// Desc: ack for set size
+// iWinid: window id
+// iArg: 2 ints, lower is new width, upper is new height
+// cArg: not defined
+#define PUKE_WIDGET_SETMINSIZE_ACK -1065
+
+// Desc: set's a a minimum size
+// iWinid: window id
+// iArg: 2 ints, lower is width , upper is height
+// cArg: not define
+#define PUKE_WIDGET_SETMAXSIZE 1070
+
+// Desc: ack for set size
+// iWinid: window id
+// iArg: 2 ints, lower is new width, upper is new height
+// cArg: not defined
+#define PUKE_WIDGET_SETMAXSIZE_ACK -1070
+
+// Desc: set widget caption
+// iWinid: window id
+// iArg: not defined
+// cArg: widget caption
+#define PUKE_WIDGET_SETCAPTION 1075
+
+// Desc: ack for set caption
+// iWinid: window id
+// iArg: not define
+// cArg: new caption
+#define PUKE_WIDGET_SETCAPTION_ACK -1075
+
+// Desc: get background colour
+// iWinid: window id
+// iArg: not defined
+// cArg: not defined
+#define PUKE_WIDGET_GET_BACKGROUND_COLOUR 1080
+
+// Desc: get background colour ack
+// iWinid: window id
+// iArg: not defined
+// cArg: 3 ints packed in rbg combo
+#define PUKE_WIDGET_GET_BACKGROUND_COLOUR_ACK -1080
+
+// Desc: set background colour
+// iWinid: window id
+// iArg: not defined
+// cArg: 3 ints packed in rbg combo
+#define PUKE_WIDGET_SET_BACKGROUND_COLOUR 1085
+
+// Desc: set background colour ack
+// iWinid: window id
+// iArg: not defined
+// cArg: not defined
+#define PUKE_WIDGET_SET_BACKGROUND_COLOUR_ACK -1085
+
+// Desc: set background pixmap
+// iWinid: window id
+// iArg: not defined
+// cArg: path name to pixmap
+#define PUKE_WIDGET_SET_BACKGROUND_PIXMAP 1086
+
+// Desc: set background pixmap ack
+// iWinid: window id
+// iArg: not defined
+// cArg: not defined
+#define PUKE_WIDGET_SET_BACKGROUND_PIXMAP_ACK -1086
+
+// Desc: set background mode
+// iWinid: window id
+// iArg: mode
+// cArg: not defined
+#define PUKE_WIDGET_SET_BACKGROUND_MODE 1087
+
+// Desc: set background mode ack
+// iWinid: window id
+// iArg: new mode
+// cArg: not defined
+#define PUKE_WIDGET_SET_BACKGROUND_MODE_ACK -1087
+
+// Desc: set widget enabled or disabled
+// iWinid: window id
+// iArg: 0 for disabled, 1 for enabled
+// cArg: not defined
+#define PUKE_WIDGET_SET_ENABLED 1090
+
+// Desc: ack for enable/disable
+// iWinid: window id
+// iArg: not defined
+// cArg: not defined
+#define PUKE_WIDGET_SET_ENABLED_ACK -1090
+
+// Desc: recreate widget with new parent, etc
+// IwinId: window id
+// iArg: window ID for new parent, 0x0 for no parent, toplevel
+// cArg: 3 packed ints, 0 = x, 1 = y, 2 = showit
+#define PUKE_WIDGET_RECREATE 1091
+
+// Desc: ACK recreate widget with new parent, etc
+// IwinId: window id
+// iArg: 0 (for all ok, other for error)
+// cArg: 0
+#define PUKE_WIDGET_RECREATE_ACK -1091
+
+// QFrame gets 1100
+
+// 1100 defines QFrame
+// Desc: set Frame style
+// iWinId: widget to chanse
+// iArg: frame style to set.
+// cArg: no define
+#define PUKE_QFRAME_SET_FRAME 1100
+
+// Desc: get/ack Frame style
+// iWinId: widget to changed
+// iArg: frame style.
+// cArg: no define
+#define PUKE_QFRAME_SET_FRAME_ACK -1100
+
+// Desc: set Frame line width
+// iWinId: widget to chanse
+// iArg: newline width.
+// cArg: no define
+#define PUKE_QFRAME_SET_LINEWIDTH 1105
+
+// Desc: get/ack Frame line width
+// iWinId: widget to changed
+// iArg: line width.
+// cArg: no define
+#define PUKE_QFRAME_SET_LINEWIDTH_ACK -1105
+
+//----------------------------------------------------
+// 1200 is a QLineEdit
+
+// Desc: set max line length
+// iWinId: widget to change
+// iArg: max line length
+// cArg: not defined
+#define PUKE_LINED_SET_MAXLENGTH 1200
+
+// Desc: set max line length
+// iWinId: widget to change
+// iArg: new max line length
+// cArg: not defined
+#define PUKE_LINED_SET_MAXLENGTH_ACK -1200
+
+// Desc: set echo mode, normal password, no echo, etc
+// iWinId: widget to change
+// iArg: echo mode
+// cArg: not defined
+#define PUKE_LINED_SET_ECHOMODE 1205
+
+// Desc: ack for set
+// iWinId: widget to change
+// iArg: current echo mode
+// cArg: not define
+#define PUKE_LINED_SET_ECHOMODE_ACK -1205
+
+// Desc: set text contents of widget
+// iWinId: widget to change
+// iArg: not defined
+// cArg: text to set widget too
+#define PUKE_LINED_SET_TEXT 1210
+
+// Desc: ack for set
+// iWinId: widget to change
+// iArg: not define
+// cArg: current test
+#define PUKE_LINED_SET_TEXT_ACK -1210
+
+// Desc: get current text
+// iWinId: widget to change
+// iArg:not define
+// cArg: not defined
+#define PUKE_LINED_GET_TEXT 1215
+
+// Desc: returned info for get text
+// iWinId: widget to change
+// iArg: not defined
+// cArg: text in widget
+#define PUKE_LINED_GET_TEXT_ACK -1215
+
+// Desc: return was pressed, action not defined
+// iWinId:
+// iArg:
+// cArg:
+#define PUKE_LINED_RETURN_PRESSED 1220
+
+// Desc: return was pressed, return information
+// iWinId: widget pressed in
+// iArg: not defined
+// cArg: not defined
+#define PUKE_LINED_RETURN_PRESSED_ACK -1220
+
+//------------------------------------------------
+
+// Desc: set's button's current text
+// iWinId: window id
+// iArg: not defined
+// cArg: text
+#define PUKE_BUTTON_SET_TEXT 1300
+
+// Desc: ack for set text
+// iWinId: widget id
+// iArg: not defined
+// cArg: text
+#define PUKE_BUTTON_SET_TEXT_ACK -1300
+
+// Desc: set button to pixmap
+// iWinId: window id
+// iArg: not defined
+// cArg: path to pixmap
+#define PUKE_BUTTON_SET_PIXMAP 1305
+
+// Desc: ack for set pixmap
+// iWinId: widget id
+// iArg: pixmap()->isNull()
+// cArg: not defined
+#define PUKE_BUTTON_SET_PIXMAP_ACK -1305
+
+// Desc: set if button resizes with content changes
+// iWinId: window id
+// iArg: reisze, 0 false, 1 true
+// cArg: not defined
+#define PUKE_BUTTON_SET_AUTORESIZE 1310
+
+// Desc: ack for autreisze
+// iWinId: widget id
+// iArg: autoresize()
+// cArg: not defined
+#define PUKE_BUTTON_SET_AUTORESIZE_ACK -1310
+
+// Desc: button was pressed, not used
+// iWinId: not defined
+// iArg: not defined
+// cArg: not define
+#define PUKE_BUTTON_PRESSED 1350
+
+// Desc: signal button was pressed
+// iWinId: winid
+// iArg: not define
+// cArg: not defined
+#define PUKE_BUTTON_PRESSED_ACK -1350
+
+// Desc: button was relased, not used
+// iWinId: not defined
+// iArg: not defined
+// cArg: not define
+#define PUKE_BUTTON_RELEASED 1351
+
+// Desc: signal button was released
+// iWinId: winid
+// iArg: not define
+// cArg: not defined
+#define PUKE_BUTTON_RELEASED_ACK -1351
+
+// Desc: button was clicked, not used
+// iWinId: not defined
+// iArg: not defined
+// cArg: not define
+#define PUKE_BUTTON_CLICKED 1352
+
+// Desc: signal button was clicked
+// iWinId: winid
+// iArg: not defined
+// cArg: not defined
+#define PUKE_BUTTON_CLICKED_ACK -1352
+
+// Desc: button was toggled, not used
+// iWinId: not defined
+// iArg: not defined
+// cArg: not define
+#define PUKE_BUTTON_TOGGLED 1353
+
+// Desc: signal button was toggled
+// iWinId: winid
+// iArg: not define
+// cArg: not defined
+#define PUKE_BUTTON_TOGGLED_ACK -1353
+
+
+//------------------------------------------------
+
+// Desc: set's the range of the control
+// iWinId: window id
+// iArg: two packed short ints. Lower is lower, upper is upper
+// cArg: not define
+#define PUKE_KSPROGRESS_SET_RANGE 1400
+
+// Desc: ack set's the range of the control
+// iWinId: window id
+// iArg: not define
+// cArg: not defined
+#define PUKE_KSPROGRESS_SET_RANGE_ACK -1400
+
+// Desc: set the top text line
+// iWinId: window id
+// iArg: not define
+// cArg: top line
+#define PUKE_KSPROGRESS_SET_TOPTEXT 1410
+
+// Desc: ack set the top text line
+// iWinId: window id
+// iArg: not defined
+// cArg: not defined
+#define PUKE_KSPROGRESS_SET_TOPTEXT_ACK -1410
+
+// Desc: set the bottom text line
+// iWinId: window id
+// iArg: not define
+// cArg: bottom line
+#define PUKE_KSPROGRESS_SET_BOTTEXT 1415
+
+// Desc: ack set the top text line
+// iWinId: window id
+// iArg: not defined
+// cArg: not defined
+#define PUKE_KSPROGRESS_SET_BOTTEXT_ACK -1415
+
+// Desc: set status value
+// iWinId: window id
+// iArg: not define
+// cArg: current value
+#define PUKE_KSPROGRESS_SET_VALUE 1420
+
+// Desc: ack set the top text line
+// iWinId: window id
+// iArg: not defined
+// cArg: not defined
+#define PUKE_KSPROGRESS_SET_VALUE_ACK -1420
+
+
+// Desc: cancel pressed, typically only ack sent.
+// iWinId: window id
+// iArg: not define
+// cArg: current value
+#define PUKE_KSPROGRESS_CANCEL 1425
+
+// Desc: send message saying cancel button was pressed
+// iWinId: window id
+// iArg: not defined
+// cArg: not defined
+#define PUKE_KSPROGRESS_CANCEL_ACK -1425
+
+// QTable View at 1500
+
+// none yet
+
+// QListBox at 1600
+
+// Desc: insert string item
+// iWinId: window id
+// iArg: number of items now in list
+// cArg: undef
+#define PUKE_LISTBOX_INSERT 1600
+
+// Desc: insert string item ack
+// iWinId: window id
+// iArg: not defined
+// cArg: not defined
+#define PUKE_LISTBOX_INSERT_ACK -1600
+
+
+// Desc: insert string item in sorted order
+// iWinId: window id
+// iArg: number of items in list
+// cArg: undef
+#define PUKE_LISTBOX_INSERT_SORT 1605
+
+// Desc: ack insert string item in sorted order
+// iWinId: window id
+// iArg: not defined
+// cArg: not defined
+#define PUKE_LISTBOX_INSERT_SORT_ACK -1605
+
+// Desc: insert pixmap
+// iWinId: window id
+// iArg: not defined
+// cArg: file name
+#define PUKE_LISTBOX_INSERT_PIXMAP 1610
+
+// Desc: ack insert pixmap
+// iWinId: window id
+// iArg: not defined
+// cArg: not defined
+#define PUKE_LISTBOX_INSERT_PIXMAP_ACK -1610
+
+// Desc: highligth number
+// iWinId: window id
+// iArg: item index to highlight
+// cArg: undef
+#define PUKE_LISTBOX_HIGHLIGHT 1615
+
+// Desc: ack
+// iWinId: window id
+// iArg: not defined
+// cArg: not defined
+#define PUKE_LISTBOX_HIGHLIGHT_ACK -1615
+
+// Desc: remove number
+// iWinId: window id
+// iArg: item index to remove
+// cArg: undef
+#define PUKE_LISTBOX_REMOVE 1620
+
+// Desc: ack
+// iWinId: window id
+// iArg: not defined
+// cArg: not defined
+#define PUKE_LISTBOX_REMOVE_ACK -1620
+
+// Desc: Get text from item number
+// iWinId: window id
+// iArg: list item
+// cArg: not defined
+#define PUKE_LISTBOX_GETTEXT 1625
+
+// Desc: ack for get text with cArg set to text
+// iWinId: window id
+// iArg: 1 for sucsess, 0 for failure
+// cArg: text
+#define PUKE_LISTBOX_GETTEXT_ACK -1625
+
+// Desc: Clear list box
+// iWinId: window id
+// iArg: not defined
+// cArg: not defined
+#define PUKE_LISTBOX_CLEAR 1630
+
+// Desc: ack for clear list box
+// iWinId: window id
+// iArg: not defined
+// cArg: not defined
+#define PUKE_LISTBOX_CLEAR_ACK -1630
+
+// Desc: set scroll bar
+// iWinId: window id
+// iArg: bool, enable/disable
+// cArg: undef
+#define PUKE_LISTBOX_SET_SCROLLBAR 1635
+
+// Desc: set scroll bar ack
+// iWinId: window id
+// iArg: undef
+// cArg: undef
+#define PUKE_LISTBOX_SET_SCROLLBAR_ACK -1635
+
+// Desc: set auto scroll bar
+// iWinId: window id
+// iArg: bool, enable/disable
+// cArg: undef
+#define PUKE_LISTBOX_SET_AUTO_SCROLLBAR 1636
+
+// Desc: set auto scroll bar ack
+// iWinId: window id
+// iArg: undef
+// cArg: undef
+#define PUKE_LISTBOX_SET_AUTO_SCROLLBAR_ACK -1636
+
+// Desc: item highlighted, not used signal to dsirc
+// iWinId: undef
+// iArg: undef
+// cArg: undef
+#define PUKE_LISTBOX_HIGHLIGHTED 1690
+
+// Desc: item highlighted
+// iWinId: window id
+// iArg: index
+// cArg: contents
+#define PUKE_LISTBOX_HIGHLIGHTED_ACK -1690
+
+// Desc: item selected
+// iWinId: window id
+// iArg: index
+// cArg: contents
+#define PUKE_LISTBOX_SELECTED 1690
+
+// Desc: send message saying cancel button was pressed
+// iWinId: window id
+// iArg: not defined
+// cArg: not defined
+#define PUKE_LISTBOX_SELECTED_ACK -1690
+
+// *** 1700 goes to the Plabel
+
+// Desc: Set label to text in carg
+// iWinId: window id
+// iArg: not defined
+// cArg: text to be set to
+#define PUKE_LABEL_SETTEXT 1700
+
+// Desc: Set label to text in carg, ack
+// iWinId: window id
+// iArg: not defined
+// cArg: not defined
+#define PUKE_LABEL_SETTEXT_ACK -1700
+
+// Desc: Set label pixmap specified by filane name
+// iWinId: window id
+// iArg: not defined
+// cArg: filena,me for pixmap
+#define PUKE_LABEL_SETPIXMAP 1705
+
+// Desc: Set label pixmap specified by filane name ACK
+// iWinId: window id
+// iArg: not defined
+// cArg: not defined
+#define PUKE_LABEL_SETPIXMAP_ACK -1705
+
+// Desc: Set label to movie specified by filename
+// iWinId: window id
+// iArg: not defined
+// cArg: movie's filename
+#define PUKE_LABEL_SETMOVIE 1710
+
+// Desc: Set label to movie specified by filename, ACK
+// iWinId: window id
+// iArg: not defined
+// cArg: not deefine
+#define PUKE_LABEL_SETMOVIE_ACK -1710
+
+// Desc: Set label's allignment
+// iWinId: window id
+// iArg: alignment
+// cArg: not defined
+#define PUKE_LABEL_SETALIGNMENT 1715
+
+// Desc: Set label's allignment, ACK
+// iWinId: window id
+// iArg: alignment
+// cArg: not defined
+#define PUKE_LABEL_SETALIGNMENT_ACK -1715
+
+// -----------------------------------------------------------------------
+// PMenuData
+
+// Desc: Inserts newtext menu item
+// iWinId: window id
+// iArg: keyboard accelerator (-1 for none)
+// cArg: Text
+#define PUKE_MENUDATA_INSERT_TEXT 1800
+
+// Desc: ack for insert
+// iWinId: window id
+// iArg: object id
+// cArg: undef
+#define PUKE_MENUDATA_INSERT_TEXT_ACK -1800
+
+// Desc: Inserts new pixmap into menu
+// iWinId: window id
+// iArg: keyboard accelerator (-1 for none)
+// cArg: Text
+#define PUKE_MENUDATA_INSERT_PIXMAP 1801
+
+// Desc: ack for insert
+// iWinId: window id
+// iArg: object id
+// cArg: undef
+#define PUKE_MENUDATA_INSERT_PIXMAP_ACK -1801
+
+
+// Desc: Item got activated, not used, only ack
+// iWinId: undef
+// iArg: undef
+// cArg: uidef
+#define PUKE_POPUPMENU_ACTIVATED 1805
+
+// Desc: Item got activate
+// iWinId: window id
+// iArg: item id
+// cArg: undef
+#define PUKE_POPUPMENU_ACTIVATED_ACK -1805
+
+// Desc: Popup to current cursor position
+// iWinId: menu id
+// iArg: undef
+// cArg: uidef
+#define PUKE_POPUPMENU_POPUP_CURRENT 1810
+
+// Desc: Ack for popup
+// iWinId: window id
+// iArg: 1 for success
+// cArg: undef
+#define PUKE_POPUPMENU_POPUP_CURRENT_ACK -1810
+
+// Desc: Remvoes an item from a popup menu
+// iWinId: menu id
+// iArg: undef
+// cArg: uidef
+#define PUKE_MENUDATA_REMOVE_ITEM 1815
+
+// Desc: Ack for remove item
+// iWinId: window id
+// iArg: 1 for success
+// cArg: undef
+#define PUKE_MENUDATA_REMOVE_ITEM_ACK -1815
+
+// -----------------------------------------------------------------------
+// PAMenuData
+
+// Desc: is the item in the top of the list?
+// iWinId: window id
+// iArg: index
+// cArg: not defined
+#define PUKE_ALISTBOX_ISTOP 1900
+
+// Desc: ack for istop
+// iWinId: window id
+// iArg: 1 for top, 0 for bottom
+// cArg: not defined
+#define PUKE_ALISTBOX_ISTOP_ACK -1900
+
+// Desc: set green highligh (voice)
+// iWinId: window id
+// iArg: highligh, 1 for set, 0 for not
+// cArg: string
+#define PUKE_ALISTBOX_SMALL_HIGHLIGHT 1905
+
+// Desc: ack for set green highligh
+// iWinId: window id
+// iArg: 0 for success, 1 for failure
+// cArg: not defined
+#define PUKE_ALISTBOX_SMALL_HIGHLIGHT_ACK -1905
+
+// Desc: set red highligh and raise to the top (op)
+// iWinId: window id
+// iArg: highlight, 1 for set, 0 for remove
+// cArg: string
+#define PUKE_ALISTBOX_BIG_HIGHLIGHT 1910
+
+// Desc: ack for set red and raise
+// iWinId: window id
+// iArg: 0 for success, 1 for failure
+// cArg: not defined
+#define PUKE_ALISTBOX_BIG_HIGHLIGHT_ACK -1910
+
+// Desc: finds nick index
+// iWinId: window id
+// iArg: not defined
+// cArg: string
+#define PUKE_ALISTBOX_FIND_NICK 1915
+
+// Desc: ack for find nick
+// iWinId: window id
+// iArg: index
+// cArg: not defined
+#define PUKE_ALISTBOX_FIND_NICK_ACK -1915
+
+// -----------------------------------------------------------------------
+// PTabDialog
+
+// Desc: add Widget defined by iArg's widget id
+// iWinId: window id
+// iArg: widget to add, widget id, in current fd
+// cArg: not defined
+#define PUKE_TABDIALOG_ADDTAB 2001
+
+// Desc: ack for istop
+// iWinId: window id
+// iArg: 1 for failure, 0 for success
+// cArg: not defined
+#define PUKE_TABDIALOG_ADDTAB_ACK -2001
+
+// -----------------------------------------------------------------------
+// PKSircListBox
+
+// Desc: is the item in the top of the list?
+// iWinId: window id
+// iArg: index
+// cArg: not defined
+#define PUKE_KSIRCLISTBOX_TOBOTTOM 2100
+
+// Desc: ack for istop
+// iWinId: window id
+// iArg: 1 for top, 0 for bottom
+// cArg: not defined
+#define PUKE_KSIRCLISTBOX_TOBOTTOM_ACK -2100
+
+// 2200 for PKFileDialog
+// 2300 for PObjFinder
+
+
+// ***********************************************************************
+// ***********************************************************************
+
+//
+// Base commands are done, next describes Widget's
+//
+
+// OBJECT base class
+#define PWIDGET_OBJECT 1
+
+// WIDGET defines a base QWidget class
+#define PWIDGET_WIDGET 2
+
+// FRAME defines a base class
+#define PWIDGET_FRAME 3
+
+// LINED defines the simple SLE
+#define PWIDGET_LINED 4
+
+// BUTTON defines the abstract class QButton
+#define PWIDGET_BUTTON 5
+
+// PUSH defined the push button
+#define PWIDGET_PUSHBT 6
+
+// Progress window for dcc and stuff
+#define PWIDGET_KSPROGRESS 7
+
+// Table view, not really used for much, base class for lots
+#define PWIDGET_TABLEVW 8
+
+// List box
+#define PWIDGET_LISTBOX 9
+
+// Label
+#define PWIDGET_LABEL 10
+
+// BoxLayout
+#define POBJECT_LAYOUT 11
+
+// MenuData
+#define PWIDGET_MENUDATA 12
+
+// PopupMenu
+
+#define PWIDGET_POPMENU 13
+
+// PAListBox
+
+#define PWIDGET_ALISTBOX 14
+
+// PKSircListBox
+
+#define PWIDGET_KSIRCLISTBOX 15
+
+// PTabDialog
+
+#define PWIDGET_TABDIALOG 16
+
+// PKFileDialog
+
+#define PWIDGET_KFILEDIALOG 17
+
+// PObjFinder
+
+#define PWIDGET_OBJFINDER 18
+
+
+// Group layout commands exist between 10000 and 11000
+
+// Desc: create new box layout
+// iWinId: PWidget parent
+// iArg: 2 shorts, short[0] direction, short[1] border
+// cArg: random character string
+#define PUKE_LAYOUT_NEW 11000
+// Desc: ack for box layout
+// iWinId: Layout ID.
+// iArg: not define
+// cArg: same random m character string as PUKE_LAYOUT_NEW
+#define PUKE_LAYOUT_NEW_ACK -11000
+
+#define PUKE_LAYOUT_ADDLAYOUT 11005
+#define PUKE_LAYOUT_ADDLAYOUT_ACK -11005
+
+// Desc: add widget into layout manager
+// iWinId: Layout Manager to add widget too
+// iArg: Widget Id to be added
+// cArg: 2 characters, char[0] strech, char[1] alignment
+#define PUKE_LAYOUT_ADDWIDGET 11010
+// Desc: ack for add widget
+// iWinId: Layout manager
+// iArg: not defined
+// cArg: not define
+#define PUKE_LAYOUT_ADDWIDGET_ACK -11010
+
+// Desc: adds a strut for the current box, ie can'be be bigger then int
+// iWinId: Layout Manager to add strut
+// iArg: strut size
+// cArg: not define
+#define PUKE_LAYOUT_ADDSTRUT 11015
+
+// Desc: ack for strut add widget
+// iWinId: Layout manager
+// iArg: not defined
+// cArg: not define
+#define PUKE_LAYOUT_ADDSTRUT_ACK -11015
+
+// Desc: activates layout management, like show() for widget
+// iWinId: Layout Manager to activate
+// iArg: undef
+// cArg: undef
+#define PUKE_LAYOUT_ACTIVATE 11020
+
+// Desc: ack for strut add widget
+// iWinId: Layout manager
+// iArg: 1 on failure, 0 on success
+// cArg: not define
+#define PUKE_LAYOUT_ACTIVATE_ACK -11020
+
+/*
+ * ----------------------------------------------------------------------
+ * persistant objects
+ */
+
+#define PUKE_CONTROLLER 1
diff --git a/ksirc/puke/controller.cpp b/ksirc/puke/controller.cpp
new file mode 100644
index 00000000..1e798be7
--- /dev/null
+++ b/ksirc/puke/controller.cpp
@@ -0,0 +1,974 @@
+#include <config.h>
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <iostream>
+#include <fcntl.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/uio.h>
+#include <sys/time.h>
+#include <sys/un.h>
+#include <sys/stat.h>
+
+using namespace std; // iostream.h include cstring which puts strlen into
+ // std:: namespace, which breaks Qt's strlen() call
+ // in qcstring.h (in gcc3's libstdc++)
+
+#include <klibloader.h>
+#include <kdebug.h>
+
+
+#include "controller.h"
+
+#include "../../config.h"
+#include "../objFinder.h"
+
+#include "palistbox.h"
+#include "pbutton.h"
+#include "pframe.h"
+#include "pkfiledialog.h"
+#include "plabel.h"
+#include "playout.h"
+#include "plined.h"
+#include "plistbox.h"
+#include "pmenudta.h"
+#include "pmessage.h"
+#include "pobject.h"
+#include "pobjfinder.h"
+#include "ppopmenu.h"
+#include "pprogress.h"
+#include "ppushbt.h"
+#include "ptabdialog.h"
+#include "ptablevw.h"
+#include "pwidget.h"
+
+#undef DEBUG
+
+uint PukeController::uiBaseWinId = 10; // Gives a little seperation from the controller id
+
+PukeController::PukeController(QString sock, QObject *parent, const char *name) : PObject( parent, name )
+{
+ int len, prev_umask;
+ struct sockaddr_un unix_addr;
+
+ running = FALSE; // Running has to be true before we do any work
+ bClosing = FALSE; // we're not trying to close so set this false.
+
+ // Set the umask to something sane that doesn't allow others to take over ksirc
+ prev_umask = umask(0177);
+
+ if(sock.length() == 0){
+ qsPukeSocket = getenv("HOME");
+ if(qsPukeSocket.length() == 0){
+ qsPukeSocket = "/tmp";
+ }
+ qsPukeSocket += "/.ksirc.socket";
+ }
+ else{
+ qsPukeSocket = sock;
+ }
+
+ unlink(qsPukeSocket);
+ iListenFd = socket(AF_UNIX, SOCK_STREAM, 0);
+ if(iListenFd < 0){
+ perror("PUKE: Unix Domain Socket create failed");
+ return;
+ }
+ memset(&unix_addr, 0, sizeof(unix_addr));
+ unix_addr.sun_family = AF_UNIX;
+ strlcpy(unix_addr.sun_path, qsPukeSocket, sizeof(unix_addr.sun_path));
+
+ len = sizeof(unix_addr.sun_family) + qsPukeSocket.length();
+#if defined(__FreeBSD__)
+ if( bind(iListenFd, (struct sockaddr *) &unix_addr, len+1) < 0){
+#else
+ if( bind(iListenFd, (struct sockaddr *) &unix_addr, len) < 0){
+#endif
+ perror("PUKE: Could not bind to Unix Domain Socket");
+ return;
+ }
+
+ if(listen(iListenFd, 5) < 0){
+ perror("PUKE: Could not listen for inbound connections");
+ return;
+ }
+
+ running = TRUE;
+
+ fcntl(iListenFd, F_SETFL, O_NONBLOCK); // Set it non-block so that
+ // accept() never blocks.
+
+ qsnListen = new QSocketNotifier(iListenFd, QSocketNotifier::Read, this, QString(name) + "_iListen");
+ connect(qsnListen, SIGNAL(activated(int)),
+ this, SLOT(NewConnect(int)));
+
+ connect(objFind, SIGNAL(inserted(QObject *)),
+ this, SLOT(slotInserted(QObject *)));
+
+ qidConnectFd.setAutoDelete(TRUE);
+
+ qidCommandTable.setAutoDelete(TRUE);
+
+ /*
+ * Setup widget data trees
+ */
+ WidgetList.setAutoDelete(TRUE);
+ revWidgetList.setAutoDelete(TRUE);
+ widgetCF.setAutoDelete(TRUE);
+
+ /*
+ * Connect outputMessage to the acutal write buffer function
+ * outputMessage signals from pobjects are chained until they finally reach us.
+ */
+ connect(this, SIGNAL(outputMessage(int, PukeMessage *)),
+ this, SLOT(writeBuffer(int, PukeMessage *)));
+
+ initHdlr(); // Setup message command handlers.
+
+ // Set umask back so it doesn't affect dcc's and so forth.
+ umask(prev_umask);
+
+ /*
+ * We are a PObject so do some init code
+ */
+ // We're always terminate by someone else so set manTerm() right now
+ manTerm();
+ setWidget(0x0);
+
+}
+
+void
+PukeController::slotInserted(QObject *obj)
+{
+ emit inserted(obj);
+}
+
+PukeController::~PukeController()
+{
+ close(iListenFd);
+ disconnect(this); // We call disconnect this so don't listen to our own destroy() signal go out
+ unlink(qsPukeSocket);
+}
+
+QStrList PukeController::allObjects()
+{
+ return objFinder::allObjects();
+}
+
+void PukeController::NewConnect(int)
+{
+ int cfd;
+ ksize_t len = 0;
+ struct sockaddr_un unix_addr;
+
+ cfd = accept(iListenFd, (struct sockaddr *)&unix_addr, &len);
+ if(cfd < 0){
+ perror("PUKE: NewConnect fired, but no new connect");
+ return;
+ }
+ fcntl(cfd, F_SETFL, O_NONBLOCK); // Set it non-block so that
+ // cfd() never blocks.
+
+ fdStatus *fds = new fdStatus();
+ fds->sr = new QSocketNotifier(cfd, QSocketNotifier::Read, this);
+ fds->sw = new QSocketNotifier(cfd, QSocketNotifier::Write, this);
+ connect(fds->sr, SIGNAL(activated(int)),
+ this, SLOT(Traffic(int)));
+ connect(fds->sw, SIGNAL(activated(int)),
+ this, SLOT(Writeable(int)));
+ qidConnectFd.insert(cfd, fds);
+ qsnListen->setEnabled(TRUE);
+
+ /*
+ * Now we add ourselves as a client to the fd so we can process messages going to us
+ */
+ WidgetS *ws = new WidgetS;
+ ws->pwidget = this;
+ ws->type = 1;
+ insertPObject(cfd, ControllerWinId, ws);
+
+}
+
+
+void PukeController::Writeable(int fd)
+{
+ if(qidConnectFd[fd]){
+ qidConnectFd[fd]->writeable = TRUE;
+ qidConnectFd[fd]->sw->setEnabled(FALSE);
+ //
+ // Insert buffer flushing code here.
+ //
+ }
+ else{
+ kdDebug(5008) << "PUKE: Unkonwn fd: " << fd << endl;
+ }
+}
+
+void PukeController::writeBuffer(int fd, PukeMessage *message)
+{
+ if(qidConnectFd[fd]){
+ // if(qidConnectFd[fd]->writeable == FALSE){
+ // kdDebug(5008) << "PUKE: Writing to FD that's not writeable: " << fd << endl;
+ // }
+ if(message != 0){
+ int bytes = 0;
+ message->iHeader = iPukeHeader;
+ if(message->iTextSize == 0 || message->cArg == 0){
+ message->iTextSize = 0;
+ message->cArg = 0;
+#ifdef DEBUG
+ printf("Traffic on: %d <= %d %d %d %d 0x%x\n",
+ fd,
+ message->iCommand,
+ message->iWinId,
+ message->iArg,
+ message->iTextSize,
+ message->cArg);
+#endif
+ bytes = write(fd, message, 5 * sizeof(int));
+ }
+ else{
+ /*
+ struct OutMessageS {
+ unsigned int iHeader;
+ int iCommand;
+ int iWinId;
+ int iArg;
+ int iTextSize;
+ char cArg[message->iTextSize];
+ } OutMessage;
+ OutMessage.iHeader = iPukeHeader;
+ OutMessage.iCommand = message->iCommand;
+ OutMessage.iWinId = message->iWinId;
+ OutMessage.iArg = message->iArg;
+ OutMessage.iTextSize = message->iTextSize;
+ memcpy(OutMessage.cArg, message->cArg, OutMessage.iTextSize);
+ // OutMessage.cArg[OutMessage.iTextSize] = 0; // Don't need to null out the last character
+ bytes = write(fd, &OutMessage, 5*sizeof(int) + (OutMessage.iTextSize) * sizeof(char));
+ */
+#ifdef DEBUG
+ printf("Traffic on: %d <= %d %d %d %d 0x%x\n",
+ fd,
+ message->iCommand,
+ message->iWinId,
+ message->iArg,
+ message->iTextSize,
+ message->cArg);
+#endif /* DEBUG */
+
+ struct iovec iov[2];
+ iov[0].iov_base = (char *) message;
+ iov[0].iov_len = 5*sizeof(int);
+ iov[1].iov_base = (char *) message->cArg;
+ iov[1].iov_len = message->iTextSize;
+ bytes = writev(fd, iov, 2);
+ }
+ // kdDebug(5008) << "Wrote: " << bytes << endl;
+ if(bytes <= 0){
+ switch(errno){
+ case EAGAIN: // Don't do anything for try again
+ break;
+// default:
+// perror("Puke: write on socket failed");
+ // Don't call closefd() since deletes are called on write's
+ // since write is being called from the destructors, etc of
+ // the widgets. (bad things happend when you call write
+ // then your return; path ceasaes to exist.
+ // closefd(fd);
+ }
+ }
+ }
+ }
+ else{
+ closefd(fd);
+ kdDebug(5008) << "PUKE: Attempt to write to unkown fd:" << fd << endl;
+ }
+}
+
+void PukeController::Traffic(int fd)
+{
+ PukeMessage pm;
+ int bytes = -1;
+ memset(&pm, 0, sizeof(pm));
+ while((bytes = read(fd, &pm, 5*sizeof(int))) > 0){
+ if(bytes != 5*sizeof(int)){
+ kdDebug(5008) << "Short message, Got: " << bytes << " Wanted: " << sizeof(PukeMessage) << " NULL Padded" << endl;
+ }
+#ifdef DEBUG
+ printf("Traffic on: %d => %d %d %d %d",
+ fd,
+ pm.iCommand,
+ pm.iWinId,
+ pm.iArg,
+ pm.iTextSize);
+ if(pm.iCommand == 0x0){
+ abort();
+ }
+#endif /* DEBUG */
+ if(pm.iHeader != iPukeHeader){
+ qWarning("Invalid packet received, discarding!");
+ return;
+ }
+ if(pm.iTextSize > 0){
+ pm.cArg = new char[pm.iTextSize + 1];
+ read(fd, pm.cArg, pm.iTextSize * sizeof(char));
+ pm.cArg[pm.iTextSize] = 0x0; // Null terminate the string.
+// printf(" %s\n", pm.cArg);
+ }
+ else {
+ pm.cArg = 0;
+// printf("\n");
+ }
+ MessageDispatch(fd, &pm);
+ delete[] pm.cArg; // Free up cArg is used
+ memset(&pm, 0, 5*sizeof(int));
+ }
+ if(bytes <= 0){ // Shutdown the socket!
+ switch(errno){
+ case EAGAIN: // Don't do anything for try again
+ break;
+ // case 0:
+ // break; // We just read nothing, don't panic
+ case EIO:
+ case EISDIR:
+ case EBADF:
+ case EINVAL:
+ case EFAULT:
+ default:
+ // perror("PukeController: read failed");
+ closefd(fd);
+ close(fd);
+ }
+ }
+ else{
+ qidConnectFd[fd]->sr->setEnabled(TRUE);
+ }
+}
+
+
+void PukeController::ServMessage(QString, int, QString)
+{
+
+}
+
+// Message Dispatcher is in messagedispatcher.cpp
+
+
+void PukeController::MessageDispatch(int fd, PukeMessage *pm)
+{
+ try {
+
+ /*
+ * Get the object id, this may produce a errorNuSuchWidget
+ */
+ PObject *obj = id2pobject(fd, pm->iWinId);
+
+ /*
+ * Call the message hanlder for the widget
+ */
+ obj->messageHandler(fd, pm);
+ }
+ catch(errorNoSuchWidget &err){
+ PukeMessage pmRet;
+ pmRet.iCommand = PUKE_INVALID;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.iTextSize = 0;
+ emit outputMessage(fd, &pmRet);
+ return;
+ }
+ catch (errorCommandFailed &err){
+ PukeMessage pmRet;
+ pmRet.iCommand = err.command();
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = err.iarg();
+ pmRet.iTextSize = 0;
+ emit outputMessage(fd, &pmRet);
+ return;
+ }
+}
+
+void PukeController::initHdlr()
+{
+
+ widgetCreate *wc;
+
+ wc = new widgetCreate;
+ wc->wc = PWidget::createWidget;
+ widgetCF.insert(PWIDGET_WIDGET, wc);
+
+ wc = new widgetCreate;
+ wc->wc = PObject::createWidget;
+ widgetCF.insert(PWIDGET_OBJECT, wc);
+
+ wc = new widgetCreate;
+ wc->wc = PLayout::createWidget;
+ widgetCF.insert(POBJECT_LAYOUT, wc);
+
+ wc = new widgetCreate;
+ wc->wc = PFrame::createWidget;
+ widgetCF.insert(PWIDGET_FRAME, wc);
+
+ wc = new widgetCreate;
+ wc->wc = PLineEdit::createWidget;
+ widgetCF.insert(PWIDGET_LINED, wc);
+
+ wc = new widgetCreate;
+ wc->wc = PButton::createWidget;
+ widgetCF.insert(PWIDGET_BUTTON, wc);
+
+ wc = new widgetCreate;
+ wc->wc = PPushButton::createWidget;
+ widgetCF.insert(PWIDGET_PUSHBT, wc);
+
+ wc = new widgetCreate;
+ wc->wc = PProgress::createWidget;
+ widgetCF.insert(PWIDGET_KSPROGRESS, wc);
+
+ wc = new widgetCreate;
+ wc->wc = PTableView::createWidget;
+ widgetCF.insert(PWIDGET_TABLEVW, wc);
+
+ wc = new widgetCreate;
+ wc->wc = PListBox::createWidget;
+ widgetCF.insert(PWIDGET_LISTBOX, wc);
+
+ wc = new widgetCreate;
+ wc->wc = PLabel::createWidget;
+ widgetCF.insert(PWIDGET_LABEL, wc);
+
+ wc = new widgetCreate;
+ wc->wc = PPopupMenu::createWidget;
+ widgetCF.insert(PWIDGET_POPMENU, wc);
+
+ wc = new widgetCreate;
+ wc->wc = PAListBox::createWidget;
+ widgetCF.insert(PWIDGET_ALISTBOX, wc);
+
+ wc = new widgetCreate;
+ wc->wc = PTabDialog::createWidget;
+ widgetCF.insert(PWIDGET_TABDIALOG, wc);
+
+ wc = new widgetCreate;
+ wc->wc = PKFileDialog::createWidget;
+ widgetCF.insert(PWIDGET_KFILEDIALOG, wc);
+
+ wc = new widgetCreate;
+ wc->wc = PObjFinder::createWidget;
+ widgetCF.insert(PWIDGET_OBJFINDER, wc);
+
+ // Each function handler gets an entry in the qidCommandTable
+ commandStruct *cs;
+
+
+ // Invalid is the default invalid handler
+ cs = new commandStruct;
+ cs->cmd = &PukeController::hdlrPukeInvalid;
+ cs->library = 0;
+ qidCommandTable.insert(PUKE_INVALID, cs);
+
+
+ // Setup's handled by the setup handler
+ cs = new commandStruct;
+ cs->cmd = &PukeController::hdlrPukeSetup;
+ cs->library = 0;
+ qidCommandTable.insert(PUKE_SETUP, cs);
+
+ // We don't receive PUKE_SETUP_ACK's we send them.
+ cs = new commandStruct;
+ cs->cmd = &PukeController::hdlrPukeInvalid;
+ cs->library = 0;
+ qidCommandTable.insert(PUKE_SETUP_ACK, cs);
+
+ cs = new commandStruct;
+ cs->cmd = &PukeController::hdlrPukeEcho;
+ cs->library = 0;
+ qidCommandTable.insert(PUKE_ECHO, cs);
+
+ // Fetch widget gets the requested widget from the ServerController
+ cs = new commandStruct;
+ cs->cmd = &PukeController::hdlrPukeFetchWidget;
+ cs->library = 0;
+ qidCommandTable.insert(PUKE_FETCHWIDGET, cs);
+
+ // Fetch widget gets the requested widget from the ServerController
+ cs = new commandStruct;
+ cs->cmd = &PukeController::hdlrPukeDumpTree;
+ cs->library = 0;
+ qidCommandTable.insert(PUKE_DUMPTREE, cs);
+
+ // Fetch widget gets the requested widget from the ServerController
+ cs = new commandStruct;
+ cs->cmd = &PukeController::hdlrPukeDeleteWidget;
+ cs->library = 0;
+ qidCommandTable.insert(PUKE_WIDGET_DELETE, cs);
+
+}
+
+// Start message handlers
+
+void PukeController::hdlrPukeInvalid(int fd, PukeMessage *)
+{
+ PukeMessage pmOut;
+ memset(&pmOut, 0, sizeof(pmOut));
+ this->writeBuffer(fd, &pmOut);
+}
+
+
+void PukeController::hdlrPukeSetup(int fd, PukeMessage *pm)
+{
+ PukeMessage pmOut;
+ memset(&pmOut, 0, sizeof(pmOut));
+ pmOut.iCommand = PUKE_SETUP_ACK;
+ pmOut.iArg = 1;
+ if((strlen(pm->cArg) > 0) &&
+ (this->qidConnectFd[fd] != NULL)){
+ this->qidConnectFd[fd]->server = qstrdup(pm->cArg);
+ pmOut.iWinId = pm->iWinId;
+ pmOut.iArg = sizeof(PukeMessage) - sizeof(char *);
+ }
+ this->writeBuffer(fd, &pmOut);
+}
+
+void PukeController::hdlrPukeEcho(int fd, PukeMessage *pm)
+{
+ PukeMessage pmOut;
+ memcpy(&pmOut, pm, sizeof(PukeMessage));
+ pmOut.iCommand = PUKE_ECHO_ACK;
+ pmOut.iWinId = pm->iWinId;
+ pmOut.iArg = pm->iArg;
+ this->writeBuffer(fd, &pmOut);
+}
+
+void PukeController::hdlrPukeDumpTree(int fd, PukeMessage *pm)
+{
+ objFinder::dumpTree();
+
+ PukeMessage pmOut;
+ memcpy(&pmOut, pm, sizeof(PukeMessage));
+ pmOut.iCommand = -pm->iCommand;
+ pmOut.iWinId = pm->iWinId;
+ pmOut.iArg = pm->iArg;
+ this->writeBuffer(fd, &pmOut);
+}
+
+
+void PukeController::hdlrPukeFetchWidget(int fd, PukeMessage *pm)
+{
+ widgetId wIret;
+
+ /*
+ * The parent widget ID and type are packed into the iArg
+ * the pattern is 2 shorts.
+ */
+
+ int iParent=-1, iType=-1;
+
+ char rand[50],name[50];
+ int found = sscanf(pm->cArg, "%d\t%d\t%49s\t%49s", &iParent, &iType, rand, name);
+ if(found != 4){
+ throw(errorCommandFailed(PUKE_INVALID,6));
+ }
+
+ uiBaseWinId++; // Get a new base win id
+
+ // wIret holds the current widget id for the new widget
+ wIret.iWinId = uiBaseWinId;
+ wIret.fd = fd;
+
+ // CreateArgs arg = CreateArgs(this, pm, &wIret, parent)
+ CreateArgs arg(this, pm, &wIret, 0);
+
+ // Let's go looking for the widget
+ // Match any class with the right name
+ QObject *obj = 0x0;
+ if(parent() && (strcmp(name, parent()->name()) == 0)){
+ obj = parent();
+ }
+ else {
+ obj = objFinder::find(name, 0x0);
+ if(obj == 0){
+ wIret.fd = 0;
+ wIret.iWinId = 0;
+ throw(errorCommandFailed(PUKE_INVALID,5));
+ }
+
+ }
+
+ arg.fetchedObj = obj;
+
+ WidgetS *ws = new WidgetS;
+ ws->pwidget = (widgetCF[iType]->wc)(arg);
+ if (ws->pwidget->hasError())
+ {
+ throw(errorCommandFailed(PUKE_INVALID, 0));
+ }
+ ws->type = iType;
+
+ connect(ws->pwidget, SIGNAL(outputMessage(int, PukeMessage*)),
+ this, SIGNAL(outputMessage(int, PukeMessage*)));
+
+ // insertPBoject(fd, uiBaseWinId, ws);
+ // The widget list has to exist since we have ourselves in the list
+ // WidgetList[wIret.fd]->insert(wIret.iWinId, ws);
+ insertPObject(wIret.fd, wIret.iWinId, ws);
+
+ PukeMessage pmRet;
+ pmRet.iCommand = PUKE_WIDGET_CREATE_ACK;
+ pmRet.iWinId = wIret.iWinId;
+ pmRet.iArg = 0;
+ pmRet.iTextSize = pm->iTextSize;
+ pmRet.cArg = pm->cArg;
+ emit outputMessage(fd, &pmRet);
+
+}
+
+void PukeController::hdlrPukeDeleteWidget(int fd, PukeMessage *pm)
+{
+ widgetId wI;
+ wI.fd = fd;
+ wI.iWinId = pm->iWinId;
+
+ if(pm->iWinId == ControllerWinId) // Don't try and delete ourselves
+ throw(errorCommandFailed(PUKE_INVALID, INVALID_DEL_NO_CONTROL));
+
+ /*
+ QIntDict<WidgetS> *qidWS = WidgetList[fd];
+ if(qidWS == 0){
+ kdDebug(5008) << "WidgetRunner:: no such set of widget descriptors?" << endl;
+ throw(errorCommandFailed(PUKE_INVALID, INVALID_DEL_NO_SUCH_CONNECTION));
+ }
+ if(qidWS->find(wI.iWinId)){
+ // Remove the list item then delete the widget. This will stop
+ // the destroyed signal from trying to remove it again.
+ PObject *pw = qidWS->find(wI.iWinId)->pwidget;
+ qidWS->remove(wI.iWinId);
+ delete pw; pw = 0;
+ pmRet.iCommand = PUKE_WIDGET_DELETE_ACK;
+ }
+ else {
+ qWarning("WidgetRunner: no such widget: %d", wI.iWinId);
+ throw(errorCommandFailed(PUKE_INVALID, INVALID_DEL_NO_SUCH_WIDGET));
+ }
+ */
+
+ if(checkWidgetId(&wI) == FALSE){
+ qWarning("WidgetRunner: no such widget: %d", wI.iWinId);
+ throw(errorCommandFailed(PUKE_INVALID, INVALID_DEL_NO_SUCH_WIDGET));
+ }
+
+ WidgetList[fd]->find(wI.iWinId)->pwidget->manTerm();
+ delete WidgetList[fd]->find(wI.iWinId)->pwidget;
+
+ PukeMessage pmRet = *pm;
+ pmRet.iCommand = PUKE_WIDGET_DELETE_ACK;
+
+ emit outputMessage(fd, &pmRet);
+}
+
+void PukeController::closefd(int fd)
+{
+ if(bClosing == TRUE)
+ return;
+ bClosing = TRUE;
+ if(qidConnectFd[fd] == NULL){
+ kdDebug(5008) << "PukeController: Connect table NULL, closed twice?" << endl;
+ return;
+ }
+ // Shutof the listener before closing the socket, just in case.
+ qidConnectFd[fd]->sr->setEnabled(FALSE); // Shut them off
+ qidConnectFd[fd]->sw->setEnabled(FALSE);
+ delete qidConnectFd[fd]->sr;
+ delete qidConnectFd[fd]->sw;
+ qidConnectFd[fd]->server.truncate(0);
+ qidConnectFd.remove(fd);
+ close(fd);
+
+ /*
+ * Now let's remove all traces of the widgets
+ */
+ QIntDict<WidgetS> *qidWS = WidgetList[fd];
+ if(qidWS == 0){
+ kdDebug(5008) << "WidgetRunner:: Close called twice?" << endl;
+ bClosing = FALSE;
+ return;
+ }
+
+ qidWS->remove(PUKE_CONTROLLER);
+
+ do {
+
+ QIntDictIterator<WidgetS> it(*qidWS);
+ if(it.count() == 0){
+ kdDebug(5008) << "WidgetRunner: nothing left to delete\n" << endl;
+ break;
+ }
+
+ PObject *po = 0x0;
+ while(it.current()){
+ /*
+ * Delete all the layouts first
+ *
+ */
+ if(it.current()->type == POBJECT_LAYOUT){
+ po = it.current()->pwidget;
+ break;
+ }
+ ++it;
+ }
+
+ if(po != 0x0){
+ po->manTerm();
+ delete po;
+ continue;
+ }
+
+ /*
+ * reset
+ */
+ it.toFirst();
+ po = it.current()->pwidget;
+ po->manTerm();
+ delete po;
+
+
+ } while (qidWS->count() > 0);
+
+ WidgetList.remove(fd);
+ bClosing = FALSE;
+}
+
+bool PukeController::checkWidgetId(widgetId *pwi)
+{
+ if(WidgetList[pwi->fd] != NULL)
+ if(WidgetList[pwi->fd]->find(pwi->iWinId) != NULL)
+ return TRUE;
+
+ return FALSE;
+}
+
+PObject *PukeController::id2pobject(widgetId *pwi){
+ if(checkWidgetId(pwi) == TRUE){
+ return WidgetList[pwi->fd]->find(pwi->iWinId)->pwidget;
+ }
+ throw(errorNoSuchWidget(*pwi));
+ return 0; // never reached
+}
+
+PObject *PukeController::id2pobject(int fd, int iWinId){
+ widgetId wi;
+ wi.fd = fd;
+ wi.iWinId = iWinId;
+
+ return id2pobject(&wi);
+}
+
+PWidget *PukeController::id2pwidget(widgetId *pwi){
+ PObject *obj = id2pobject(pwi);
+ if(obj->widget()->isWidgetType())
+ return (PWidget *) obj;
+ else
+ throw(errorNoSuchWidget(*pwi));
+ return NULL;
+}
+void PukeController::insertPObject(int fd, int iWinId, WidgetS *obj){
+ // If no widget list exists for this fd, create one
+ if(WidgetList[fd] == NULL){
+ QIntDict<WidgetS> *qidWS = new QIntDict<WidgetS>;
+ qidWS->setAutoDelete(TRUE);
+ WidgetList.insert(fd, qidWS);
+ }
+ // Set main widget structure list
+ WidgetList[fd]->insert(iWinId, obj);
+
+ // Set reverse list used durring delete to remove the widget
+ widgetId *pwi = new widgetId;
+ pwi->fd = fd;
+ pwi->iWinId = iWinId;
+ char key[keySize];
+ memset(key, 0, keySize);
+ sprintf(key, "%p", obj->pwidget);
+ revWidgetList.insert(key, pwi);
+
+ // Now connect to the destroyed signal so we can remove the object from the lists
+ // Once it is deleted
+ connect(obj->pwidget, SIGNAL(destroyed()),
+ this, SLOT(pobjectDestroyed()));
+}
+
+void PukeController::pobjectDestroyed(){
+
+ char key[keySize];
+ memset(key, 0, keySize);
+ sprintf(key, "%p", this->sender());
+
+ widgetId *pwi = revWidgetList[key];
+
+ if(pwi == NULL){
+ kdDebug(5008) << "Someone broke the rules for pwi: " << pwi->fd << ", " << pwi->iWinId << endl;
+ return;
+ }
+
+ if(checkWidgetId(pwi) == TRUE){
+ WidgetList[pwi->fd]->remove(pwi->iWinId);
+ }
+ else {
+ kdDebug(5008) << "Someone stole pwi: " << pwi->fd << ", " << pwi->iWinId << endl;
+ }
+
+ pwi = 0x0; // remove deletes pwi
+ revWidgetList.remove(key);
+
+}
+
+void PukeController::messageHandler(int fd, PukeMessage *pm) {
+ widgetId wI, wIret;
+ wI.fd = fd;
+ wI.iWinId = pm->iWinId;
+
+ commandStruct *cs;
+
+ cs = qidCommandTable[pm->iCommand];
+
+ if(cs != NULL){
+ (this->*(cs->cmd))(fd,pm);
+ }
+ else if(pm->iCommand == PUKE_WIDGET_CREATE){
+ wIret = wI;
+ wIret.iWinId = createWidget(wI, pm).iWinId; // Create the acutal pw
+
+ PukeMessage pmRet;
+ pmRet.iCommand = PUKE_WIDGET_CREATE_ACK;
+ pmRet.iWinId = wIret.iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = strdup(pm->cArg);
+ pmRet.iTextSize = strlen(pm->cArg);
+ emit outputMessage(fd, &pmRet);
+ free(pmRet.cArg);
+ }
+ else if(pm->iCommand == PUKE_WIDGET_LOAD){
+ PukeMessage pmRet = *pm;
+ KLibrary *library;
+ PObject *(*wc)(CreateArgs &ca);
+ widgetCreate *wC;
+
+ if(widgetCF[pm->iArg]){
+ pmRet.iCommand = -pm->iCommand;
+ pmRet.iTextSize = 0;
+ emit outputMessage(fd, &pmRet);
+ return;
+ }
+
+ if(pm->iTextSize == 0){
+ emit(errorCommandFailed(-pm->iCommand, 1));
+ return;
+ }
+
+ QString libName = "ksirc/lib"+QString::fromLatin1(pm->cArg);
+ if (libName.right(3) == ".so")
+ libName = libName.left(libName.length()-2)+"la";
+
+ library = KLibLoader::self()->library(libName);
+ if (!library) {
+ emit(errorCommandFailed(-pm->iCommand, 1));
+ return;
+ }
+ wc = (PObject *(*)(CreateArgs &ca) )
+ library->symbol("createWidget");
+
+ wC = new widgetCreate;
+ wC->wc = wc;
+ wC->library = library;
+ widgetCF.insert(pm->iArg, wC);
+
+ pmRet.iCommand = -pm->iCommand;
+ pmRet.iTextSize = 0;
+ emit outputMessage(fd, &pmRet);
+ }
+ else if(pm->iCommand == PUKE_WIDGET_UNLOAD){
+ if(widgetCF[pm->iArg]){
+// delete widgetCF[pm->iArg]->library;
+ widgetCF.remove(pm->iArg);
+ pm->iCommand = -pm->iCommand;
+ emit outputMessage(fd, pm);
+ }
+ }
+ else{
+ if(checkWidgetId(&wI) == TRUE){
+ WidgetList[wI.fd]->find(wI.iWinId)->pwidget->messageHandler(fd, pm);
+ }
+ else{
+ PukeMessage pmRet;
+ pmRet.iCommand = PUKE_INVALID;
+ pmRet.iWinId = wI.iWinId;
+ pmRet.iArg = 0;
+ pmRet.iTextSize = 0;
+ emit outputMessage(fd, &pmRet);
+ }
+ }
+}
+
+widgetId PukeController::createWidget(widgetId wI, PukeMessage *pm)
+{
+ widgetId wIret;
+ PWidget *parent = 0; // Defaults to no parent
+ WidgetS *ws = new WidgetS;
+
+ /*
+ * The parent widget ID and type are packed into the iArg
+ * the pattern is 2 shorts.
+ */
+
+ int iParent, iType;
+ int found = sscanf(pm->cArg, "%d\t%d", &iParent, &iType);
+ if(found != 2)
+ throw(errorCommandFailed(PUKE_INVALID,7));
+
+ wI.iWinId = iParent; // wI is the identifier for the parent widget
+
+ if(widgetCF[iType] == NULL){ // No such widget, bail out.
+ wIret.fd = 0;
+ wIret.iWinId = 0;
+ throw(errorCommandFailed(PUKE_INVALID,1));
+ }
+
+ uiBaseWinId++; // Get a new base win id
+
+ // wIret holds the current widget id for the new widget
+ wIret.iWinId = uiBaseWinId;
+ wIret.fd = wI.fd;
+
+ if(checkWidgetId(&wI) == TRUE){
+ PObject *obj = WidgetList[wI.fd]->find(wI.iWinId)->pwidget;
+ if(obj->widget()->isWidgetType() == FALSE){
+ throw(errorCommandFailed(PUKE_INVALID, 0));
+ }
+ parent = (PWidget *) obj;
+ }
+
+ // CreateArgs arg = CreateArgs(this, pm, &wIret, parent)
+ CreateArgs arg(this, pm, &wIret, parent);
+ ws->pwidget = (widgetCF[iType]->wc)(arg);
+ if (ws->pwidget->hasError())
+ {
+ throw(errorCommandFailed(PUKE_INVALID, 0));
+ }
+ ws->type = iType;
+
+ connect(ws->pwidget, SIGNAL(outputMessage(int, PukeMessage*)),
+ this, SIGNAL(outputMessage(int, PukeMessage*)));
+
+ // insertPBoject(fd, uiBaseWinId, ws);
+ // The widget list has to exist since we have ourselves in the list
+ insertPObject(wIret.fd, wIret.iWinId, ws);
+// WidgetList[wIret.fd]->insert(wIret.iWinId, ws);
+ return wIret;
+}
+
+
+#include "controller.moc"
+
diff --git a/ksirc/puke/controller.h b/ksirc/puke/controller.h
new file mode 100644
index 00000000..80728224
--- /dev/null
+++ b/ksirc/puke/controller.h
@@ -0,0 +1,211 @@
+/*
+ * Main controller for:
+ *
+ * PUKE = Perl gUi Kontrol Environment
+ *
+ */
+
+#ifndef PUKE_CONTROLLER_H
+#define PUKE_CONTROLLER_H
+
+#include <qobject.h>
+#include <qsocketnotifier.h>
+#include <qstring.h>
+#include <qdict.h>
+#include <qintdict.h>
+#include <qstrlist.h>
+
+#include "pmessage.h"
+#include "pobject.h"
+#include "pwidget.h"
+#include "commands.h"
+
+class PukeController;
+class KLibrary;
+
+typedef struct {
+ QString server;
+ bool writeable;
+ QSocketNotifier *sr,*sw;
+} fdStatus;
+
+
+struct commandStruct {
+ void (PukeController::*cmd)(int, PukeMessage*);
+ KLibrary *library;
+};
+
+typedef struct {
+ PObject *pwidget; // The widget
+ int type; // The type so casting is "safer"
+} WidgetS; // WidgetStruct
+
+typedef struct {
+ PObject *(*wc)(CreateArgs &ca);
+ KLibrary *library;
+} widgetCreate;
+
+class errorNoSuchWidget {
+public:
+ errorNoSuchWidget(widgetId &_wi)
+ {
+ wi = _wi;
+ }
+
+ widgetId &widgetIden() {
+ return wi;
+ }
+private:
+ widgetId wi;
+};
+
+class errorCommandFailed {
+public:
+ errorCommandFailed(int _command, int _iarg){
+ __command = _command;
+ __iarg = _iarg;
+ }
+
+ int command() { return __command; }
+ int iarg() { return __iarg; }
+
+private:
+ int __command, __iarg;
+};
+
+#define INVALID_DEL_NO_CONTROL 100
+#define INVALID_DEL_NO_SUCH_CONNECTION 101
+#define INVALID_DEL_NO_SUCH_WIDGET 102
+
+class PukeController : public PObject
+{
+ Q_OBJECT
+public:
+ PukeController(QString socket = "", QObject *parent=0, const char *name=0);
+ virtual ~PukeController();
+ bool running;
+
+ /**
+ * Verifies the widgetId exists and is a valid widget.
+ * True is valid, false if invalid.
+ */
+ bool checkWidgetId(widgetId *pwI);
+
+ /**
+ * id2pobject takes a window id and returns the reuired object
+ * it throw an errorNoSuchWidget on failures
+ */
+ PObject *id2pobject(int fd, int iWinId);
+ PObject *id2pobject(widgetId *pwi);
+ /**
+ * Return a PWidget if it's a widget, throws an exception if not found
+ */
+ PWidget *id2pwidget(widgetId *pwi);
+
+ QStrList allObjects();
+
+signals:
+ void PukeMessages(QString server, int command, QString args);
+ void inserted(QObject *);
+
+public slots:
+ void ServMessage(QString, int, QString);
+
+protected slots:
+ void Traffic(int);
+ void Writeable(int);
+ void NewConnect(int);
+ void slotInserted(QObject *obj);
+
+ /**
+ * When we delete a widget, this removes it from our internal
+ * list of widgets. We never remove a widget ourselfs, we call delete
+ * and this function removes it.
+ */
+ void pobjectDestroyed();
+
+ /**
+ * Fd to write to
+ * PukeMessage message to be written, if null buffer is flushed.
+ */
+ void writeBuffer(int fd, PukeMessage *message);
+
+
+private:
+ QString qsPukeSocket;
+ int iListenFd;
+ bool bClosing; // Set true if we are closing, we don't try and close twice at the same time.
+ QSocketNotifier *qsnListen;
+ QIntDict<fdStatus> qidConnectFd;
+
+ /**
+ * Controller ID is defined as 1
+ */
+ enum { ControllerWinId = PUKE_CONTROLLER };
+
+
+ // List of widgets and the fle descriptors they belong too
+ QIntDict<QIntDict<WidgetS> > WidgetList;
+ // I use a char * key that's the %p (hex address) of the pwidget
+ QDict<widgetId> revWidgetList;
+ enum { keySize = 10 };
+
+ // Funtions used to create new widget
+ QIntDict<widgetCreate> widgetCF; // widgetCreatingFuntion List
+
+ QIntDict<commandStruct> qidCommandTable;
+
+ void initHdlr();
+
+ void closefd(int fd);
+
+ void MessageDispatch(int fd, PukeMessage *pm);
+
+ /**
+ * WinId comes from a static unsigned int we increment for each new window
+ */
+ static uint uiBaseWinId;
+
+ /**
+ * Create new Widget, returns new iWinId for it.
+ * Takes server fd and parent winid, and type as arguments
+ */
+ widgetId createWidget(widgetId wI, PukeMessage *pm);
+
+ /**
+ * Used to process messages going to controller, winId #1
+ *
+ */
+ void messageHandler(int fd, PukeMessage *pm);
+
+ /**
+ * NOT APPLICAABLE
+ */
+ void setWidget(QObject *) { }
+ /**
+ * NOT APPLICAABLE
+ */
+ virtual QObject *widget() { return 0x0; }
+
+ /**
+ * Inserts a PObject into our internal list
+ */
+ void insertPObject(int fd, int iWinId, WidgetS *obj);
+
+ /**
+ * Closes a widget, checking for sanity
+ */
+// void closeWidget(widgetId wI);
+
+ // Message handlers
+ void hdlrPukeSetup(int fd, PukeMessage *pm);
+ void hdlrPukeInvalid(int fd, PukeMessage *pm);
+ void hdlrPukeEcho(int fd, PukeMessage *pm);
+ void hdlrPukeDumpTree(int fd, PukeMessage *pm);
+ void hdlrPukeFetchWidget(int fd, PukeMessage *pm);
+ void hdlrPukeDeleteWidget(int fd, PukeMessage *pm);
+
+};
+
+#endif
+
diff --git a/ksirc/puke/convert_commands.pl b/ksirc/puke/convert_commands.pl
new file mode 100755
index 00000000..98ad7e35
--- /dev/null
+++ b/ksirc/puke/convert_commands.pl
@@ -0,0 +1,13 @@
+#!/usr/bin/perl
+
+open(CMD, "cat commands.h *-cmd.h|");
+open(CMDP, ">commands-perl.pl");
+while(<CMD>){
+ if(/#define (\S+) (.+)/){
+ print CMDP "\$${1} = $2;\n";
+ print CMDP "\$PUKE_NAME2NUM\{'$1'\} = $2;\n";
+ print CMDP "\$PUKE_NUM2NAME\{'$2'\} = '$1';\n";
+ }
+}
+
+print CMDP "\n1;\n";
diff --git a/ksirc/puke/dcc_progress.pm b/ksirc/puke/dcc_progress.pm
new file mode 100644
index 00000000..a21ee26e
--- /dev/null
+++ b/ksirc/puke/dcc_progress.pm
@@ -0,0 +1,55 @@
+
+&docommand("/load pprogress.pm");
+
+package DCCProgress;
+
+@ISA = qw(PProgress);
+use strict;
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new($class, @_);
+
+ $self->create();
+
+ $self->installHandler($::PUKE_KSPROGRESS_CANCEL_ACK,
+ sub {$self->cancelPressed(@_)});
+
+ return $self;
+}
+
+
+sub setRange {
+ my $self = shift;
+ my $min = shift;
+ my $max = shift;
+
+ $self->{'min'} = $min;
+ $self->{'max'} = $max;
+ $self->{'step'} = ($max - $min) / 100;
+ $self->{'step'} = 10240 if $self->{'step'} == 0; # if sized messed don't divide by 0 :)
+ $self->PProgress::setRange(0, 100);
+}
+
+sub setValue {
+ my $self = shift;
+
+ my $value = shift;
+
+ my $steps = int($value / $self->{'step'});
+
+ $self->PProgress::setValue($steps);
+}
+
+sub setCancel {
+ my $self = shift;
+ $self->{'cancelMessage'} = shift;
+}
+
+sub cancelPressed {
+ my $self = shift;
+
+ &::docommand($self->{'cancelMessage'});
+ $self->hide;
+
+} \ No newline at end of file
diff --git a/ksirc/puke/dcc_status.pm b/ksirc/puke/dcc_status.pm
new file mode 100644
index 00000000..65bc1b07
--- /dev/null
+++ b/ksirc/puke/dcc_status.pm
@@ -0,0 +1,525 @@
+#use lib "/opt/kde/share/apps/ksirc";
+
+&docommand("/load pbase.pm");
+&docommand("/load pwidget.pm");
+&docommand("/load pframe.pm");
+&docommand("/load ptablevw.pm");
+&docommand("/load plistbox.pm");
+&docommand("/load pbutton.pm");;
+&docommand("/load pboxlayout.pm");
+&docommand("/load plabel.pm");
+&docommand("/load pbutton.pm");
+&docommand("/load ppushbt.pm");
+&docommand("/load plined.pm");
+&docommand("/load pkfiledialog.pm");
+&docommand("/load ppopmenu.pm");
+
+&docommand("/load dcc_progress.pm");
+
+&docommand("/load plined.pm");
+&docommand("/load pprogress.pm");
+
+use POSIX qw(getcwd);
+use strict;
+
+package DCCSendDialog;
+use vars qw(@ISA);
+@ISA = qw(PFrame);
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new($class, @_);
+ $self->create();
+
+ my $gm_main = new PBoxLayout($self, $PBoxLayout::TopToBottom, 5);
+
+ my $gm_to = new PBoxLayout($PBoxLayout::LeftToRight, 5);
+ $gm_main->addLayout($gm_to);
+
+ my $label_to = new PLabel($self);
+ $label_to->setText("To Nick:");
+ $label_to->setMaximumSize(1000,30);
+ $label_to->setMinimumSize(50,30);
+ $gm_to->addWidget($label_to, 0, $PBoxLayout::AlignCenter);
+
+ my $line_to = new PLineEdit($self);
+ $gm_to->addWidget($line_to, 5, $PBoxLayout::AlignCenter);
+
+ my $gm_file = new PBoxLayout($PBoxLayout::LeftToRight, 5);
+ $gm_main->addLayout($gm_file);
+
+ my $label_file = new PLabel($self);
+ $label_file->setText("Filename:");
+ $label_file->setMaximumSize(1000,30);
+ $label_file->setMinimumSize(50,30);
+ $gm_file->addWidget($label_file, 0, $PBoxLayout::AlignCenter);
+
+ my $line_file = new PLineEdit($self);
+ $gm_file->addWidget($line_file, 5, $PBoxLayout::AlignLeft);
+
+ my $button_file = new PPushButton($self);
+ $button_file->setText("&Browse");
+ $button_file->installHandler($::PUKE_BUTTON_CLICKED_ACK, sub{$self->browseClicked});
+ $gm_file->addWidget($button_file, 2, $PBoxLayout::AlignRight);
+
+ my $button_send = new PPushButton($self);
+ $button_send->setText("&Send");
+ $button_send->installHandler($::PUKE_BUTTON_CLICKED_ACK, sub{$self->sendClicked});
+ $gm_main->addWidget($button_send, 4, $PBoxLayout::AlignRight);
+
+ @$self{'gm_main', 'gm_to', 'gm_file', 'label_to', 'line_to', 'label_file', 'line_file', 'button_file', 'button_send'}
+ = ($gm_main, $gm_to, $gm_file, $label_to, $line_to, $label_file, $line_file, $button_file, $button_send);
+
+ print "*I* Finished creating DCCSend\n";
+
+ $self->{fileDialog} = new PKFileDialog();
+ my $dlg = $self->{fileDialog};
+ $dlg->setDir(POSIX::getcwd());
+ $dlg->installHandler($::PUKE_KBFD_FILE_SELECTED_ACK, sub{$self->fileSelected(shift())});
+
+ $self->setMinimumSize(450, 110);
+ $self->setMaximumSize(2000, 2000);
+ $self->resize(450, 110);
+
+ return $self;
+
+}
+
+sub browseClicked {
+ my $self = shift;
+
+ $self->{fileDialog}->show();
+
+}
+
+sub fileSelected {
+ my $self = shift;
+
+ my $hargs = shift;
+
+ $self->{fileDialog}->hide();
+
+ my $file = $hargs->{'cArg'};
+
+ if($file ne ''){
+ $self->{'line_file'}->setText($file);
+ }
+}
+
+sub sendClicked {
+ my $self = shift;
+
+ my $to_nick = $self->{'line_to'}->text();
+ my $to_file = $self->{'line_file'}->text();
+
+ if($to_nick eq '' || $to_file eq ''){
+ return;
+ }
+
+ &::docommand("dcc send $to_nick $to_file");
+ $self->hide();
+}
+
+
+use vars qw(@ISA $KSIRC_DCC %KSIRC_DCC);
+
+package DCCStatus;
+use vars qw(@ISA);
+@ISA = qw(PFrame);
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new($class, @_);
+ $self->create();
+
+ my $gm_main = new PBoxLayout($self, $PBoxLayout::TopToBottom, 5);
+
+ my $label = new PLabel($self);
+ $label->setText("Pending DCC");
+ $label->setMaximumSize(1000,20);
+ $gm_main->addWidget($label, 5, $PBoxLayout::AlignCenter);
+ my $lb = new PListBox($self);
+ $gm_main->addWidget($lb, 5, $PBoxLayout::AlignCenter);
+
+ my $gm_but1 = new PBoxLayout($PBoxLayout::LeftToRight, 5);
+ $gm_main->addLayout($gm_but1);
+
+ my $button_get = new PPushButton($self);
+ $button_get->setText("&Open Connection");
+ $button_get->setMaximumSize(1000,30);
+ $button_get->setMinimumSize(10,30);
+ $button_get->installHandler($::PUKE_BUTTON_CLICKED_ACK, sub{$self->openClicked});
+ $gm_but1->addWidget($button_get, 5);
+
+ my $button_forget = new PPushButton($self);
+ $button_forget->setText("&Forget Connection");
+ $button_forget->setMaximumSize(1000,30);
+ $button_forget->setMinimumSize(10,30);
+ $button_forget->installHandler($::PUKE_BUTTON_CLICKED_ACK, sub{$self->forgetClicked});
+ $gm_but1->addWidget($button_forget, 5);
+
+ my $gm_but2 = new PBoxLayout($PBoxLayout::LeftToRight, 5);
+ $gm_main->addLayout($gm_but2);
+
+ my $button_send = new PPushButton($self);
+ $button_send->setText("&Send File");
+ $button_send->setMaximumSize(1000,30);
+ $button_send->setMinimumSize(10,30);
+ $button_send->installHandler($::PUKE_BUTTON_CLICKED_ACK, sub{$self->sendClicked});
+ $gm_but2->addWidget($button_send, 5);
+
+ $gm_main->activate();
+
+ $self->setMinimumSize(400, 275);
+ $self->setMaximumSize(2000, 2000);
+ $self->resize(400, 275);
+
+ @$self{'gm_main', 'label1', 'lb', 'button_get', 'button_chat', 'button_forget', 'gm_but1', 'gm_but2', 'button_send' }
+ = ( $gm_main, $label, $lb, $button_get, $button_send, $button_forget, $gm_but1, $gm_but2, $button_send );
+
+
+ print "*I* Finished creating DCCStatus\n";
+
+ return $self;
+}
+
+sub addItem {
+ my $self = shift;
+
+ my %hargs = @_;
+
+ my $line = $hargs{'line'};
+
+ if($self->{'lines'}->{$line}){
+ return -1;
+ }
+
+ $self->{'lines'}->{$line}->{'OpenCode'} = $hargs{'open'};
+ $self->{'lines'}->{$line}->{'ForgetCode'} = $hargs{'forget'};
+
+ $self->{'lb'}->insertText($line, -1);
+ if($self->{'lb'}->currentText() eq ''){
+ $self->{'lb'}->setCurrentItem(0);
+ }
+
+ return 0;
+}
+
+sub openClicked {
+ my $self = shift;
+
+ my $line = $self->{'lb'}->currentText();
+ if($line eq ''){
+ return;
+ }
+
+ &{$self->{'lines'}->{$line}->{'OpenCode'}};
+ $self->{'lb'}->removeItem($self->{'lb'}->current());
+ if($self->{'lb'}->{count} == 0){
+ $self->hide();
+ }
+
+ delete $self->{'lines'}->{$line};
+
+}
+
+sub forgetClicked {
+ my $self = shift;
+
+ my $line = $self->{'lb'}->currentText();
+ if($line eq ''){
+ return;
+ }
+
+ &{$self->{'lines'}->{$line}->{'ForgetCode'}};
+ $self->{'lb'}->removeItem($self->{'lb'}->current());
+ if($self->{'lb'}->{count} == 0){
+ $self->hide();
+ }
+
+
+ delete $self->{'lines'}->{$line};
+
+}
+
+sub sendClicked {
+ my $self = shift;
+
+ if(!$self->{sendDialog}){
+ my $dlg = new DCCSendDialog();
+ if($dlg == undef){
+ &print("*E* Could not load DCCSendDialog");
+ return;
+ }
+ $self->{sendDialog} = $dlg;
+ }
+
+ $self->{sendDialog}->show();
+}
+
+sub DESTROY {
+ print "*E* Destroying dcc status widget\n";
+ shift()->close();
+}
+
+sub close {
+ my $self = shift;
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_DELETE,
+ 'CallBack' => sub {},
+ 'WaitFor' => 1);
+ # $self->{'gm_main'}->DESTROY;
+ #elete $self->{'gm_main'};
+}
+
+package DCCPopupMenu;
+use vars qw(@ISA);
+@ISA = qw(PPopupMenu);
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new($class, @_);
+ $self->create();
+ return $self;
+}
+
+sub insertText {
+ my $self = shift;
+
+ my $id = $self->SUPER::insertText(@_);
+
+ my @arr;
+
+ if(ref($self->{'Ids'}) ne 'ARRAY'){
+ $self->{'Ids'} = \@arr;
+ }
+
+ @arr = @{$self->{'Ids'}};
+
+ $arr[$#arr+1] = $id;
+
+ $self->{'Ids'} = \@arr;
+
+ return $id;
+}
+
+sub DESTROY {
+ my $self = shift;
+
+ my @arr = @{$self->{'Ids'}};
+ my $id;
+
+ foreach $id (@arr) {
+ $self->removeItem($id);
+ }
+
+ $self->sendMessage('iCommand' => $::PUKE_RELEASEWIDGET,
+ 'CallBack' => sub {});
+
+
+}
+
+
+package main;
+use vars qw($KSIRC_DCC %KSIRC_DCC $who $KSIRC_DCCSTATUS $silent $nick $KSIRC_POPSC $KSIRC_POPDOCK);
+
+sub hook_ksirc_dcc_request {
+ my($type) = shift;
+ my($machine) = shift;
+ my($port) = shift;
+ my($file) = shift;
+ my($size) = shift;
+ my($mwho) = $who;
+ if($KSIRC_DCCSTATUS == undef){
+ $KSIRC_DCCSTATUS = new DCCStatus;
+ $KSIRC_DCCSTATUS->resize(400, 275);
+ }
+
+ if($type eq 'SEND'){
+ my $open = sub {
+ &docommand("/dcc get $mwho $file");
+ };
+ my $forget = sub {
+ &docommand("/dcc close get $mwho $file");
+ };
+ $::KSIRC_FILE_SIZES{$file} = $size;
+ $KSIRC_DCCSTATUS->addItem('line' => "SEND: $who offered $file at size $size",
+ 'open' => $open,
+ 'forget' => $forget);
+ }
+ elsif($type eq 'CHAT'){
+ $KSIRC_DCCSTATUS->addItem('line' => "CHAT: $who",
+ 'open' => sub { &docommand("/dcc chat $mwho"); },
+ 'forget' => sub { &docommand("/dcc close chat $mwho"); });
+
+ }
+ $KSIRC_DCCSTATUS->show;
+
+}
+
+&addhook("dcc_request", "ksirc_dcc_request");
+
+sub hook_ksirc_dcc_send {
+ my $nick = shift;
+ my $file = shift;
+ my $size = shift;
+ my $fh = shift;
+
+ # print "*I* Starting dcc into with: $nick, $file, $size, $fh\n";
+
+ my($window) = new DCCProgress;
+ $size = 10240 if $size == 0;
+ $window->setRange(0, $size);
+ $window->setCaption("$file=>$nick");
+ $window->setTopText("Sending: $file Size: $size");
+ $window->setBotText("Status: pending");
+ $window->setCancel("dcc close send $nick $file");
+ $KSIRC_DCC{$fh}{$file}{'Window'} = $window;
+ $KSIRC_DCC{$fh}{$file}{'StartTime'} = time() - 1;
+ $window->show;
+}
+
+&addhook("dcc_send", "ksirc_dcc_send");
+
+sub hook_ksirc_dcc_send_status {
+ my $file = shift;
+ my $bytes = shift;
+ my $fh = shift;
+
+ my $window = $KSIRC_DCC{$fh}{$file}{'Window'};
+ if($window == undef){
+ my($window) = new DCCProgress;
+ $window->setRange(0, 1);
+ $window->setCaption("$file=>$nick");
+ $window->setTopText("Sending: $file Size: Unkown");
+ $window->setCancel("dcc close send $nick $file");
+ $KSIRC_DCC{$fh}{$file}{'Window'} = $window;
+ $KSIRC_DCC{$fh}{$file}{'StartTime'} = time() - 1;
+ $window->show;
+ }
+ $window->setBotText("BPS: " . int($bytes/(time() - $KSIRC_DCC{$fh}{$file}{'StartTime'})));
+ $window->setValue($bytes);
+}
+
+&addhook("dcc_send_status", "ksirc_dcc_send_status");
+
+sub hook_ksirc_dcc_get {
+ my $nick = shift;
+ my $file = shift;
+ my $fh = shift;
+
+ my $size = $::KSIRC_FILE_SIZES{$file};
+
+#print "*I* Starting dcc into with: $nick, $file, $size, $fh\n";
+
+ if($KSIRC_DCC{$fh}{$file}{'Window'} == undef){
+ my($window) = new DCCProgress;
+ $size = 10240 if $size == 0;
+ $window->setRange(0, $size);
+ $window->setCaption("$file<=$nick");
+ $window->setTopText("Receiver: $file Size: $size");
+ $window->setBotText("Status: pending");
+ $window->setCancel("dcc close get $nick $file");
+ $KSIRC_DCC{$fh}{$file}{'Window'} = $window;
+ $KSIRC_DCC{$fh}{$file}{'StartTime'} = time() - 1;
+ $window->show;
+ }
+}
+
+&addhook("dcc_get", "ksirc_dcc_get");
+
+sub hook_ksirc_dcc_get_status {
+ my $file = shift;
+ my $bytes = shift;
+ my $fh = shift;
+
+ my $window = $KSIRC_DCC{$fh}{$file}{'Window'};
+ if($window == undef){
+ my($window) = new DCCProgress;
+ $window->setRange(0, 1);
+ $window->setCaption("$file<=$nick");
+ $window->setTopText("Receiver: $file Size: Unkown");
+ $window->setBotText("Status: pending");
+ $window->setCancel("dcc close get $nick $file");
+ $KSIRC_DCC{$fh}{$file}{'Window'} = $window;
+ $KSIRC_DCC{$fh}{$file}{'StartTime'} = time() - 1;
+ $window->show;
+ }
+ $window->setBotText("BPS: " . int($bytes/(time() - $KSIRC_DCC{$fh}{$file}{'StartTime'})));
+ $window->setValue($bytes);
+}
+
+&addhook("dcc_get_status", "ksirc_dcc_get_status");
+
+
+sub hook_ksirc_dcc_disconnect {
+ my $nick = shift;
+ my $file = shift;
+ my $bytes = shift;
+ my $time = shift;
+ my $fh = shift;
+
+ if($fh){
+ my $window = $KSIRC_DCC{$fh}{$file}{'Window'};
+ $window->close();
+ delete $KSIRC_DCC{$fh}{$file};
+ delete $KSIRC_DCC{$fh};
+ print "*D* DCC transfer with $nick ($file) terminated; $bytes transferred in $time seconds (" . int(($bytes/($time+1))/1024) . "KBps)";
+ $silent = 1;
+ }
+}
+
+addhook("dcc_disconnect", "ksirc_dcc_disconnect");
+
+
+
+&print("*I* Done DCC Status");
+#$::test = new DCCStatus;
+#$::test->resize(400, 275);
+#$::test->show();
+
+sub popup_dccstatus{
+ if($KSIRC_DCCSTATUS == undef){
+ $KSIRC_DCCSTATUS = new DCCStatus;
+ $KSIRC_DCCSTATUS->resize(400, 275);
+ }
+ $KSIRC_DCCSTATUS->show();
+}
+
+sub popup_dccsend{
+ if($KSIRC_DCCSTATUS == undef){
+ $KSIRC_DCCSTATUS = new DCCStatus;
+ $KSIRC_DCCSTATUS->resize(400, 275);
+ }
+ $KSIRC_DCCSTATUS->sendClicked();
+}
+
+=cut
+if(!$KSIRC_POPSC){
+ $KSIRC_POPSC = new DCCPopupMenu();
+ if($KSIRC_POPSC->fetchWidget("servercontroller_menu_file") >= 0){
+ my $id_control = $KSIRC_POPSC->insertText("Show DCC Control ($::server)");
+ my $id_send = $KSIRC_POPSC->insertText("Show DCC Send ($::server)");
+ $KSIRC_POPSC->installMenu($id_control, sub{&popup_dccstatus();});
+ $KSIRC_POPSC->installMenu($id_send, sub{&popup_dccsend();});
+ }
+}
+
+if(!$KSIRC_POPDOCK){
+ $KSIRC_POPDOCK = new DCCPopupMenu();
+ if($KSIRC_POPDOCK->fetchWidget("dockServerController_menu_pop") >= 0){
+ my $id_control = $KSIRC_POPDOCK->insertText("Show DCC Control ($::server)");
+ my $id_send = $KSIRC_POPDOCK->insertText("Show DCC Send ($::server)");
+ $KSIRC_POPDOCK->installMenu($id_control, sub { &popup_dccstatus(); } );
+ $KSIRC_POPDOCK->installMenu($id_send, sub { &popup_dccsend(); } );
+ }
+}
+=cut
+
+sub hook_quit_release {
+ $KSIRC_POPDOCK->DESTROY();
+ $KSIRC_POPSC->DESTROY();
+}
+
+&addhook("quit", "quit_release");
+
+1;
diff --git a/ksirc/puke/load_all.pm b/ksirc/puke/load_all.pm
new file mode 100644
index 00000000..26594c0f
--- /dev/null
+++ b/ksirc/puke/load_all.pm
@@ -0,0 +1,14 @@
+&docommand("/load pbase.pm");
+&docommand("/load pwidget.pm");
+&docommand("/load pframe.pm");
+&docommand("/load pboxlayout.pm");
+&docommand("/load plined.pm");
+&docommand("/load pbutton.pm");
+&docommand("/load ppushbt.pm");
+&docommand("/load pprogress.pm");
+&docommand("/load ptablevw.pm");
+&docommand("/load plistbox.pm");
+&docommand("/load ppopmenu.pm");
+&docommand("/load ptabdialog.pm");
+&docommand("/load pkfiledialog.pm");
+&docommand("/load pobjfinder.pm");
diff --git a/ksirc/puke/palistbox.cpp b/ksirc/puke/palistbox.cpp
new file mode 100644
index 00000000..8f3f22f1
--- /dev/null
+++ b/ksirc/puke/palistbox.cpp
@@ -0,0 +1,156 @@
+#include <kdebug.h>
+
+
+#include "palistbox.h"
+
+PObject *
+PAListBox::createWidget(CreateArgs &ca)
+{
+ PAListBox *plb = new PAListBox(ca.parent);
+ aListBox *lb;
+ if(ca.fetchedObj != 0 && ca.fetchedObj->inherits("aListBox") == TRUE){
+ lb = (aListBox *) ca.fetchedObj;
+ plb->setDeleteAble(FALSE);
+ }
+ else if(ca.parent != 0 && ca.parent->widget()->isWidgetType() == TRUE)
+ lb = new aListBox((QWidget *) ca.parent->widget());
+ else
+ lb = new aListBox();
+ plb->setWidget(lb);
+ plb->setWidgetId(ca.pwI);
+ return plb;
+}
+
+
+PAListBox::PAListBox(PObject *parent)
+ : PListBox(parent)
+{
+ // kdDebug(5008) << "PListBox PListBox called" << endl;
+ lb = 0;
+ setWidget(lb);
+}
+
+PAListBox::~PAListBox()
+{
+ // kdDebug(5008) << "PListBox: in destructor" << endl;
+ /*
+ delete widget(); // Delete the frame
+ lb=0; // Set it to 0
+ setWidget(lb); // Now set all widget() calls to 0.
+ */
+}
+
+void PAListBox::messageHandler(int fd, PukeMessage *pm)
+{
+ PukeMessage pmRet;
+ switch(pm->iCommand){
+ case PUKE_LISTBOX_INSERT_SORT:
+ if(!checkWidget())
+ return;
+
+ widget()->inSort(pm->cArg, (bool) pm->iArg);
+ pmRet.iCommand = - pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = widget()->count();
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ case PUKE_ALISTBOX_ISTOP:
+ if(!checkWidget())
+ return;
+
+ pmRet.iArg = widget()->isTop(pm->iArg);
+
+ pmRet.iCommand = - pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ case PUKE_ALISTBOX_FIND_NICK:
+ if(!checkWidget())
+ return;
+
+ pmRet.iArg = widget()->findNick(pm->cArg);
+
+ pmRet.iCommand = - pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ case PUKE_ALISTBOX_SMALL_HIGHLIGHT:
+ {
+ if(!checkWidget())
+ return;
+
+ int index = widget()->findNick(pm->cArg);
+ nickListItem *item = new nickListItem();
+ *item = *widget()->item(index);
+ widget()->removeItem(index);
+ item->setVoice(pm->iArg);
+ widget()->inSort(item);
+ widget()->repaint(TRUE);
+
+ pmRet.iCommand = - pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ }
+ case PUKE_ALISTBOX_BIG_HIGHLIGHT:
+ {
+ if(!checkWidget())
+ return;
+
+ int index = widget()->findNick(pm->cArg);
+ nickListItem *item = new nickListItem();
+ *item = *widget()->item(index);
+ widget()->removeItem(index);
+ item->setOp(pm->iArg);
+ widget()->inSort(item);
+ widget()->repaint(TRUE);
+
+ pmRet.iCommand = - pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ }
+
+ default:
+ PListBox::messageHandler(fd, pm);
+ }
+}
+
+void PAListBox::setWidget(QObject *_lb)
+{
+ if(_lb != 0 && _lb->inherits("aListBox") == FALSE)
+ {
+ errorInvalidSet(_lb);
+ return;
+ }
+
+ lb = (aListBox *) _lb;
+ if(lb != 0){
+ }
+ PListBox::setWidget(lb);
+
+}
+
+
+aListBox *PAListBox::widget()
+{
+ return lb;
+}
+
+bool PAListBox::checkWidget(){
+ if(widget() == 0){
+ kdDebug(5008) << "PAListBox: No Widget set" << endl;
+ return FALSE;
+ }
+ return TRUE;
+}
+
+#include "palistbox.moc"
+
diff --git a/ksirc/puke/palistbox.h b/ksirc/puke/palistbox.h
new file mode 100644
index 00000000..0731bef9
--- /dev/null
+++ b/ksirc/puke/palistbox.h
@@ -0,0 +1,35 @@
+#ifndef PALISTBOX_H
+#define PALISTBOX_H
+
+class PAListBox;
+
+#include "../alistbox.h"
+#include "pmessage.h"
+#include "plistbox.h"
+#include "controller.h"
+
+class PAListBox : public PListBox
+{
+ Q_OBJECT
+public:
+ static PObject *createWidget(CreateArgs &ca);
+
+ PAListBox ( PObject * parent );
+ virtual ~PAListBox ();
+
+ virtual void messageHandler(int fd, PukeMessage *pm);
+
+ virtual void setWidget(QObject *_lb = 0x0);
+ virtual aListBox *widget();
+
+public slots:
+
+protected:
+ bool checkWidget();
+
+private:
+ aListBox *lb;
+
+};
+
+#endif
diff --git a/ksirc/puke/palistbox.pm b/ksirc/puke/palistbox.pm
new file mode 100644
index 00000000..e1dcb691
--- /dev/null
+++ b/ksirc/puke/palistbox.pm
@@ -0,0 +1,117 @@
+
+&::PukeSendMessage($::PUKE_WIDGET_LOAD,
+ $::PUKE_CONTROLLER,
+ $::PWIDGET_ALISTBOX,
+ "palistbox.so",
+ sub { my %ARG = %{shift()};
+ if($ARG{'iArg'} == 1){
+ print "*E* PAListBox Load failed!\n";
+ }
+ }
+ );
+
+
+package PAListBox;
+@ISA = qw(PListBox);
+use strict;
+
+if($PListBox::usage == undef){
+ $PListBox::usage = 0;
+}
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new($class, @_);
+
+ $self->{widgetType} = $::PWIDGET_ALISTBOX;
+
+ if($class eq 'PAListBox'){
+ $self->create();
+ }
+
+ $self->installHandler($::PUKE_LISTBOX_SELECTED_ACK, sub{$self->selected(@_)});
+
+ return $self;
+
+}
+
+sub DESTROY {
+ my $self = shift;
+ $self->SUPER::DESTROY(@_);
+ $PAListBox::usage--;
+ if($PAListBox::usage == 0){
+ &::PukeSendMessage($::PUKE_WIDGET_UNLOAD,
+ 0,
+ $::PWIDGET_ALISTBOX,
+ "",
+ sub {}
+ );
+
+ }
+}
+
+sub inSort {
+ my $self = shift;
+ my $text = shift;
+ my $top = shift;
+
+ $self->sendMessage('iCommand' => $::PUKE_LISTBOX_INSERT_SORT,
+ 'cArg' => $text,
+ 'iArg' => $text >= 1 ? 1 : 0,
+ 'CallBack' => sub {});
+
+}
+
+sub isTop {
+ my $self = shift;
+ my $text = shift;
+
+ my %ret = $self->sendMessage('iCommand' => $::PUKE_ALISTBOX_ISTOP,
+ 'cArg' => $text,
+ 'CallBack' => sub {});
+
+ return $ret{'iArg'};
+
+}
+
+sub findNick {
+ my $self = shift;
+ my $text = shift;
+
+ my %ret = $self->sendMessage('iCommand' => $::PUKE_ALISTBOX_FIND_NICK,
+ 'cArg' => $text,
+ 'CallBack' => sub {},
+ 'WaitFor' => 1);
+
+ return $ret{'iArg'};
+
+}
+
+sub smallHighligh {
+ my $self = shift;
+ my $text = shift;
+ my $highlight = shift;
+
+ $self->sendMessage('iCommand' => $::PUKE_ALISTBOX_SMALL_HIGHLIGHT,
+ 'cArg' => $text,
+ 'iArg' => $highlight,
+ 'CallBack' => sub {});
+
+}
+
+sub bigHighligh {
+ my $self = shift;
+ my $text = shift;
+ my $highlight = shift;
+
+ $self->sendMessage('iCommand' => $::PUKE_ALISTBOX_BIG_HIGHLIGHT,
+ 'cArg' => $text,
+ 'iArg' => $highlight,
+ 'CallBack' => sub {});
+
+}
+
+
+package main;
+
+1;
diff --git a/ksirc/puke/pbase.pm b/ksirc/puke/pbase.pm
new file mode 100644
index 00000000..b8345cdb
--- /dev/null
+++ b/ksirc/puke/pbase.pm
@@ -0,0 +1,265 @@
+
+package PBase;
+use Carp;
+#use Data::Dumper;
+use strict;
+
+$PBase::NO_WIDGET = -1;
+
+$::AlignLeft = 0x0001;
+$::AlignRight = 0x0002;
+$::AlignHCenter = 0x0004;
+$::AlignTop = 0x0008;
+$::AlignBottom = 0x0010;
+$::AlignVCenter = 0x0020;
+$::AlignCenter = $::AlignVCenter | $::AlignHCenter;
+
+sub sendMessage {
+ my $self = shift;
+
+ my %ARG = @_;
+ $ARG{"iWinId"} = $self->{iWinId} if($ARG{"iWinId"} == undef);
+
+ return &::PukeSendMessage($ARG{"iCommand"},
+ $ARG{"iWinId"},
+ $ARG{"iArg"},
+ $ARG{"cArg"},
+ $ARG{"CallBack"},
+ $ARG{"WaitFor"}
+ );
+}
+
+sub rndchr {
+ my $string = "";
+ my $i;
+ for($i = 0; $i < 8; $i++){
+ $string .= chr(int(rand(93)) + 0x21); # 0x21 since we don't want spaces and 0x20 is space.
+ }
+ return $string;
+}
+
+sub new {
+ my $class = shift;
+ my $parent = $_[$#_];
+
+ my $self = {};
+
+
+# print "Parent: $parent\n";
+
+ bless($self, $class);
+
+ $parent = 0 if($parent == undef);
+
+ $self->{iWinId} = -1;
+ $self->{Parent} = $parent if $parent != 0;
+ $self->{initId} = $self->rndchr();
+ $self->{widgetType} = $PBase::NO_WIDGET;
+ $self->{cmdQueue} = ();
+
+ if($::PUKE_FETCH_WIDGET == 1) {
+ $self->{Fetch} = 1;
+ }
+
+ # $self->installHandler($::PUKE_WIDGET_DELETE_ACK, sub{$self->DESTROY});
+
+ return $self;
+
+}
+
+sub create {
+ my $self = shift;
+
+ if($self->{widgetType} == undef ||
+ $self->{widgetType} == $PBase::NO_WIDGET) {
+ print("*E* PBase: Widget type was undefined, $self is really broken\n");
+ print("*E* PBase: Giving up\n");
+ return;
+ }
+
+ my $parent = $self->{Parent} ? $self->{Parent}->{iWinId} : 0;
+
+ # print "*I* Createing widget of type: " . $self->{widgetType} . " with parent " . $parent . "\n";
+
+ $self->{runable} = 1;
+
+ my $carg = $parent . "\t" . $self->{widgetType} . "\t" . $self->{initId};
+
+ my %REPLY = $self->sendMessage('iCommand' => $::PUKE_WIDGET_CREATE,
+ 'iWinId' => $::PUKE_CONTROLLER,
+ 'cArg' => $carg,
+ 'CallBack' => sub { },
+ 'WaitFor' => 1);
+
+ if($REPLY{iWinId} <= 0){
+ print "*E* Widget Create Failed!\n";
+ }
+
+ $self->ackWinId(%REPLY);
+
+ $self->clearQueue();
+ # $self->setRunable(0);
+}
+
+sub fetchWidget {
+ my $self = shift;
+
+ $self->{objName} = shift;
+ my $regex = shift;
+
+# $self->sendMessage('iCommand' => $::PUKE_WIDGET_DELETE,
+# 'CallBack' => sub { print "Deleted\n"; });
+
+ $regex = "0" if($regex eq '');
+ my $carg = $regex . "\t" . $self->{widgetType} . "\t" . $self->{initId} . "\t" . $self->{objName};
+
+ my %REPLY = $self->sendMessage('iCommand' => $::PUKE_FETCHWIDGET,
+ 'iWinId' => $::PUKE_CONTROLLER,
+ 'cArg' => $carg,
+ 'CallBack' => sub { },
+ 'WaitFor' => 1);
+
+ if($REPLY{iWinId} <= 0){
+ print "*E* Widget Fetch Failed!\n";
+ return -1;
+ }
+ my $winid;
+ my $cmd;
+ foreach $cmd (values %::PUKE_W_HANDLER){
+ next unless ref $cmd eq 'CODE';
+ foreach $winid (values %{$::PUKE_W_HANDLER{$cmd}}){
+ if($winid == $self->{'iWinId'}){
+ $::PUKE_W_HANDLER{$cmd}{$REPLY{iWinId}} = $::PUKE_W_HANDLER{$cmd}{$self->{iWinId}};
+ delete $::PUKE_W_HANDLER{$cmd}{$self->{iWinId}};
+ }
+ }
+ }
+
+ $self->ackWinId(%REPLY);
+ $self->{'Fetch'} = 1;
+ # $self->setRunable(0);
+ return 0;
+}
+
+sub releaseWidget {
+ my $self = shift;
+ $self->sendMessage('iCommand' => $::PUKE_RELEASEWIDGET,
+ 'CallBack' => sub {});
+}
+
+sub treeInfo {
+ my $self = shift;
+
+ my %REPLY = $self->sendMessage('iCommand' => $::PUKE_DUMPTREE,
+ 'iWinId' => $::PUKE_CONTROLLER,
+ 'CallBack' => sub { },
+ 'WaitFor' => 0);
+
+}
+
+
+sub DESTROY {
+ my $self = shift;
+
+ # print "*I* Widget Deleted\n";
+ eval{ $self->hide(); }; # Hide doesn't exist for all PBase's
+
+ # $self->setRunable(1);
+
+ delete($::PBASE_IMORTALS{$self->{IMMORTAL}});
+
+ if($self->{'Fetch'} != 1 && $self->{DESTROYED} != 1 && $self->{Parent} == 0){
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_DELETE,
+ 'CallBack' => sub {});
+ }
+
+ if($self->{'Fetch'} == 1){
+ $self->sendMessage('iCommand' => $::PUKE_RELEASEWIDGET,
+ 'CallBack' => sub {});
+
+ }
+
+ # $self->setRunable(0);
+ $self->{iWinId} = -1;
+ $self->{DESTROYED} = 1;
+
+}
+
+sub close {
+ my $self = shift;
+
+ $self->hide();
+
+ $self->DESTROY;
+
+}
+
+sub ackWinId {
+ my $self = shift;
+ my %ARG = @_;
+
+ if($ARG{'iWinId'} <= 1){
+ die("Failed on ack'ing Window ID, stopping!");
+ }
+
+ $self->{iWinId} = $ARG{'iWinId'};
+}
+
+
+sub installHandler {
+ my $self = shift;
+
+ my $command = shift;
+ my $handler = shift;
+
+ my $cmd =
+ sub {
+ $::PUKE_W_HANDLER{$command}{$self->{iWinId}} = $handler;
+ };
+
+ if($self->{iWinId} == -1){
+ $self->addQueue($cmd);
+ }
+ else{
+ &$cmd();
+ }
+
+}
+
+sub onNext {
+ my $self = shift;
+
+ my $cb = shift;
+
+ $self->sendMessage('iCommand' => $::PUKE_ECHO,
+ 'iArg' => 0,
+ 'iWinId' => $self->{iWinId},
+ 'cArg' => "",
+ 'CallBack' => $cb);
+}
+
+sub immortal {
+ my $self = shift;
+ $self->{IMMORTAL} = &rndchr;
+ $::PBASE_IMORTALS{$self->{IMMORTAL}} = $self;
+ return $self;
+}
+
+sub addQueue {
+ my $self = shift;
+
+ push(@{$self->{cmdQueue}}, shift());
+}
+
+sub clearQueue {
+ my $self = shift;
+
+ my $cmd;
+ while($cmd = pop(@{$self->{cmdQueue}})){
+ &$cmd;
+ }
+}
+
+package main;
+
+1;
diff --git a/ksirc/puke/pboxlayout.pm b/ksirc/puke/pboxlayout.pm
new file mode 100644
index 00000000..505ddc0d
--- /dev/null
+++ b/ksirc/puke/pboxlayout.pm
@@ -0,0 +1,201 @@
+
+package PBoxLayout;
+@ISA = qw(PBase);
+use strict;
+
+# setup default handlers
+
+$PBoxLayout::LeftToRight = 0;
+$PBoxLayout::RightToLeft = 1;
+$PBoxLayout::TopToBottom = 2;
+$PBoxLayout::BottomToTop = 3;
+
+$PBoxLayout::AlignLeft = 0x0001;
+$PBoxLayout::AlignRight = 0x0002;
+$PboxLayout::AlignHCenter = 0x0004;
+$PBoxLayout::AlignTop = 0x0008;
+$PBoxLayout::AlignBottom = 0x0010;
+$PBoxLayout::AlignVCenter = 0x0020;
+$PBoxLayout::AlignCenter = $PBoxLayout::AlignVCenter |
+ $PBoxLayout::AlignHCenter;
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new($class, @_);
+
+ my $widget = shift;
+
+ # print "Widget: " . ref($widget) . "\n";
+
+ # if(ref($widget) eq ''){
+ # print "*E* Error Creating PBoxLayout, did not give valid parent\n";
+ # return;
+ #}
+ # elsif(ref($widget) eq 'PBoxLayout'){
+ # $self->{Parent} = $widget;
+ # $self->{ParentType} = 'Layout';
+ # $self->{Direction} = shift;
+ # $self->{Border} = shift;
+ # $self->{Added} = 0;
+ #}
+ # else{
+ if(ref($widget) ne ''){
+ # print "*\cbI\cb* Generic Non-topleve layout type\n";
+ $self->{Parent} = $widget;
+ $self->{ParentType} = 'Widget';
+ $self->{Direction} = shift;
+ $self->{Border} = shift;
+ $self->{Added} = 1;
+ }
+ else{
+ $self->{Parent} = undef;
+ $self->{ParentType} = 'Layout';
+ $self->{Direction} = $widget;
+ $self->{Border} = shift;
+ $self->{Added} = 0;
+
+ }
+
+ $self->{IAmALayout} = 1;
+ $self->{Widgets} = ();
+
+ $self->create();
+
+ return $self;
+
+}
+
+sub create {
+ my $self = shift;
+
+ #
+ # PLayout redefines create since it uses a special cArg
+ #
+ my($paren_id) = 0;
+ $paren_id = $self->{Parent}->{iWinId} if $self->{Parent} != -1;
+
+ if($paren_id eq ''){
+ $paren_id = "0";
+ }
+
+ my $carg = $paren_id . "\t" . $::POBJECT_LAYOUT . "\t" . $self->{Direction} . "\t" . $self->{Border} . "\t" . $self->{initId},
+
+ my %REPLY;
+ %REPLY = $self->sendMessage('iCommand' => $::PUKE_WIDGET_CREATE,
+ 'iWinId' => $::PUKE_CONTROLLER,
+ 'cArg' => $carg,
+ 'CallBack' => sub { },
+ 'WaitFor' => 1);
+
+ $self->ackWinId(%REPLY);
+
+}
+
+sub addWidget {
+ my $self = shift;
+
+ my $widget = shift;
+ my $stretch = shift;
+ my $align = shift;
+
+ if($self->{Added} == 0){
+ print "*E* Burp: Can't add widget without first being added to parent layout\n";
+ return;
+ }
+
+ $align = $PBoxLayout::AlignCenter if $align == undef;
+ $stretch = 0 if $stretch == undef;
+
+ # $widget->immortal(); # If it's a widget, it cannot be deleted
+ if($widget->{iWinId} <= 0){
+ print "*E* Trying to add invalid widget " . ref($widget) . "\n";
+ return;
+ }
+
+ my $cArg = pack("CC", $stretch, $align);
+
+ $self->sendMessage('iCommand' => $::PUKE_LAYOUT_ADDWIDGET,
+ 'iArg' => $widget->{iWinId},
+ 'cArg' => $cArg,
+ 'CallBack' => sub { },
+ 'WaitFor' => 1);
+
+ $self->{Widgets}->[ $#{$self->{Widgets}} + 1] = $widget;
+
+}
+
+sub addLayout {
+ my $self = shift;
+
+ if($self->{Added} == 0){
+ print "*E* Burp: Can't add layout without first being added to parent layout\n";
+ }
+
+
+ my $layout = shift;
+ if(ref($layout) ne 'PBoxLayout'){
+ print "*E* Passed non layout type to addLayout\n";
+ return 1;
+ }
+
+ if($layout->{iWinId} <= 0){
+ print "*E* Trying to add invalid layout " . ref($layout) . "\n";
+ return;
+ }
+
+
+ # make sure we can run, and the widget we want to add can run.
+ # my @ARG = ($layout);
+ #$self->canRun($self, \&PBoxLayout::addLayout, \@ARG) || return;
+ #$layout->canRun($self, \&PBoxLayout::addLayout, \@ARG) || return;
+
+ my %REPLY = $self->sendMessage('iCommand' => $::PUKE_LAYOUT_ADDLAYOUT,
+ 'iWinId' => $self->{iWinId},
+ 'iArg' => $layout->{iWinId},
+ 'cArg' => pack("C", 0),
+ 'CallBack' => sub { },
+ 'WaitFor' => 1);
+
+ # print "*I* Adding layout\n";
+ if($REPLY{'iArg'} != 0){
+ print "*E* AddLayout call failed\n";
+ }
+ else{
+ # print "*I* Added new Layout for " . $layout->{iWinId} . "\n";
+ $layout->{Added} = 1;
+ }
+
+}
+
+sub DESTROY {
+ my $self = shift;
+
+ # print "*I* Layout Deleted\n";
+
+ # if($self->{DESTROYED} != 1){
+ # $self->sendMessage('iCommand' => $::PUKE_WIDGET_DELETE,
+ # 'CallBack' => sub { print "Deleted\n"; });
+ #}
+
+ $self->{iWinId} = -1;
+ $self->{DESTROYED} = 1;
+
+}
+
+sub activate {
+ my $self = shift;
+
+ if($self->{ParentType} != 'Widget'){
+ print "*E* Only call for TopLevel managers\n";
+ return;
+ }
+
+ $self->sendMessage('iCommand' => $::PUKE_LAYOUT_ACTIVATE,
+ 'CallBack' => sub { },
+ 'WaitFor' => 1);
+
+}
+
+
+package main;
+1;
diff --git a/ksirc/puke/pbutton.cpp b/ksirc/puke/pbutton.cpp
new file mode 100644
index 00000000..309f2ac7
--- /dev/null
+++ b/ksirc/puke/pbutton.cpp
@@ -0,0 +1,157 @@
+#include <stdio.h>
+
+
+#include <qpixmap.h>
+
+#include <kdebug.h>
+
+#include "pbutton.h"
+
+PObject *
+PButton::createWidget(CreateArgs &ca)
+{
+ PButton *pb = new PButton(ca.parent);
+ QButton *qb;
+ if(ca.parent != 0 && ca.parent->widget()->isWidgetType() == TRUE)
+ qb = new QButton((QWidget *) ca.parent->widget());
+ else
+ qb = new QButton();
+ pb->setWidget(qb);
+ pb->setWidgetId(ca.pwI);
+ return pb;
+}
+
+
+PButton::PButton(PObject *parent)
+ : PWidget(parent)
+{
+ // kdDebug(5008) << "PLineEdit PLineEdit called" << endl;
+ button = 0;
+ setWidget(0);
+}
+
+PButton::~PButton()
+{
+ // kdDebug(5008) << "PLineEdit: in destructor" << endl;
+ /*
+ delete widget(); // Delete the frame
+ button=0; // Set it to 0
+ setWidget(button); // Now set all widget() calls to 0.
+ */
+}
+
+void PButton::messageHandler(int fd, PukeMessage *pm)
+{
+ PukeMessage pmRet;
+ switch(pm->iCommand){
+ case PUKE_BUTTON_SET_TEXT:
+ if(checkWidget() == FALSE)
+ return;
+
+ widget()->setText(pm->cArg); // set the text
+
+ pmRet.iCommand = - pm->iCommand;// Create ack
+ pmRet.iWinId = pm->iWinId;
+ pmRet.cArg = (char*) widget()->text().ascii(); // It's const, but we don't mess with it anyways
+ pmRet.iTextSize = strlen(pmRet.cArg);
+ emit outputMessage(fd, &pmRet);
+ break;
+ case PUKE_BUTTON_SET_PIXMAP:
+ if(checkWidget() == FALSE)
+ return;
+
+ widget()->setPixmap(QPixmap(pm->cArg));
+
+ pmRet.iCommand = - pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = widget()->pixmap()->isNull();
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ case PUKE_BUTTON_SET_AUTORESIZE:
+ if(checkWidget() == FALSE)
+ return;
+
+ pmRet.iCommand = - pm->iCommand;
+ pmRet.iWinId = - pm->iWinId;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ default:
+ PWidget::messageHandler(fd, pm);
+ }
+}
+
+void PButton::setWidget(QObject *_qb)
+{
+ if(_qb != 0 && _qb->inherits("QButton") == FALSE)
+ {
+ errorInvalidSet(_qb);
+ return;
+ }
+
+ button = (QButton *) _qb;
+ if(button != 0){
+ connect(button, SIGNAL(pressed()),
+ this, SLOT(buttonPressed()));
+ connect(button, SIGNAL(released()),
+ this, SLOT(buttonReleased()));
+ connect(button, SIGNAL(clicked()),
+ this, SLOT(buttonClicked()));
+ connect(button, SIGNAL(toggled(bool)),
+ this, SLOT(buttonToggled(bool)));
+
+ }
+ PWidget::setWidget(_qb);
+
+}
+
+
+QButton *PButton::widget()
+{
+ return button;
+}
+
+void PButton::buttonMessage(int iCommand)
+{
+ PukeMessage pmRet;
+
+ pmRet.iCommand = iCommand;
+ pmRet.iArg = 0;
+ pmRet.iWinId = widgetIden().iWinId;
+ pmRet.cArg = 0;
+
+ emit outputMessage(widgetIden().fd, &pmRet);
+}
+
+void PButton::buttonPressed()
+{
+ buttonMessage(PUKE_BUTTON_PRESSED_ACK);
+}
+
+void PButton::buttonReleased()
+{
+ buttonMessage(PUKE_BUTTON_RELEASED_ACK);
+}
+
+void PButton::buttonClicked()
+{
+ buttonMessage(PUKE_BUTTON_CLICKED_ACK);
+}
+
+void PButton::buttonToggled(bool)
+{
+ buttonMessage(PUKE_BUTTON_TOGGLED_ACK);
+}
+
+bool PButton::checkWidget()
+{
+ if(widget() == 0){
+ kdDebug(5008) << "PButton: No Widget set" << endl;
+ return FALSE;
+ }
+ return TRUE;
+}
+
+#include "pbutton.moc"
+
diff --git a/ksirc/puke/pbutton.h b/ksirc/puke/pbutton.h
new file mode 100644
index 00000000..e43bd681
--- /dev/null
+++ b/ksirc/puke/pbutton.h
@@ -0,0 +1,40 @@
+#ifndef PBUTTON_H
+#define PBUTTON_H
+
+class PButton;
+
+#include <qbutton.h>
+#include "pmessage.h"
+#include "pwidget.h"
+#include "pobject.h"
+#include "controller.h"
+
+
+class PButton : public PWidget
+{
+ Q_OBJECT
+public:
+ static PObject *createWidget(CreateArgs &ca);
+
+ PButton ( PObject * parent );
+ virtual ~PButton ();
+
+ virtual void messageHandler(int fd, PukeMessage *pm);
+
+ virtual void setWidget(QObject *_qb = 0x0);
+ virtual QButton *widget();
+
+public slots:
+ void buttonPressed();
+ void buttonReleased();
+ void buttonClicked();
+ void buttonToggled(bool);
+
+private:
+ QButton *button;
+
+ void buttonMessage(int iCommand);
+ bool checkWidget();
+};
+
+#endif
diff --git a/ksirc/puke/pbutton.pm b/ksirc/puke/pbutton.pm
new file mode 100644
index 00000000..81e524fc
--- /dev/null
+++ b/ksirc/puke/pbutton.pm
@@ -0,0 +1,79 @@
+
+&::PukeSendMessage($PUKE_WIDGET_LOAD,
+ $PUKE_CONTROLLER,
+ $PWIDGET_BUTTON,
+ "pbutton.so",
+ sub { my %ARG = %{shift()};
+ if($ARG{'iArg'} == 1){
+ print "*E* PButton Load failed!\n";
+ }
+ }
+ );
+
+package PButton;
+@ISA = qw(PWidget);
+use strict;
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new($class, @_);
+
+ $self->{widgetType} = $::PWIDGET_BUTTON;
+
+ if($class eq 'PButton'){
+ $self->create();
+ }
+
+ $self->installHandler($::PUKE_BUTTON_PRESSED_ACK, sub{});
+ $self->installHandler($::PUKE_BUTTON_RELEASED_ACK, sub{});
+ $self->installHandler($::PUKE_BUTTON_CLICKED_ACK, sub{});
+ $self->installHandler($::PUKE_BUTTON_TOGGLED_ACK, sub{});
+
+ return $self;
+
+}
+
+sub setText {
+ my $self = shift;
+
+ my $text = shift;
+
+ $self->{text} = $text;
+
+ $self->sendMessage('iCommand' => $::PUKE_BUTTON_SET_TEXT,
+ 'cArg' => $text,
+ 'CallBack' => sub {}
+ );
+}
+
+sub setPixmap {
+ my $self = shift;
+
+ my $file = shift;
+
+ $self->sendMessage('iCommand' => $::PUKE_BUTTON_SET_PIXMAP,
+ 'cArg' => $file,
+ 'CallBack' =>
+ sub {
+ my $arg = shift();
+ # if($arg == undef){ return; }
+ #my %ARG = %{shift()};
+ #if($ARG{'iArg'} == 0){
+ #print "*E* Pixmap set failed\n";
+ #}
+ }
+ );
+}
+
+sub setAutoResize {
+ my $self = shift;
+
+ my $resize = shift;
+
+ $self->sendMessage('iCommand' => $::PUKE_BUTTON_SET_PIXMAP,
+ 'iArg' => $resize,
+ 'CallBack' => sub {}
+ );
+}
+
+package main;
diff --git a/ksirc/puke/pframe.cpp b/ksirc/puke/pframe.cpp
new file mode 100644
index 00000000..fcff1d96
--- /dev/null
+++ b/ksirc/puke/pframe.cpp
@@ -0,0 +1,84 @@
+#include "pframe.h"
+
+
+PObject *
+PFrame::createWidget(CreateArgs &ca)
+{
+ PFrame *pw = new PFrame(ca.parent);
+ QFrame *tf;
+ if(ca.parent != 0 &&
+ ca.parent->widget()->isWidgetType() == TRUE)
+ tf = new QFrame((QWidget *) ca.parent->widget());
+ else
+ tf = new QFrame();
+ pw->setWidget(tf);
+ pw->setWidgetId(ca.pwI);
+ pw->setPukeController(ca.pc);
+ return pw;
+}
+
+
+PFrame::PFrame( PObject *parent)
+ : PWidget(parent)
+{
+ // kdDebug(5008) << "PFrame PFrame called" << endl;
+ frame = 0;
+}
+
+PFrame::~PFrame()
+{
+ // kdDebug(5008) << "PFrame: in destructor" << endl;
+ /*
+ delete frame; // Delete the frame
+ frame=0; // Set it to 0
+ setWidget(frame); // Now set all widget() calls to 0.
+ */
+}
+
+void PFrame::messageHandler(int fd, PukeMessage *pm)
+{
+ // kdDebug(5008) << "PFrame handler called" << endl;
+ PukeMessage pmRet;
+ switch(pm->iCommand){
+ case PUKE_QFRAME_SET_FRAME:
+ widget()->setFrameStyle(pm->iArg);
+ pmRet.iCommand = PUKE_QFRAME_SET_FRAME_ACK;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = widget()->frameStyle();
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ case PUKE_QFRAME_SET_LINEWIDTH:
+ widget()->setLineWidth(pm->iArg);
+ pmRet.iCommand = PUKE_QFRAME_SET_LINEWIDTH_ACK;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = widget()->lineWidth();
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ default:
+ PWidget::messageHandler(fd, pm);
+ }
+}
+
+void PFrame::setWidget(QObject *w)
+{
+ if(w != 0 && w->inherits("QFrame") == FALSE)
+ {
+ errorInvalidSet(w);
+ return;
+ }
+
+ frame = (QFrame *) w;
+ PWidget::setWidget((QWidget *) w);
+}
+
+
+QFrame *PFrame::widget()
+{
+ // kdDebug(5008) << "PFrame widget called" << endl;
+ return frame;
+}
+
+#include "pframe.moc"
+
diff --git a/ksirc/puke/pframe.h b/ksirc/puke/pframe.h
new file mode 100644
index 00000000..e98750aa
--- /dev/null
+++ b/ksirc/puke/pframe.h
@@ -0,0 +1,28 @@
+#ifndef PFRAME_H
+#define PFRAME_H
+
+class PFrame;
+
+#include <qframe.h>
+#include "pmessage.h"
+#include "pwidget.h"
+
+class PFrame : public PWidget
+{
+ Q_OBJECT
+public:
+ static PObject *createWidget(CreateArgs &ca);
+
+ PFrame ( PObject * parent );
+ virtual ~PFrame ();
+
+ virtual void messageHandler(int fd, PukeMessage *pm);
+
+ virtual void setWidget(QObject *w = 0x0);
+ virtual QFrame *widget();
+
+private:
+ QFrame *frame;
+};
+
+#endif
diff --git a/ksirc/puke/pframe.pm b/ksirc/puke/pframe.pm
new file mode 100644
index 00000000..f851cdb8
--- /dev/null
+++ b/ksirc/puke/pframe.pm
@@ -0,0 +1,57 @@
+
+&::PukeSendMessage($PUKE_WIDGET_LOAD,
+ $PUKE_CONTROLLER,
+ $PWIDGET_FRAME,
+ "pframe.so",
+ sub { my %ARG = %{shift()};
+ if($ARG{'iArg'} == 1){
+ print "*E* PFrame Load failed!\n";
+ }
+ }
+ );
+
+package PFrame;
+@ISA = qw(PWidget);
+use strict;
+
+$PFrame::NoFrame = 0;
+$PFrame::Box = 0x0001;
+$PFrame::Panel = 0x0002;
+$PFrame::WinPanel = 0x0003;
+$PFrame::HLine = 0x0004;
+$PFrame::VLine = 0x0005;
+$PFrame::MShape = 0x000f;
+$PFrame::Plain = 0x0010;
+$PFrame::Raised = 0x0020;
+$PFrame::Sunken = 0x0030;
+$PFrame::MShadow = 0x00f0;
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new($class, @_);
+
+ $self->{widgetType} = $::PWIDGET_FRAME;
+
+ if($class eq 'PFrame'){
+ $self->create();
+ }
+
+ return $self;
+
+}
+
+sub setFrameStyle {
+ my $self = shift;
+
+ my $frame = shift;
+ my $repaint = shift;
+
+ $self->sendMessage('iCommand' => $::PUKE_QFRAME_SET_FRAME,
+ 'iArg' => $frame,
+ 'CallBack' => sub {});
+
+ $self->repaint(1) if($repaint == 1);
+
+}
+
+package main;
diff --git a/ksirc/puke/pkfiledialog-cmd.h b/ksirc/puke/pkfiledialog-cmd.h
new file mode 100644
index 00000000..6aebd59e
--- /dev/null
+++ b/ksirc/puke/pkfiledialog-cmd.h
@@ -0,0 +1,56 @@
+#ifndef PKFILEDIALOG_CMD_H
+#define PKFILEDIALOG_CMD_H
+
+/*
+ * We get 2200
+ */
+
+// Desc: sets the current directory
+// iWinId: widget
+// iArg: not defined
+// cArg: path
+#define PUKE_KBFD_SET_PATH 2200
+
+// Desc: ack for the set
+// iWinId: widget
+// iArg: not defined
+// cArg: actual path
+#define PUKE_BFD_SET_PATH_ACK -2200
+
+// Desc: sets the current filter
+// iWinId: widget
+// iArg: not defined
+// cArg: filter, as defined in KFileBaseDialog::setFilter
+#define PUKE_KBFD_SET_FILTER 2201
+
+// Desc: ack for the set
+// iWinId: widget
+// iArg: not defined
+// cArg: not define
+#define PUKE_KBFD_SET_FILTER_ACK -2201
+
+// Desc: sets the current file
+// iWinId: widget
+// iArg: not defined
+// cArg: filename (does it need the full path?)
+#define PUKE_KBFD_SET_SELECTION 2202
+
+// Desc: ack for the set
+// iWinId: widget
+// iArg: not defined
+// cArg: not define
+#define PUKE_KBFD_SET_SELECTION_ACK -2202
+
+// Desc: ack for current file select
+// iWinId: not defined
+// iArg: not defined
+// cArg: not defined
+#define PUKE_KBFD_FILE_SELECTED 2203
+
+// Desc: ack for current file select
+// iWinId: widget
+// iArg: not defined
+// cArg: filename
+#define PUKE_KBFD_FILE_SELECTED_ACK -2203
+
+#endif
diff --git a/ksirc/puke/pkfiledialog.cpp b/ksirc/puke/pkfiledialog.cpp
new file mode 100644
index 00000000..c99aea9f
--- /dev/null
+++ b/ksirc/puke/pkfiledialog.cpp
@@ -0,0 +1,123 @@
+#include <stdio.h>
+
+
+#include <kdebug.h>
+
+#include "pkfiledialog.h"
+#include "pkfiledialog-cmd.h"
+
+PObject *
+PKFileDialog::createWidget(CreateArgs &ca)
+{
+ PKFileDialog *pw = new PKFileDialog(ca.parent);
+ KFileDialog *kfbd;
+ if(ca.fetchedObj != 0 && ca.fetchedObj->inherits("KFileDialog") == TRUE){
+ kfbd = (KFileDialog *) ca.fetchedObj;
+ pw->setDeleteAble(FALSE);
+ }
+ else // Never takes a parent in Puke
+ kfbd = new KFileDialog("/", QString::null, 0L, "PukeKFileDialog", TRUE);
+ pw->setWidget(kfbd);
+ pw->setWidgetId(ca.pwI);
+ return pw;
+}
+
+
+PKFileDialog::PKFileDialog(PObject *parent)
+ : PWidget(parent)
+{
+ kfbd = 0;
+ setWidget(kfbd);
+}
+
+PKFileDialog::~PKFileDialog()
+{
+ // kdDebug(5008) << "PLineEdit: in destructor" << endl;
+ /*
+ delete widget(); // Delete the frame
+ kfbd=0; // Set it to 0
+ setWidget(kfbd); // Now set all widget() calls to 0.
+ */
+}
+
+void PKFileDialog::messageHandler(int fd, PukeMessage *pm)
+{
+ QString selFile;
+ PukeMessage pmRet;
+ if(widget() == 0){
+ kdDebug(5008) << "PKFileDialog: No Widget set" << endl;
+ return;
+ }
+ switch(pm->iCommand){
+ case PUKE_KBFD_SET_PATH:
+ ((KFileDialog*)widget())->setURL(KURL(pm->cArg));
+
+ pmRet.iCommand = - pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.iTextSize = widget()->baseURL().path().length();
+#warning check if the cast is okay
+ pmRet.cArg = (char*) widget()->baseURL().path().ascii();
+ emit outputMessage(fd, &pmRet);
+ break;
+ case PUKE_KBFD_SET_FILTER:
+ widget()->setFilter(pm->cArg);
+
+ pmRet.iCommand = - pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.iTextSize = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ case PUKE_KBFD_SET_SELECTION:
+ widget()->setSelection(pm->cArg);
+
+ pmRet.iCommand = - pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ selFile = widget()->selectedURL().path();
+ pmRet.iTextSize = selFile.length();
+#warning check if the cast is okay
+ pmRet.cArg = (char*) selFile.ascii();
+ emit outputMessage(fd, &pmRet);
+ break;
+ case PUKE_WIDGET_SHOW:
+ widget()->exec();
+ pmRet.iCommand = PUKE_KBFD_FILE_SELECTED_ACK;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = new char[selFile.length()];
+ selFile = widget()->selectedURL().path();
+ // #### HPB: using strlen() 'cause we want the length of the .ascii()
+ // string. We should probably replace in the future.
+ memcpy(pmRet.cArg, selFile.ascii(), strlen(selFile.ascii()));
+ pmRet.iTextSize = selFile.length();
+ emit outputMessage(widgetIden().fd, &pmRet);
+ delete pmRet.cArg;
+ break;
+
+ default:
+ PWidget::messageHandler(fd, pm);
+ }
+}
+
+void PKFileDialog::setWidget(QObject *_kbfd)
+{
+ if(_kbfd != 0 && _kbfd->inherits("KFileBaseDialog") == FALSE)
+ {
+ errorInvalidSet(_kbfd);
+ return;
+ }
+
+ kfbd = (KFileDialog *) _kbfd;
+ PWidget::setWidget(kfbd);
+}
+
+
+KFileDialog *PKFileDialog::widget()
+{
+ return kfbd;
+}
+
+#include "pkfiledialog.moc"
diff --git a/ksirc/puke/pkfiledialog.h b/ksirc/puke/pkfiledialog.h
new file mode 100644
index 00000000..c8dbea3f
--- /dev/null
+++ b/ksirc/puke/pkfiledialog.h
@@ -0,0 +1,31 @@
+#ifndef PKFILEDIALOG_H
+#define PKFILEDIALOG_H
+
+class PKFileDialog;
+
+#include <kfiledialog.h>
+#include "pmessage.h"
+#include "pwidget.h"
+#include "controller.h"
+
+class PKFileDialog : public PWidget
+{
+ Q_OBJECT
+public:
+ static PObject *createWidget(CreateArgs &ca);
+
+ PKFileDialog ( PObject * parent );
+ virtual ~PKFileDialog ();
+
+ virtual void messageHandler(int fd, PukeMessage *pm);
+
+ virtual void setWidget(QObject *_f = 0x0);
+ virtual KFileDialog *widget();
+
+public slots:
+
+private:
+ KFileDialog *kfbd;
+};
+
+#endif
diff --git a/ksirc/puke/pkfiledialog.pm b/ksirc/puke/pkfiledialog.pm
new file mode 100644
index 00000000..6da8c229
--- /dev/null
+++ b/ksirc/puke/pkfiledialog.pm
@@ -0,0 +1,76 @@
+
+&::PukeSendMessage($PUKE_WIDGET_LOAD,
+ $::PUKE_CONTROLLER,
+ $PWIDGET_KFILEDIALOG,
+ "pkfiledialog.so",
+ sub { my %ARG = %{shift()};
+ if($ARG{'iArg'} == 1){
+ print "*E* PKFileDialog Load failed!\n";
+ }
+ }
+ );
+
+use strict;
+
+package PKFileDialog;
+use vars qw(@ISA);
+@ISA = qw(PWidget);
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new($class, @_);
+
+ $self->{widgetType} = $::PWIDGET_KFILEDIALOG;
+
+ if($class eq 'PKFileDialog'){
+ $self->create();
+ }
+
+ $self->installHandler($::PUKE_KBFD_FILE_SELECTED_ACK, sub{$self->fileSelected(shift())});
+
+ return $self;
+
+}
+
+sub setDir {
+ my $self = shift;
+
+ my $dir = shift;
+
+ $self->sendMessage('iCommand' => $::PUKE_KBFD_SET_PATH,
+ 'cArg' => $dir,
+ 'CallBack' => sub{});
+
+}
+
+sub setFilter {
+ my $self = shift;
+
+ my $filter = shift;
+
+ $self->sendMessage('iCommand' => $::PUKE_KBFD_SET_FILTER,
+ 'cArg' => $filter,
+ 'CallBack' => sub{});
+
+}
+
+sub setSelected {
+ my $self = shift;
+
+ my $sel = shift;
+
+ $self->sendMessage('iCommand' => $::PUKE_KBFD_SET_SELECTION,
+ 'cArg' => $sel,
+ 'CallBack' => sub{});
+
+}
+
+sub fileSelected {
+ my $self = shift;
+ my $rargs = shift;
+
+ &::print("*I* File Selected: " . $rargs->{'cArg'});
+
+}
+
+package main;
diff --git a/ksirc/puke/plabel.cpp b/ksirc/puke/plabel.cpp
new file mode 100644
index 00000000..17ca851d
--- /dev/null
+++ b/ksirc/puke/plabel.cpp
@@ -0,0 +1,127 @@
+#include <qmovie.h>
+
+
+#include <kdebug.h>
+
+#include "plabel.h"
+
+PObject *
+PLabel::createWidget(CreateArgs &ca)
+{
+ PLabel *pw = new PLabel(ca.parent);
+ QLabel *le;
+ if(ca.fetchedObj != 0 && ca.fetchedObj->inherits("QLabel") == TRUE){
+ le = (QLabel *) ca.fetchedObj;
+ pw->setDeleteAble(FALSE);
+ }
+ else if(ca.parent != 0 && ca.parent->widget()->isWidgetType() == TRUE)
+ le = new QLabel((QWidget *) ca.parent->widget());
+ else
+ le = new QLabel((QWidget *)0L);
+ pw->setWidget(le);
+ pw->setWidgetId(ca.pwI);
+ return pw;
+}
+
+
+PLabel::PLabel(PObject *parent)
+ : PFrame(parent)
+{
+ // kdDebug(5008) << "PLabel PLabel called" << endl;
+ label = 0;
+ setWidget(label);
+}
+
+PLabel::~PLabel()
+{
+ // kdDebug(5008) << "PLabel: in destructor" << endl;
+ /*
+ delete widget(); // Delete the frame
+ label=0; // Set it to 0
+ setWidget(label); // Now set all widget() calls to 0.
+ */
+}
+
+void PLabel::messageHandler(int fd, PukeMessage *pm)
+{
+ PukeMessage pmRet;
+ switch(pm->iCommand){
+ case PUKE_LABEL_SETTEXT:
+ if(!checkWidget())
+ return;
+
+ widget()->setText(pm->cArg);
+ pmRet.iCommand = - pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ case PUKE_LABEL_SETPIXMAP:
+ if(!checkWidget())
+ return;
+
+ widget()->setPixmap(QPixmap(pm->cArg));
+ pmRet.iCommand = - pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ case PUKE_LABEL_SETMOVIE:
+ if(!checkWidget())
+ return;
+
+ widget()->setMovie(QMovie(pm->cArg));
+ pmRet.iCommand = - pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ case PUKE_LABEL_SETALIGNMENT:
+ if(!checkWidget())
+ return;
+
+ widget()->setAlignment(pm->iArg);
+ pmRet.iCommand = - pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ default:
+ PFrame::messageHandler(fd, pm);
+ }
+}
+
+void PLabel::setWidget(QObject *_l)
+{
+ if(_l != 0 && _l->inherits("QLabel") == FALSE)
+ {
+ errorInvalidSet(_l);
+ return;
+ }
+
+ label = (QLabel *) _l;
+ PWidget::setWidget(_l);
+
+}
+
+
+QLabel *PLabel::widget()
+{
+ return label;
+}
+
+bool PLabel::checkWidget(){
+ if(widget() == 0){
+ kdDebug(5008) << "PLabel: No Widget set" << endl;
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+#include "plabel.moc"
+
diff --git a/ksirc/puke/plabel.h b/ksirc/puke/plabel.h
new file mode 100644
index 00000000..c53705b1
--- /dev/null
+++ b/ksirc/puke/plabel.h
@@ -0,0 +1,34 @@
+#ifndef PLABEL_H
+#define PLABEL_H
+
+class PLabel;
+
+#include <qlabel.h>
+#include "pmessage.h"
+#include "pframe.h"
+#include "controller.h"
+
+class PLabel : public PFrame
+{
+ Q_OBJECT
+public:
+ static PObject *createWidget(CreateArgs &ca);
+
+ PLabel ( PObject * parent );
+ virtual ~PLabel ();
+
+ virtual void messageHandler(int fd, PukeMessage *pm);
+
+ virtual void setWidget(QObject *_obj = 0);
+ virtual QLabel *widget();
+
+public slots:
+
+protected:
+ bool checkWidget();
+
+private:
+ QLabel *label;
+};
+
+#endif
diff --git a/ksirc/puke/plabel.pm b/ksirc/puke/plabel.pm
new file mode 100644
index 00000000..bc557b5e
--- /dev/null
+++ b/ksirc/puke/plabel.pm
@@ -0,0 +1,105 @@
+
+&::PukeSendMessage($PUKE_WIDGET_LOAD,
+ $::PUKE_CONTROLLER,
+ $PWIDGET_LABEL,
+ "plabel.so",
+ sub { my %ARG = %{shift()};
+ if($ARG{'iArg'} == 1){
+ print "*E* PLabel Load failed!\n";
+ }
+ }
+ );
+
+package PLabel;
+@ISA = qw(PFrame);
+use strict;
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new($class, @_);
+
+ $self->{widgetType} = $::PWIDGET_LABEL;
+
+ if($class eq 'PLabel'){
+ $self->create();
+ }
+
+ return $self;
+
+}
+
+sub setText {
+ my $self = shift;
+
+ my $text = shift;
+
+ $self->{text} = $text;
+
+ # Don't need the ouput since GET_TEXT_ACK will be called and
+ # we'll set it there
+ $self->sendMessage('iCommand' => $::PUKE_LABEL_SETTEXT,
+ 'iArg' => 0,
+ 'cArg' => $text,
+ 'CallBack' => sub {});
+
+}
+
+sub setPixmap {
+ my $self = shift;
+
+ my $text = shift;
+
+ $self->{text} = "***PIXMAP***" . $text;
+
+ # Don't need the ouput since GET_TEXT_ACK will be called and
+ # we'll set it there
+ $self->sendMessage('iCommand' => $::PUKE_LABEL_SETPIXMAP,
+ 'cArg' => $text,
+ 'CallBack' => sub {});
+
+}
+
+sub setMovie {
+ my $self = shift;
+
+ my $text = shift;
+
+ $self->{text} = "***MOVIE***" . $text;
+
+ # Don't need the ouput since GET_TEXT_ACK will be called and
+ # we'll set it there
+ $self->sendMessage('iCommand' => $::PUKE_LABEL_SETMOVIE,
+ 'cArg' => $text,
+ 'CallBack' => sub {});
+
+}
+
+
+sub text {
+ my $self = shift;
+
+ return $self->{text};
+}
+
+
+
+sub setAlignment {
+ my $self = shift;
+
+ my $align = shift;
+
+
+ $self->{align} = $align;
+
+ # Don't need the ouput since GET_TEXT_ACK will be called and
+ # we'll set it there
+ $self->sendMessage('iCommand' => $::PUKE_LABEL_SETALIGNMENT,
+ 'iArg' => $align,
+ 'CallBack' => sub {});
+
+}
+
+
+
+package main;
+
diff --git a/ksirc/puke/playout.cpp b/ksirc/puke/playout.cpp
new file mode 100644
index 00000000..9690f418
--- /dev/null
+++ b/ksirc/puke/playout.cpp
@@ -0,0 +1,157 @@
+#include <stdio.h>
+
+
+#include "playout.h"
+#include "commands.h"
+
+PLayout::PLayout(QObject *pobject)
+ : PObject(pobject)
+{
+ // Connect slots as needed
+ setWidget();
+}
+
+PLayout::~PLayout()
+{
+ // kdDebug(5008) << "PObject: in destructor" << endl;
+ /*
+ delete widget();
+ layout = 0;
+ setWidget();
+ */
+}
+
+PObject *PLayout::createWidget(CreateArgs &ca)
+{
+ PLayout *pw = new PLayout(ca.parent);
+ QBoxLayout *qbl;
+ int direction, border, iType, iParent;
+ // Retreive the border and direction information out of the
+ // carg string
+ if(sscanf(ca.pm->cArg, "%d\t%d\t%d\t%d", &iParent, &iType, &direction, &border) < 4)
+ throw(errorCommandFailed(-ca.pm->iCommand, -1));
+
+ if((ca.parent != 0) &&
+ (ca.parent->widget()->isWidgetType() == TRUE)){
+ qbl = new QBoxLayout((QWidget *) ca.parent->widget(), (QBoxLayout::Direction) direction, border);
+ // kdDebug(5008) << "Creating layout with parent: " << parent.iWinId << endl;
+
+ }
+ else{
+ qbl = new QBoxLayout((QBoxLayout::Direction) direction, border);
+ // kdDebug(5008) << "Creating layout NO PARENT" << endl;
+ }
+ pw->setWidget(qbl);
+ pw->setWidgetId(ca.pwI);
+ pw->setPukeController(ca.pc);
+ return pw;
+}
+
+void PLayout::messageHandler(int fd, PukeMessage *pm)
+{
+ PukeMessage pmRet;
+
+// kdDebug(5008) << "In PLayout: " << pm->iCommand << endl;
+
+ if(pm->iCommand == PUKE_LAYOUT_ADDWIDGET){
+ if(pm->iTextSize != 2*sizeof(char)){
+ qWarning("PLayout/addwidget: incorrent cArg size, bailing out. Needed: %u wanted: %d\n", sizeof(int), pm->iTextSize);
+ pmRet.iCommand = PUKE_LAYOUT_ADDWIDGET_ACK; // ack the add widget
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 1;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ return;
+ }
+ widgetId wiWidget;
+ wiWidget.fd = fd;
+ wiWidget.iWinId = pm->iArg;
+ PWidget *pw = controller()->id2pwidget(&wiWidget);
+ // kdDebug(5008) << "Adding widget with stretch: " << (int) pm->cArg[0] << " and align: " << // (int) pm->cArg[1] << endl;
+ widget()->addWidget(pw->widget(), pm->cArg[0], pm->cArg[1]);
+
+ pmRet.iCommand = PUKE_LAYOUT_ADDWIDGET_ACK; // ack the add widget
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ }
+ else if(pm->iCommand == PUKE_LAYOUT_ADDLAYOUT){
+ if(pm->iTextSize != sizeof(char)){
+ qWarning("PLayout: incorrent cArg size, bailing out. Needed: %u wanted: %d\n", sizeof(int), pm->iTextSize);
+ pmRet.iCommand = PUKE_LAYOUT_ADDLAYOUT_ACK; // ack the add widget
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 1;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ return;
+ }
+ PObject *pld = controller()->id2pobject(fd, pm->iWinId);
+ PObject *pls = controller()->id2pobject(fd, pm->iArg);
+ if( (pld->widget()->inherits("QBoxLayout") == FALSE) || (pls->widget()->inherits("QBoxLayout") == FALSE))
+ throw(errorCommandFailed(PUKE_LAYOUT_ADDLAYOUT_ACK, 1));
+ PLayout *plbd = (PLayout *) pld;
+ PLayout *plbs = (PLayout *) pls;
+ plbd->widget()->addLayout(plbs->widget(), pm->cArg[0]);
+
+ pmRet.iCommand = PUKE_LAYOUT_ADDLAYOUT_ACK; // ack the add widget
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ }
+ else if(pm->iCommand == PUKE_LAYOUT_ADDSTRUT){
+ PObject *po = controller()->id2pobject(fd, pm->iWinId);
+ if(po->widget()->inherits("PBoxLayout") != TRUE)
+ throw(errorCommandFailed(PUKE_LAYOUT_ADDSTRUT_ACK, 1));
+ PLayout *pl = (PLayout *) po;
+
+ pl->widget()->addStrut(pm->iArg);
+
+ pmRet.iCommand = PUKE_LAYOUT_ADDSTRUT_ACK; // ack the add widget
+ pmRet.iWinId = pm->iWinId;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ }
+ else if(pm->iCommand == PUKE_LAYOUT_ACTIVATE){
+ PObject *po = controller()->id2pobject(fd, pm->iWinId);
+ if(po->widget()->inherits("PBoxLayout") != TRUE)
+ throw(errorCommandFailed(PUKE_LAYOUT_ACTIVATE_ACK, 1));
+ PLayout *pl = (PLayout *) po;
+
+ pmRet.iArg = 0; // setup failure case
+ pl->widget()->activate();
+
+ pmRet.iCommand = PUKE_LAYOUT_ACTIVATE_ACK; // ack the add widget
+ pmRet.iWinId = pm->iWinId;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ }
+ else {
+ PObject::messageHandler(fd, pm);
+ }
+
+}
+
+void PLayout::setWidget(QObject *_layout)
+{
+ // kdDebug(5008) << "PObject setwidget called" << endl;
+ if(_layout != 0 && _layout->inherits("QBoxLayout") == FALSE)
+ {
+ errorInvalidSet(_layout);
+ return;
+ }
+
+ layout = (QBoxLayout *) _layout;
+ PObject::setWidget(_layout);
+
+}
+
+QBoxLayout *PLayout::widget()
+{
+ return layout;
+}
+
+
+#include "playout.moc"
+
diff --git a/ksirc/puke/playout.h b/ksirc/puke/playout.h
new file mode 100644
index 00000000..4aec01a1
--- /dev/null
+++ b/ksirc/puke/playout.h
@@ -0,0 +1,42 @@
+#ifndef PLAYOUT_H
+#define PLAYOUT_H
+
+class PLayout;
+
+#include <qobject.h>
+#include <qlayout.h>
+#include "pmessage.h"
+#include "pobject.h"
+
+class PLayout : public PObject
+{
+ Q_OBJECT
+public:
+ static PObject *createWidget(CreateArgs &ca);
+
+ PLayout(QObject *parent = 0);
+ virtual ~PLayout();
+
+ /**
+ * Handles messages from dsirc
+ * PObject can't get messages so return an error
+ */
+ virtual void messageHandler(int fd, PukeMessage *pm);
+
+ /**
+ * Sets the current opbect
+ */
+ virtual void setWidget(QObject *qb = 0x0);
+
+ /**
+ * Returns the current object
+ */
+ virtual QBoxLayout *widget();
+
+private:
+
+ QBoxLayout *layout;
+
+};
+
+#endif
diff --git a/ksirc/puke/plined.cpp b/ksirc/puke/plined.cpp
new file mode 100644
index 00000000..3f3e6a09
--- /dev/null
+++ b/ksirc/puke/plined.cpp
@@ -0,0 +1,153 @@
+#include <stdio.h>
+
+
+#include <kdebug.h>
+
+#include "plined.h"
+
+PObject *
+PLineEdit::createWidget(CreateArgs &ca)
+{
+ PLineEdit *pw = new PLineEdit(ca.parent);
+ QLineEdit *le;
+ if(ca.parent != 0 && ca.parent->widget()->isWidgetType() == TRUE)
+ le = new QLineEdit((QWidget *) ca.parent->widget());
+ else
+ le = new QLineEdit(0L);
+ pw->setWidget(le);
+ pw->setWidgetId(ca.pwI);
+ return pw;
+}
+
+
+PLineEdit::PLineEdit(PObject *parent)
+ : PWidget(parent)
+{
+ // kdDebug(5008) << "PLineEdit PLineEdit called" << endl;
+ lineedit = 0;
+ setWidget(lineedit);
+}
+
+PLineEdit::~PLineEdit()
+{
+ // kdDebug(5008) << "PLineEdit: in destructor" << endl;
+ /*
+ delete widget(); // Delete the frame
+ lineedit=0; // Set it to 0
+ setWidget(lineedit); // Now set all widget() calls to 0.
+ */
+}
+
+void PLineEdit::messageHandler(int fd, PukeMessage *pm)
+{
+ PukeMessage pmRet;
+ switch(pm->iCommand){
+ case PUKE_LINED_SET_MAXLENGTH:
+ if(widget() == 0){
+ kdDebug(5008) << "PLineEdit: No Widget set" << endl;
+ return;
+ }
+ widget()->setMaxLength(pm->iArg);
+ pmRet.iCommand = - pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = widget()->maxLength();
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ case PUKE_LINED_SET_ECHOMODE:
+ if(widget() == 0){
+ kdDebug(5008) << "PLineEdit: No Widget set" << endl;
+ return;
+ }
+ widget()->setEchoMode((QLineEdit::EchoMode) pm->iArg);
+ pmRet.iCommand = - pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = widget()->echoMode();
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ case PUKE_LINED_SET_TEXT:
+ if(widget() == 0){
+ kdDebug(5008) << "PLineEdit: No Widget set" << endl;
+ return;
+ }
+ kdDebug(5008) << "PukeLine Edit: Got: " << pm->cArg << endl;
+ widget()->setText(pm->cArg);
+ pmRet.iCommand = - pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.iTextSize = strlen(widget()->text());
+ pmRet.cArg = new char[strlen(widget()->text())+1];
+ strcpy(pmRet.cArg, widget()->text());
+ emit outputMessage(fd, &pmRet);
+ delete[] pmRet.cArg;
+ break;
+ case PUKE_LINED_GET_TEXT:
+ if(widget() == 0){
+ kdDebug(5008) << "PLineEdit: No Widget set" << endl;
+ return;
+ }
+ pmRet.iCommand = - pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.iTextSize = strlen(widget()->text());
+ pmRet.cArg = new char[strlen(widget()->text())+1];
+ strcpy(pmRet.cArg, widget()->text());
+ emit outputMessage(fd, &pmRet);
+ delete[] pmRet.cArg;
+ break;
+ default:
+ PWidget::messageHandler(fd, pm);
+ }
+}
+
+void PLineEdit::setWidget(QObject *_le)
+{
+ if(_le != 0 && _le->inherits("QLineEdit") == FALSE)
+ {
+ errorInvalidSet(_le);
+ return;
+ }
+
+ lineedit = (QLineEdit *) _le;
+ if(lineedit != 0){
+ connect(lineedit, SIGNAL(textChanged(const char *)),
+ this, SLOT(updateText(const char *)));
+ connect(lineedit, SIGNAL(returnPressed()),
+ this, SLOT(returnPress()));
+ }
+ PWidget::setWidget(_le);
+
+}
+
+
+QLineEdit *PLineEdit::widget()
+{
+ return lineedit;
+}
+
+void PLineEdit::updateText(const char *text){
+ PukeMessage pmRet;
+
+ pmRet.iCommand = PUKE_LINED_GET_TEXT_ACK;
+ pmRet.iWinId = widgetIden().iWinId;
+ pmRet.iArg = 0;
+ pmRet.iTextSize = strlen(text);
+ pmRet.cArg = new char[strlen(text)+1];
+ strcpy(pmRet.cArg, text);
+ emit outputMessage(widgetIden().fd, &pmRet);
+ delete[] pmRet.cArg;
+}
+
+void PLineEdit::returnPress() {
+ PukeMessage pmRet;
+
+ pmRet.iCommand = PUKE_LINED_RETURN_PRESSED_ACK;
+ pmRet.iWinId = widgetIden().iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(widgetIden().fd, &pmRet);
+}
+
+#include "plined.moc"
+
diff --git a/ksirc/puke/plined.h b/ksirc/puke/plined.h
new file mode 100644
index 00000000..78f04bdf
--- /dev/null
+++ b/ksirc/puke/plined.h
@@ -0,0 +1,33 @@
+#ifndef PLINEEDIT_H
+#define PLINEEDIT_H
+
+class PLineEdit;
+
+#include <qlineedit.h>
+#include "pmessage.h"
+#include "pwidget.h"
+#include "controller.h"
+
+class PLineEdit : public PWidget
+{
+ Q_OBJECT
+public:
+ static PObject *createWidget(CreateArgs &ca);
+
+ PLineEdit ( PObject * parent );
+ virtual ~PLineEdit ();
+
+ virtual void messageHandler(int fd, PukeMessage *pm);
+
+ virtual void setWidget(QObject *_f);
+ virtual QLineEdit *widget();
+
+public slots:
+ void updateText(const char *);
+ void returnPress();
+
+private:
+ QLineEdit *lineedit;
+};
+
+#endif
diff --git a/ksirc/puke/plined.pm b/ksirc/puke/plined.pm
new file mode 100644
index 00000000..fbff6f96
--- /dev/null
+++ b/ksirc/puke/plined.pm
@@ -0,0 +1,84 @@
+
+&::PukeSendMessage($PUKE_WIDGET_LOAD,
+ $::PUKE_CONTROLLER,
+ $PWIDGET_LINED,
+ "plined.so",
+ sub { my %ARG = %{shift()};
+ if($ARG{'iArg'} == 1){
+ print "*E* PLineEdit Load failed!\n";
+ }
+ }
+ );
+
+package PLineEdit;
+@ISA = qw(PWidget);
+use strict;
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new($class, @_);
+
+ $self->{widgetType} = $::PWIDGET_LINED;
+ $self->{maxLength} = -1;
+
+ if($class eq 'PLineEdit'){
+ $self->create();
+ }
+
+ $self->installHandler($::PUKE_WIDGET_EVENT_TIMER, sub{});
+ $self->installHandler($::PUKE_LINED_GET_TEXT_ACK, sub{
+ my %ARG = %{shift()};
+ $ARG{'cArg'} =~ s/^([^\000]*).*/$1/;
+ $self->{text} = $ARG{'cArg'};});
+
+ return $self;
+
+}
+
+sub setMaxLength {
+ my $self = shift;
+
+ my $length = shift;
+
+ $self->{maxLength} = $length;
+ $self->sendMessage('iCommand' => $::PUKE_LINED_SET_MAXLENGTH,
+ 'iArg' => $length,
+ 'CallBack' => sub {my %ARG = %{shift()};
+ $self->{maxLength} = $ARG{'iArg'};});
+
+}
+
+sub setEchoMode {
+ my $self = shift;
+
+ my $mode = shift;
+
+ $self->sendMessage('iCommand' => $::PUKE_LINED_SET_ECHOMODE,
+ 'iArg' => $mode,
+ 'CallBack' => sub {my %ARG = %{shift()};
+ $self->{echoMode} = $ARG{'iArg'};});
+
+}
+
+sub setText {
+ my $self = shift;
+
+ my $text = shift;
+
+ $self->{text} = $text;
+
+ # Don't need the ouput since GET_TEXT_ACK will be called and
+ # we'll set it there
+ $self->sendMessage('iCommand' => $::PUKE_LINED_SET_TEXT,
+ 'cArg' => $text,
+ 'CallBack' => sub {});
+
+}
+
+sub text {
+ my $self = shift;
+
+ return $self->{text};
+}
+
+package main;
diff --git a/ksirc/puke/plistbox.cpp b/ksirc/puke/plistbox.cpp
new file mode 100644
index 00000000..482e08c7
--- /dev/null
+++ b/ksirc/puke/plistbox.cpp
@@ -0,0 +1,224 @@
+#include <kdebug.h>
+
+
+#include "plistbox.h"
+
+PObject *
+PListBox::createWidget(CreateArgs &ca)
+{
+ PListBox *plb = new PListBox(ca.parent);
+ QListBox *lb;
+ if(ca.fetchedObj != 0 && ca.fetchedObj->inherits("QListBox") == TRUE){
+ lb = (QListBox *) ca.fetchedObj;
+ plb->setDeleteAble(FALSE);
+ }
+ else if(ca.parent != 0 && ca.parent->widget()->isWidgetType() == TRUE)
+ lb = new QListBox((QWidget *) ca.parent->widget());
+ else
+ lb = new QListBox();
+ plb->setWidget(lb);
+ plb->setWidgetId(ca.pwI);
+ return plb;
+}
+
+
+PListBox::PListBox(PObject *parent)
+ : PFrame(parent)
+{
+ // kdDebug(5008) << "PListBox PListBox called" << endl;
+ lb = 0;
+ setWidget(lb);
+}
+
+PListBox::~PListBox()
+{
+ // kdDebug(5008) << "PListBox: in destructor" << endl;
+ /*
+ delete widget(); // Delete the frame
+ lb=0; // Set it to 0
+ setWidget(lb); // Now set all widget() calls to 0.
+ */
+}
+
+void PListBox::messageHandler(int fd, PukeMessage *pm)
+{
+ PukeMessage pmRet;
+ switch(pm->iCommand){
+ case PUKE_LISTBOX_INSERT:
+ if(!checkWidget())
+ return;
+
+ widget()->insertItem(pm->cArg, pm->iArg);
+ pmRet.iCommand = - pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = widget()->count();
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ case PUKE_LISTBOX_INSERT_SORT:
+ if(!checkWidget())
+ return;
+
+ widget()->insertItem(pm->cArg);
+ widget()->sort();
+ pmRet.iCommand = - pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = widget()->count();
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ case PUKE_LISTBOX_INSERT_PIXMAP:
+ if(!checkWidget())
+ return;
+
+ widget()->insertItem(QPixmap(pm->cArg), pm->iArg);
+ pmRet.iCommand = - pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = widget()->count();
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ case PUKE_LISTBOX_HIGHLIGHT:
+ if(!checkWidget())
+ return;
+
+ widget()->setCurrentItem(pm->iArg);
+ pmRet.iCommand = - pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = widget()->currentItem();
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ case PUKE_LISTBOX_REMOVE:
+ if(!checkWidget())
+ return;
+
+ widget()->removeItem(pm->iArg);
+
+ pmRet.iCommand = - pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ case PUKE_LISTBOX_GETTEXT:
+ if(!checkWidget())
+ return;
+
+ pmRet.iCommand = - pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ if(widget()->text(pm->iArg) != 0x0){
+ pmRet.iArg = 1;
+ pmRet.iTextSize = strlen(widget()->text(pm->iArg));
+ pmRet.cArg = new char[strlen(widget()->text(pm->iArg))+1];
+ strcpy(pmRet.cArg, widget()->text(pm->iArg));
+ emit outputMessage(fd, &pmRet);
+ delete[] pmRet.cArg;
+ }
+ else{
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ }
+ break;
+ case PUKE_LISTBOX_SET_SCROLLBAR:
+ widget()->setVScrollBarMode( (bool) pm->iArg ? QListBox::AlwaysOn : QListBox::AlwaysOff );
+ pmRet.iCommand = PUKE_LISTBOX_SET_SCROLLBAR_ACK;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ case PUKE_LISTBOX_SET_AUTO_SCROLLBAR:
+ widget()->setVScrollBarMode( (bool) pm->iArg ? QListBox::Auto : QListBox::AlwaysOff );
+ pmRet.iCommand = PUKE_LISTBOX_SET_AUTO_SCROLLBAR_ACK;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ case PUKE_LISTBOX_CLEAR:
+ widget()->clear();
+ pmRet.iCommand = PUKE_LISTBOX_CLEAR_ACK;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ default:
+ PFrame::messageHandler(fd, pm);
+ }
+}
+
+void PListBox::setWidget(QObject *_lb)
+{
+ if(_lb != 0 && _lb->inherits("QListBox") == FALSE)
+ {
+ errorInvalidSet(_lb);
+ return;
+ }
+
+ lb = (QListBox *) _lb;
+ if(lb != 0){
+ connect(lb, SIGNAL(highlighted(int)),
+ this, SLOT(highlighted(int)));
+ connect(lb, SIGNAL(selected(int)),
+ this, SLOT(selected(int)));
+ }
+ PFrame::setWidget(lb);
+
+}
+
+
+QListBox *PListBox::widget()
+{
+ return lb;
+}
+
+
+void PListBox::highlighted(int index) {
+ PukeMessage pmRet;
+
+ kdDebug(5008) << "Got highlight" << endl;
+ pmRet.iCommand = PUKE_LISTBOX_HIGHLIGHTED_ACK;
+ pmRet.iWinId = widgetIden().iWinId;
+ pmRet.iArg = index;
+ if(widget()->text(index) != 0){
+ pmRet.iTextSize = strlen(widget()->text(index));
+ pmRet.cArg = new char[strlen(widget()->text(index)) + 1];
+ strcpy(pmRet.cArg, widget()->text(index));
+ }
+ else
+ pmRet.cArg = 0;
+ emit outputMessage(widgetIden().fd, &pmRet);
+ delete[] pmRet.cArg;
+}
+
+void PListBox::selected(int index) {
+ PukeMessage pmRet;
+
+ kdDebug(5008) << "Got selected" << endl;
+ pmRet.iCommand = PUKE_LISTBOX_SELECTED_ACK;
+ pmRet.iWinId = widgetIden().iWinId;
+ pmRet.iArg = index;
+ if(widget()->text(index) != 0){
+ pmRet.iTextSize = strlen(widget()->text(index));
+ pmRet.cArg = new char[strlen(widget()->text(index)) + 1];
+ strcpy(pmRet.cArg, widget()->text(index));
+ }
+ else
+ pmRet.cArg = 0;
+ emit outputMessage(widgetIden().fd, &pmRet);
+ delete[] pmRet.cArg;
+}
+
+bool PListBox::checkWidget(){
+ if(widget() == 0){
+ kdDebug(5008) << "PListBox: No Widget set" << endl;
+ return FALSE;
+ }
+ return TRUE;
+}
+
+#include "plistbox.moc"
+
diff --git a/ksirc/puke/plistbox.h b/ksirc/puke/plistbox.h
new file mode 100644
index 00000000..cad454a8
--- /dev/null
+++ b/ksirc/puke/plistbox.h
@@ -0,0 +1,37 @@
+#ifndef PLISTBOX_H
+#define PLISTBOX_H
+
+class PListBox;
+
+#include <qlistbox.h>
+#include "pmessage.h"
+#include "ptablevw.h"
+#include "controller.h"
+
+class PListBox : public PFrame
+{
+ Q_OBJECT
+public:
+ static PObject *createWidget(CreateArgs &ca);
+
+ PListBox ( PObject * parent );
+ virtual ~PListBox ();
+
+ virtual void messageHandler(int fd, PukeMessage *pm);
+
+ virtual void setWidget(QObject *_lb);
+ virtual QListBox *widget();
+
+public slots:
+ void highlighted(int);
+ void selected(int);
+
+protected:
+ bool checkWidget();
+
+private:
+ QListBox *lb;
+
+};
+
+#endif
diff --git a/ksirc/puke/plistbox.pm b/ksirc/puke/plistbox.pm
new file mode 100644
index 00000000..2e7af417
--- /dev/null
+++ b/ksirc/puke/plistbox.pm
@@ -0,0 +1,196 @@
+
+&::PukeSendMessage($::PUKE_WIDGET_LOAD,
+ $::PUKE_CONTROLLER,
+ $::PWIDGET_LISTBOX,
+ "plistbox.so",
+ sub { my %ARG = %{shift()};
+ if($ARG{'iArg'} == 1){
+ print "*E* PListBox Load failed!\n";
+ }
+ }
+ );
+
+
+package PListBox;
+@ISA = qw(PTableView);
+use strict;
+
+if($PListBox::usage == undef){
+ $PListBox::usage = 0;
+}
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new($class, @_);
+
+ $self->{widgetType} = $::PWIDGET_LISTBOX;
+
+ if($class eq 'PListBox'){
+ $self->create();
+ }
+
+ $self->{count} = 0;
+ $self->{items} = ();
+
+ $self->installHandler($::PUKE_LISTBOX_SELECTED_ACK, sub{$self->selected(@_)});
+
+ return $self;
+
+}
+
+sub DESTROY {
+ my $self = shift;
+ $self->SUPER::DESTROY(@_);
+ $PListBox::usage--;
+ if($PListBox::usage == 0){
+ &::PukeSendMessage($::PUKE_WIDGET_UNLOAD,
+ 0,
+ $::PWIDGET_LISTBOX,
+ "",
+ sub {}
+ );
+
+ }
+}
+
+sub insertText {
+ my $self = shift;
+
+ my $text = shift;
+ my $index = shift;
+ my $rindex = $index;
+
+ if($index < 0 || $index >= $self->{count}){
+ $rindex = $self->{count};
+ }
+
+ $self->{count} ++;
+
+ # Don't need the ouput since GET_TEXT_ACK will be called and
+ # we'll set it there
+ $self->sendMessage('iCommand' => $::PUKE_LISTBOX_INSERT,
+ 'iArg' => $rindex,
+ 'cArg' => $text,
+ 'CallBack' => sub {});
+
+}
+
+sub text {
+ my $self = shift;
+ my $index = shift;
+
+ my %arg = $self->sendMessage('iCommand' => $::PUKE_LISTBOX_GETTEXT,
+ 'iArg' => $index,
+ 'WaitFor' => 1);
+
+ if($arg{'iArg'} != 1){
+ return undef;
+ }
+ $arg{'cArg'} =~ s/\000//g;
+ return $arg{'cArg'};
+}
+
+sub insertPixmap {
+ my $self = shift;
+
+ my $file = shift;
+ my $index = shift;
+ my $rindex = $index;
+
+ if($index < 0 || $index >= $self->{count}){
+ $rindex = $self->{count};
+ }
+ # $self->{items}->[$rindex] = "***PIXMAP***" . $file;
+ $self->{count} ++;
+
+
+ # Don't need the ouput since GET_TEXT_ACK will be called and
+ # we'll set it there
+ $self->sendMessage('iCommand' => $::PUKE_LISTBOX_INSERT_PIXMAP,
+ 'iArg' => $rindex,
+ 'cArg' => $file,
+ 'CallBack' => sub {});
+
+}
+sub selected {
+ my $self = shift;
+ my %ARGS = %{shift()};
+
+ $self->{current} = $ARGS{'iArg'};
+ $ARGS{'cArg'} =~ s/\000//g;
+ $self->{currentText} = $ARGS{'cArg'};
+}
+
+sub current {
+ my $self = shift;
+ return $self->{current};
+}
+
+sub currentText {
+ my $self = shift;
+ return $self->text($self->{current});
+}
+
+sub setCurrentItem {
+ my $self = shift;
+
+ my $index = shift;
+ my $rindex = $index;
+
+ # Async call be default, no need to wait result
+ $self->sendMessage('iCommand' => $::PUKE_LISTBOX_HIGHLIGHT,
+ 'iArg' => $index,
+ 'CallBack' => sub {});
+
+
+}
+
+sub removeItem {
+ my $self = shift;
+
+ my $index = shift;
+
+ $self->{count} --;
+
+ # Async call be default, no need to wait result
+ $self->sendMessage('iCommand' => $::PUKE_LISTBOX_REMOVE,
+ 'iArg' => $index,
+ 'CallBack' => sub {});
+
+
+}
+
+sub setScrollBar {
+ my $self = shift;
+
+ $self->sendMessage('iCommand' => $::PUKE_LISTBOX_SET_SCROLLBAR,
+ 'iArg' => shift(),
+ 'CallBack' => sub {});
+
+}
+
+sub setAutoScrollBar {
+ my $self = shift;
+
+ $self->sendMessage('iCommand' => $::PUKE_LISTBOX_SET_AUTO_SCROLLBAR,
+ 'iArg' => shift(),
+ 'CallBack' => sub {});
+
+}
+
+sub clear {
+ my $self = shift;
+
+ $self->{count} = 0;
+ $self->{items} = ();
+
+ $self->sendMessage('iCommand' => $::PUKE_LISTBOX_CLEAR,
+ 'CallBack' => sub {});
+
+}
+
+
+
+package main;
+
+1;
diff --git a/ksirc/puke/pmenudta.cpp b/ksirc/puke/pmenudta.cpp
new file mode 100644
index 00000000..30b375fc
--- /dev/null
+++ b/ksirc/puke/pmenudta.cpp
@@ -0,0 +1,79 @@
+#include "pmenudta.h"
+#include "pobject.h"
+#include <qpopupmenu.h>
+
+
+PMenuData::PMenuData(PObject *_child)
+: PObject()
+{
+ child = _child;
+ connect(this, SIGNAL(outputMessage(int, PukeMessage*)),
+ child, SIGNAL(outputMessage(int, PukeMessage*)));
+}
+
+PMenuData::~PMenuData()
+{
+ // We don't nuke anything since we're kind of abstract and we let the parent take care of it
+}
+
+void PMenuData::messageHandler(int , PukeMessage *)
+{
+ // We don't do anything since we should never ben involked directly
+}
+
+bool PMenuData::menuMessageHandler(int fd, PukeMessage *pm)
+{
+ PukeMessage pmRet;
+ int id = 0;
+ switch(pm->iCommand){
+ case PUKE_MENUDATA_INSERT_TEXT:
+ {
+ QPopupMenu *widget = (QPopupMenu *) child->widget();
+ id = widget->insertItem(pm->cArg);
+ if(pm->iArg > 0){
+ widget->setAccel(pm->iArg, id);
+ }
+
+ pmRet.iCommand = PUKE_MENUDATA_INSERT_TEXT_ACK;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = id;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ }
+ case PUKE_MENUDATA_INSERT_PIXMAP:
+ {
+ QPopupMenu *widget = (QPopupMenu *) child->widget();
+ id = widget->insertItem(QPixmap(pm->cArg));
+ if(pm->iArg > 0){
+ widget->setAccel(pm->iArg, id);
+ }
+
+ pmRet.iCommand = PUKE_MENUDATA_INSERT_PIXMAP_ACK;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = id;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ }
+ case PUKE_MENUDATA_REMOVE_ITEM:
+ {
+ QPopupMenu *widget = (QPopupMenu *) child->widget();
+ widget->removeItem(pm->iArg);
+
+ pmRet.iCommand = PUKE_MENUDATA_REMOVE_ITEM_ACK;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = pm->iArg;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ }
+
+ default:
+ return FALSE;
+ }
+ return TRUE;
+}
+
+#include "pmenudta.moc"
+
diff --git a/ksirc/puke/pmenudta.h b/ksirc/puke/pmenudta.h
new file mode 100644
index 00000000..0c3bfc6a
--- /dev/null
+++ b/ksirc/puke/pmenudta.h
@@ -0,0 +1,57 @@
+#ifndef PMENUDATA_H
+#define PMENUDATA_H
+
+class PMenuData;
+
+#include <qobject.h>
+#include <qmenudata.h>
+#include "pmessage.h"
+#include "pframe.h"
+#include "pobject.h"
+#include "controller.h"
+
+/**
+ * Little helper class here gives us access to needed info inside
+ * QMenuData
+ */
+
+class PMenuDataHelper : public QMenuData
+{
+public:
+ PMenuDataHelper(QMenuData &qmd) {
+ memcpy(this, &qmd, sizeof(QMenuData));
+ }
+ int active() {
+ return QMenuData::actItem;
+ }
+ int actItem;
+};
+
+/**
+ * We're subclased off QMenuData so we can access it's internal proteted vars
+ * We do not initialize NOR create it!!!!
+ */
+
+class PMenuData : public PObject
+{
+ Q_OBJECT
+public:
+ PMenuData (PObject *_child);
+ virtual ~PMenuData ();
+
+ virtual void messageHandler(int fd, PukeMessage *pm);
+ virtual bool menuMessageHandler(int fd, PukeMessage *pm);
+
+// virtual void setWidget(QMenuData *_qmd);
+ // virtual QMenuData *widget();
+
+ virtual int activeItem()
+ {
+ return PMenuDataHelper(*((QMenuData *) child->widget())).active();
+ }
+
+ private:
+ PObject *child;
+};
+
+#endif
diff --git a/ksirc/puke/pmenudta.pm b/ksirc/puke/pmenudta.pm
new file mode 100644
index 00000000..f98acf91
--- /dev/null
+++ b/ksirc/puke/pmenudta.pm
@@ -0,0 +1,60 @@
+&::PukeSendMessage($PUKE_WIDGET_LOAD,
+ $PUKE_CONTROLLER,
+ $PWIDGET_MENUDATA,
+ "pmenudta.so",
+ sub { my %ARG = %{shift()};
+ if($ARG{'iArg'} == 1){
+ print "*E* PMenuData Load failed!\n";
+ }
+ }
+ );
+
+package PMenuData;
+use strict;
+
+#
+# Only methods, constructor must create $self elsewhere and must of PBase type
+#
+
+sub new {
+ print "*E* Can't call new for this class\n";
+}
+
+sub insertText {
+ my $self = shift;
+
+ my $text = shift;
+
+ my %ARG = $self->sendMessage('iCommand' => $::PUKE_MENUDATA_INSERT_TEXT,
+ 'cArg' => $text,
+ 'WaitFor' => 1);
+
+ return $ARG{'iArg'};
+}
+
+sub insertPixmap {
+ my $self = shift;
+
+ my $text = shift;
+
+ my %ARG = $self->sendMessage('iCommand' => $::PUKE_MENUDATA_INSERT_PIXMAP,
+ 'cArg' => $text,
+ 'WaitFor' => 1);
+
+ return $ARG{'iArg'};
+
+}
+
+sub removeItem {
+ my $self = shift;
+
+ my $id = shift;
+
+ my %ARG = $self->sendMessage('iCommand' => $::PUKE_MENUDATA_REMOVE_ITEM,
+ 'iArg' => $id);
+
+}
+
+package main;
+
+1;
diff --git a/ksirc/puke/pmessage.h b/ksirc/puke/pmessage.h
new file mode 100644
index 00000000..5c777b24
--- /dev/null
+++ b/ksirc/puke/pmessage.h
@@ -0,0 +1,38 @@
+#ifndef PUKE_MESSAGE_H
+#define PUKE_MESSAGE_H
+
+typedef struct {
+ unsigned int iHeader; // Filled in durring in PukeController, do not set
+ int iCommand;
+ int iWinId;
+ int iArg;
+ int iTextSize; // Size of the text message that follows
+ char *cArg;
+} PukeMessage;
+
+typedef struct {
+ int fd;
+ int iWinId;
+} widgetId;
+
+const uint iPukeHeader = 42U;
+
+#if 0
+class errorInvalidSet {
+public:
+ errorInvalidSet(QObject *_from, const char *_to)
+ : __from(_from), __to(_to)
+ {
+ }
+
+ QObject *from() { return __from; }
+ const char *to() { return __to; }
+
+private:
+ QObject *__from;
+ const char *__to;
+
+};
+#endif
+
+#endif
diff --git a/ksirc/puke/pobject.cpp b/ksirc/puke/pobject.cpp
new file mode 100644
index 00000000..f2481a04
--- /dev/null
+++ b/ksirc/puke/pobject.cpp
@@ -0,0 +1,138 @@
+#include "pobject.h"
+#include "commands.h"
+
+
+PObject::PObject(QObject *pobject, const char *name)
+ : QObject(pobject, name)
+{
+ // Connect slots as needed
+ obj = 0;
+ setWidget(0);
+ manualTerm = FALSE;
+ deleteAble = TRUE;
+ m_hasError = false;
+}
+
+PObject::~PObject()
+{
+ if(isDeleteAble())
+ delete widget();
+ obj = 0;
+ setWidget(0);
+}
+
+PObject *PObject::createWidget(CreateArgs &ca)
+{
+ PObject *pw = new PObject(ca.parent);
+ QObject *o;
+ if(ca.parent != 0)
+ o = new QObject(ca.parent->widget());
+ else
+ o = new QObject();
+ pw->setWidget(o);
+ pw->setWidgetId(ca.pwI);
+ pw->setPukeController(ca.pc);
+ return pw;
+}
+
+void PObject::messageHandler(int fd, PukeMessage *pm)
+{
+ PukeMessage pmRet;
+ if(pm->iCommand == PUKE_WIDGET_DELETE){
+ /**
+ * Emit the ack before the delete since we don't exist afterwards.
+ */
+ pmRet.iCommand = PUKE_WIDGET_DELETE_ACK;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+
+ manTerm();
+ delete this;
+ }
+ if(pm->iCommand == PUKE_RELEASEWIDGET){
+ /**
+ * Emit the ack before the delete since we don't exist afterwards.
+ */
+ pmRet.iCommand = PUKE_RELEASEWIDGET_ACK;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+
+ /**
+ * By setting the widget to 0 we loose the pointer and then don't delete it
+ */
+ setWidget(0);
+ manTerm();
+ delete this;
+ }
+ else {
+ qWarning("PObject: Unkown Command: %d", pm->iCommand);
+ pmRet.iCommand = PUKE_INVALID;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ }
+}
+
+void PObject::setWidget(QObject *_o)
+{
+ // Disconnect everything from the object we where listning too
+ // Just in case it fires something off, we don't want to get it
+ if(widget() != 0){
+ disconnect(widget(), SIGNAL(destroyed()),
+ this, SLOT(swidgetDestroyed()));
+ }
+
+ obj = _o;
+ if(obj != 0){
+ connect(widget(), SIGNAL(destroyed()),
+ this, SLOT(swidgetDestroyed()));
+ }
+}
+
+QObject *PObject::widget()
+{
+ // kdDebug(5008) << "PObject widget called" << endl;
+ return obj;
+}
+
+void PObject::setWidgetId(widgetId *pwI)
+{
+ wI = *pwI;
+ // kdDebug(5008) << "PObject: set widget id " << wI.iWinId << endl;
+}
+
+widgetId PObject::widgetIden()
+{
+ // kdDebug(5008) << "PObject: called widget id " << wI.iWinId << endl;
+ return wI;
+}
+
+void PObject::swidgetDestroyed(){
+ setWidget(0x0);
+ if(manualTerm == FALSE){
+ manTerm();
+ delete this;
+ }
+}
+
+PukeController *PObject::controller() {
+
+ return pController;
+}
+
+void PObject::manTerm() {
+ manualTerm = TRUE;
+}
+
+void PObject::errorInvalidSet(QObject *_w)
+{
+ m_error = QString("Tried setting a %1 to %2").arg(_w->className()).arg(className());
+ m_hasError = true;
+}
+#include "pobject.moc"
+
diff --git a/ksirc/puke/pobject.h b/ksirc/puke/pobject.h
new file mode 100644
index 00000000..8e5c7c5a
--- /dev/null
+++ b/ksirc/puke/pobject.h
@@ -0,0 +1,134 @@
+#ifndef POBJECT_H
+#define POBJECT_H
+
+class PObject;
+class PukeController;
+class CreateArgs;
+
+#include <qobject.h>
+#include "pmessage.h"
+
+
+class CreateArgs {
+public:
+ CreateArgs(PukeController *_pc, PukeMessage *_pm, widgetId *_pwI, PObject *_parent){
+ pc = _pc;
+ pwI = _pwI;
+ parent = _parent;
+ pm = _pm;
+ fetchedObj = 0;
+ }
+ PukeController *pc;
+ widgetId *pwI;
+ PObject *parent;
+ PukeMessage *pm;
+
+ /**
+ * name of the widget which was fetched from kSirc, this has to be set explicitly
+ */
+ QObject *fetchedObj;
+};
+
+class PObject : public QObject
+{
+ Q_OBJECT
+ public:
+ PObject(QObject *parent = 0, const char *name = 0);
+ virtual ~PObject();
+
+ /**
+ * Creates a new QObject and returns a PObject
+ */
+ static PObject *createWidget(CreateArgs &ca);
+
+ /**
+ * Handles messages from dsirc
+ * PObject can't get messages so return an error
+ */
+ virtual void messageHandler(int fd, PukeMessage *pm);
+
+ /**
+ * Sets the current opbect
+ */
+ virtual void setWidget(QObject *w);
+
+ /**
+ * Returns the current object
+ */
+ virtual QObject *widget();
+
+ /**
+ * Sets the window id
+ */
+ virtual void setWidgetId(widgetId *pwI);
+ /**
+ * Returns the current window identifier
+ */
+ virtual widgetId widgetIden();
+
+ /**
+ * Set's the puke controller for the widget
+ */
+ void setPukeController(PukeController *pc){
+ pController = pc;
+ }
+
+ /**
+ * If we cannot delete the widget, check this (ie fetched widgets)
+ */
+ bool isDeleteAble(){
+ return deleteAble;
+ }
+
+ /**
+ * Returns if an error was encountered.
+ */
+ bool hasError() {
+ return m_hasError;
+ }
+
+ /**
+ * Returns error description
+ */
+ QString error() {
+ m_hasError = false;
+ return m_error;
+ }
+
+ /**
+ * Set this for fetched widgets and such that cannot be deleted
+ */
+ void setDeleteAble(bool _d){
+ deleteAble = _d;
+ }
+ /**
+ * Before deleting the widget, call manTerm() to signal manual
+ * termination of the widget
+ */
+ void manTerm();
+
+
+ signals:
+ void outputMessage(int fd, PukeMessage *pm);
+ void widgetDestroyed(widgetId wI);
+
+ protected slots:
+ void swidgetDestroyed();
+
+protected:
+ PukeController *controller();
+ void errorInvalidSet(QObject *_w);
+
+private:
+ QObject *obj;
+ PukeController *pController;
+ widgetId wI;
+
+ bool manualTerm;
+ bool deleteAble;
+ QString m_error;
+ bool m_hasError;
+};
+
+#include "controller.h"
+#endif
diff --git a/ksirc/puke/pobjfinder-cmd.h b/ksirc/puke/pobjfinder-cmd.h
new file mode 100644
index 00000000..4f89cfec
--- /dev/null
+++ b/ksirc/puke/pobjfinder-cmd.h
@@ -0,0 +1,32 @@
+#ifndef POBJFINDER_CMD_H
+#define POBJFINDER_CMD_H
+
+/*
+ * We get 2300
+ */
+
+// Desc: fetchs all object names that kSirc knows about
+// iWinId: widget
+// iArg: not defined
+// cArg: path
+#define PUKE_OBJFINDER_ALLOBJECTS 2300
+
+// Desc: ack for the fetch
+// iWinId: widget
+// iArg: not defined
+// cArg: new line seperated list of widgets className::name
+#define PUKE_OBJFINDER_ALLOBJECTS_ACK -2300
+
+// Desc: signal for creation of a new object, not used, only ack
+// iWinId: not defined
+// iArg: not defined
+// cArg: not defined
+#define PUKE_OBJFINDER_NEWOBJECT 2301
+
+// Desc: signal for new widget created
+// iWinId: widget
+// iArg: not defined
+// cArg: className::name of new object
+#define PUKE_OBJFINDER_NEWOBJECT_ACK -2301
+
+#endif
diff --git a/ksirc/puke/pobjfinder.cpp b/ksirc/puke/pobjfinder.cpp
new file mode 100644
index 00000000..0f510ea4
--- /dev/null
+++ b/ksirc/puke/pobjfinder.cpp
@@ -0,0 +1,86 @@
+#include "pobjfinder.h"
+#include "pobjfinder-cmd.h"
+
+
+PObject *
+PObjFinder::createWidget(CreateArgs &ca)
+{
+ PObjFinder *pw = new PObjFinder(ca.parent);
+ pw->setWidget(0x0);
+ pw->setWidgetId(ca.pwI);
+ pw->setPukeController(ca.pc);
+ return pw;
+}
+
+
+PObjFinder::PObjFinder(PObject *parent)
+ : PObject(parent)
+{
+ // We don't actually encase a widget since all the ObjFinder interface
+ // is static
+ setWidget(0x0);
+ connect(controller(), SIGNAL(inserted(QObject *)),
+ this, SLOT(newObject(QObject *)));
+}
+
+PObjFinder::~PObjFinder()
+{
+}
+
+void PObjFinder::messageHandler(int fd, PukeMessage *pm)
+{
+ PukeMessage pmRet;
+ switch(pm->iCommand){
+ case PUKE_OBJFINDER_ALLOBJECTS:
+ {
+ QString qscArg;
+ QStrList allObj = controller()->allObjects();
+ for(uint i = 0; i <= allObj.count(); i++){
+ qscArg += allObj.at(i);
+ qscArg += "\n";
+ }
+
+ pmRet.iCommand = - pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = qstrdup(qscArg);
+ pmRet.iTextSize = qscArg.length();
+ emit outputMessage(fd, &pmRet);
+ delete pmRet.cArg;
+ break;
+ }
+ default:
+ PObject::messageHandler(fd, pm);
+ }
+}
+
+void PObjFinder::setWidget(QObject *_obj)
+{
+ PObject::setWidget(_obj);
+}
+
+
+objFinder *PObjFinder::widget()
+{
+ return 0x0;
+}
+
+
+void PObjFinder::newObject(QObject *name){
+ QString info;
+
+ info = name->className();
+ info += "::";
+ info += name->name("unnamed");
+
+ PukeMessage pmRet;
+ pmRet.iCommand = - PUKE_OBJFINDER_NEWOBJECT_ACK;
+ pmRet.iWinId = widgetIden().iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = qstrdup(info);
+ pmRet.iTextSize = info.length();
+ emit outputMessage(widgetIden().fd, &pmRet);
+ delete pmRet.cArg;
+}
+
+#include "pobjfinder.moc"
diff --git a/ksirc/puke/pobjfinder.h b/ksirc/puke/pobjfinder.h
new file mode 100644
index 00000000..9149aa86
--- /dev/null
+++ b/ksirc/puke/pobjfinder.h
@@ -0,0 +1,33 @@
+#ifndef POBJFINDER_H
+#define POBJFINDER_H
+
+#include "pobject.h"
+#include "../objFinder.h"
+#include "pmessage.h"
+#include "controller.h"
+
+
+class PObjFinder : public PObject
+{
+ Q_OBJECT
+public:
+ static PObject *createWidget(CreateArgs &ca);
+
+ PObjFinder ( PObject * parent );
+ virtual ~PObjFinder ();
+
+ virtual void messageHandler(int fd, PukeMessage *pm);
+
+ virtual void setWidget(QObject *_obj = 0);
+ virtual objFinder *widget();
+
+public slots:
+ virtual void newObject(QObject *obj);
+
+protected:
+ bool checkWidget();
+
+private:
+};
+
+#endif
diff --git a/ksirc/puke/pobjfinder.pm b/ksirc/puke/pobjfinder.pm
new file mode 100644
index 00000000..6cf6c5bb
--- /dev/null
+++ b/ksirc/puke/pobjfinder.pm
@@ -0,0 +1,89 @@
+
+&::PukeSendMessage($PUKE_WIDGET_LOAD,
+ $::PUKE_CONTROLLER,
+ $PWIDGET_OBJFINDER,
+ "pobjfinder.so",
+ sub { my %ARG = %{shift()};
+ if($ARG{'iArg'} == 1){
+ print "*E* PLabel Load failed!\n";
+ }
+ }
+ );
+
+package PObjFinder;
+@ISA = qw(PBase);
+use strict;
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new($class, @_);
+
+ $self->{widgetType} = $::PWIDGET_OBJFINDER;
+
+ if($class eq 'PObjFinder'){
+ $self->create();
+ }
+
+ $self->installHandler($::PUKE_OBJFINDER_NEWOBJECT, sub {$self->newObject(shift())});
+
+ return $self;
+
+}
+
+sub newObject {
+}
+
+sub interAllObjects {
+ my $self = shift;
+ my %REPLY = $self->sendMessage('iCommand' => $::PUKE_OBJFINDER_ALLOBJECTS,
+ 'WaitFor' => 1);
+
+ return $REPLY{'cArg'};
+
+}
+
+sub allObjects {
+ my $self = shift;
+ my $line = $self->interAllObjects();
+
+ $line =~ s/\S+::unnamed//gm;
+
+ return $line;
+
+}
+
+
+sub allObjectsHash {
+ my $self = shift;
+
+ my $line = $self->allObjects();
+
+ my $widget;
+ my %hash;
+
+ foreach $widget (split(/\n/, $line)){
+ $hash{$widget} = 1;
+ }
+
+ return \%hash;
+
+}
+
+sub allObjectsArray {
+ my $self = shift;
+
+ my $line = $self->allObjects();
+
+ my $widget;
+ my @arr;
+
+ foreach $widget (split(/\n/, $line)){
+ next if $widget eq '';
+ $arr[$#arr+1] = $widget;
+ }
+
+ return @arr;
+}
+
+package main;
+
diff --git a/ksirc/puke/ppopmenu.cpp b/ksirc/puke/ppopmenu.cpp
new file mode 100644
index 00000000..4c07d800
--- /dev/null
+++ b/ksirc/puke/ppopmenu.cpp
@@ -0,0 +1,120 @@
+#include <kdebug.h>
+#include <qcursor.h>
+
+#include "ppopmenu.h"
+
+PObject *
+PPopupMenu::createWidget(CreateArgs &ca)
+{
+ PPopupMenu *pm = new PPopupMenu(ca.parent);
+ QPopupMenu *qpm;
+ if(ca.fetchedObj != 0 && ca.fetchedObj->inherits("QPopupMenu") == TRUE){
+ qpm= (QPopupMenu *) ca.fetchedObj;
+ pm->setDeleteAble(FALSE);
+ }
+ else if(ca.parent != 0 && ca.parent->widget()->isWidgetType() == TRUE)
+ qpm = new QPopupMenu((QWidget *) ca.parent->widget());
+ else
+ qpm = new QPopupMenu();
+ pm->setWidget(qpm);
+ pm->setWidgetId(ca.pwI);
+ return pm;
+}
+
+
+PPopupMenu::PPopupMenu(PObject *parent)
+ : PFrame(parent)
+{
+ // kdDebug(5008) << "PLineEdit PLineEdit called" << endl;
+ menu = 0;
+ setWidget(menu);
+ pmd = new PMenuData(this);
+}
+
+PPopupMenu::~PPopupMenu()
+{
+ // kdDebug(5008) << "PLineEdit: in destructor" << endl;
+/* delete widget(); // Delete the frame
+ menu = 0; // Set it to 0
+ setWidget(menu); // Now set all widget() calls to 0.
+*/
+ delete pmd;
+}
+
+void PPopupMenu::messageHandler(int fd, PukeMessage *pm)
+{
+ PukeMessage pmRet;
+ switch(pm->iCommand){
+ /*
+ case PUKE_LINED_SET_MAXLENGTH:
+ if(widget() == 0){
+ kdDebug(5008) << "PLineEdit: No Widget set" << endl;
+ return;
+ }
+ widget()->setMaxLength(pm->iArg);
+ pmRet.iCommand = - pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = widget()->maxLength();
+ emit outputMessage(fd, &pmRet);
+ break;
+ */
+ case PUKE_POPUPMENU_POPUP_CURRENT:
+ if(widget() == 0){
+ kdDebug(5008) << "PPopupMenu: No Widget set" << endl;
+ return;
+ }
+
+ widget()->popup(QCursor::pos(), 0);
+
+ pmRet.iCommand = - pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 1;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+
+ default:
+ if(pmd->menuMessageHandler(fd, pm) == FALSE) // Call pmd's even filter
+ PFrame::messageHandler(fd, pm);
+ }
+}
+
+void PPopupMenu::setWidget(QObject *_menu)
+{
+ if(_menu != 0 && _menu->inherits("QPopupMenu") == FALSE)
+ {
+ errorInvalidSet(_menu);
+ return;
+ }
+
+ menu = (QPopupMenu *) _menu;
+ if(menu != 0x0){
+ connect(menu, SIGNAL(activated(int)),
+ this, SLOT(got_activated(int)));
+ }
+ PFrame::setWidget(menu);
+}
+
+
+QPopupMenu *PPopupMenu::widget()
+{
+ return menu;
+}
+
+void PPopupMenu::got_activated(int itemId){
+ qWarning("Item got activated: %d", itemId);
+
+ widgetId wI;
+ PukeMessage pmRet;
+
+ wI = widgetIden();
+ pmRet.iCommand = PUKE_POPUPMENU_ACTIVATED_ACK;
+ pmRet.iWinId = wI.iWinId;
+ pmRet.iArg = itemId;
+ pmRet.cArg = 0;
+ emit outputMessage(wI.fd, &pmRet);
+
+}
+
+#include "ppopmenu.moc"
+
diff --git a/ksirc/puke/ppopmenu.h b/ksirc/puke/ppopmenu.h
new file mode 100644
index 00000000..9044b935
--- /dev/null
+++ b/ksirc/puke/ppopmenu.h
@@ -0,0 +1,36 @@
+#ifndef PPOPMENU_H
+#define PPOPMENU_H
+
+class PPopupMenu;
+
+#include <qpopupmenu.h>
+#include "pobject.h"
+#include "pmessage.h"
+
+#include "ptablevw.h"
+#include "pmenudta.h"
+
+class PPopupMenu : public PFrame
+{
+ Q_OBJECT
+public:
+ static PObject *createWidget(CreateArgs &ca);
+
+ PPopupMenu(PObject *child);
+ virtual ~PPopupMenu();
+
+ virtual void messageHandler(int fd, PukeMessage *pm);
+
+ virtual void setWidget(QObject *_menu);
+ virtual QPopupMenu *widget();
+
+protected slots:
+ void got_activated ( int itemId );
+
+private:
+ QPopupMenu *menu;
+ PMenuData *pmd;
+
+};
+
+#endif
diff --git a/ksirc/puke/ppopmenu.pm b/ksirc/puke/ppopmenu.pm
new file mode 100644
index 00000000..c1c011fa
--- /dev/null
+++ b/ksirc/puke/ppopmenu.pm
@@ -0,0 +1,65 @@
+
+&::PukeSendMessage($PUKE_WIDGET_LOAD,
+ $PUKE_CONTROLLER,
+ $PWIDGET_POPMENU,
+ "ppopmenu.so",
+ sub { my %ARG = %{shift()};
+ if($ARG{'iArg'} == 1){
+ print "*E* PPopMenu Load failed!\n";
+ }
+ }
+ );
+
+package PPopupMenu;
+@ISA = qw(PTableView PMenuData);
+use strict;
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new($class, @_);
+
+ $self->{widgetType} = $::PWIDGET_POPMENU;
+
+ if($class eq 'PPopupMenu'){
+ $self->create();
+ }
+
+ $self->installHandler($::PUKE_POPUPMENU_ACTIVATED_ACK,
+ sub {$self->activated(@_)});
+
+ return $self;
+
+}
+
+sub activated {
+ my $self = shift;
+
+ my %ARG = %{shift()};
+
+ if($self->{'menu_id'}{$ARG{'iArg'}}){
+ &{$self->{'menu_id'}{$ARG{'iArg'}}}(%ARG);
+ }
+ else {
+ # There's not handler, don't make noise, since if we used fetchWidget()
+ # We don't handlers for everything
+ # &::tell("*E* No handler for id: $ARG{iArg}\n");
+ }
+}
+
+sub installMenu {
+ my $self = shift;
+
+ my $id = shift;
+ my $func = shift;
+ $self->{'menu_id'}{$id} = $func;
+}
+
+sub popupAtCurrent {
+ my $self = shift;
+
+ $self->sendMessage('iCommand' => $::PUKE_POPUPMENU_POPUP_CURRENT,
+ 'CallBack' => sub {});
+}
+
+
+package main;
diff --git a/ksirc/puke/pprogress.cpp b/ksirc/puke/pprogress.cpp
new file mode 100644
index 00000000..75c7fa4b
--- /dev/null
+++ b/ksirc/puke/pprogress.cpp
@@ -0,0 +1,133 @@
+#include <stdio.h>
+
+
+#include <kdebug.h>
+
+#include "pprogress.h"
+
+PObject *
+PProgress::createWidget(CreateArgs &ca)
+{
+ PProgress *pw = new PProgress(ca.parent);
+ KSProgress *ksp;
+ if(ca.parent != 0 && ca.parent->widget()->isWidgetType() == TRUE)
+ ksp = new KSProgress((QWidget *) ca.parent->widget());
+ else
+ ksp = new KSProgress();
+ pw->setWidget(ksp);
+ pw->setWidgetId(ca.pwI);
+ return pw;
+}
+
+
+PProgress::PProgress( PObject *parent)
+ : PWidget(parent)
+{
+ // kdDebug(5008) << "PProgress PProgress called" << endl;
+ ksp = 0;
+}
+
+PProgress::~PProgress()
+{
+ // kdDebug(5008) << "PProgress: in destructor" << endl;
+ /*
+ delete widget(); // Delete the frame
+ ksp=0; // Set it to 0
+ setWidget(ksp); // Now set all widget() calls to 0.
+ */
+}
+
+void PProgress::messageHandler(int fd, PukeMessage *pm)
+{
+ // kdDebug(5008) << "PProgress handler called" << endl;
+ PukeMessage pmRet;
+ if(widget() == 0){
+ qWarning("Null widget");
+ return;
+ }
+ switch(pm->iCommand){
+ case PUKE_KSPROGRESS_SET_RANGE:
+ {
+ int start=0, stop=1;
+ int found = sscanf(pm->cArg, "%d\t%d", &start, &stop);
+ if(found != 2)
+ throw(errorCommandFailed(PUKE_INVALID,13));
+ if(start >= stop){
+ stop = start+1;
+ start = 0;
+ }
+
+ widget()->setRange(start, stop);
+ pmRet.iCommand = PUKE_KSPROGRESS_SET_RANGE_ACK;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ }
+ case PUKE_KSPROGRESS_SET_TOPTEXT:
+ widget()->setTopText(QString(pm->cArg));
+ pmRet.iCommand = PUKE_KSPROGRESS_SET_TOPTEXT;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ case PUKE_KSPROGRESS_SET_BOTTEXT:
+ widget()->setBotText(QString(pm->cArg));
+ pmRet.iCommand = PUKE_KSPROGRESS_SET_BOTTEXT;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ case PUKE_KSPROGRESS_SET_VALUE:
+ widget()->setValue(pm->iArg);
+ pmRet.iCommand = PUKE_KSPROGRESS_SET_VALUE_ACK;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ default:
+ PWidget::messageHandler(fd, pm);
+ }
+}
+
+void PProgress::cancelPressed(){
+ kdDebug(5008) << "Cancel Pressed" << endl;
+ PukeMessage pmRet;
+ pmRet.iCommand = PUKE_KSPROGRESS_CANCEL_ACK;
+ pmRet.iWinId = widgetIden().iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(widgetIden().fd, &pmRet);
+}
+
+void PProgress::setWidget(QObject *_f)
+{
+ // kdDebug(5008) << "PProgress setWidget called" << endl;
+ if(_f != 0 && _f->inherits("KSProgress") == FALSE)
+ {
+ errorInvalidSet(_f);
+ return;
+ }
+
+ ksp = (KSProgress *) _f;
+ if(widget() != 0){
+ connect(widget(), SIGNAL(cancel()),
+ this, SLOT(cancelPressed()));
+ }
+ PWidget::setWidget(ksp);
+
+}
+
+
+KSProgress *PProgress::widget()
+{
+ // kdDebug(5008) << "PProgress widget called" << endl;
+ return ksp;
+}
+
+#include "pprogress.moc"
+
diff --git a/ksirc/puke/pprogress.h b/ksirc/puke/pprogress.h
new file mode 100644
index 00000000..f81fd976
--- /dev/null
+++ b/ksirc/puke/pprogress.h
@@ -0,0 +1,32 @@
+#ifndef PPROGRESS_H
+#define PPROGRESS_H
+
+class PProgress;
+
+#include "../KSProgress/ksprogress.h"
+#include "pmessage.h"
+//#include "pwidget.h"
+#include "pobject.h"
+#include "controller.h"
+
+class PProgress : public PWidget {
+ Q_OBJECT
+public:
+ static PObject *createWidget(CreateArgs &ca);
+
+ PProgress ( PObject * parent = 0);
+ virtual ~PProgress ();
+
+ virtual void messageHandler(int fd, PukeMessage *pm);
+
+ virtual void setWidget(QObject *_f);
+ virtual KSProgress *widget();
+
+protected slots:
+ void cancelPressed();
+
+private:
+ KSProgress *ksp;
+};
+
+#endif
diff --git a/ksirc/puke/pprogress.pm b/ksirc/puke/pprogress.pm
new file mode 100644
index 00000000..b889483e
--- /dev/null
+++ b/ksirc/puke/pprogress.pm
@@ -0,0 +1,86 @@
+
+&::PukeSendMessage($PUKE_WIDGET_LOAD,
+ $PUKE_CONTROLLER,
+ $PWIDGET_KSPROGRESS,
+ "pprogress.so",
+ sub { my %ARG = %{shift()};
+ if($ARG{'iArg'} == 1){
+ print "*E* PProgress Load failed!\n";
+ }
+ }
+ );
+
+package PProgress;
+@ISA = qw(PWidget);
+use strict;
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new($class, @_);
+
+ $self->{widgetType} = $::PWIDGET_KSPROGRESS;
+
+ $self->installHandler($::PUKE_KSPROGRESS_CANCEL_ACK,
+ sub {$self->cancelPressed(@_)});
+
+
+ if($class eq 'PProgress'){
+ $self->create();
+ }
+
+ return $self;
+
+}
+
+sub setTopText {
+ my $self = shift;
+
+ my $text = shift;
+
+ $self->sendMessage('iCommand' => $::PUKE_KSPROGRESS_SET_TOPTEXT,
+ 'cArg' => $text,
+ 'CallBack' => sub {});
+
+}
+
+sub setBotText {
+ my $self = shift;
+
+ my $text = shift;
+
+ $self->sendMessage('iCommand' => $::PUKE_KSPROGRESS_SET_BOTTEXT,
+ 'cArg' => $text,
+ 'CallBack' => sub {});
+
+}
+
+sub setRange {
+ my $self = shift;
+
+ my $lower = shift;
+ my $upper = shift;
+
+ my $carg = "$lower\t$upper";
+
+ $self->sendMessage('iCommand' => $::PUKE_KSPROGRESS_SET_RANGE,
+ 'cArg' => $carg,
+ 'CallBack' => sub {});
+
+}
+
+sub setValue {
+ my $self = shift;
+
+ my $value = shift;
+
+ $self->sendMessage('iCommand' => $::PUKE_KSPROGRESS_SET_VALUE,
+ 'iArg' => $value,
+ 'CallBack' => sub {});
+
+}
+
+sub cancelPressed {
+ print "*E* Cancel pressed\n";
+}
+
+package main;
diff --git a/ksirc/puke/ppushbt.cpp b/ksirc/puke/ppushbt.cpp
new file mode 100644
index 00000000..48cf6121
--- /dev/null
+++ b/ksirc/puke/ppushbt.cpp
@@ -0,0 +1,70 @@
+#include "ppushbt.h"
+#include <stdio.h>
+
+
+PObject *
+PPushButton::createWidget(CreateArgs &ca)
+{
+ PPushButton *pb = new PPushButton(ca.parent);
+ QPushButton *qb;
+ if(ca.parent != 0 && ca.parent->widget()->isWidgetType() == TRUE)
+ qb = new QPushButton((QWidget *) ca.parent->widget());
+ else
+ qb = new QPushButton(0L);
+ pb->setWidget(qb);
+ pb->setWidgetId(ca.pwI);
+ return pb;
+}
+
+
+PPushButton::PPushButton(PObject *parent)
+ : PButton(parent)
+{
+ // kdDebug(5008) << "PLineEdit PLineEdit called" << endl;
+ button = 0;
+ setWidget(button);
+}
+
+PPushButton::~PPushButton()
+{
+ // kdDebug(5008) << "PLineEdit: in destructor" << endl;
+/* delete widget(); // Delete the frame
+ button=0; // Set it to 0
+ setWidget(button); // Now set all widget() calls to 0.
+ */
+}
+
+void PPushButton::messageHandler(int fd, PukeMessage *pm)
+{
+// PukeMessage pmRet;
+ switch(pm->iCommand){
+ default:
+ PButton::messageHandler(fd, pm);
+ }
+}
+
+void PPushButton::setWidget(QObject *_qb)
+{
+ if(_qb != 0 && _qb->inherits("QPushButton") == FALSE)
+ {
+ errorInvalidSet(_qb);
+ return;
+ }
+
+ button = (QPushButton *) _qb;
+ if(_qb != 0){
+ }
+ PButton::setWidget(_qb);
+
+}
+
+
+QPushButton *PPushButton::widget()
+{
+ return button;
+}
+
+
+
+#include "ppushbt.moc"
+
diff --git a/ksirc/puke/ppushbt.h b/ksirc/puke/ppushbt.h
new file mode 100644
index 00000000..87336679
--- /dev/null
+++ b/ksirc/puke/ppushbt.h
@@ -0,0 +1,33 @@
+#ifndef PPUSHBUTTON_H
+#define PPUSHBUTTON_H
+
+class PPushButton;
+
+#include <qpushbutton.h>
+#include "pmessage.h"
+#include "pbutton.h"
+#include "pobject.h"
+#include "controller.h"
+
+class PPushButton : public PButton
+{
+ Q_OBJECT
+public:
+ static PObject *createWidget(CreateArgs &ca);
+
+ PPushButton ( PObject * parent );
+ virtual ~PPushButton ();
+
+ virtual void messageHandler(int fd, PukeMessage *pm);
+
+ virtual void setWidget(QObject *_b = 0);
+ virtual QPushButton *widget();
+
+public slots:
+
+private:
+ QPushButton *button;
+
+};
+
+#endif
diff --git a/ksirc/puke/ppushbt.pm b/ksirc/puke/ppushbt.pm
new file mode 100644
index 00000000..c1d00349
--- /dev/null
+++ b/ksirc/puke/ppushbt.pm
@@ -0,0 +1,30 @@
+
+&::PukeSendMessage($PUKE_WIDGET_LOAD,
+ $PUKE_CONTROLLER,
+ $PWIDGET_PUSHBT,
+ "ppushbt.so",
+ sub { my %ARG = %{shift()};
+ if($ARG{'iArg'} == 1){
+ print "*E* PPushButton Load failed!\n";
+ }
+ }
+ );
+
+package PPushButton;
+@ISA = qw(PButton);
+use strict;
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new($class, @_);
+
+ $self->{widgetType} = $::PWIDGET_PUSHBT;
+
+ if($class eq 'PPushButton'){
+ $self->create();
+ }
+ return $self;
+
+}
+
+package main;
diff --git a/ksirc/puke/ptabdialog.cpp b/ksirc/puke/ptabdialog.cpp
new file mode 100644
index 00000000..b0e3ba2c
--- /dev/null
+++ b/ksirc/puke/ptabdialog.cpp
@@ -0,0 +1,101 @@
+#include <stdio.h>
+
+
+#include "ptabdialog.h"
+#include "commands.h"
+#include <iostream>
+
+PObject *
+PTabDialog::createWidget(CreateArgs &ca)
+{
+ PTabDialog *ptd = new PTabDialog(ca.parent);
+ QTabDialog *qtd;
+ // Retreive the border and direction information out of the
+ // carg string
+ if(ca.fetchedObj != 0 && ca.fetchedObj->inherits("QTabDialog") == TRUE){
+ qtd = (QTabDialog *) ca.fetchedObj;
+ ptd->setDeleteAble(FALSE);
+ }
+ else if(ca.parent != 0 && ca.parent->widget()->isWidgetType() == TRUE)
+ qtd = new QTabDialog((QWidget *) ca.parent->widget());
+ else
+ qtd = new QTabDialog();
+ ptd->setWidget(qtd);
+ ptd->setWidgetId(ca.pwI);
+ ptd->setPukeController(ca.pc);
+ return ptd;
+}
+
+PTabDialog::PTabDialog(QObject *)
+ : PWidget()
+{
+ // Connect slots as needed
+ setWidget(0);
+}
+
+PTabDialog::~PTabDialog()
+{
+ // kdDebug(5008) << "PObject: in destructor" << endl;
+ /*
+ delete widget();
+ tab = 0;
+ setWidget(0);
+ */
+}
+
+void PTabDialog::messageHandler(int fd, PukeMessage *pm)
+{
+ PukeMessage pmRet;
+
+ if(pm->iCommand == PUKE_TABDIALOG_ADDTAB){
+ if(!(pm->iTextSize > 0)){
+ qWarning("QTabDialog/addtab: incorrent cArg size, bailing out. Needed: >0 got: %d\n", pm->iTextSize);
+ pmRet.iCommand = PUKE_TABDIALOG_ADDTAB_ACK; // ack the add widget
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 1;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ return;
+ }
+ widgetId wiWidget;
+ wiWidget.fd = fd;
+ wiWidget.iWinId = pm->iArg;
+ PWidget *pw = controller()->id2pwidget(&wiWidget);
+ // kdDebug(5008) << "Adding widget with stretch: " << (int) pm->cArg[0] << " and align: " << // (int) pm->cArg[1] << endl;
+ widget()->addTab(pw->widget(), pm->cArg);
+
+ pmRet.iCommand = PUKE_TABDIALOG_ADDTAB_ACK; // ack the add widget
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ }
+ else {
+ PWidget::messageHandler(fd, pm);
+ }
+
+}
+
+void PTabDialog::setWidget(QObject *tb)
+{
+ if(tb != 0 && tb->inherits("QTabDialog") == FALSE)
+ {
+ errorInvalidSet(tb);
+ return;
+ }
+
+ tab = (QTabDialog *) tb;
+ if(tab != 0){
+ }
+ PObject::setWidget(tb);
+
+}
+
+QTabDialog *PTabDialog::widget()
+{
+ // kdDebug(5008) << "PObject widget called" << endl;
+ return tab;
+}
+
+#include "ptabdialog.moc"
+
diff --git a/ksirc/puke/ptabdialog.h b/ksirc/puke/ptabdialog.h
new file mode 100644
index 00000000..6e669074
--- /dev/null
+++ b/ksirc/puke/ptabdialog.h
@@ -0,0 +1,41 @@
+#ifndef PTABDIALOG_H
+#define PTABDIALOG_H
+
+class PTabDialog;
+
+#include <qtabdialog.h>
+#include "pmessage.h"
+#include "pwidget.h"
+
+class PTabDialog : public PWidget
+{
+ Q_OBJECT
+public:
+ static PObject *createWidget(CreateArgs &ca);
+
+ PTabDialog(QObject *parent = 0);
+ virtual ~PTabDialog();
+
+ /**
+ * Handles messages from dsirc
+ * PObject can't get messages so return an error
+ */
+ virtual void messageHandler(int fd, PukeMessage *pm);
+
+ /**
+ * Sets the current opbect
+ */
+ virtual void setWidget(QObject *tb);
+
+ /**
+ * Returns the current object
+ */
+ virtual QTabDialog *widget();
+
+private:
+
+ QTabDialog *tab;
+
+};
+
+#endif
diff --git a/ksirc/puke/ptabdialog.pm b/ksirc/puke/ptabdialog.pm
new file mode 100644
index 00000000..65435fb9
--- /dev/null
+++ b/ksirc/puke/ptabdialog.pm
@@ -0,0 +1,49 @@
+
+&::PukeSendMessage($PUKE_WIDGET_LOAD,
+ $PUKE_CONTROLLER,
+ $PWIDGET_TABDIALOG,
+ "ptabdialog.so",
+ sub { my %ARG = %{shift()};
+ if($ARG{'iArg'} == 1){
+ print "*E* PTabDialog Load failed!\n";
+ }
+ }
+ );
+
+package PTabDialog;
+@ISA = qw(PWidget);
+use strict;
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new($class, @_);
+
+ $self->{widgetType} = $::PWIDGET_TABDIALOG;
+
+ if($class eq 'PTabDialog'){
+ $self->create();
+ }
+
+ return $self;
+
+}
+
+sub addTab {
+ my $self = shift;
+
+ my $widget = shift;
+ my $text = shift;
+
+ if($widget->{iWinId} <= 0){
+ print "*E* Trying to add invalid widget " . ref($widget) . "\n";
+ return;
+ }
+
+ $self->sendMessage('iCommand' => $::PUKE_TABDIALOG_ADDTAB,
+ 'iArg' => $widget->{iWinId},
+ 'cArg' => $text,
+ 'CallBack' => sub {});
+
+}
+
+package main;
diff --git a/ksirc/puke/ptablevw.cpp b/ksirc/puke/ptablevw.cpp
new file mode 100644
index 00000000..1dba614b
--- /dev/null
+++ b/ksirc/puke/ptablevw.cpp
@@ -0,0 +1,76 @@
+#include "ptablevw.h"
+
+
+PObject *
+PTableView::createWidget(CreateArgs &ca)
+{
+ qWarning("Table View is abstract class, cannot create an object from it!!!");
+ PTableView *pt = new PTableView(ca.parent);
+ pt->setWidget(0);
+ pt->setWidgetId(ca.pwI);
+ return pt;
+}
+
+
+PTableView::PTableView(PObject *parent)
+ : PFrame(parent)
+{
+ // kdDebug(5008) << "PTableView PTableView called" << endl;
+ tbl = 0;
+ setWidget(tbl);
+}
+
+PTableView::~PTableView()
+{
+ // don't delete the widget since none acutally exists.
+ // delete widget(); // Delete the frame
+ // tbl=0; // Set it to 0
+// setWidget(tbl); // Now set all widget() calls to 0.
+}
+
+void PTableView::messageHandler(int fd, PukeMessage *pm)
+{
+// PukeMessage pmRet;
+ switch(pm->iCommand){
+ /*
+ case PUKE_LINED_SET_MAXLENGTH:
+ if(widget() == 0){
+ kdDebug(5008) << "PTableView: No Widget set" << endl;
+ return;
+ }
+ widget()->setMaxLength(pm->iArg);
+ pmRet.iCommand = - pm->iCommand;
+ pmRet.iWinId = - pm->iWinId;
+ pmRet.iArg = widget()->maxLength();
+ emit outputMessage(fd, &pmRet);
+ break;
+ */
+ default:
+ PFrame::messageHandler(fd, pm);
+ }
+}
+
+void PTableView::setWidget(QObject *_tbv)
+{
+ if(_tbv != 0 && _tbv->inherits("QGridView") == FALSE)
+ {
+ errorInvalidSet(_tbv);
+ return;
+ }
+
+ tbl = (QGridView *) _tbv;
+ if(tbl != 0){
+ }
+ PFrame::setWidget(_tbv);
+
+}
+
+
+QGridView *PTableView::widget()
+{
+ return tbl;
+}
+
+
+#include "ptablevw.moc"
+
diff --git a/ksirc/puke/ptablevw.h b/ksirc/puke/ptablevw.h
new file mode 100644
index 00000000..33ba4015
--- /dev/null
+++ b/ksirc/puke/ptablevw.h
@@ -0,0 +1,33 @@
+#ifndef PTABLEVIEW_H
+#define PTABLEVIEW_H
+
+class PTableView;
+
+#include <qgridview.h>
+
+#include "pmessage.h"
+#include "pframe.h"
+#include "controller.h"
+
+// Init and setup code
+class PTableView : public PFrame
+{
+ Q_OBJECT
+public:
+ static PObject *createWidget(CreateArgs &ca);
+
+ PTableView ( PObject * parent );
+ virtual ~PTableView ();
+
+ virtual void messageHandler(int fd, PukeMessage *pm);
+
+ virtual void setWidget(QObject *_tbl);
+ virtual QGridView *widget();
+
+public slots:
+
+private:
+ QGridView *tbl;
+};
+
+#endif
diff --git a/ksirc/puke/ptablevw.pm b/ksirc/puke/ptablevw.pm
new file mode 100644
index 00000000..297d7b29
--- /dev/null
+++ b/ksirc/puke/ptablevw.pm
@@ -0,0 +1,57 @@
+
+&::PukeSendMessage($::PUKE_WIDGET_LOAD,
+ $::PUKE_CONTROLLER,
+ $::PWIDGET_TABLEVW,
+ "ptablevw.so",
+ sub { my %ARG = %{shift()};
+ if($ARG{'iArg'} == 1){
+ print "*E* PTableView Load failed!\n";
+ }
+ }
+ );
+
+
+package PTableView;
+@ISA = qw(PFrame);
+use strict;
+
+if($PTableView::usage == undef){
+ $PTableView::usage = 0;
+}
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new($class, @_);
+
+ if($PTableView::usage == 0){
+ }
+ $PTableView::usage++;
+
+ $self->{widgetType} = $::PWIDGET_TABLEVW;
+
+ if($class eq 'PTableView'){
+ $self->create();
+ }
+
+ return $self;
+
+}
+
+sub DESTROY {
+ my $self = shift;
+ $self->SUPER::DESTROY(@_);
+ $PTableView::usage--;
+ if($PTableView::usage == 0){
+ # &::PukeSendMessage($::PUKE_WIDGET_UNLOAD,
+ # 0,
+ # $::PWIDGET_TABLEVW,
+ # "",
+ # sub {}
+ # );
+
+ }
+}
+
+
+package main;
+1;
diff --git a/ksirc/puke/puke.pl b/ksirc/puke/puke.pl
new file mode 100644
index 00000000..f0d2c7fd
--- /dev/null
+++ b/ksirc/puke/puke.pl
@@ -0,0 +1,225 @@
+use Socket;
+use Fcntl;
+
+#
+# Clean up if this is the second load.
+#
+# Don't close anything so we can be loaded twice.
+#
+#if($PUKEFd != undef){
+# &remsel($PUKEFd);
+# close($PUKEFd);
+# sleep(1);
+# $PUKEFd = undef;
+#}
+
+#
+# Puke timeout waiting for messages
+$PUKE_TIMEOUT = 10;
+
+#
+# Setup flag fo syncronous operation
+# 1 for sync
+# 0 for async/fly by the seat of your pants
+#
+$SYNC = 0;
+
+#
+# Setup debugging logger, comment out for production use
+#
+$DEBUG = 0;
+if($DEBUG){
+ open(LOG, ">msg-log") || warn "Failed to open log file: $!\n";
+ select(LOG); $| = 1; select(STDOUT);
+ print LOG "Start time: ". `date`;
+}
+
+
+
+#
+# Multi operation level handler, winId Based.
+#
+# PUKE_HANDLER{Cmd}{winId} = sub();
+
+%PUKE_HANDLER = ();
+
+#
+# Default handler is called if no handler defined
+# Default handlers defined in commands-handler.pl
+# Single level PUKE_DEF_HANDLER{$cmd};
+#
+
+#%PUKE_DEF_HANDLER = ();
+
+#require 'commands-perl.pl';
+&docommand("/load commands-perl.pl");
+#require 'commands-handler.pl';
+&docommand("/load commands-handler.pl");
+
+$PukeHeader = 42; # Alternating 1010 for 32 bits
+$PukePacking = "Iiiiia*"; # 4 ints, followed by any number of of characters
+$PukeMSize = length(pack($PukePacking, $PukeHeader, 0, 0, 0, 0, ""));
+
+if(!$ENV{'PUKE_SOCKET'}) {
+ $sock = $ENV{'HOME'} . "/.ksirc.socket";
+}
+else {
+ $sock = $ENV{'PUKE_SOCKET'};
+}
+
+if($PUKEFd == undef){
+ $PUKEFd = &newfh;
+ $proto = getprotobyname('tcp');
+ socket($PUKEFd, PF_UNIX, SOCK_STREAM, 0) || print "PUKE: Sock failed: $!\n";
+ $sun = sockaddr_un($sock);
+ print "*P* PUKE: Connecting to $sock\n";
+ connect($PUKEFd,$sun) || (die "Puke: Connect failed: $!\n",$PUKEFailed=1);
+ select($PUKEFd); $| = 1; select(STDOUT);
+ #fcntl($PUKEFd, F_SETFL, O_NONBLOCK);
+}
+
+# Arg1: Command
+# Arg2: WinId
+# Arg3: iArg
+# Arg4: cArg
+sub PukeSendMessage {
+ my($cmd, $winid, $iarg, $carg, $handler, $waitfor) = @_;
+ # print("PUKE: cArg message too long $cArg\n") if(length($carg) > 50);
+ $PUKE_HANDLER{$cmd}{$winid} = $handler if $handler != undef;
+ my $msg = pack($PukePacking, $PukeHeader, $cmd, $winid, $iarg, length($carg), $carg);
+ syswrite($PUKEFd, $msg, length($msg));
+ # print STDERR "*** " . $msg . "\n";
+ print LOG kgettimeofday() . " SEND message: CMD: $PUKE_NUM2NAME{$cmd} WIN: $winid IARG: $iarg LEN: " . length($carg) . " CARG: $carg\n" if $DEBUG;
+ if($SYNC == 1 || $waitfor == 1){
+ return &sel_PukeRecvMessage(1, $winid, -$cmd, $carg);
+ }
+ return ();
+}
+
+sub sel_PukeRecvMessage {
+ ($wait, $wait_winid, $wait_cmd, $wait_carg) = @_;
+ my($m);
+ my($cmd, $winid, $iarg, $carg, $junk);
+
+ while(1){
+ my $old_a = $SIG{'alarm'};
+ $SIG{'alarm'} = sub { die "alarm\n"; };
+ my $old_time = alarm($PUKE_TIMEOUT);
+ eval {
+ $len = sysread($PUKEFd, $m, $PukeMSize);
+ };
+ if($@){
+ print "*E* Timeout waiting for data for first sysread\n";
+ $SIG{ALRM} = $old_a;
+ alarm($old_time);
+ return;
+ }
+ $SIG{ALRM} = $old_a;
+ alarm($old_time);
+
+ if($len== 0){
+ &remsel($PUKEFd);
+ close($PUKEFd);
+ return;
+ }
+ # print "Length: $len " . length($m) . "\n";
+ ($header, $cmd, $winid, $iarg, $length, $carg) = unpack($PukePacking, $m);
+ if($header != $PukeHeader){
+ print("*E* Invalid message received! Discarding! Got: $header wanted: $PukeHeader\n");
+ # return;
+ }
+ if($length > 0){
+ my $old_a = $SIG{'alarm'};
+ $SIG{'alarm'} = sub { die "alarm\n"; };
+ my $old_time = alarm($PUKE_TIMEOUT);
+ eval {
+ $clen = sysread($PUKEFd, $m2, $length);
+ };
+ if($@){
+ print "*E* Timeout waiting for cArg data\n";
+ }
+ $SIG{ALRM} = $old_a;
+ alarm($old_time);
+
+ if($length != $clen){
+ print "\n*E* Warning: wanted to read: $length got $clen\n";
+ }
+ $m .= $m2;
+ ($header, $cmd, $winid, $iarg, $length, $carg) = unpack($PukePacking, $m);
+ }
+ # print("PUKE: Got => $PUKE_NUM2NAME{$cmd}/$cmd\n");
+ # print("PUKE: Got: $cmd, $winid, $iarg, $length, $carg\n");
+ # print("\n");
+ if($winid == undef){ $winid = 0; }
+ $blah = $carg;
+ $blah =~ s/\000//g;
+ print LOG kgettimeofday() . " GOT message: CMD: $PUKE_NUM2NAME{$cmd} WIN: $winid IARG: $iarg LEN: $length CARG: $blah\n" if $DEBUG;
+ #
+ # Check both $cmd and the correct reply -$cmd
+ #
+ my(%ARG) = ('iCommand' => $cmd,
+ 'iWinId' => $winid,
+ 'iArg' => $iarg,
+ 'cArg' => $carg);
+
+ # print "*I* Def handler: $PUKE_DEF_HANDLER{$cmd}\n";
+
+ if($wait == 1 && $winid == $wait_winid && $wait_cmd == $cmd){
+ print LOG kgettimeofday() . " WAIT message: CMD: $PUKE_NUM2NAME{$cmd} WIN: $winid IARG: $iarg LEN: $length CARG: $blah\n" if $DEBUG;
+ ($wait, $wait_winid, $wait_cmd, $wait_carg) = ();
+ return %ARG;
+ }
+
+ if($PUKE_HANDLER{-$cmd}{$winid}){ # one shot/command handler
+ &{$PUKE_HANDLER{-$cmd}{$winid}}(\%ARG);
+ } elsif ($PUKE_HANDLER{$cmd}{$winid}){
+ &{$PUKE_HANDLER{$cmd}{$winid}}(\%ARG);
+ } elsif ($PUKE_W_HANDLER{$cmd}{$winid}) { # widget specific handler
+ &{$PUKE_W_HANDLER{$cmd}{$winid}}(\%ARG);
+ } elsif ($PUKE_DEF_HANDLER{"$cmd"}) {# catch all
+ &{$PUKE_DEF_HANDLER{"$cmd"}}(\%ARG);
+ }
+ else {
+ #
+ # If there was no handler this is a widget creation falling throuhg
+ #
+
+ if($wait == 1 && (substr($wait_carg,0,7) eq substr($carg,0,7))){
+ print LOG kgettimeofday() . " WAI2 message: CMD: $PUKE_NUM2NAME{$cmd} WIN: $winid IARG: $iarg LEN: $length CARG: $blah\n" if $DEBUG;
+ ($wait, $wait_winid, $wait_cmd, $wait_carg) = ();
+ return %ARG;
+ }
+ # No handler at all, unkown reply
+ print("*E* PUKE: Got unkown command: $cmd/$PUKE_NUM2NAME{$cmd}\n");
+ # print("PUKE: Got: $cmd, $winid, $iarg, $carg\n");
+ }
+
+ #
+ # If we're not waiting for a message, return
+ #
+ if(!$wait){
+ ($wait, $wait_winid, $wait_cmd, $wait_carg) = ();
+ return ();
+ }
+
+ my($rin, $rout) =('', '');
+ vec($rin,fileno($PUKEFd),1) = 1;
+ $nfound = select($rout=$rin, undef, undef, 1);
+ if($nfound < 1){
+ print "*E* PUKE: Timed out waiting for reply, returning null\n";
+ print LOG kgettimeofday() . " FAIL message: CMD: $PUKE_NUM2NAME{$wait_cmd} WIN: $wait_winid IARG: ### LEN: $length CARG: $wait_carg\n" if $DEBUG;
+ return ();
+ }
+ }
+}
+
+&addsel($PUKEFd, "PukeRecvMessage", 0);
+
+# Basics are up and running, now init Puke/Ksirc Interface.
+
+my(%ARG) = &PukeSendMessage($PUKE_SETUP, $::PUKE_CONTROLLER, 0, $server, undef, 1);
+
+$PukeMSize = $ARG{'iArg'};
+print "*P* Puke: Initial Setup complete\n";
+print "*P* Puke: Communications operational\n";
+
diff --git a/ksirc/puke/pwidget.cpp b/ksirc/puke/pwidget.cpp
new file mode 100644
index 00000000..d254832b
--- /dev/null
+++ b/ksirc/puke/pwidget.cpp
@@ -0,0 +1,492 @@
+#include "pwidget.h"
+#include "commands.h"
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#include <qpixmap.h>
+
+PWidget::PWidget(PObject *)
+ : PObject()
+{
+ // kdDebug(5008) << "PWidget constructor called" << endl;
+
+ w = 0;
+ setWidget(0);
+
+ eventList[0] = &PWidget::eventNone;
+ eventList[1] = &PWidget::eventTimer;
+ eventList[2] = &PWidget::eventMouse;
+ eventList[3] = &PWidget::eventMouse;
+ eventList[4] = &PWidget::eventMouse;
+ eventList[5] = &PWidget::eventMouse;
+ eventList[6] = &PWidget::eventKey;
+ eventList[7] = &PWidget::eventKey;
+ eventList[8] = &PWidget::eventFocus;
+ eventList[9] = &PWidget::eventFocus;
+ eventList[10] = &PWidget::eventFocus;
+ eventList[11] = &PWidget::eventFocus;
+ eventList[12] = &PWidget::eventPaint;
+ eventList[13] = &PWidget::eventMove;
+ eventList[14] = &PWidget::eventResize;
+ eventList[15] = &PWidget::eventNone;
+ eventList[16] = &PWidget::eventNone;
+ eventList[17] = &PWidget::eventNone;
+ eventList[18] = &PWidget::eventNone;
+ eventList[19] = &PWidget::eventNone;
+
+ // Connect slots as needed
+
+}
+
+PWidget::~PWidget()
+{
+ // kdDebug(5008) << "PWidget: in destructor" << endl;
+ /*
+ delete widget();
+ w = 0;
+ setWidget(0);
+ */
+}
+
+PObject *PWidget::createWidget(CreateArgs &ca)
+{
+ PWidget *pw = new PWidget();
+ QWidget *tw;
+ if(ca.fetchedObj != 0 && ca.fetchedObj->inherits("QWidget") == TRUE){
+ tw = (QWidget *) ca.fetchedObj;
+ pw->setDeleteAble(FALSE);
+ }
+ else if(ca.parent != 0 && ca.parent->widget()->isWidgetType() == TRUE)
+ tw = new QWidget((QWidget *) ca.parent->widget());
+ else
+ tw = new QWidget();
+ pw->setWidget(tw);
+ pw->setWidgetId(ca.pwI);
+ pw->setPukeController(ca.pc);
+ return pw;
+}
+
+void PWidget::messageHandler(int fd, PukeMessage *pm)
+{
+ PukeMessage pmRet;
+ switch(pm->iCommand){
+ case PUKE_WIDGET_SHOW:
+ widget()->show();
+ pmRet.iCommand = PUKE_WIDGET_SHOW_ACK;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ case PUKE_WIDGET_HIDE:
+ widget()->hide();
+ pmRet.iCommand = PUKE_WIDGET_HIDE_ACK;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ case PUKE_WIDGET_REPAINT:
+ widget()->repaint(pm->iArg);
+ pmRet.iCommand = PUKE_WIDGET_REPAINT_ACK;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ case PUKE_WIDGET_RESIZE:
+ {
+ int x, y;
+ int found = sscanf(pm->cArg, "%d\t%d", &x, &y);
+ if(found != 2)
+ throw(errorCommandFailed(PUKE_INVALID,10));
+
+ widget()->resize(x, y);
+
+ pmRet.iCommand = PUKE_WIDGET_RESIZE_ACK;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = pm->iArg;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ }
+ break;
+ case PUKE_WIDGET_MOVE:
+ {
+ int x, y;
+ int found = sscanf(pm->cArg, "%d\t%d", &x, &y);
+ if(found != 2)
+ throw(errorCommandFailed(PUKE_INVALID,10));
+
+ // kdDebug(5008) << "Moving to: " << pm->iArg << " => " << pos[0] << " " << pos[1] << endl;
+ widget()->move(x, y);
+ pmRet.iCommand = PUKE_WIDGET_MOVE_ACK;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ }
+ break;
+ case PUKE_WIDGET_SETMINSIZE:
+ {
+ int x, y;
+ int found = sscanf(pm->cArg, "%d\t%d", &x, &y);
+ if(found != 2)
+ throw(errorCommandFailed(PUKE_INVALID,11));
+
+ widget()->setMinimumSize(x, y);
+
+ pmRet.iCommand = PUKE_WIDGET_SETMINSIZE_ACK;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ }
+ break;
+ case PUKE_WIDGET_SETMAXSIZE:
+ {
+ int x, y;
+ int found = sscanf(pm->cArg, "%d\t%d", &x, &y);
+ if(found != 2)
+ throw(errorCommandFailed(PUKE_INVALID,12));
+
+ widget()->setMaximumSize(x, y);
+
+ pmRet.iCommand = -pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = pm->iArg;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ }
+ case PUKE_WIDGET_SETCAPTION:
+ widget()->setCaption(pm->cArg);
+ pmRet.iCommand = PUKE_WIDGET_SETCAPTION_ACK;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.iTextSize = strlen(widget()->caption());
+ pmRet.cArg = strdup(widget()->caption());
+ emit outputMessage(fd, &pmRet);
+ free(pmRet.cArg);
+ break;
+ case PUKE_WIDGET_GET_BACKGROUND_COLOUR:
+ {
+ pmRet.cArg = new char[15];
+ pmRet.iTextSize = 15;
+ QColor back = widget()->backgroundColor();
+ sprintf(pmRet.cArg, "%d,%d,%d", back.red(), back.green(), back.blue());
+
+ pmRet.iCommand = -pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ emit outputMessage(fd, &pmRet);
+ delete pmRet.cArg;
+ break;
+ }
+ case PUKE_WIDGET_SET_BACKGROUND_PIXMAP:
+ widget()->setBackgroundPixmap(QPixmap(pm->cArg));
+
+ pmRet.iCommand = -pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ case PUKE_WIDGET_SET_BACKGROUND_MODE:
+ widget()->setBackgroundMode((QWidget::BackgroundMode) pm->iArg);
+
+ pmRet.iCommand = -pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = (int) widget()->backgroundMode();
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+
+ case PUKE_WIDGET_SET_BACKGROUND_COLOUR:
+ {
+ int *pos;
+ pos = (int *) pm->cArg;
+ QColor bg(pos[0], pos[1], pos[2]);
+ QColorGroup cg = QColorGroup(widget()->colorGroup().foreground(),
+ bg,
+ widget()->colorGroup().light(),
+ widget()->colorGroup().dark(),
+ widget()->colorGroup().mid(),
+ widget()->colorGroup().text(),
+ bg);
+ widget()->setPalette(QPalette(cg,cg,cg));
+
+ pmRet.iCommand = -pm->iCommand;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ }
+
+ case PUKE_WIDGET_SET_ENABLED:
+ widget()->setEnabled((bool) pm->iArg);
+ pmRet.iCommand = PUKE_WIDGET_SET_ENABLED_ACK;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ case PUKE_WIDGET_RECREATE:
+ {
+ QWidget *nparent = 0x0;
+ if(pm->iArg != 0x0){
+ widgetId wiWidget;
+ wiWidget.fd = fd;
+ wiWidget.iWinId = pm->iArg;
+ nparent = controller()->id2pwidget(&wiWidget)->widget();
+ }
+ if(pm->iTextSize != 3*sizeof(int)){
+ throw(errorCommandFailed(pm->iCommand, pm->iArg));
+ }
+ int *point_show = (int *) pm->cArg;
+
+ qWarning("Recreate: %d %d %d", point_show[0], point_show[1], point_show[3]);
+
+ widget()->reparent(nparent, (WFlags) 0, QPoint(point_show[0], point_show[1]), point_show[3]);
+
+ pmRet.iCommand = PUKE_WIDGET_RECREATE_ACK;
+ pmRet.iWinId = pm->iWinId;
+ pmRet.iArg = 0;
+ pmRet.cArg = 0;
+ emit outputMessage(fd, &pmRet);
+ break;
+ }
+ default:
+ PObject::messageHandler(fd, pm);
+ }
+}
+
+void PWidget::setWidget(QObject *_w)
+{
+ if(_w != 0 && _w->inherits("QWidget") == FALSE)
+ {
+ errorInvalidSet(_w);
+ return;
+ }
+
+ w = (QWidget *) _w;
+ if(w != 0){
+ widget()->installEventFilter(this);
+ }
+ PObject::setWidget(_w);
+}
+
+QWidget *PWidget::widget()
+{
+ // kdDebug(5008) << "PWidget widget called" << endl;
+ return w;
+}
+
+// PWidget specific
+bool PWidget::eventFilter(QObject *o, QEvent *e)
+{
+ if(e->type() < 20 && e->type() >= 0){
+ (this->*(eventList[e->type()]))(o,e);
+ }
+ else{
+ PukeMessage pm;
+ widgetId wI;
+
+ wI = widgetIden();
+ pm.iCommand = PUKE_EVENT_UNKOWN;
+ pm.iWinId = wI.iWinId;
+ pm.iArg = e->type();
+ pm.cArg = 0;
+ emit outputMessage(wI.fd, &pm);
+
+ }
+
+ return false;
+}
+
+void PWidget::eventNone(QObject *, QEvent *e)
+{
+ PukeMessage pm;
+ widgetId wI;
+
+ // kdDebug(5008) << "PWidget: eventNone" << endl;
+
+ wI = widgetIden();
+ pm.iCommand = - e->type() - 1020; // 1030 offset for events
+ pm.iWinId = wI.iWinId;
+ pm.iArg = 0;
+ pm.cArg = 0;
+
+ emit outputMessage(wI.fd, &pm);
+
+}
+
+void PWidget::eventTimer(QObject *, QEvent *e)
+{
+ PukeMessage pm;
+ widgetId wI;
+
+ QTimerEvent *et = (QTimerEvent *)(e);
+
+ wI = widgetIden();
+ pm.iCommand = PUKE_WIDGET_EVENT_TIMER;
+ pm.iWinId = wI.iWinId;
+ pm.iArg = et->timerId();
+ pm.cArg = 0;
+
+ emit outputMessage(wI.fd, &pm);
+
+}
+
+void PWidget::eventMouse(QObject *, QEvent *e)
+{
+ PukeMessage pm;
+ widgetId wI;
+
+ QMouseEvent *me = (QMouseEvent *)(e);
+
+ wI = widgetIden();
+ pm.iCommand = - e->type() - 1020; // 1020 offset for events
+ pm.iWinId = wI.iWinId;
+ pm.iArg = 0;
+
+ // special cArg handling
+ pm.iTextSize = 4*sizeof(int);
+ int *icArg = new int[4];
+ icArg[0] = me->x();
+ icArg[1] = me->y();
+ icArg[2] = me->button();
+ icArg[3] = me->state();
+ pm.cArg = (char *) icArg;
+
+ emit outputMessage(wI.fd, &pm);
+
+ delete[] icArg;
+
+}
+
+void PWidget::eventKey(QObject *, QEvent *e)
+{
+ PukeMessage pm;
+ widgetId wI;
+
+ QKeyEvent *ke = (QKeyEvent *)(e);
+
+ wI = widgetIden();
+ pm.iCommand = - e->type() - 1020; // 1020 offset for events
+ pm.iWinId = wI.iWinId;
+ pm.iArg = 0;
+
+ // special cArg handling
+ pm.iTextSize = 3*sizeof(int);
+ int *icArg = new int[3];
+ icArg[0] = ke->key();
+ icArg[1] = ke->ascii();
+ icArg[2] = ke->state();
+ pm.cArg = (char *) icArg;
+
+ emit outputMessage(wI.fd, &pm);
+
+ delete[] icArg;
+
+}
+
+void PWidget::eventFocus(QObject *, QEvent *e)
+{
+ PukeMessage pm;
+ widgetId wI;
+
+ // kdDebug(5008) << "PWidget: eventFocus" << endl;
+
+ QFocusEvent *fe = (QFocusEvent *)(e);
+
+ wI = widgetIden();
+ pm.iCommand = - e->type() - 1020; // 1020 offset for events
+ pm.iWinId = wI.iWinId;
+ pm.iArg = 0;
+
+ pm.cArg = new char[2];
+ pm.iTextSize = 2*sizeof(char);
+ pm.cArg[0] = fe->gotFocus();
+ pm.cArg[1] = fe->lostFocus();
+
+ emit outputMessage(wI.fd, &pm);
+
+ delete[] pm.cArg;
+}
+
+void PWidget::eventPaint(QObject *, QEvent *e)
+{
+ PukeMessage pm;
+ widgetId wI;
+
+ wI = widgetIden();
+ pm.iCommand = - e->type() - 1020; // 1020 offset for events
+ pm.iWinId = wI.iWinId;
+ pm.iArg = 0;
+ pm.cArg = 0;
+
+ emit outputMessage(wI.fd, &pm);
+
+}
+
+void PWidget::eventMove(QObject *, QEvent *e)
+{
+ PukeMessage pm;
+ widgetId wI;
+
+ QMoveEvent *me = (QMoveEvent *)(e);
+
+ wI = widgetIden();
+ pm.iCommand = - e->type() - 1020; // 1020 offset for events
+ pm.iWinId = wI.iWinId;
+ pm.iArg = 0;
+
+ // special cArg handling
+ pm.iTextSize = 4*sizeof(int);
+ int *icArg = new int[4];
+ icArg[0] = me->pos().x();
+ icArg[1] = me->pos().y();
+ icArg[2] = me->oldPos().x();
+ icArg[3] = me->oldPos().y();
+ pm.cArg = (char *) icArg;
+
+ emit outputMessage(wI.fd, &pm);
+
+ delete[] icArg;
+
+}
+
+void PWidget::eventResize(QObject *, QEvent *e)
+{
+ PukeMessage pm;
+ widgetId wI;
+
+ QResizeEvent *re = (QResizeEvent *)(e);
+
+ wI = widgetIden();
+ pm.iCommand = - e->type() - 1020; // 1020 offset for events
+ pm.iWinId = wI.iWinId;
+ pm.iArg = 0;
+
+ // special cArg handling
+ pm.iTextSize = 4*sizeof(int);
+ int *icArg = new int[4];
+ icArg[0] = re->size().height();
+ icArg[1] = re->size().width();
+ icArg[2] = re->oldSize().height();
+ icArg[3] = re->oldSize().width();
+ pm.cArg = (char *) icArg;
+
+ emit outputMessage(wI.fd, &pm);
+
+ delete[] icArg;
+
+}
+
+
+#include "pwidget.moc"
+
diff --git a/ksirc/puke/pwidget.h b/ksirc/puke/pwidget.h
new file mode 100644
index 00000000..f7f748fb
--- /dev/null
+++ b/ksirc/puke/pwidget.h
@@ -0,0 +1,45 @@
+#ifndef PWIDGET_H
+#define PWIDGET_H
+
+class PWidget;
+
+#include <qobject.h>
+#include <qwidget.h>
+#include "pobject.h"
+#include "pmessage.h"
+
+class PWidget : public PObject
+{
+ Q_OBJECT
+ public:
+ PWidget(PObject *parent = 0);
+ virtual ~PWidget();
+
+ // Init and setup code
+ static PObject *createWidget(CreateArgs &ca);
+
+ virtual void messageHandler(int fd, PukeMessage *pm);
+
+ virtual void setWidget(QObject *w = 0x0);
+ virtual QWidget *widget();
+
+ protected:
+ bool eventFilter(QObject *o, QEvent *e);
+
+ private:
+ QWidget *w;
+
+ void (PWidget::*eventList[20])(QObject *, QEvent *);
+
+ void eventNone(QObject *, QEvent *);
+ void eventTimer(QObject *, QEvent *);
+ void eventMouse(QObject *, QEvent *);
+ void eventKey(QObject *, QEvent *);
+ void eventFocus(QObject *, QEvent *);
+ void eventPaint(QObject *, QEvent *);
+ void eventMove(QObject *, QEvent *);
+ void eventResize(QObject *, QEvent *);
+
+};
+
+#endif
diff --git a/ksirc/puke/pwidget.pm b/ksirc/puke/pwidget.pm
new file mode 100644
index 00000000..5a73d393
--- /dev/null
+++ b/ksirc/puke/pwidget.pm
@@ -0,0 +1,231 @@
+
+package PWidget;
+@ISA = qw(PBase);
+use strict;
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new($class, @_);
+
+ $self->{widgetType} = $::PWIDGET_WIDGET;
+
+ # Default handlers
+ $self->installHandler($::PUKE_WIDGET_EVENT_RESIZE,
+ sub {$self->resizeEvent(@_)});
+ $self->installHandler($::PUKE_WIDGET_EVENT_PAINT,
+ sub {$self->paintEvent(@_)});
+ $self->installHandler($::PUKE_WIDGET_EVENT_MOVE,
+ sub {$self->moveEvent(@_)});
+ $self->installHandler($::PUKE_EVENT_UNKOWN,
+ sub {$self->miscEvent(@_)});
+ # Examplesto listen for mouse events
+ # $self->installHandler($::PUKE_WIDGET_EVENT_MOUSEBUTTONPRESS,
+ # sub {$self->mousePressEvent(@_)});
+ #$self->installHandler($::PUKE_WIDGET_EVENT_MOUSEBUTTONRELEASE,
+ # sub {$self->mouseReleaseEvent(@_)});
+
+
+
+ if($class eq 'PWidget'){
+ $self->create();
+ }
+
+ return $self;
+
+}
+
+sub close {
+ my $self = shift;
+
+ $self->hide();
+
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_DELETE,
+ 'CallBack' => sub {});
+
+ $self->{DESTROYED} = 1;
+
+}
+
+sub show {
+ my $self = shift;
+
+ # make sure we are runable then show continue.
+ my @ARG = ();
+ # $self->canRun($self, \&PWidget::show, \@ARG) || return;
+
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_SHOW);
+}
+
+sub hide {
+ my $self = shift;
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_HIDE);
+}
+
+sub repaint {
+ my $self = shift;
+
+ my $erase = shift; # 1 for erase and reapint
+
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_REPAINT,
+ 'iArg' => $erase);
+}
+
+sub resize {
+ my $self = shift;
+
+ my $width = shift;
+ my $height = shift;
+
+ my $carg = "$width\t$height";
+
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_RESIZE,
+ 'cArg' => $carg);
+
+}
+
+sub move {
+ my $self = shift;
+
+ my $x = shift;
+ my $y = shift;
+
+ my $carg = "$x\t$y";
+
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_MOVE,
+ 'cArg' => $carg);
+
+}
+
+sub setMinimumSize {
+ my $self = shift;
+
+ my $w = shift;
+ my $h = shift;
+
+ my $carg = "$w\t$h";
+
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_SETMINSIZE,
+ 'cArg' => $carg,
+ 'CallBack' => sub {});
+
+}
+
+sub setMaximumSize {
+ my $self = shift;
+
+ my $w = shift;
+ my $h = shift;
+
+ my $carg = "$w\t$h";
+
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_SETMAXSIZE,
+ 'cArg' => $carg,
+ 'CallBack' => sub {});
+
+}
+
+
+sub setCaption {
+ my $self = shift;
+
+ my $text = shift;
+
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_SETCAPTION,
+ 'cArg' => $text,
+ 'CallBack' => sub {});
+
+}
+
+sub resizeEvent {
+ my $self = shift;
+
+ my %ARG = %{shift()};
+
+ my($h, $w, $oh, $ow) = unpack("iiii", $ARG{'cArg'});
+ $self->{'height'} = $h;
+ $self->{'width'} = $w;
+
+}
+
+sub paintEvent {
+}
+
+sub moveEvent {
+ my $self = shift;
+
+ my %ARG = %{shift()};
+
+ my($x, $y, $ox, $oy) = unpack("iiii", $ARG{'cArg'});
+ $self->{'x'} = $x;
+ $self->{'y'} = $y;
+
+}
+
+sub miscEvent {
+}
+
+sub backgroundColor {
+ my $self = shift;
+
+ my %arg = $self->sendMessage('iCommand' => $::PUKE_WIDGET_GET_BACKGROUND_COLOUR,
+ 'WaitFor' => 1);
+
+ # print "Got: " . $arg{'cArg'} . "\n";
+
+ $arg{'cArg'} =~ s/\000//g;
+ my ($r, $g, $b) = split(/,/, $arg{'cArg'});
+
+ return ($r, $g, $b);
+}
+
+sub setBackgroundColor {
+ my $self = shift;
+
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_SET_BACKGROUND_COLOUR,
+ 'cArg' => pack("i3", shift(), shift(), shift()),
+ 'CallBack' => sub {});
+
+}
+
+sub setBackgroundPixmap {
+ my $self = shift;
+
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_SET_BACKGROUND_PIXMAP,
+ 'cArg' => shift(),
+ 'CallBack' => sub {});
+}
+
+sub setBackgroundMode {
+ my $self = shift;
+
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_SET_BACKGROUND_MODE,
+ 'iArg' => shift(),
+ 'CallBack' => sub {});
+}
+
+
+sub setEnabled {
+ my $self = shift;
+
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_SET_ENABLED,
+ 'iArg' => shift(),
+ 'CallBack' => sub {});
+
+}
+
+sub recreate {
+ my $self = shift;
+
+ my $nparent = shift;
+ my $wflags = shift; # Not used!
+
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_RECREATE,
+ 'iArg' => $nparent ? $nparent->{'iWinId'} : 0,
+ 'cArg' => pack("iii", shift(), shift(), shift()),
+ 'CallBack' => sub {});
+
+}
+
+package main;
+
+1;
diff --git a/ksirc/puke/small.pl b/ksirc/puke/small.pl
new file mode 100644
index 00000000..7e7b251d
--- /dev/null
+++ b/ksirc/puke/small.pl
@@ -0,0 +1,65 @@
+&docommand("/load pbase.pm");
+&docommand("/load pwidget.pm");
+&docommand("/load pframe.pm");
+&docommand("/load pboxlayout.pm");
+&docommand("/load plined.pm");
+&docommand("/load pbutton.pm");
+&docommand("/load ppushbt.pm");
+&docommand("/load pprogress.pm");
+&docommand("/load ptablevw.pm");
+&docommand("/load plistbox.pm");
+&docommand("/load plabel.pm");
+
+$pw = new PWidget;
+$pw->resize(250,500);
+
+$pf = new PFrame($pw);
+$pf->setFrameStyle($PFrame::Panel|$PFrame::Sunken, 1);
+$pf->move(50,50);
+$pf->resize(150,400);
+$pf->setMinimumSize(50,50);
+
+$pf2 = new PFrame($pw);
+$pf2->setFrameStyle($PFrame::Panel|$PFrame::Raised, 1);
+$pf2->setMinimumSize(50,50);
+
+
+$pl = new PListBox($pw);
+$pl->move(50,50);
+$pl->resize(300, 50);
+$pl->setMinimumSize(50,50);
+
+$label = new PLabel($pw);
+$label->setText("Label");
+$label->setMinimumSize(50,50);
+
+$pb = new PBoxLayout($pw, $PBoxLayout::TopToBottom, 5);
+$pb2 = new PBoxLayout($PBoxLayout::LeftToRight, 5);
+$pb3 = new PBoxLayout($PBoxLayout::TopToBottom, 5);
+$pb->addLayout($pb2);
+$pb->addLayout($pb3);
+$pb->addWidget($pf, 1, $PBoxLayout::AlignCenter);
+$pb2->addWidget($pf2, 10, $PBoxLayout::AlignCenter);
+$pb2->addWidget($pl, 10, $PBoxLayout::AlignCenter);
+$pb2->addWidget($label, 10, $PBoxLayout::AlignCenter);
+
+$pb4 = new PBoxLayout($PBoxLayout::RightToLeft, 1);
+$pb3->addLayout($pb4);
+
+$pb4->addWidget($pf2, 0, $PBoxLayout::AlignCenter);
+
+$pbutton = new PPushButton($pw);
+$pbutton->setText("Hello");
+#$pbutton->setPixmap("/opt/kde/share/icons/ksirc.gif");
+$pbutton->setMaximumSize(50,50);
+$pbutton->setMinimumSize(50,50);
+$pb->addWidget($pbutton, 10, $PBoxLayout::AlignCenter);
+
+$pline = new PLineEdit($pw);
+$pline->setMinimumSize(50, 30);
+$pline->resize(200, 20);
+$pline->setMaximumSize(1000, 30);
+$pline->setText("Hello!");
+$pb->addWidget($pline, 0);
+
+$pw->show; \ No newline at end of file
diff --git a/ksirc/puke/test.pl b/ksirc/puke/test.pl
new file mode 100644
index 00000000..4b4c3169
--- /dev/null
+++ b/ksirc/puke/test.pl
@@ -0,0 +1,63 @@
+&docommand("/load pbase.pm");
+&docommand("/load pwidget.pm");
+&docommand("/load pframe.pm");
+&docommand("/load pboxlayout.pm");
+&docommand("/load plined.pm");
+&docommand("/load pbutton.pm");
+&docommand("/load ppushbt.pm");
+&docommand("/load pprogress.pm");
+&docommand("/load ptablevw.pm");
+&docommand("/load plistbox.pm");
+
+$pw = new PWidget;
+$pw->resize(250,500);
+
+$pf = new PFrame($pw);
+$pf->setFrameStyle($PFrame::Panel|$PFrame::Sunken, 1);
+$pf->move(50,50);
+$pf->resize(150,400);
+
+$pf2 = new PListBox($pw);
+#$pf2->setFrameStyle($PFrame::Box|$PFrame::Raised, 1);
+$pf2->move(50,50);
+$pf2->resize(50,300);
+
+$pb = new PBoxLayout($pw, $PBoxLayout::TopToBottom, 5);
+$pb->addWidget($pf, 10);
+$pb->addWidget($pf2, 5);
+
+$pb2 = new PBoxLayout($PBoxLayout::LeftToRight, 5);
+$pb->addLayout($pb2, 0);
+
+$pl = new PLineEdit($pw);
+$pl->setMinimumSize(30,50);
+$pl->setMaximumSize(30,1000);
+$pl->setText("Blah blah");
+#$pl->resize(50,75);
+$pb2->addWidget($pl, 0, $PBoxLayout::AlignCenter);
+
+$pp = new PPushButton($pw);
+$pp->setMinimumSize(65,65);
+$pp->setMaximumSize(65,65);
+$pp->setPixmap("/opt/kde/share/icons/ksirc.gif");
+$pp->installHandler($::PUKE_BUTTON_CLICKED_ACK, sub
+ {
+ print "*I* Clocked!\n";
+ $pw->close;
+ }
+ );
+$pb2->addWidget($pp, 0, $PBoxLayout::AlignRight);
+
+for(my $i = 0; $i < 100; $i++){
+ $pf2->insertPixmap("/opt/kde/share/icons/ksirc.gif", -1);
+ $pf2->insertText("Test $i", -1);
+}
+
+$pp = new PProgress;
+
+$pw->onNext(sub{$pw->show()});
+$pp->onNext(sub{$pw->show(); $pp->show()});
+#$pw->show();
+#$pf->show();
+#$pf2->show();
+
diff --git a/ksirc/puke/tester.pl b/ksirc/puke/tester.pl
new file mode 100755
index 00000000..d3b25462
--- /dev/null
+++ b/ksirc/puke/tester.pl
@@ -0,0 +1,28 @@
+#!/usr/bin/perl
+
+$sock = $ENV{'HOME'} . "/.ksirc.socket";
+
+use Socket;
+
+$proto = getprotobyname('tcp');
+socket(fd, PF_UNIX, SOCK_STREAM, 0) || die "Sock failed: $!\n";
+$sun = sockaddr_un($sock);
+print "Connecting to $sock\n";
+connect(fd,$sun) || die "Connect failed: $!\n";
+
+select(fd); $| = 1; select(STDOUT);
+
+while(1){
+ print "Command: ";
+ chomp($cmd = <STDIN>);
+ print "WinId: ";
+ chomp($winid = <STDIN>);
+ print "iArg: ";
+ chomp($iarg = <STDIN>);
+ print "cArg: ";
+ chomp($carg = <STDIN>);
+ $m = pack("iiia50xx", $cmd, $winid, $iarg, $carg);
+ print fd $m;
+
+}
+
diff --git a/ksirc/puke/user_monitor.ks b/ksirc/puke/user_monitor.ks
new file mode 100644
index 00000000..a0b2a56a
--- /dev/null
+++ b/ksirc/puke/user_monitor.ks
@@ -0,0 +1,440 @@
+&docommand("/load pbase.pm");
+&docommand("/load pwidget.pm");
+&docommand("/load pframe.pm");
+&docommand("/load ptablevw.pm");
+&docommand("/load plistbox.pm");
+&docommand("/load pboxlayout.pm");
+&docommand("/load plabel.pm");
+&docommand("/load pmenudta.pm");
+&docommand("/load ppopmenu.pm");
+&docommand("/load pbutton.pm");
+&docommand("/load ppushbt.pm");
+&docommand("/load palistbox.pm");
+&docommand("/load plined.pm");
+
+use Net::SMTP;
+
+my $WHO = "$ENV{HOME}/who_online.pl";
+my $INFO = "$ENV{HOME}/mysql_fetch";
+
+my %ALLOW_MULT = ();
+$ALLOW_MULT{'asj'} = 1;
+$ALLOW_MULT{'administrator'} = 1;
+
+@PAGE_PPL = ('andrew', 'lee', 'william', 'seamus', 'gerry', 'jason', 'derik');
+
+$PUKE_DEF_HANDLER{-999} = sub {};
+
+package UserList;
+
+@ISA = qw(PFrame);
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new($class, @_);
+
+ $self->create();
+
+ my $gm = new PBoxLayout($self, $PBoxLayout::TopToBottom, 5);
+
+ my $list_box = new PListBox($self);
+ $gm->addWidget($list_box, 5);
+
+ my $event_list = new PListBox($self);
+ $event_list->setMaximumSize(110, 2000);
+ $event_list->setMinimumSize(110, 1);
+ # $event_list->setFrameStyle($PFrame::Box|$PFrame::Raised);
+ $event_list->setFrameStyle(0);
+ $event_list->setBackgroundColor($self->backgroundColor());
+ # Turn off the widget so people can't click in it
+ $event_list->setEnabled(0);
+ $event_list->setAutoScrollBar(0);
+ $event_list->setScrollBar(0);
+ $gm->addWidget($event_list, 5);
+
+ my $gm_but = new PBoxLayout($PBoxLayout::LeftToRight, 5);
+ $gm->addLayout($gm_but, 5);
+
+ my $refresh_but = new PPushButton($self);
+ $refresh_but->setMaximumSize(25, 2000);
+ $refresh_but->setMinimumSize(25, 25);
+ $refresh_but->installHandler($::PUKE_BUTTON_PRESSED_ACK, sub { } );
+ $refresh_but->installHandler($::PUKE_BUTTON_RELEASED_ACK, sub { } );
+ $refresh_but->installHandler($::PUKE_BUTTON_CLICKED_ACK, sub { &::docommand("refresh_users"); } );
+ $refresh_but->setText("&Refresh Users");
+ $gm_but->addWidget($refresh_but, 5);
+
+ my $page_dialog = new pageDialog();
+ $page_dialog->resize(265, 250);
+
+ my $page_but = new PPushButton($self);
+ $page_but->setMaximumSize(25, 2000);
+ $page_but->setMinimumSize(25, 25);
+ $page_but->installHandler($::PUKE_BUTTON_PRESSED_ACK, sub { } );
+ $page_but->installHandler($::PUKE_BUTTON_RELEASED_ACK, sub { } );
+ $page_but->installHandler($::PUKE_BUTTON_CLICKED_ACK, sub { $self->{'page_dialog'}->show(); } );
+ $page_but->setText("&Page");
+ $gm_but->addWidget($page_but, 5);
+
+
+ my $user_count = new PLabel($self);
+ $user_count->setMaximumSize(25, 2000);
+ $user_count->setMinimumSize(25, 25);
+ $user_count->setFrameStyle($PFrame::Box|$PFrame::Raised);
+ $gm->addWidget($user_count, 5);
+
+ $user_count->setText($list_box->{count});
+
+ my $menu = new PPopupMenu();
+ my $menu_online = $menu->insertText("Online Time");
+ $menu->installMenu($menu_online, sub { &::say("online " . $self->{'list_box'}->currentText() . "\n"); });
+ my $menu_info = $menu->insertText("User Information");
+ $menu->installMenu($menu_info, sub { my $user = $self->{'list_box'}->currentText(); print `$INFO $user`; });
+ my $menu_info2 = $menu->insertText("Connection Information");
+ $menu->installMenu($menu_info2, sub { my $exec = "$WHO info " . $self->{'list_box'}->currentText(); print `$exec`; });
+
+ my $menu_rem = $menu->insertText("Remove User From List");
+ $menu->installMenu($menu_rem, sub {
+ my $user = $self->{'list_box'}->currentText();
+ my $count = $self->{'list_box'}->current();
+ $self->{'list_box'}->removeItem($count);
+ if($users_online->{$user} > 0){
+ $users_online->{$user}--;
+ }
+ if($users_online->{$user} == 0){
+ delete $users_online->{$user};
+ }
+ });
+ my $menu_kill = $menu->insertText("Disconnect User");
+ $menu->installMenu($menu_kill, sub { my $exec = "$WHO reset " . $self->{'list_box'}->currentText(); print "Running: $exec\n"; system($exec); });
+
+ # Install listner for mouse events
+
+ $list_box->installHandler($::PUKE_WIDGET_EVENT_MOUSEBUTTONPRESS,
+ sub {$self->popupMenu(@_)});
+ $list_box->installHandler($::PUKE_WIDGET_EVENT_MOUSEBUTTONRELEASE,
+ sub {$self->popdownMenu(@_)});
+
+
+ @$self{'gm', 'list_box', 'user_count', 'max', 'event_list', 'menu', 'page_dialog', 'page_but', 'gm_but'} = ($gm, $list_box, $user_count, 0, $event_list, $menu, $page_dialog, $page_but, $gm_but);
+
+ return $self;
+
+}
+
+sub DESTROY {
+ # $self->hide();
+ $self->{'gm'}->DESTROY;
+ delete $self->{'gm'};
+ delete $self->{'gm2'};
+ $self->{'list_box'}->DESTROY;
+ delete $self->{'list_box'};
+ $self->{'use_count'}->DESTROY;
+ delete $self->{'use_count'};
+
+ $self->SUPER::DESTROY();
+}
+
+sub popupMenu {
+ my $self = shift;
+ my $arg = shift;
+
+ my($x, $y, $b, $s) = unpack("i4", $arg->{'cArg'});
+ # print "$x $y $b $s\n";
+
+ # Only popup for button 2
+ $self->{'menu'}->popupAtCurrent() if $b == 2;
+}
+
+sub popdownMenu {
+ my $self = shift;
+
+ $self->{'menu'}->hide();
+}
+
+sub addEvent {
+ my $self = shift;
+
+ my $event_list = $self->{'event_list'};
+
+ while($event_list->{count} >= 10){
+ $event_list->removeItem($event_list->{count});
+ }
+
+ my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
+
+ my $text = sprintf("%02d:%02d:%02d " . shift(), $hour, $min, $sec);
+
+ $event_list->insertText($text, 0);
+}
+
+sub insertText {
+ my $self = shift;
+
+ $self->{'list_box'}->insertText(@_);
+
+ if($self->{'list_box'}->{count} > $self->{'max'}){
+ $self->{'max'} = $self->{'list_box'}->{count};
+ }
+
+ $self->{'user_count'}->setText("C: " . $self->{'list_box'}->{count} . " M: " . $self->{'max'});
+}
+
+sub removeItem {
+ my $self = shift;
+
+ $self->{'list_box'}->removeItem(@_);
+
+ $self->{'user_count'}->setText("C: " . $self->{'list_box'}->{count} . " M: " . $self->{'max'});
+}
+
+sub text {
+ my $self = shift;
+
+ return $self->{'list_box'}->text(@_);
+}
+
+sub count {
+ my $self = shift;
+
+ return $self->{'list_box'}->{count};
+}
+
+sub AUTOLOAD {
+ my $self = shift;
+
+ return if $AUTOLOAD =~ /::DESTROY$/;
+
+ $AUTOLOAD =~ /.+::(.+)/;
+ return $self->{'list_box'}->$1(@_);
+}
+
+package pageDialog;
+
+@ISA = qw(PFrame);
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new($class, @_);
+ $self->create();
+
+ my $gm = new PBoxLayout($self, $PBoxLayout::TopToBottom, 5);
+
+ my $ppl_label = new PLabel($self);
+ $ppl_label->setText("Person to page:");
+ $ppl_label->setMaximumSize(25, 2000);
+ $ppl_label->setMinimumSize(25, 25);
+ $gm->addWidget($ppl_label, 5);
+
+ my $page_ppl = new PListBox($self);
+ $gm->addWidget($page_ppl, 5);
+
+ my $msg_label = new PLabel($self);
+ $msg_label->setText("Message to page:");
+ $msg_label->setMaximumSize(25, 2000);
+ $msg_label->setMinimumSize(25, 25);
+ $gm->addWidget($msg_label, 5);
+
+ my $page_msg = new PLineEdit($self);
+ $page_msg->setMaximumSize(25, 2000);
+ $page_msg->setMinimumSize(25, 25);
+ $page_msg->setMaxLength(49);
+ $page_msg->installHandler($::PUKE_EVENT_UNKOWN, sub {});
+ $gm->addWidget($page_msg, 5);
+
+ my $send_but = new PPushButton($self);
+ $send_but->setMaximumSize(25, 2000);
+ $send_but->setMinimumSize(25, 25);
+ $send_but->installHandler($::PUKE_BUTTON_PRESSED_ACK, sub { } );
+ $send_but->installHandler($::PUKE_BUTTON_RELEASED_ACK, sub { } );
+ $send_but->installHandler($::PUKE_BUTTON_CLICKED_ACK, sub { &::docommand("msg #polarcom page " . $self->{'page_ppl'}->currentText() . " " . $self->{'page_msg'}->text()); $self->hide() } );
+ $send_but->setText("&Send");
+ $gm->addWidget($send_but, 5);
+
+ $self->setCaption("Page User");
+
+ @$self{'gm', 'page_ppl', 'page_msg', 'send_but', 'msg_label', 'ppl_label'} =
+ ($gm, $page_ppl, $page_msg, $send_but, $msg_label, $ppl_label);
+
+ return $self;
+
+}
+
+sub show {
+ my $self = shift;
+ my $page_ppl = $self->{'page_ppl'};
+
+ $self->hide();
+
+ my $c = $page_ppl->current();
+
+ $page_ppl->clear();
+ my $person;
+ foreach $person (@main::PAGE_PPL) {
+ $page_ppl->insertText($person, -1);
+ }
+ $page_ppl->setCurrentItem($c);
+
+ $self->resize(265, 250);
+ $self->recreate(0, 0, 265, 250, 1);
+
+# $self->SUPER::show();
+#
+# $self->resize(265,250);
+# $self->move(400,270);
+
+}
+
+
+package main;
+
+
+if($online == undef){
+ $online = new UserList();
+ $online->setCaption("Users Online");
+ $online->show();
+ $online->resize(196,740);
+ $online->move(823,0);
+
+ eval {
+ $main::polar = new PWidget();
+ $main::polar->fetchWidget("199.247.156.200_toplevel");
+ $main::polar->move(0,0);
+ $main::polar->resize(816, 740);
+ };
+ if($@) {
+ eval {
+ $main::polar = new PWidget();
+ $main::polar->fetchWidget("199.247.156.200_#polarcom_toplevel");
+ $main::polar->move(0,0);
+ $main::polar->resize(816, 740);
+ };
+ }
+ $users_online = {};
+}
+
+sub hook_online_mon {
+ my $channel = shift;
+ my $msg = shift;
+ return unless $channel eq '#polarcom';
+ return unless $msg =~ /Login|Logoff/;
+ return if $msg =~ /administrator/;
+
+ if($msg =~ /ice: Login (\S+)/){
+ my $nick = $1;
+ #return if $nick =~ /administrator/;
+ $nick =~ s/(\S+)\@\S+/$1/g;
+ $online->addEvent("On: $nick");
+ if($users_online->{$nick} > 0){
+ my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
+ my $date;
+ chomp($date = `date`);
+ my $times = $users_online->{$nick} + 1;
+ &say("$date Duplicate login for $nick, logged on $times times") if (($main::nick eq 'action') || ($nick eq 'administrator'));
+ $online->addEvent("Duplicate: $nick");
+ if($ALLOW_MULT{$nick} != 1){
+ my $exec = "$WHO reset " . $nick;
+ print "*I* Running: $exec\n";
+ system($exec);
+ my $smtp = new Net::SMTP->new;
+ $smtp->mail("sysadmin\@polarcom.com");
+ $smtp->to("$nick\@polarcom.com", "sysadmin\@polarcom.com");
+ $smtp->data();
+ $smtp->datasend("To: $nick\@polarcom.com\n");
+ $smtp->datasend("From: Polarcom System Admin <sysadmin\@polarcom.com>\n");
+ $smtp->datasend("Subject: Security Alert\n\n\n");
+ $smtp->datasend("To: $nick\n");
+ $smtp->datasend("Your account was simultaneously access by 2 or more users.\n");
+ $smtp->datasend("The second user was automatically terminated.\n\n");
+ $smtp->datasend("If you have any question, please email sysadmin\@polarcom.com\n");
+ $smtp->datasend("-- Security Monitor\n");
+ $smtp->datasend();
+ $smtp->quit();
+ }
+ else {
+ print "*I* $nick not being removed, in exclude list\n";
+ }
+ }
+ # Make the list sorted
+ my $i = 0;
+ SEARCH: while($online->text($i) ne undef){
+
+ if(($online->text($i) cmp $nick) >= 0){
+ last SEARCH;
+ }
+ $i++;
+ }
+ $online->insertText($nick, $i);
+ $users_online->{$nick}++;
+ }
+ elsif($msg =~ /ice: Logoff (\S+)/){
+ my $i = 0;
+ my $nick = $1;
+ $nick =~ s/(\S+)\@\S+/$1/g;
+ # print "Trying to logoff: $nick\n";
+ $online->addEvent("Off: $nick");
+ if($users_online->{$nick} > 0){
+ # print "$nick in list\n";
+ $users_online->{$nick}--;
+ if($users_online->{$nick} == 0){
+ delete $users_online->{$nick};
+ }
+ while($online->text($i) ne undef){
+ if($online->text($i) eq $nick){
+ # print "Removing $i for $nick which is really: " . $online->text($i) . "\n";
+ $online->removeItem($i);
+ return;
+ }
+ $i++;
+ }
+ }
+ }
+}
+
+&addhook("public", "online_mon");
+
+sub hook_get_users {
+ my $mesg = shift;
+
+ if($mesg =~ /^send users online/){
+ my $reply = 'Online: ';
+ for($i = 0; $i <= $online->count(); $i++){
+ $reply .= $online->text($i) . " ";
+ }
+ &msg($who, $reply);
+ }
+ if($mesg = /Online: (.+)\s+$/){
+ &tell("*I* Updating user list from $who");
+ $online->addEvent("Update user list: $who");
+ my $users = $1;
+ while($online->count() > 0){
+ $online->removeItem(0);
+ }
+ $users_online = {};
+ foreach $user (split(/\s+/, $users)){
+ $users_online->{$user}++;
+ $online->insertText($user, -1);
+ }
+ }
+}
+
+&addhook("msg", "get_users");
+
+sub cmd_refresh_users {
+ $online->clear();
+ $users_online = {};
+ my $output = `$WHO list`;
+ my @users = split(/\n/, $output);
+ # while($online->count() > 0){
+ # $online->removeItem(0);
+ #}
+ foreach $user (@users){
+ $user =~ s/(\S+)\@\S+/$1/g;
+ next if $user eq '';
+ next if $user =~ /administrator/;
+ $users_online->{$user}++;
+ $online->insertText($user, -1);
+ }
+}
+
+&addcmd("refresh_users");
diff --git a/ksirc/puke/widgethdlr.h b/ksirc/puke/widgethdlr.h
new file mode 100644
index 00000000..6c3e93c7
--- /dev/null
+++ b/ksirc/puke/widgethdlr.h
@@ -0,0 +1,3 @@
+void hdlrCreateWidget(int fd, PukeMessage *pm);
+void hdlrShowWidget(int fd, PukeMessage *pm);
+