diff -u showimg1/main.cpp showimg2/main.cpp
--- showimg1/main.cpp	Mon Jul  8 12:28:14 2002
+++ showimg2/main.cpp	Mon Aug 19 15:10:58 2002
@@ -12,6 +12,9 @@
 #include "imagefip.h"
 #include <qapplication.h>
 #include <qimage.h>
+#include <qlibrary.h>
+
+QLibrary* mpPluginLib = 0;
 
 int main( int argc, char **argv )
 {
@@ -19,12 +22,12 @@
 	QApplication::setColorSpec( QApplication::ManyColor );
 	argc--;
 	argv++;
-    } 
+    }
     else if ( argc > 1 && QString(argv[1]) == "-n" ) {
 	QApplication::setColorSpec( QApplication::NormalColor );
 	argc--;
 	argv++;
-    } 
+    }
     else {
 	QApplication::setColorSpec( QApplication::CustomColor );
     }
@@ -54,5 +57,9 @@
 
     QObject::connect(qApp, SIGNAL(lastWindowClosed()), qApp, SLOT(quit()));
 
-    return a.exec();
+  int ret = a.exec();
+
+  if(mpPluginLib)
+    delete mpPluginLib;
+  return ret;
 }
diff -u showimg1/showimg.cpp showimg2/showimg.cpp
--- showimg1/showimg.cpp	Mon Jul  8 12:28:14 2002
+++ showimg2/showimg.cpp	Mon Aug 19 15:12:11 2002
@@ -10,6 +10,7 @@
 
 #include "showimg.h"
 #include "imagetexteditor.h"
+#include <qlibrary.h>
 #include <qmenubar.h>
 #include <qfiledialog.h>
 #include <qmessagebox.h>
@@ -27,12 +28,28 @@
   The menu uses a single slot to simplify the process of adding
   more items to the options menu.
 */
+extern QLibrary* mpPluginLib;
+
 ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags )
     : QWidget( parent, name, wFlags ),
       conversion_flags( PreferDither ),
       filename( 0 ),
       helpmsg( 0 )
 {
+  bool plugin_ok = false;
+  mDeviceName = QString::null;
+  if(!mpPluginLib)
+// use the following line if the plugin was compiled without thread support
+//  mpPluginLib = new QLibrary("quiteinsane_plugin");
+    mpPluginLib = new QLibrary("quiteinsane_plugin_mt");
+
+    quiteInsaneProc qisp = (quiteInsaneProc) mpPluginLib->resolve( "init_libquiteinsane_plugin" );
+    if(qisp)
+    {
+      qisp(this);
+      plugin_ok = true;
+    }
+
     pickx = -1;
     picky = -1;
     clickx = -1;
@@ -59,7 +76,18 @@
     si = file->insertItem( "Save image", saveimage );
     sp = file->insertItem( "Save pixmap", savepixmap );
     file->insertSeparator();
-    file->insertItem( "E&xit", qApp,  SLOT(quit()), CTRL+Key_Q );
+    //We only enable the menu items, if the plugin could be loaded
+    int id;
+    id = file->insertItem(tr("&Setup scanner..."),this,
+                          SLOT(slotSetupScanner()),0,1);
+    if(!plugin_ok)
+      file->setItemEnabled(id,false);
+    id = file->insertItem(tr("Scan &image..."),this,
+                          SLOT(slotScanImage()),0,2);
+    if(!plugin_ok)
+      file->setItemEnabled(id,false);
+    file->insertSeparator();
+    file->insertItem( "E&xit", this,  SLOT(close()), CTRL+Key_Q );
 
     edit =  new QPopupMenu( menubar );
     menubar->insertItem( "&Edit", edit );
@@ -117,9 +145,9 @@
 
 ImageViewer::~ImageViewer()
 {
-    if ( alloc_context )
-	QColor::destroyAllocContext( alloc_context );
-    if ( other == this )
+   if ( alloc_context )
+      QColor::destroyAllocContext( alloc_context );
+   if ( other == this )
 	other = 0;
 }
 
@@ -669,4 +697,34 @@
     image = image.convertDepth(d);
     reconvertImage();
     repaint( image.hasAlphaBuffer() );
+}
+
+void ImageViewer::slotSetupScanner()
+{
+  emit signalQisGetDeviceName();
+}
+
+void ImageViewer::slotScanImage()
+{
+  emit signalQisScanImage(mDeviceName,false);
+}
+
+void ImageViewer::slotQisNewDeviceName(QString device_name)
+{
+  //A "real" application could save the device_name, e.g by using QSettings.
+  //This way we mustn't bother the user with a device selection dialog
+  //the next time the application is started and "Scan image" is selected.
+  mDeviceName = device_name;
+}
+
+/** No descriptions */
+void ImageViewer::slotQisScanReady(QPtrList<QImage>& il)
+{
+  if(il.count() < 1)
+    return;
+  filename = QString::null;
+  setImage(*(il.at(0)));
+//Clearing the PtrList will delete the images
+//if autoDelete is true
+  il.clear();
 }
diff -u showimg1/showimg.h showimg2/showimg.h
--- showimg1/showimg.h	Mon Jul  8 12:28:14 2002
+++ showimg2/showimg.h	Mon Aug 19 11:45:18 2002
@@ -13,9 +13,12 @@
 
 #include <qwidget.h>
 #include <qimage.h>
+#include <qstring.h>
 
+typedef bool (*quiteInsaneProc)(QWidget*);
 
 class QLabel;
+class QLibrary;
 class QMenuBar;
 class QPopupMenu;
 
@@ -54,6 +57,7 @@
 
     QWidget    *helpmsg;
     QLabel     *status;
+    QString mDeviceName;
     int         si, sp, ac, co, mo, fd, bd, // Menu item ids
 		td, ta, ba, fa, au, ad, dd,
 		ss, cc, t1, t8, t32;
@@ -65,6 +69,11 @@
     bool	may_be_other;
     static ImageViewer* other;
     void	setImage(const QImage& newimage);
+public slots:
+  /** No descriptions */
+  void slotQisNewDeviceName(QString device_name);
+  /** No descriptions */
+  void slotQisScanReady(QPtrList<QImage>&);
 
 private slots:
     void	to1Bit();
@@ -88,6 +97,15 @@
     void	giveHelp();
     void	doOption(int);
     void	copyFrom(ImageViewer*);
+    /** No descriptions */
+    void slotSetupScanner();
+    /** No descriptions */
+    void slotScanImage();
+signals: // Public slots
+  /** No descriptions */
+  void signalQisScanImage(QString device_name,bool allow_multiple_scans);
+  /** No descriptions */
+  void signalQisGetDeviceName();
 };
 
 
