| @@ -0,0 +1,341 @@ | ||
| // $Id$ | ||
| // Revision 1.87 1998/01/27 20:17:01 kulow | ||
| // $Log$ | ||
| // Revision 1.1.1.1 1997/04/09 00:28:06 cvsuser | ||
| // Sources imported | ||
| // | ||
| // Revision 1.10 1997/03/16 22:29:56 kalle | ||
| // look for config variables in ~/.kde/config/.appnamerc if the | ||
| // environment variable USE_NEW_CONFIG_LOCATION is set | ||
| // | ||
| // Revision 1.9 1997/03/16 22:21:26 kalle | ||
| // patches from Nicolas Hadacek | ||
| // | ||
| // Revision 1.8 1997/03/16 21:59:58 kalle | ||
| // initialize KKeyConfig | ||
| // | ||
| // Revision 1.7 1997/03/10 20:04:39 kalle | ||
| // Merged changes from 0.6.3 | ||
| // | ||
| // Revision 1.6 1997/03/09 17:28:46 kalle | ||
| // KTextStream -> QTextStream | ||
| // | ||
| // Revision 1.5 1997/01/15 20:14:28 kalle | ||
| // merged changes from 0.52 | ||
| // | ||
| // Revision 1.4 1996/12/14 13:50:08 kalle | ||
| // finding out the state the application config object is in | ||
| // | ||
| // Revision 1.3 1996/12/07 22:23:26 kalle | ||
| // Drag and Drop stuff from Torben added | ||
| // | ||
| // Revision 1.2 1996/12/07 17:50:49 kalle | ||
| // Patches from Nicolas | ||
| // | ||
| // Revision 1.1 1996/12/01 11:19:55 kalle | ||
| // Initial revision | ||
| // | ||
| // | ||
| // KApplication implementation | ||
| // | ||
| // (C) 1996 Matthias Kalle Dalheimer <mda@stardivision.de> | ||
| // | ||
| // DND stuff by Torben Weis <weis@stud.uni-frankfurt.de> | ||
| // 09.12.96 | ||
| // Revision 1.69 1997/11/03 14:41:28 ettrich | ||
| #ifndef _KAPP_H | ||
| // Matthias: tiny fix for command line arguments: "-icon" will also be used | ||
| #endif | ||
|
|
||
| #ifndef _KKEYCONF_H | ||
| // for the miniicon if "-miniicon" is not defined. | ||
| #endif | ||
|
|
||
| #include <stdlib.h> // getenv() | ||
| // Revision 1.62 1997/10/17 15:46:22 stefan | ||
| // Matthias: registerTopWidget/unregisterTopWidget are obsolete and empty now. | ||
|
|
||
| // I'm not sure, why this have been removed, but I'm sure, they are | ||
| // needed. | ||
| // | ||
| // Revision 1.59 1997/10/16 11:14:27 torben | ||
| // Kalle: Copyright headers | ||
| // kdoctoolbar removed | ||
| aAppName = aArgv0.remove( 0, nSlashPos ); | ||
| // Revision 1.57 1997/10/14 13:31:57 kulow | ||
| // removed one more default value from the implementation | ||
| // | ||
| init(); | ||
| // Matthias: fix to generation of SM command | ||
| // | ||
| // Revision 1.54 1997/10/12 14:36:34 kalle | ||
| // KApplication::tempSaveName() and KApplication::checkRecoverFile() | ||
| // now implemented as documented. | ||
| // The change in kapp.h is only in the documentation and thus *-compatible. | ||
| // | ||
| // Revision 1.53 1997/10/11 22:39:27 ettrich | ||
| init(); | ||
| // Matthias: mainWidget -> topWidget for SM | ||
| // Matthias: fixed an async reply problem with invokeHTMLHelp | ||
| // | ||
| // Revision 1.50 1997/10/10 22:09:17 ettrich | ||
| KApp = this; | ||
| #include <qtstream.h> | ||
| #include "kprocctrl.h" | ||
| if( char* pHome = getenv( "HOME" ) ) | ||
|
|
||
| KApplication* KApplication::KApp = 0L; | ||
| QStrList* KApplication::pSearchPaths; | ||
| if( getenv( "USE_NEW_CONFIG_LOCATION" ) ) | ||
| aConfigName += "/.kde/config/."; | ||
| else | ||
| aConfigName += "/."; | ||
|
|
||
| KApplication::KApplication( int& argc, char** argv ) : | ||
| QApplication( argc, argv ) | ||
| pConfigFile = new QFile( aConfigName ); | ||
| int nSlashPos = aArgv0.findRev( '/' ); | ||
| if( nSlashPos != -1 ) | ||
| bool bSuccess = pConfigFile->open( IO_ReadWrite ); | ||
| else | ||
| aAppName = aArgv0; | ||
|
|
||
| bSuccess = pConfigFile->open( IO_ReadOnly ); | ||
|
|
||
| parseCommandLine( argc, argv ); | ||
|
|
||
| pConfig = new KConfig(); | ||
|
|
||
|
|
||
| KApplication::KApplication( int& argc, char** argv, const QString& rAppName ) : | ||
| QApplication( argc, argv ) | ||
| { | ||
| pConfigStream = new QTextStream( pConfigFile ); | ||
| pConfig = new KConfig( pConfigStream ); | ||
|
|
||
| init(); | ||
|
|
||
| parseCommandLine( argc, argv ); | ||
|
|
||
| } | ||
| pConfigStream = new QTextStream( pConfigFile ); | ||
| pConfig = new KConfig( pConfigStream ); | ||
| void KApplication::init() | ||
| { | ||
| // this is important since we fork() to launch the help (Matthias) | ||
|
|
||
| display = XOpenDisplay( NULL ); | ||
| // by creating the KProcController instance (if its not already existing) | ||
| if ( theKProcessController == 0L) | ||
| theKProcessController = new KProcessController(); | ||
|
|
||
| KApp = this; | ||
| bLocaleConstructed = false; // no work around mutual dependencies | ||
|
|
||
| pIconLoader = 0L; | ||
| mkdir (configPath.data(), 0755); // make it public(?) | ||
| configPath += "/share"; | ||
| KDEChangePalette = XInternAtom( display, "KDEChangePalette", False ); | ||
| KDEChangeGeneral = XInternAtom( display, "KDEChangeGeneral", False ); | ||
| KDEChangeStyle = XInternAtom( display, "KDEChangeStyle", False); | ||
| else | ||
| aIconPixmap = getIconLoader()->loadApplicationIcon( argv[i+1] ); | ||
| delete kKeys; // must be done befor "delete pConfig" | ||
| case miniicon: | ||
| delete pConfigStream; | ||
| pConfigFile->close(); | ||
| delete pConfigFile; | ||
| aMiniIconPixmap = getIconLoader()->loadApplicationMiniIcon( argv[i+1] ); | ||
| aDummyString2 += parameter_strings[miniicon-1]; | ||
| aDummyString2 += " "; | ||
| aDummyString2 += argv[i+1]; | ||
| aDummyString2 += " "; | ||
| break; | ||
| case restore: | ||
| { | ||
| aSessionName = argv[i+1]; | ||
| QString aSessionConfigName; | ||
| if (argv[i+1][0] == '/') | ||
|
|
||
| cme->window != topWidget()->winId()){ | ||
| KWM::setWmCommand(cme->window, ""); | ||
| return true; | ||
| } | ||
|
|
||
| emit saveYourself(); // give applications a chance to | ||
| // save their data | ||
| if (bSessionManagementUserDefined) | ||
| KWM::setWmCommand( topWidget()->winId(), aWmCommand); | ||
| else { | ||
|
|
||
| if (pSessionConfig && !aSessionName.isEmpty()){ | ||
| QString aCommand = aAppName.copy(); | ||
| if (aAppName != argv()[0]){ | ||
| if (argv()[0][0]=='/') | ||
| aCommand = argv()[0]; | ||
| else { | ||
| char* s = new char[1024]; | ||
| aCommand=(getcwd(s, 1024)); | ||
| aCommand+="/"; | ||
| delete [] s; | ||
| aCommand+=aAppName; | ||
| } | ||
| } | ||
| aCommand+=" -restore "; | ||
| aCommand+=aSessionName; | ||
| aCommand+=aDummyString2; | ||
| KWM::setWmCommand( topWidget()->winId(), | ||
| aCommand); | ||
| pSessionConfig->sync(); | ||
| } else { | ||
| QString aCommand = argv()[0]; | ||
| aCommand+=aDummyString2; | ||
| KWM::setWmCommand( topWidget()->winId(), | ||
| aCommand); | ||
| } | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
| if(str == "Motif") | ||
| applyGUIStyle(MotifStyle); | ||
| else | ||
| if(str == "Windows 95") | ||
| applyGUIStyle(WindowsStyle); | ||
| QString str; | ||
| for ( dz = dropZones.first(); dz != 0L; dz = dropZones.next() ) | ||
| getConfig()->setGroup("GUI Style"); | ||
| QPoint p2 = dz->getWidget()->mapFromGlobal( p ); | ||
| if ( dz->getWidget()->rect().contains( p2 ) ) | ||
| result = dz; | ||
| applyGUIStyle(MotifStyle); | ||
| */ | ||
| if(str == "Windows 95") | ||
| applyGUIStyle(WindowsStyle); | ||
| return TRUE; | ||
| } | ||
| { | ||
| if ( cme->message_type == KDEChangePalette ) | ||
| { | ||
| if ( dz->getWidget() == w ) | ||
| result = dz; | ||
| } | ||
| return True; | ||
| } | ||
| w = w->parentWidget(); | ||
| } | ||
| readSettings(); | ||
| kdisplaySetStyleAndFont(); | ||
| kdisplaySetPalette(); | ||
| for ( dz = dropZones.first(); dz != 0L; dz = dropZones.next() ) | ||
| return True; | ||
| QPoint p2 = dz->getWidget()->mapFromGlobal( p ); | ||
| if ( dz->getWidget()->rect().contains( p2 ) ) | ||
| if ( cme->message_type == DndLeaveProtocol ) | ||
| { | ||
| if ( lastEnteredDropZone != 0L ) | ||
| lastEnteredDropZone->leave(); | ||
| { | ||
| lastEnteredDropZone = 0L; | ||
| { | ||
| result->drop( (char*)Data, Size, (int)cme->data.l[0], p.x(), p.y() ); | ||
| } | ||
| else if ( cme->message_type != DndProtocol && cme->message_type != DndEnterProtocol && | ||
| { | ||
| return FALSE; | ||
| if ( lastEnteredDropZone != 0L && lastEnteredDropZone != result ) | ||
| lastEnteredDropZone->leave(); | ||
|
|
||
| // Notify the drop zone over which the pointer is right now. | ||
| result->enter( (char*)Data, Size, (int)cme->data.l[0], p.x(), p.y() ); | ||
| Atom ActualType; | ||
| int ActualFormat; | ||
| unsigned long RemainingBytes; | ||
|
|
||
| XGetWindowProperty(display,root,DndSelection, | ||
| 0L,1000000L, | ||
| FALSE,AnyPropertyType, | ||
| &ActualType,&ActualFormat, | ||
| &Size,&RemainingBytes, | ||
| &Data); | ||
|
|
||
| QPoint p( (int)cme->data.l[3], (int)cme->data.l[4] ); | ||
|
|
||
| if ( cme->message_type == DndRootProtocol ) | ||
| { | ||
| if ( rootDropEventID == (int)cme->data.l[1] ) | ||
| emit kdisplayPaletteChanged(); | ||
| { | ||
| if( !aAutosaveDir.mkdir( aAutosaveDir.absPath() ) ) | ||
| { | ||
| // Last chance: use /tmp | ||
| aAutosaveDir.setPath( "/tmp" ); | ||
| } | ||
| } | ||
|
|
||
| aFilename.replace( QRegExp( "/" ), "\\!" ).prepend( "#" ).append( "#" ).prepend( "/" ).prepend( aAutosaveDir.absPath() ); | ||
|
|
||
| return qstrdup( aFilename.data() ); | ||
| } | ||
|
|
||
|
|
||
|
|
||
| const char* KApplication::checkRecoverFile( const char* pFilename, | ||
| bool& bRecover ) | ||
| { | ||
| QString aFilename; | ||
|
|
||
| if( pFilename[0] != '/' ) | ||
| { | ||
| KDEBUG( KDEBUG_WARN, 101, "Relative filename passed to KApplication::tempSaveName" ); | ||
| aFilename = QFileInfo( QDir( "." ), pFilename ).absFilePath(); | ||
| } | ||
| else | ||
| aFilename = pFilename; | ||
|
|
||
| QDir aAutosaveDir( QDir::homeDirPath() + "/autosave/" ); | ||
| if( !aAutosaveDir.exists() ) | ||
| { | ||
| if( !aAutosaveDir.mkdir( aAutosaveDir.absPath() ) ) | ||
| { | ||
| // Last chance: use /tmp | ||
| aAutosaveDir.setPath( "/tmp" ); | ||
| } | ||
| } | ||
|
|
||
| aFilename.replace( QRegExp( "/" ), "\\!" ).prepend( "#" ).append( "#" ).prepend( "/" ).prepend( aAutosaveDir.absPath() ); | ||
|
|
||
| if( QFile( aFilename ).exists() ) | ||
| { | ||
| bRecover = true; | ||
| return qstrdup( aFilename.data() ); | ||
| } | ||
| else | ||
| { | ||
| bRecover = false; | ||
| return qstrdup( pFilename ); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| void KApplication::setTopWidget( QWidget *topWidget ) | ||
| { | ||
| pTopWidget = topWidget; | ||
| if (topWidget){ | ||
| // set the specified icons | ||
| KWM::setIcon(topWidget->winId(), getIcon()); | ||
| KWM::setMiniIcon(topWidget->winId(), getMiniIcon()); | ||
| if (bSessionManagement) | ||
| enableSessionManagement(bSessionManagementUserDefined); | ||
| else | ||
| KWM::setWmCommand( topWidget->winId(), aWmCommand); | ||
| } | ||
| } | ||
|
|
||
| void KApplication::registerTopWidget() | ||
| { | ||
| } | ||
|
|
||
| void KApplication::unregisterTopWidget() | ||
| { | ||
| } |
| @@ -0,0 +1,207 @@ | ||
| // $Id$ | ||
| // Revision 1.41 1998/01/06 22:54:29 kulow | ||
| // $Log$ | ||
| // Revision 1.1.1.1 1997/04/09 00:28:07 cvsuser | ||
| // Sources imported | ||
| // | ||
| // Revision 1.10 1997/03/16 22:33:39 kalle | ||
| // appName() | ||
| // | ||
| // Revision 1.9 1997/03/09 17:28:32 kalle | ||
| // KTextStream -> QTextStream | ||
| // | ||
| // Revision 1.8 1997/01/15 21:46:26 kalle | ||
| // getConfig() and getConfigState() public (kfm needs them) | ||
| // | ||
| // Revision 1.7 1997/01/15 20:18:36 kalle | ||
| // merged changed from 0.52 | ||
| // | ||
| // Revision 1.6 1996/12/14 13:52:46 kalle | ||
| // Some documentation to the constructors added. | ||
| // | ||
| // Revision 1.5 1996/12/14 13:49:58 kalle | ||
| // finding out the state the application config object is in | ||
| // | ||
| // Revision 1.4 1996/12/14 12:49:31 kalle | ||
| // method names start with a small letter | ||
| // | ||
| // Revision 1.3 1996/12/07 22:22:23 kalle | ||
| // Drag and Drop | ||
| // | ||
| // Revision 1.2 1996/12/01 11:20:23 kalle | ||
| // private members, GetConfig() inline | ||
| // | ||
| // Revision 1.1 1996/12/01 10:57:10 kalle | ||
| // Initial revision | ||
| // | ||
| // | ||
| // KApplication header file - base class for all KDE applications | ||
| // | ||
| // (C) 1996 Matthias Kalle Dalheimer <mda@stardivision.de> | ||
| // | ||
| // DND stuff by Torben Weis <weis@stud.uni-frankfurt.de> | ||
| // 09.12.96 | ||
| // | ||
| // Revision 1.25 1997/10/04 19:42:45 kalle | ||
| // new KConfig | ||
| // | ||
| #ifndef _KCONFIG_H | ||
| #include <Kconfig.h> | ||
| #endif | ||
| // Save icon and mini-icon pixmap | ||
| // - KApplication::saveYourself (signal) | ||
| // - KApplication::tempFileName() | ||
| // - KApplication::checkRecoverFile() | ||
| // | ||
| // MD: Implemented reading of the colour scheme contrast variable. This allows | ||
| // you to choose the highlights and lowlights used to draw widgets and has been | ||
| // part of the colour scheme specification for some time | ||
| /// KApplication: A base class for all KDE applications | ||
| /** KApplication provides the application with KDE defaults such as | ||
| accelerators, common menu entries, a KCOnfig object etc. */ | ||
|
|
||
| class KIconLoader; | ||
|
|
||
| /// Constructor: pass command-line arguments | ||
| /** Constructor. Pass command-line arguments. A KConfig object is | ||
| created that contains an application-specific config file whose | ||
| name is "~/." + argv[0] + "rc". This constructor should be considered | ||
| obsolete. The state of the application-specific config file may be | ||
| queried afterwards with getConfigState(). */ | ||
| * Constructor. Pass command-line arguments. | ||
| * | ||
| /// Constructor: pass command-line arguments and set a logical app name | ||
| /** Constructor. Pass command-line arguments. A KConfig object is | ||
| created that contains an application-specific config file whose | ||
| name is "~/." + rAppName + "rc". The state of the application-specific | ||
| config file may be queried afterwards with getConfigState(). */ | ||
| /** | ||
| * Constructor. Pass command-line arguments. | ||
| /// Destructor | ||
| /** Destructor */ | ||
| * name is "~/." + rAppName + "rc". The state of the application-specific | ||
| * Destructor | ||
| /// Return the current application object | ||
| /** Return the current application object */ | ||
| /** | ||
| * Return the current application object. | ||
| /// Return the logical application name | ||
| /** Return the logical application name as set in the constructor */ | ||
| * created in the same application. It saves the trouble of having to pass | ||
| * the pointer to it explicitly to every function that may require it. | ||
| /// Retrieve the application config object. | ||
| /** Retrieve the application config object. */ | ||
|
|
||
| /** | ||
| /** | ||
| * Get the mini-icon for the application. | ||
| * @return a QPixmap with the icon. | ||
| /// Retrieve the state of the app-config object. | ||
| /** Retrieve the state of the app-config object. Possible return values | ||
| are APPCONFIG_NONE (the application-specific config file could not be | ||
| opened neither read-write nor read-only), APPCONFIG_READONLY (the | ||
| application-specific config file is opened read-only, but not | ||
| read-write) and APPCONFIG_READWRITE (the application-specific config | ||
| file is opened read-write). | ||
| */ | ||
| * are APPCONFIG_NONE (the application-specific config file could not be | ||
| * Get the KDE base dir. | ||
| //@Man: Drag 'n Drop stuff | ||
| //@{ | ||
| /// An X11 atom used for IPC | ||
| * document. | ||
| /// An X11 atom used for IPC | ||
| * @return A new filename for auto-saving. You have to free() this | ||
| /// An X11 atom used for IPC | ||
|
|
||
| /// An X11 atom used for IPC | ||
| * @param pFilename The full path to the document you want to open. | ||
| /// An X11 atom used for IPC | ||
| * pointer yourself, otherwise you have a memory leak. | ||
| /// Get the X11 display | ||
| /** | ||
| /// Used by KDNDDropZone to register | ||
| * @return whether the KLocale object has already been constructed | ||
| /// Used by KDNDDropZone during shutdown | ||
| /** | ||
| /// Set the DropZone which reveives root drop events. | ||
| /** | ||
| //@} | ||
| * An X11 atom used for IPC | ||
| * Used by KDNDDropZone during shutdown | ||
| //@Man: Drag 'n Drop stuff | ||
| //@{ | ||
| /// List of all DropZones. | ||
| * Set the DropZone which reveives root drop events. | ||
| /// The last drop zone the mouse was over | ||
| /** | ||
| If we get a DndLeaveProtocol we must inform 'lastEnteredDropZone' | ||
| that the mouse left the DropZone. | ||
| */ | ||
| */ | ||
| /// The DropZone which receives root drop events. | ||
| * If we get a DndLeaveProtocol we must inform 'lastEnteredDropZone' | ||
| * that the mouse left the DropZone. | ||
| /// Used to catch X11 events | ||
| /** | ||
| * The DropZone which receives root drop events. | ||
| /// An X11 atom used for IPC | ||
| /** | ||
| /// An X11 atom used for IPC | ||
| * List of all DropZones. | ||
| /// An X11 atom used for IPC | ||
| */ | ||
| /// An X11 atom used for IPC | ||
| QList<KDNDDropZone> dropZones; | ||
| /// An X11 atom used for IPC | ||
|
|
||
| /// The X11 display | ||
| * that the mouse left the DropZone. | ||
| //@} | ||
| */ | ||
| * The X11 display | ||
| */ | ||
| /** | ||
| * Two X11 atoms used for session management | ||
| private slots: | ||
| QTextStream* pConfigStream; // stream of the application-specific config file | ||
| QFile* pConfigFile; // application-specific config file | ||
| * X11 atoms used for IPC | ||
| Atom DndProtocol; | ||
| void appHelpActivated(); | ||
| void aboutKDE(); | ||
| void kdisplayStyleChanged(); | ||
| /** | ||
| * KApplication has changed its Font due to a KDisplay request. | ||
| * | ||
| * Normally widgets will update their fonts automatically, but you should | ||
| * connect to this to monitor global font changes, especially if you are | ||
| * using explicit fonts. | ||
| */ | ||
| void kdisplayFontChanged(); | ||
|
|
||
| /** | ||
| * KApplication has changed either its GUI style, its font or its palette | ||
| * due to a kdisplay request. Normally, widgets will update their styles | ||
| * automatically, but yout should connect to this to program special | ||
| * behavior. */ | ||
| void appearanceChanged(); | ||
|
|
||
| /** Session management is about to close your application. | ||
| * | ||
| * Connect to this signal in order to save your data. Do NOT | ||
| * manipulate the UI in that slot, it is blocked by kwm. | ||
| * | ||
| * Use the getSessionConfig() Kconfig object to store all | ||
| * your instance specific datas. | ||
| * | ||
| * Note: you should not do that if you are using the KTopLevelWidget. | ||
| * Overload saveProperties(...)/readProperties(...) in that case. | ||
| * This gives you also the possibillity to handle multiple windows | ||
| * application in an easy manner. | ||
| */ | ||
| void saveYourself(); | ||
| }; | ||
|
|
||
| #endif |
| @@ -0,0 +1,160 @@ | ||
| // $Id$ | ||
| // Revision 1.1.1.3 1997/12/11 07:19:11 jacek | ||
| // $Log$ | ||
| // Kalle: Copyright headers | ||
| // kdoctoolbar removed | ||
| // | ||
| // Revision 1.3 1997/10/09 11:46:19 kalle | ||
| // Assorted patches by Fritz Elfert, Rainer Bawidamann, Bernhard Kuhn and Lars Kneschke | ||
| // | ||
| // Revision 1.2 1997/10/04 19:42:45 kalle | ||
| // new KConfig | ||
| // | ||
| // Revision 1.1.1.1 1997/04/13 14:42:41 cvsuser | ||
| // Source imported | ||
| // | ||
| // Revision 1.1.1.1 1997/04/09 00:28:05 cvsuser | ||
| // Sources imported | ||
| // | ||
| #include <kcolorgroup.h> | ||
| // method names start with a small letter | ||
| // | ||
| // Revision 1.1 1996/11/24 12:54:16 kalle | ||
| // Initial revision | ||
| // | ||
| // | ||
| // KColorGroup implementation | ||
| // | ||
| // (C) 1996 Matthias Kalle Dalheimer <mda@stardivision.de> | ||
|
|
||
| #ifndef _KCOLORGROUP_H | ||
| #include "kcolorgroup.h" | ||
| #endif | ||
|
|
||
| KColorGroup::KColorGroup() | ||
| { | ||
| pQColorGroup = new QColorGroup(); | ||
| } | ||
|
|
||
| KColorGroup::KColorGroup( const QColor& rForeground, const QColor& rBackground, | ||
| const QColor& rLight, const QColor& rMid, | ||
| const QColor& rDark, const QColor& rText, | ||
| const QColor& rBase ) | ||
| { | ||
| pQColorGroup = new QColorGroup( rForeground, rBackground, rLight, rMid, | ||
| QString aGroupName = *pString; | ||
| KColorGroup::~KColorGroup() | ||
| { | ||
| delete pQColorGroup; | ||
| QColor aForeColor( rConfig.readEntry( "Foreground-Red" ).toInt(), | ||
| rConfig.readEntry( "Foreground-Green" ).toInt(), | ||
| rConfig.readEntry( "Foreground-Blue" ).toInt() ); | ||
|
|
||
| QColor aBackColor( rConfig.readEntry( "Background-Red" ).toInt(), | ||
| rConfig.readEntry( "Background-Green" ).toInt(), | ||
| rConfig.readEntry( "Background-Blue" ).toInt() ); | ||
|
|
||
| QColor aLightColor( rConfig.readEntry( "Light-Red" ).toInt(), | ||
| rConfig.readEntry( "Light-Green" ).toInt(), | ||
| rConfig.readEntry( "Light-Blue" ).toInt() ); | ||
|
|
||
| QColor aMidColor( rConfig.readEntry( "Mid-Red" ).toInt(), | ||
| rConfig.readEntry( "Mid-Green" ).toInt(), | ||
| rConfig.readEntry( "Mid-Blue" ).toInt() ); | ||
|
|
||
| QColor aDarkColor( rConfig.readEntry( "Dark-Red" ).toInt(), | ||
| rConfig.readEntry( "Dark-Green" ).toInt(), | ||
| rConfig.readEntry( "Dark-Blue" ).toInt() ); | ||
|
|
||
| QColor aTextColor( rConfig.readEntry( "Text-Red" ).toInt(), | ||
| rConfig.readEntry( "Text-Green" ).toInt(), | ||
| rConfig.readEntry( "Text-Blue" ).toInt() ); | ||
|
|
||
| QColor aBaseColor( rConfig.readEntry( "Base-Red" ).toInt(), | ||
| rConfig.readEntry( "Base-Green" ).toInt(), | ||
| rConfig.readEntry( "Base-Blue" ).toInt() ); | ||
|
|
||
| delete pQColorGroup; | ||
| aGroupName = *pString; | ||
| aGroupName += "ColorGroup"; | ||
| rConfig.setGroup( aGroupName ); | ||
|
|
||
| QColor aForeColor( rConfig.readColorEntry( "Foreground" ) ); | ||
| QColor aBackColor( rConfig.readColorEntry( "Background" ) ); | ||
| QColor aLightColor( rConfig.readColorEntry( "Light" ) ); | ||
| QColor aMidColor( rConfig.readColorEntry( "Mid" ) ); | ||
| QColor aDarkColor( rConfig.readColorEntry( "Dark" ) ); | ||
| QColor aTextColor( rConfig.readColorEntry( "Text" ) ); | ||
| QColor aBaseColor( rConfig.readColorEntry( "Base" ) ); | ||
| QString aGroupName = *pString; | ||
| aBaseColor ); | ||
|
|
||
| rConfig.setGroup( aOldGroup ); | ||
| QString aRedName; | ||
| QString aGreenName; | ||
| QString aBlueName; | ||
|
|
||
| aRedName.setNum( pQColorGroup->foreground().red() ); | ||
| aGreenName.setNum( pQColorGroup->foreground().green() ); | ||
| aBlueName.setNum( pQColorGroup->foreground().blue() ); | ||
| rConfig.writeEntry( "Foreground-Red", aRedName ); | ||
| rConfig.writeEntry( "Foreground-Green", aGreenName ); | ||
| rConfig.writeEntry( "Foreground-Blue", aBlueName ); | ||
|
|
||
| aRedName.setNum( pQColorGroup->background().red() ); | ||
| aGreenName.setNum( pQColorGroup->background().green() ); | ||
| aBlueName.setNum( pQColorGroup->background().blue() ); | ||
| rConfig.writeEntry( "Background-Red", aRedName ); | ||
| rConfig.writeEntry( "Background-Green", aGreenName ); | ||
| rConfig.writeEntry( "Background-Blue", aBlueName ); | ||
|
|
||
| aRedName.setNum( pQColorGroup->light().red() ); | ||
| aGreenName.setNum( pQColorGroup->light().green() ); | ||
| aBlueName.setNum( pQColorGroup->light().blue() ); | ||
| rConfig.writeEntry( "Light-Red", aRedName ); | ||
| rConfig.writeEntry( "Light-Green", aGreenName ); | ||
| rConfig.writeEntry( "Light-Blue", aBlueName ); | ||
|
|
||
| aRedName.setNum( pQColorGroup->mid().red() ); | ||
| aGreenName.setNum( pQColorGroup->mid().green() ); | ||
| aBlueName.setNum( pQColorGroup->mid().blue() ); | ||
| rConfig.writeEntry( "Mid-Red", aRedName ); | ||
| rConfig.writeEntry( "Mid-Green", aGreenName ); | ||
| rConfig.writeEntry( "Mid-Blue", aBlueName ); | ||
|
|
||
| aRedName.setNum( pQColorGroup->dark().red() ); | ||
| aGreenName.setNum( pQColorGroup->dark().green() ); | ||
| aBlueName.setNum( pQColorGroup->dark().blue() ); | ||
| rConfig.writeEntry( "Dark-Red", aRedName ); | ||
| rConfig.writeEntry( "Dark-Green", aGreenName ); | ||
| rConfig.writeEntry( "Dark-Blue", aBlueName ); | ||
|
|
||
| aRedName.setNum( pQColorGroup->text().red() ); | ||
| aGreenName.setNum( pQColorGroup->text().green() ); | ||
| aBlueName.setNum( pQColorGroup->text().blue() ); | ||
| rConfig.writeEntry( "Text-Red", aRedName ); | ||
| rConfig.writeEntry( "Text-Green", aGreenName ); | ||
| rConfig.writeEntry( "Text-Blue", aBlueName ); | ||
|
|
||
| aRedName.setNum( pQColorGroup->base().red() ); | ||
| aGreenName.setNum( pQColorGroup->base().green() ); | ||
| aBlueName.setNum( pQColorGroup->base().blue() ); | ||
| rConfig.writeEntry( "Base-Red", aRedName ); | ||
| rConfig.writeEntry( "Base-Green", aGreenName ); | ||
| rConfig.writeEntry( "Base-Blue", aBlueName ); | ||
| aGroupName = *pString; | ||
| aGroupName += "ColorGroup"; | ||
| rConfig.setGroup( aGroupName ); | ||
|
|
||
| rConfig.writeEntry( "Mid", pQColorGroup->mid() ); | ||
| rConfig.writeEntry( "Dark", pQColorGroup->dark() ); | ||
| rConfig.writeEntry( "Text", pQColorGroup->text() ); | ||
| rConfig.writeEntry( "Base", pQColorGroup->base() ); | ||
|
|
||
| rConfig.setGroup( aOldGroup ); | ||
| } | ||
|
|
||
| const QColorGroup* KColorGroup::colorGroup() const | ||
| { | ||
| return pQColorGroup; | ||
| } |
| @@ -0,0 +1,128 @@ | ||
| // $Id$ | ||
| // Revision 1.1.1.3 1997/12/11 07:19:11 jacek | ||
| // $Log$ | ||
| // Kalle: Copyright headers | ||
| // kdoctoolbar removed | ||
| // | ||
| // Revision 1.3 1997/10/09 11:46:20 kalle | ||
| // Assorted patches by Fritz Elfert, Rainer Bawidamann, Bernhard Kuhn and Lars Kneschke | ||
| // | ||
| // Revision 1.2 1997/10/04 19:42:46 kalle | ||
| // new KConfig | ||
| // | ||
| // Revision 1.1.1.1 1997/04/13 14:42:41 cvsuser | ||
| // Source imported | ||
| // | ||
| // Revision 1.1.1.1 1997/04/09 00:28:07 cvsuser | ||
| // Sources imported | ||
| // | ||
| // Revision 1.1 1996/11/24 12:54:42 kalle | ||
| // Initial revision | ||
| // | ||
| // | ||
| #include <Kconfig.h> | ||
| // | ||
| // (C) 1996 Matthias Kalle Dalheimer <mda@stardivision.de> | ||
|
|
||
| #ifndef _KCOLORGROUP_H | ||
| #define _KCOLORGROUP_H | ||
|
|
||
| #ifdef HAVE_CONFIG_H | ||
| #include <config.h> | ||
| #endif | ||
|
|
||
| #ifndef _KCONFIG_H | ||
| #include <kconfig.h> | ||
| #endif | ||
|
|
||
| #include <qpalette.h> | ||
| #include <qstring.h> | ||
|
|
||
| /// KColorGroup: A collection of color entries for application widgets | ||
| /** A KColorGroup provides seven colors for widgets: foreground, | ||
| background, light, mid, dark, text and base - exactly as the | ||
| QColorGroup. KColorGroup adds the possibility to store the | ||
| KColorGroup via the KConfig mechanism. It would be nicer if | ||
| KColorGroup was derived from QColorGroup, but QColorGroup provides | ||
| no write access to its data members except via the constructor. | ||
| */ | ||
| class KColorGroup | ||
| { | ||
| private: | ||
| QColorGroup* pQColorGroup; | ||
| public: | ||
| /// Construct a KColorGroup with all colors black | ||
| /** Construct a KColorGroup with all colors black */ | ||
| KColorGroup(); | ||
|
|
||
| /// Construct a KColorGroup with given colors. | ||
| /** Construct a KColorGroup with given colors. */ | ||
| KColorGroup( const QColor& rForeground, const QColor& rBackground, | ||
| const QColor& rLight, const QColor& rMid, const QColor& | ||
| rDark, const QColor& rText, const QColor& rBase ); | ||
|
|
||
| /// KColorGroup destructor | ||
| /** KColorGroup destructor */ | ||
| ~KColorGroup(); | ||
|
|
||
| /// Retrieve the foreground value. | ||
| /** Retrieve the foreground value. */ | ||
| const QColor& foreground() const | ||
| { return pQColorGroup->foreground(); } | ||
|
|
||
| /// Retrieve the background value. | ||
| /** Retrieve the background value. */ | ||
| const QColor& background() const | ||
| { return pQColorGroup->background(); } | ||
|
|
||
| /// Retrieve the light value. | ||
| /** Retrieve the light value. */ | ||
| const QColor& light() const | ||
| { return pQColorGroup->light(); } | ||
|
|
||
| /// Retrieve the mid value. | ||
| /** Retrieve the mid value. */ | ||
| const QColor& mid() const | ||
| { return pQColorGroup->mid(); } | ||
|
|
||
| /// Retrieve the dark value. | ||
| /** Retrieve the dark value. */ | ||
| const QColor& dark() const | ||
| { return pQColorGroup->dark(); } | ||
|
|
||
| /// Retrieve the text value. | ||
| /** Retrieve the text value. */ | ||
| const QColor& text() const | ||
| { return pQColorGroup->text(); } | ||
|
|
||
| /// Retrieve the base value. | ||
| /** Retrieve the base value. */ | ||
| const QColor& base() const | ||
| { return pQColorGroup->base(); } | ||
|
|
||
| is used. If pString is not NULL, the value of pString is prepended | ||
| /** Compare two KColorGroups. */ | ||
| bool operator==( const KColorGroup& rColorGroup ) const | ||
| void load( KConfig& rConfig, QString* pString = NULL ); | ||
|
|
||
| /// Compare two KColorGroups. | ||
| /** Compare two KColorGroups. */ | ||
| used. If pString is not NULL, the value of pString is prepended to | ||
| { return (*pQColorGroup) != (*rColorGroup.pQColorGroup); } | ||
|
|
||
| void save( KConfig& rConfig, QString* pString = NULL ); | ||
|
|
||
| /// Save color values to a KConfig object. | ||
| /** Save color values to a KConfig object. The group "ColorGroup" is | ||
| used. If pString is not 0, the value of pString is prepended to | ||
| the group name. | ||
| */ | ||
| void save( KConfig& rConfig, QString* pString = 0L ); | ||
|
|
||
| /// Return the QColorGroup object | ||
| /** Return the QColorGroup object (for drawing shades e.g.). | ||
| */ | ||
| const QColorGroup *colorGroup() const; | ||
| }; | ||
|
|
||
| #endif |
| @@ -0,0 +1,176 @@ | ||
| #ifndef _KKEYCONF_H | ||
| #define _KKEYCONF_H | ||
|
|
||
| #include <qdict.h> | ||
| #include <qaccel.h> | ||
|
|
||
| #include <Kconfig.h> | ||
| #include <kkeydata.h> | ||
|
|
||
| /** Pointer to current KKeyConfig object. */ | ||
| #define kKeys KKeyConfig::getKKeyConfig() | ||
|
|
||
| /** Create a KKeyConfig object. This should not be used in a KApplication. | ||
| */ | ||
| void initKKeyConfig( KConfig *pconf ); | ||
|
|
||
| /** Return the keycode corresponding to the given string. The string must | ||
| * be something like "SHIFT+A" or "F1+CTRL+ALT" or "Backspace" | ||
| * for instance. | ||
| * Return 0 if the string is not recognized. | ||
| */ | ||
| uint stringToKey(const QString& sKey ); | ||
|
|
||
| /** Return the string corresponding to the given keycode. | ||
| * Return NULL if the keyCode is not recognized. | ||
| */ | ||
| const QString keyToString( uint keyCode ); | ||
|
|
||
|
|
||
| /** The KKeyConfig class allows the easy management of "function/key" | ||
| * associations. It allows the user to configure (configurable) keys via | ||
| * the config file or via a dialog window. | ||
| * | ||
| * There is three differents levels : | ||
| * \begin{itemize} | ||
| * \item the "functionName" : it is just a string which represents an action | ||
| * which can be handle via different methods in different widgets. | ||
| * \item the "keyCode" : it represents a key + modifiers (SHIFT, CTRL | ||
| * or/and ALT). | ||
| * \item the "widgetName" : each widget using keys should have such a name. | ||
| * \end{itemize} | ||
| * | ||
| * How it works : | ||
| * \begin{itemize} | ||
| * \item Each "functionName" is associated with exactly one "keyCode" : | ||
| * addKey( functionName, keyCode ) | ||
| * \item Each widget is registered with a "widgetName" : | ||
| * registerWidget( widgetName, this ) | ||
| * \item For a given widget you can connect a "functionName/keyCode" | ||
| * association to a SLOT : | ||
| * connectFunction( widgetName, functionName, receiver, SLOT(...) ) | ||
| * \item Then KKeyConfig manages automatically the keypress. | ||
| * \end{itemize} | ||
| */ | ||
|
|
||
| class KKeyConfig | ||
| { | ||
| friend KKeyWidgetEntry; | ||
| friend KKeyConfigure; | ||
|
|
||
| public: | ||
| /** Construct a KKeyConfig object. Do not use directly this construstor : | ||
| * use initKKeyConfig() instead. | ||
| */ | ||
| KKeyConfig( KConfig* pConfig); | ||
|
|
||
| /** Call sync() and destroy the KKeyConfig object. */ | ||
| ~KKeyConfig(); | ||
|
|
||
| /** Return the current KKeyConfig object. */ | ||
| static KKeyConfig * getKKeyConfig() { return pKKeyConfig; } | ||
|
|
||
| /** Read the current key code associated with the function. */ | ||
| uint readCurrentKey( const QString& functionName ); | ||
|
|
||
| /** Read the default key code associated with the function. */ | ||
| uint readDefaultKey( const QString& functionName); | ||
|
|
||
| /** Add a "functionName/keyCode" association. | ||
| * | ||
| * If "configurable" is set : search the KConfig object for a | ||
| * value. If such a value exists, it is taken as the current key. | ||
| * | ||
| * NB : adding a preexisting function will remove the old association | ||
| * and eventually the old connections. | ||
| * | ||
| * @return FALSE if the keyCode is not correct. | ||
| */ | ||
| bool addKey( const QString& functionName, uint defaultKeyCode, | ||
| bool configurable = TRUE ); | ||
|
|
||
| /** Add a "functionName/keyCode" association. | ||
| * | ||
| * If "configurable" is set : search the KConfig object for a | ||
| * value. If such a value exists, it is taken as the current key. | ||
| * | ||
| * NB : adding a preexisting function will remove the old association | ||
| * and eventually the old connections. | ||
| * | ||
| * @return FALSE if the keyCode is not correct. | ||
| */ | ||
| bool addKey( const QString& functionName, const QString& defaultKeyCode, | ||
| bool configurable = TRUE ); | ||
|
|
||
| /** Remove a "functionName/keyCode" association. | ||
| * | ||
| * NB : it will remove the eventual connections | ||
| */ | ||
| void removeKey( const QString& functionName ); | ||
|
|
||
| /** Register a widget for future connections. */ | ||
| void registerWidget( const QString& widgetName, QWidget* currentWidget ); | ||
|
|
||
| /** Connect the functionName to a slot for a specific widget. */ | ||
| void connectFunction( const QString& widgetName, | ||
| const QString& functionName, | ||
| const QObject* receiver, const char* member, | ||
| bool activate = TRUE ); | ||
|
|
||
| /** Activate/disactivate a connection. */ | ||
| void toggleFunction( const QString& widgetName, | ||
| const QString& functionName, bool activate ); | ||
|
|
||
| /** Remove the connection for a specific widget. */ | ||
| void disconnectFunction( const QString& widgetName, | ||
| const QString& functionName ); | ||
|
|
||
| /** Disconnect all the functionName for a specific widget. */ | ||
| void disconnectAllFunctions( const QString& widgetName ); | ||
|
|
||
| /** Write the current configurable associations in the KConfig object. */ | ||
| void sync(); | ||
|
|
||
| /** Create a dialog showing all the associations and allow the user | ||
| * to configure the configurable ones. On OK it will use the new values, | ||
| * save them in the KConfig object and return TRUE. | ||
| * Nothing is change on CANCEL. | ||
| */ | ||
| bool configureKeys( QWidget *parent ); | ||
|
|
||
| private: | ||
| KConfig *pConfig; | ||
| int aAvailableId; | ||
| QDict<KKeyEntry> aKeyDict; | ||
| QDict<KKeyWidgetEntry> aWidgetDict; | ||
|
|
||
| void KKeyConfig::internalDisconnectFunction( const QString& widgetName, | ||
| KKeyWidgetEntry *pWEntry, KKeyEntry *pEntry, KKeyConnectEntry *pCEntry ); | ||
|
|
||
| protected: | ||
| static KKeyConfig *pKKeyConfig; | ||
|
|
||
| void destroyWidgetEntry( const QString& widgetName ); | ||
| void internalDisconnectAll( const QString& widgetName ); | ||
| }; | ||
|
|
||
| /** must be used for one-button dialog with the functionName "Close dialog". | ||
| * It registers the dialog widget and connect the function. | ||
| */ | ||
| #define D_CLOSE_KEY( dialogName, pDialog ) \ | ||
| { kKeys->registerWidget( dialogName, pDialog ); \ | ||
| kKeys->connectFunction( dialogName, "Close dialog", \ | ||
| pDialog, SLOT(accept()) ); } | ||
|
|
||
| /** must be used for ok/cancel dialog with functionNames "Ok dialog" | ||
| * and "Cancel dialog". | ||
| * It registers the dialog and connect the function. | ||
| */ | ||
| #define D_OKCANCEL_KEY( dialogName, pDialog ) \ | ||
| { kKeys->registerWidget( dialogName, pDialog ); \ | ||
| kKeys->connectFunction( dialogName, "Ok dialog", \ | ||
| pDialog, SLOT(accept()) ); \ | ||
| kKeys->connectFunction( dialogName, "Cancel dialog", \ | ||
| pDialog, SLOT(reject()) ); } | ||
|
|
||
| #endif |
| @@ -0,0 +1,94 @@ | ||
| #ifndef KKEYDATA_H | ||
| #define KKEYDATA_H | ||
|
|
||
| #include <qdict.h> | ||
| #include <qaccel.h> | ||
|
|
||
| #include <qdialog.h> | ||
| #include <qlistbox.h> | ||
| #include <qlabel.h> | ||
| #include <qpushbt.h> | ||
| #include <qchkbox.h> | ||
| #include <qlined.h> | ||
|
|
||
|
|
||
| struct KKeyConnectEntry { | ||
| QObject* pReceiver; | ||
| QString sMember; | ||
| }; | ||
|
|
||
| struct KKeyEntry { | ||
| uint aCurrentKeyCode, aDefaultKeyCode, aConfigKeyCode; | ||
| // configKeyCode is used when configuring via configureKeys() | ||
| bool bConfigurable; | ||
| int aAccelId; | ||
| QDict<KKeyConnectEntry> *pConnectDict; | ||
| }; | ||
|
|
||
| class KKeyWidgetEntry : public QObject | ||
| { | ||
| Q_OBJECT | ||
|
|
||
| public: | ||
| KKeyWidgetEntry( QWidget *widget, const QString& widgetName ); | ||
| ~KKeyWidgetEntry(); | ||
| void createItem( int accelId, uint keyCode, QObject *receiver, | ||
| const char *member ); | ||
| void setItemEnabled( int accelId, bool activate ); | ||
| void deleteItem( int accelId, QObject *receiver, | ||
| const char *member ); | ||
| bool isItemEnabled( int accelId ); | ||
|
|
||
| private: | ||
| QString sWidgetName; | ||
| QWidget *pWidget; | ||
| QAccel *pAccel; | ||
|
|
||
| protected slots: | ||
| void widgetDestroyed(); | ||
| }; | ||
|
|
||
|
|
||
| class KKeyConfigure : public QDialog | ||
| { | ||
| Q_OBJECT | ||
|
|
||
| public: | ||
| KKeyConfigure( QDictIterator<KKeyEntry> *aKeyIt, QWidget *parent=0 ); | ||
| ~KKeyConfigure(); | ||
|
|
||
| private slots: | ||
| void toChange(int index); | ||
| void allDefault(); | ||
| void changeKey(); | ||
| void defaultKey(); | ||
| void shiftClicked(); | ||
| void ctrlClicked(); | ||
| void altClicked(); | ||
| void editKey(); | ||
| void editEnd(); | ||
|
|
||
| protected: | ||
| void keyPressEvent( QKeyEvent *e ); | ||
|
|
||
| private: | ||
| QDictIterator<KKeyEntry> *aIt; | ||
| KKeyEntry *pEntry; | ||
| QString sEntryKey; | ||
| QListBox *wList; | ||
| QLabel *lInfo, *lNotConfig; | ||
| QPushButton *bAllDefault, *bChange, *bEdit, *bDefault, *bOk, *bCancel; | ||
| QCheckBox *cShift, *cCtrl, *cAlt; | ||
| QFrame *fCArea; | ||
| QLineEdit *eKey; | ||
|
|
||
| bool bKeyIntercept; | ||
|
|
||
| const QString item( uint keyCode, const QString& entryKey ); | ||
| bool isKeyPresent(); | ||
| void setKey( uint kCode ); | ||
| }; | ||
|
|
||
|
|
||
|
|
||
| #endif |
| @@ -0,0 +1,7 @@ | ||
| #ifdef HAVE_CONFIG_H | ||
| #include <config.h> | ||
| #endif | ||
|
|
||
| #ifndef HAVE_FUNC_SETENV | ||
| int setenv(const char *name, const char *value, int overwrite) ; | ||
| #endif |
| @@ -0,0 +1,321 @@ | ||
| /* | ||
| * $Id$ | ||
| * | ||
| * $Log$ | ||
| * Revision 1.1.1.1 1997/04/09 00:28:07 cvsuser | ||
| * Sources imported | ||
| * | ||
| * Revision 1.6 1997/03/09 17:43:13 kalle | ||
| * load() returns bool | ||
| * | ||
| * Revision 1.5 1997/03/09 17:38:35 kalle | ||
| * Read other formats than xpm again (bug report by Martin Jones) | ||
| * | ||
| * Revision 1.4 1997/01/15 20:24:48 kalle | ||
| * merged changes from Matthias | ||
| * | ||
| * Revision 1.3 1996/12/07 22:14:53 kalle | ||
| * formatting | ||
| * | ||
| * Revision 1.2 1996/12/07 22:13:44 kalle | ||
| * RCS header | ||
| * | ||
| * | ||
| * KPixmap implementation. Taken from kfm | ||
| */ | ||
|
|
||
| #include "kpixmap.h" | ||
| #include <ctype.h> | ||
|
|
||
| KPixmap::KPixmap() : QPixmap() | ||
| { | ||
| } | ||
|
|
||
| KPixmap::KPixmap( const char *_file ) : QPixmap() | ||
| { | ||
| load( _file ); | ||
| } | ||
|
|
||
| bool KPixmap::loadXPM( const char *_file ) { | ||
| QFile f( _file ); | ||
|
|
||
| if ( !f.open( IO_ReadOnly ) ) | ||
| return false; | ||
|
|
||
| bool head_passed = false; | ||
| bool colors_passed = false; | ||
|
|
||
| int x=-1; | ||
| int y=-1; | ||
| int ncolors=-1; | ||
| int chars_per_pixel=-1; | ||
| int colors_done = 0; | ||
|
|
||
| char *color_chars = 0L; | ||
| QColor *colors = 0L; | ||
| int transparent = -1; | ||
|
|
||
| int col = 0; | ||
|
|
||
| QPainter painter; | ||
| QPainter maskpaint; | ||
|
|
||
| while ( !f.atEnd() ) | ||
| { | ||
| char str[ 1024 ]; | ||
| f.readLine( str, 1024 ); | ||
| if ( str[0] == '\"' ) | ||
| { | ||
| if ( !head_passed ) | ||
| { | ||
| char *p = str + 1; | ||
| while (isspace(*p))p++; | ||
| x = atoi( p ); | ||
| while (isdigit(*p))p++; | ||
| while (isspace(*p))p++; | ||
| y = atoi( p ); | ||
| while (isdigit(*p))p++; | ||
| while (isspace(*p))p++; | ||
| ncolors = atoi( p ); | ||
| while (isdigit(*p))p++; | ||
| while (isspace(*p))p++; | ||
| chars_per_pixel = atoi( p ); | ||
|
|
||
| head_passed = true; | ||
|
|
||
| colors = new QColor[ ncolors ]; | ||
| color_chars = new char[ ncolors ]; | ||
|
|
||
| resize( x, y ); | ||
| bitmap.resize( x, y ); | ||
|
|
||
| painter.begin( this ); | ||
| maskpaint.begin( &bitmap ); | ||
|
|
||
| fill( white ); | ||
| bitmap.fill( color0 ); | ||
| } | ||
| else if ( !colors_passed ) | ||
| { | ||
| char *p = str + 1; | ||
| color_chars[ colors_done ] = *p; | ||
| do | ||
| p = strchr( p+1, 'c' ); | ||
| while (p != 0L && | ||
| !isspace(*(p-1)) && | ||
| !isspace(*p+1)); | ||
| if ( p == 0L ) | ||
| { | ||
| painter.end(); | ||
| maskpaint.end(); | ||
| resize( 0, 0 ); | ||
| bitmap.resize( 0, 0 ); | ||
| delete colors; | ||
| delete color_chars; | ||
| return false; | ||
| } | ||
| p+=2; | ||
|
|
||
| char *p2 = strchr( p, '\"' ); | ||
| if ( p2 == 0L ) | ||
| { | ||
| painter.end(); | ||
| maskpaint.end(); | ||
| resize( 0, 0 ); | ||
| bitmap.resize( 0, 0 ); | ||
| delete colors; | ||
| delete color_chars; | ||
| return false; | ||
| } | ||
| *p2 = 0; | ||
|
|
||
| /* if ( *p == '#' && strlen( p ) == 6 ) | ||
| { | ||
| } | ||
| else if ( *p == '#' && strlen( p ) == 12 ) | ||
| { | ||
| } | ||
| else */ | ||
|
|
||
| if ( strcasecmp( p, "None" ) == 0 ) | ||
| { | ||
| transparent = colors_done; | ||
| colors[ colors_done ].setRgb( 0, 0, 0 ); | ||
| } | ||
| else | ||
| colors[ colors_done ].setNamedColor( p ); | ||
|
|
||
| colors_done++; | ||
| if ( colors_done == ncolors ) | ||
| colors_passed = true; | ||
| } | ||
| else | ||
| { | ||
| if ( col < y ) | ||
| { | ||
| char *p = str + 1; | ||
|
|
||
| for ( int i = 0; i < x; i++ ) | ||
| { | ||
| for ( int j = 0; j < ncolors; j++ ) | ||
| if ( *p == color_chars[ j ] ) | ||
| { | ||
| painter.setPen( colors[ j ] ); | ||
| painter.drawPoint( i, col ); | ||
| if ( j == transparent ) | ||
| maskpaint.setPen( color0 ); | ||
| else | ||
| maskpaint.setPen( color1 ); | ||
| maskpaint.drawPoint( i, col ); | ||
| } | ||
| p++; | ||
| } | ||
| col++; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| painter.end(); | ||
| maskpaint.end(); | ||
|
|
||
| setMask( bitmap ); | ||
|
|
||
| if ( colors != 0 ) | ||
| delete colors; | ||
| if ( color_chars != 0 ) | ||
| delete color_chars; | ||
|
|
||
| f.close(); | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| #define M_PIXMAP_TYPE_UNKNOWN 0 | ||
| #define M_PIXMAP_TYPE_XPM 1 | ||
| #define M_PIXMAP_TYPE_XVPICS 2 | ||
|
|
||
|
|
||
| bool KPixmap::loadXVPICS( const char *_file ) { | ||
| QFile f( _file ); | ||
|
|
||
| if ( !f.open( IO_ReadOnly ) ) | ||
| return false; | ||
|
|
||
| int x=-1; | ||
| int y=-1; | ||
| int maxval=-1; | ||
|
|
||
| QPainter painter; | ||
| QPainter maskpaint; | ||
|
|
||
| char str[ 1024 ]; | ||
|
|
||
| // magic number must be "P7 332" | ||
| f.readLine( str, 1024); | ||
| if (strncmp(str,"P7 332",6)) return false; | ||
|
|
||
| // next line #XVVERSION | ||
| f.readLine( str, 1024 ); | ||
| if (strncmp(str, "#XVVERSION", 10)) | ||
| return false; | ||
|
|
||
| // now it gets interesting, #BUILTIN means we are out. | ||
| // if IMGINFO comes, we are happy! | ||
| f.readLine( str, 1024 ); | ||
| if (strncmp(str, "#IMGINFO:", 9)) | ||
| return false; | ||
|
|
||
| // after this an #END_OF_COMMENTS signals everything to be ok! | ||
| f.readLine( str, 1024 ); | ||
| if (strncmp(str, "#END_OF", 7)) | ||
| return false; | ||
|
|
||
| // now a last line with width, height, maxval which is supposed to be 255 | ||
| f.readLine( str, 1024 ); | ||
| sscanf(str, "%d %d %d", &x, &y, &maxval); | ||
|
|
||
| if (maxval != 255) return false; | ||
|
|
||
| // now follows a binary block of x*y bytes. | ||
|
|
||
| char block[x*y]; | ||
|
|
||
| if (f.readBlock(block, x*y) != x*y) | ||
| printf("kpixmap::readXVPICS could not read datablock of %d bytes\n", | ||
| x*y); | ||
|
|
||
| resize( x,y ); | ||
| bitmap.resize( x,y ); | ||
|
|
||
| painter.begin( this ); | ||
| maskpaint.begin( &bitmap ); | ||
|
|
||
| fill( white ); | ||
| bitmap.fill( color0 ); | ||
|
|
||
| // how do the color handling? they are absolute 24bpp | ||
| // or at least can be calculated as such. | ||
|
|
||
| int i, maxi, r,g,b, posx, posy; | ||
| QColor color; | ||
|
|
||
| maskpaint.setPen( color1); | ||
|
|
||
| char *p; | ||
|
|
||
| maxi = x*y; | ||
|
|
||
| for (i=0, p=block; i<maxi; i++, p++) { | ||
|
|
||
| r = ( ((int) ((*p >> 5) & 0x07)) * 255) / 7; | ||
| g = ( ((int) ((*p >> 2) & 0x07)) * 255) / 7; | ||
| b = ( ((int) ((*p >> 0) & 0x03)) * 255) / 3; | ||
|
|
||
| posx = (int) i%x; | ||
| posy = (int) i/x; | ||
|
|
||
| color.setRgb(r,g,b); | ||
|
|
||
| painter.setPen(color); | ||
| painter.drawPoint(posx, posy); | ||
| maskpaint.drawPoint(posx, posy); | ||
| } | ||
|
|
||
| painter.end(); | ||
| maskpaint.end(); | ||
|
|
||
| setMask( bitmap ); | ||
|
|
||
| f.close(); | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| bool KPixmap::load( const char *_file ) | ||
| { | ||
| // int pixmap_type = M_PIXMAP_TYPE_UNKNOWN; | ||
|
|
||
| // Old strategie: _file does not end with .xpm, call QPixmap-loader. | ||
| // New strategie: use QPixmap::imageformat(const char *filename)! | ||
|
|
||
| if (_file) { | ||
| //#ifdef DEBUG | ||
| // printf("KPixmap::load(\"%s\"): type %s\n", | ||
| // _file, QPixmap::imageFormat(_file)); | ||
| //#endif | ||
|
|
||
| // let QT find out if it can handle this, if so, call QPixmap | ||
| if (QPixmap::imageFormat(_file) != NULL) | ||
| return QPixmap::load( _file ); | ||
|
|
||
| // otherwise call our readingfunctions. | ||
|
|
||
| // FIXME! This should of course not be decided on .xpm filename! | ||
| if (!strstr( _file, ".xpm" ) == 0 ) | ||
| return loadXPM(_file); | ||
|
|
||
| return loadXVPICS(_file); | ||
| } else // if filename is NULL | ||
| return false; | ||
| } |
| @@ -0,0 +1,86 @@ | ||
| /* | ||
| * $Id$ | ||
| * Revision 1.1.1.3 1997/12/11 07:19:13 jacek | ||
| * $Log$ | ||
| * Various widgets moved from apps to libs | ||
| * Added KSeparator | ||
| * Several bugs fixed | ||
| * Patches from Matthias Ettrich | ||
| * Made ksock.cpp more alpha-friendly | ||
| * Removed XPM-Loading from KPixmap | ||
| * Reaping zombie KDEHelp childs | ||
| * WidgetStyle of KApplication objects configurable via kdisplay | ||
| * | ||
| * Revision 1.1.1.1 1997/04/13 14:42:41 cvsuser | ||
| * Source imported | ||
| * | ||
| * Revision 1.1.1.1 1997/04/09 00:28:07 cvsuser | ||
| * Sources imported | ||
| * | ||
| * Revision 1.4 1997/03/09 17:43:00 kalle | ||
| * load() returns bool | ||
| * | ||
| * Revision 1.3 1996/12/07 22:12:15 kalle | ||
| * autoconf and documentation | ||
| * | ||
| * Revision 1.2 1996/12/07 22:08:40 kalle | ||
| #ifdef HAVE_CONFIG_H | ||
| #include <config.h> | ||
| #endif | ||
| #include <stdio.h> | ||
| #ifdef STDC_HEADERS | ||
| #include <stdlib.h> | ||
| #else | ||
| #error Declare functions needed from stdlib.h | ||
| #endif | ||
| * RCS header | ||
| #include <qfile.h> | ||
| #include <qtstream.h> | ||
| #include <qapp.h> | ||
| #include <qbitmap.h> | ||
| #include <qcolor.h> | ||
| #include <qpainter.h> | ||
| /// QPixmap that may be loaded from an .xpm file. | ||
| /** QPixmap that may be loaded from an .xpm file. */ | ||
| class KPixmap : public QPixmap | ||
| { | ||
| public: | ||
| /// Default constructor. | ||
| /** Default constructor. */ | ||
| KPixmap(); | ||
|
|
||
| /// Constructor with filename. | ||
| /** Constructor with filename. Loads a pixmap from the specified | ||
| .xpm file */ | ||
| KPixmap( const char * ); | ||
|
|
||
| /// Destructor. | ||
| /** Destructor. */ | ||
| virtual ~KPixmap() { } | ||
|
|
||
| /// Load a pixmap from an .xpm file | ||
| /** Load a pixmap from an .xpm file */ | ||
| virtual bool load( const char * ); | ||
| virtual bool loadXPM( const char *); | ||
| virtual bool loadXVPICS( const char *); | ||
| * | ||
| protected: | ||
| QBitmap bitmap; | ||
| }; | ||
| * KPixmap - taken from kfm | ||
| * | ||
| * Author: Torben Weis | ||
| * | ||
| */ | ||
|
|
||
| #ifndef KPIXMAP_H | ||
| #define KPIXMAP_H | ||
|
|
||
| #include <qpixmap.h> | ||
|
|
||
| #define KPixmap QPixmap | ||
|
|
||
| #endif |
| @@ -0,0 +1,263 @@ | ||
| /* | ||
| * $Id$ | ||
| * $Log$ | ||
| * Revision 1.1.1.1 1997/04/09 00:28:06 cvsuser | ||
| * Sources imported | ||
| * | ||
| * Revision 1.4 1997/01/15 20:31:41 kalle | ||
| * merged changes from 0.52 | ||
| * | ||
| * Revision 1.3 1996/12/07 18:31:00 kalle | ||
| * Qt debugging functions instead of printf and formatting | ||
| * | ||
| * Revision 1.2 1996/12/07 18:22:56 kalle | ||
| * RCS-Header | ||
| * | ||
| * | ||
| * The KDE Socket Classes. | ||
| * | ||
| * Torben Weis | ||
| * weis@stud.uni-frankfurt.de | ||
| * | ||
| * Last change: 10.11.96 | ||
| * | ||
| * Part of the KDE Project. | ||
| * Kalle: new stopsign.xpm | ||
| * KConfig: environment variables are resolved in readEntry() | ||
| * Added KFloater | ||
| KSocket::KSocket( const char *_host, unsigned short int _port ) | ||
| #include <errno.h> | ||
| if ( !connect ( _host, _port ) ) | ||
| { | ||
| sock = -1; | ||
| return; | ||
| } | ||
| readNotifier = 0L; | ||
| writeNotifier = 0L; | ||
| #include <stdlib.h> | ||
| #include <string.h> | ||
| #endif | ||
| #ifdef HAVE_UNISTD_H | ||
| #include <unistd.h> | ||
| #endif | ||
| if ( readNotifier == 0L ) | ||
| #include <sysent.h> | ||
| #endif | ||
| #include <sys/types.h> | ||
| #include <sys/stat.h> | ||
| #include <sys/socket.h> | ||
| readNotifier->setEnabled( TRUE ); | ||
| # include <sys/time.h> | ||
| else if ( readNotifier == 0L ) | ||
| readNotifier->setEnabled( FALSE ); | ||
| # if HAVE_SYS_TIME_H | ||
| # include <sys/time.h> | ||
| # else | ||
| # include <time.h> | ||
| # endif | ||
| #endif | ||
| if ( writeNotifier == 0L ) | ||
| #include <netinet/in.h> | ||
| #include <arpa/inet.h> | ||
| QObject::connect( readNotifier, SIGNAL( activated(int) ), this, | ||
| #endif | ||
| KSocket::KSocket( const char *_host, unsigned short int _port ) : | ||
| writeNotifier->setEnabled( TRUE ); | ||
| { | ||
| else if ( writeNotifier == 0L ) | ||
| writeNotifier->setEnabled( FALSE ); | ||
| } | ||
| void KSocket::slotRead( int _sock ) | ||
| { | ||
| if ( _state ) | ||
| { | ||
| if ( !readNotifier ) | ||
| { | ||
| readNotifier = new QSocketNotifier( sock, QSocketNotifier::Read ); | ||
| QObject::connect( readNotifier, SIGNAL( activated(int) ), this, SLOT( slotRead(int) ) ); | ||
| } | ||
| else | ||
| readNotifier->setEnabled( true ); | ||
| void KSocket::slotWrite( int _sock ) | ||
| else if ( readNotifier ) | ||
| readNotifier->setEnabled( false ); | ||
| } | ||
| void KSocket::enableWrite( bool _state ) | ||
| { | ||
| if ( _state ) | ||
| { | ||
| if ( !writeNotifier ) | ||
| { | ||
| writeNotifier = new QSocketNotifier( sock, QSocketNotifier::Write ); | ||
| QObject::connect( writeNotifier, SIGNAL( activated(int) ), this, | ||
| SLOT( slotWrite(int) ) ); | ||
| } | ||
| else | ||
| writeNotifier->setEnabled( true ); | ||
| if ( hostinfo == 0L ) | ||
| else if ( writeNotifier ) | ||
| writeNotifier->setEnabled( false ); | ||
| return FALSE; | ||
| void KSocket::slotRead( int ) | ||
| { | ||
| return TRUE; | ||
| int n = recv( sock, buffer, 1, MSG_PEEK ); | ||
| if ( n <= 0 ) | ||
| emit closeEvent( this ); | ||
| else | ||
| emit readEvent( this ); | ||
| } | ||
| void KSocket::slotWrite( int ) | ||
| return FALSE; | ||
| emit writeEvent( this ); | ||
| } | ||
| return FALSE; | ||
| if ( domain != PF_INET ) | ||
| return false; | ||
| return FALSE; | ||
| if ( !hostinfo ) | ||
| return TRUE; | ||
| warning("Unknown host %s.\n",hostname); | ||
| return false; | ||
| long KSocket::getAddr() | ||
| } | ||
| struct sockaddr_in name; int len = sizeof(name); | ||
| return true; | ||
| } | ||
| */ | ||
| bool KSocket::connect( const char *_host, unsigned short int _port ) | ||
| { | ||
| if ( domain != PF_INET ) | ||
| if ( readNotifier != 0L ) | ||
|
|
||
| if ( writeNotifier != 0L ) | ||
| if (sock < 0) | ||
| if ( readNotifier ) | ||
| close( sock ); | ||
| if ( writeNotifier ) | ||
| return false; | ||
| } | ||
| KServerSocket::KServerSocket( int _port ) | ||
| if ( 0 > ::connect( sock, (struct sockaddr*)(&server_name), | ||
| sizeof( server_name ) ) ) | ||
| { | ||
| sock = -1; | ||
| ::close( sock ); | ||
| sock = -1; | ||
| return false; | ||
| } | ||
|
|
||
| unsigned long KSocket::getAddr() | ||
| { | ||
| if ( domain != PF_INET ) | ||
| return 0; | ||
|
|
||
| struct sockaddr_in name; ksize_t len = sizeof(name); | ||
| getsockname(sock, (struct sockaddr *) &name, &len); | ||
| return ntohl(name.sin_addr.s_addr); | ||
| } | ||
|
|
||
| KSocket::~KSocket() | ||
| return FALSE; | ||
| if ( readNotifier ) | ||
| { | ||
| delete readNotifier; | ||
| } | ||
| if ( writeNotifier ) | ||
| } | ||
|
|
||
| notifier = new QSocketNotifier( sock, QSocketNotifier::Read ); | ||
|
|
||
| return FALSE; | ||
| } | ||
|
|
||
| if ( !init ( _port ) ) | ||
| { | ||
| fatal("Error constructing\n"); | ||
| return FALSE; | ||
|
|
||
| bool KServerSocket::init( unsigned short int _port ) | ||
| return TRUE; | ||
| if ( domain != PF_INET ) | ||
| { | ||
| int KServerSocket::getPort() | ||
| return false; | ||
| struct sockaddr_in name; int len = sizeof(name); | ||
| sock = ::socket( PF_INET, SOCK_STREAM, 0 ); | ||
| if (sock < 0) | ||
| { | ||
| warning( "Could not create socket\n"); | ||
| long KServerSocket::getAddr() | ||
| } | ||
| struct sockaddr_in name; int len = sizeof(name); | ||
| name.sin_family = AF_INET; | ||
| name.sin_port = htons( _port ); | ||
| name.sin_addr.s_addr = htonl(INADDR_ANY); | ||
|
|
||
| void KServerSocket::slotAccept( int _sock ) | ||
| { | ||
| warning("Could not bind to socket\n"); | ||
| ::close( sock ); | ||
| sock = -1; | ||
| int size = sizeof(clientname); | ||
| } | ||
|
|
||
| if ( listen( sock, 1000 ) < 0 ) | ||
| { | ||
| warning("Error listening on socket\n"); | ||
| ::close( sock ); | ||
| sock = -1; | ||
| return false; | ||
| } | ||
|
|
||
| unsigned short KServerSocket::getPort() | ||
| { | ||
| if ( notifier != 0L ) | ||
| return false; | ||
|
|
||
| struct sockaddr_in name; ksize_t len = sizeof(name); | ||
|
|
||
| unsigned long KServerSocket::getAddr() | ||
| { | ||
| if ( domain != PF_INET ) | ||
| return false; | ||
|
|
||
| struct sockaddr_in name; ksize_t len = sizeof(name); | ||
| struct sockaddr_in clientname; | ||
| int new_sock; | ||
|
|
||
| ksize_t size = sizeof(clientname); | ||
| else if ( domain == PF_UNIX ) | ||
| if ((new_sock = accept (sock, (struct sockaddr *) &clientname, &size)) < 0) | ||
| struct sockaddr_un clientname; | ||
| warning("Error accepting\n"); | ||
| return; | ||
| ksize_t size = sizeof(clientname); | ||
|
|
||
| emit accepted( new KSocket( new_sock ) ); | ||
| warning("Error accepting\n"); | ||
| return; | ||
| } | ||
|
|
||
| emit accepted( new KSocket( new_sock ) ); | ||
| } | ||
| } | ||
|
|
||
| KServerSocket::~KServerSocket() | ||
| { | ||
| if ( notifier ) | ||
| delete notifier; | ||
|
|
||
| close( sock ); | ||
| } | ||
|
|
||
|
|
| @@ -0,0 +1,288 @@ | ||
| /* | ||
| * $Id$ | ||
| * | ||
| * $Log$ | ||
| * Revision 1.8 1997/10/16 11:15:03 torben | ||
| * Kalle: Copyright headers | ||
| * kdoctoolbar removed | ||
| * | ||
| * Revision 1.7 1997/09/18 12:16:05 kulow | ||
| * corrected some header dependencies. Removed most of them in drag.h and put | ||
| * them in drag.cpp. Now it should compile even under SunOS 4.4.1 ;) | ||
| * | ||
| * Revision 1.6 1997/08/30 08:32:56 kdecvs | ||
| * Coolo: changed the location of the include files to get rid of the | ||
| * hardcoded HAVE_STDC_HEADERS | ||
| * | ||
| * Revision 1.5 1997/07/27 13:43:59 kalle | ||
| * Even more SGI and SCC patches, security patch for kapp, various fixes for ksock | ||
| * | ||
| * Revision 1.4 1997/07/25 19:46:43 kalle | ||
| * SGI changes | ||
| * | ||
| * Revision 1.3 1997/07/18 05:49:18 ssk | ||
| * Taj: All kdecore doc now in javadoc format (hopefully). | ||
| * | ||
| * Revision 1.2 1997/06/25 14:22:13 ssk | ||
| * Taj: updated some documentation. | ||
| * | ||
| * Revision 1.1.1.1 1997/04/13 14:42:42 cvsuser | ||
| * Source imported | ||
| * | ||
| * Revision 1.1.1.1 1997/04/09 00:28:07 cvsuser | ||
| #include <stdio.h> | ||
| #include <errno.h> | ||
| #ifdef STDC_HEADERS | ||
| #include <stdlib.h> | ||
| #include <string.h> | ||
| #else | ||
| #error Declare functions needed from stdlib.h and string.h | ||
| #endif | ||
| #ifdef HAVE_UNISTD_H | ||
| #include <unistd.h> | ||
| #else | ||
| #error Declare functions needed from unistd.h | ||
| #endif | ||
| #include <sys/types.h> | ||
| #include <sys/stat.h> | ||
| #include <sys/socket.h> | ||
| #if TIME_WITH_SYS_TIME | ||
| # include <sys/time.h> | ||
| # include <time.h> | ||
| #else | ||
| # if HAVE_SYS_TIME_H | ||
| # include <sys/time.h> | ||
| # else | ||
| # include <time.h> | ||
| # endif | ||
| #endif | ||
| #include <sys/time.h> | ||
| * | ||
| #include <arpa/inet.h> | ||
| #include <netdb.h> | ||
| #include <fcntl.h> | ||
| #include <signal.h> | ||
| * Revision 1.4 1997/01/15 20:34:14 kalle | ||
| * merged changes from 0.52 | ||
| * | ||
| /// KSocket: Internet connections in KDE | ||
| /** This is a normal socket. You can connect this socket to any internet | ||
| address. | ||
| The socket gives you three signals: When ready for reading/writing or if the | ||
| connection is broken. | ||
| Using socket() you get a file descriptor which you can use with usual unix | ||
| commands like write(..) or read(...). | ||
| If you have already such a socket identifier you can construct a KSocket on | ||
| this identifier. | ||
| If socket() delivers a value of -1 or less, the connection had no success. | ||
| */ | ||
| * @author Torben Weis <weis@uni-frankfurt.de> | ||
| * @version $Id$ | ||
| Q_OBJECT | ||
| */ | ||
| /// Constructor with file descriptor | ||
| /** | ||
| Create a KSocket with the file descriptor _sock. | ||
| */ | ||
| KSocket( int _sock ) { sock = _sock; readNotifier = 0L; writeNotifier = 0L; } | ||
| * Create a KSocket with the provided file descriptor. | ||
| /// Constructor with host and port | ||
| /** | ||
| Create a socket and connect to _host:_port. | ||
| */ | ||
| * Create a socket and connect to a host. | ||
| * @param _host the remote host to which to connect. | ||
| /// Destructor, closes the socket. | ||
| /** | ||
| Close the socket. | ||
| */ | ||
|
|
||
| /** | ||
| /// Return the file descriptor | ||
| /** | ||
| Returns a file descriptor for this socket. | ||
| */ | ||
| int socket() { return sock; } | ||
| /** | ||
| /// Enable the socket for reading. | ||
| /** | ||
| If you enable read mode, the socket will emit the signal | ||
| readEvent whenever there is something to read out of this | ||
| socket. | ||
| */ | ||
| * If you enable read mode, the socket will emit the signal | ||
| * readEvent whenever there is something to read out of this | ||
| /// Enable the socket for writing. | ||
| /** | ||
| If you enable write mode, the socket will emit the signal | ||
| writeEvent whenever the socket is ready for writing. | ||
| */ | ||
| * | ||
| * If you enable write mode, the socket will emit the signal | ||
| /// Return address. | ||
| long getAddr(); | ||
| /** | ||
| //@Man: signals | ||
| //@{ | ||
| * Return address. | ||
| /// Data has arrived. | ||
| /** | ||
| Tells that data has arrived on the socket. You must call | ||
| enableRead( TRUE ) before you get this signal. | ||
| */ | ||
| * | ||
| * This signal will only be raised if enableRead( TRUE ) was called | ||
| /// Socket is ready for writing. | ||
| /** | ||
| Tells that the socket is ready for writing. You must call | ||
| enableWrite( TRUE ) before you get this signal. | ||
| */ | ||
| * | ||
| * This signal will only be raised if enableWrite( TRUE ) was called | ||
| /// The connection is broken. | ||
| /** | ||
| Tells you that the connection is broken. | ||
| */ | ||
|
|
||
| /** | ||
| //@} | ||
| //@Man: slots | ||
| //@{ | ||
| * Raised when the connection is broken. | ||
| /// Slot for the writeNotifier | ||
| /** | ||
| Connected to the writeNotifier. | ||
| */ | ||
| public slots: | ||
| /** | ||
| /// Slot for the readNotifier | ||
| /** | ||
| Connected to the readNotifier. | ||
| */ | ||
|
|
||
| //@} | ||
| /** | ||
| * Connected to the readNotifier. | ||
| */ | ||
| void slotRead( int ); | ||
|
|
||
| * Socket is ready for writing. | ||
| bool connect( const char *_host, unsigned short int _port ); | ||
| bool init_sockaddr( const char *hostname, unsigned short int port ); | ||
|
|
||
| struct sockaddr_in server_name; | ||
|
|
||
| /****************************************************** | ||
| * The file descriptor for this socket. sock may be -1. | ||
| * This indicates that it is not connected. | ||
| */ | ||
| int sock; | ||
|
|
||
| QSocketNotifier *readNotifier; | ||
| /// KServerSocket: Listen on a port. | ||
| /** | ||
| You can use a KServerSocket to listen on a port for incoming | ||
| connections. When a connection arrived in the port, a KSocket | ||
| is created and the signal accepted is raised. Make shure you | ||
| always connect to this signal. If you dont the ServerSocket will | ||
| create new KSocket's and no one will delete them! | ||
| If socket() is -1 or less the socket was not created properly. | ||
| */ | ||
| * @author Torben Weis <weis@stud.uni-frankfurt.de> | ||
| * @version $Id$ | ||
| Q_OBJECT | ||
| int sock; | ||
| /// Constructor. | ||
| /** | ||
| Listen on port _port for incoming connections. | ||
| */ | ||
| /** | ||
| * Constructor. | ||
| /// Destructor. | ||
| /** | ||
| Close the port. | ||
| */ | ||
|
|
||
| /** | ||
| /// Return the file descriptor. | ||
| /** | ||
| Get the file descriptor assoziated with the socket. | ||
| */ | ||
| int socket() { return sock; } | ||
| /** | ||
| /// Return the port. | ||
| /** | ||
| Get the port the server is listening on. | ||
| */ | ||
| int getPort(); | ||
| /** | ||
| /// Return address. | ||
| long getAddr(); | ||
| /** | ||
| //@Man: slots | ||
| //@{ | ||
| public slots: | ||
| /// Someone connects. | ||
| /** | ||
| Called when someone connected to our port. | ||
| */ | ||
| */ | ||
| //@} | ||
| /** | ||
| //@Man: signals | ||
| //@{ | ||
| signals: | ||
| /// A connection has been accepted. | ||
| /** | ||
| Tells you that someone connected to the port. It is your | ||
| task to delete the KSocket if it is no longer needed. | ||
| */ | ||
| ~KServerSocket(); | ||
| //@} | ||
| /** A connection has been accepted. | ||
| * It is your task to delete the KSocket if it is no longer needed. | ||
| */ | ||
| void accepted( KSocket* ); | ||
| /****************************************************** | ||
| * Notifies us when there is something to read on the port. | ||
| */ | ||
| */ | ||
| /** | ||
| /****************************************************** | ||
| * The file descriptor for this socket. sock may be -1. | ||
| * This indicates that it is not connected. | ||
| */ | ||
| /** | ||
| * The file descriptor for this socket. sock may be -1. | ||
| * This indicates that it is not connected. | ||
| */ | ||
| int sock; | ||
| */ | ||
| virtual void slotAccept( int ); | ||
|
|
||
| signals: | ||
| /** | ||
| * A connection has been accepted. | ||
| void accepted( KSocket* ); | ||
| protected: | ||
| bool init( short unsigned int ); | ||
| bool init( const char* _path ); | ||
| /** | ||
| * Notifies us when there is something to read on the port. | ||
| */ | ||
| QSocketNotifier *notifier; | ||
| * The file descriptor for this socket. sock may be -1. | ||
| * This indicates that it is not connected. | ||
| */ | ||
| int sock; | ||
|
|
||
| int domain; | ||
| }; | ||
|
|
||
| #endif | ||
|
|
||
|
|
| @@ -0,0 +1,379 @@ | ||
| // -*-C++-*- | ||
| // KURL | ||
| // | ||
| // Mon Nov 25 10:07:17 1996 -- Steffen Hansen | ||
|
|
||
| // Reference: RFC 1738 Uniform Resource Locators | ||
| // Syntax? | ||
| // TODO: user, password, port | ||
|
|
||
| #include "kurl.h" | ||
| #include <iostream.h> | ||
|
|
||
| void | ||
| KURL::detach() | ||
| { | ||
| protocol_part.detach(); | ||
| host_part.detach(); | ||
| path_part.detach(); | ||
| ref_part.detach(); | ||
| /* temporarily removed */ | ||
| // dir_part.detach(); | ||
| user_part.detach(); | ||
| passwd_part.detach(); | ||
| } | ||
|
|
||
| static void split1(QString _in, char* sep, QString* _out1, QString* _out2) | ||
| /* <_in> -> [<_out1><sep>]<out2> */ | ||
| { | ||
| } | ||
|
|
||
| static void split2(QString _in, char* sep, QString* _out1, QString* _out2) | ||
| /* <_in> -> <_out1>[<sep><out2>] */ | ||
| { | ||
| } | ||
|
|
||
| KURL::KURL( KURL & _base_url, const char * _rel_url ) | ||
| { | ||
| malformed = _base_url.malformed; | ||
| protocol_part = _base_url.protocol_part; | ||
| host_part = _base_url.host_part; | ||
| path_part = _base_url.path_part; | ||
| ref_part = _base_url.ref_part; | ||
| dir_part = _base_url.dir_part; | ||
| user_part = _base_url.user_part; | ||
| passwd_part = _base_url.passwd_part; | ||
| detach(); | ||
|
|
||
| if ( strstr( _rel_url, ":/" ) == 0 ) | ||
| cdPath( _rel_url ); | ||
| else | ||
| parse( _rel_url ); | ||
| } | ||
|
|
||
| KURL::KURL( const char* _url) | ||
| { | ||
| parse( _url ); | ||
| } | ||
|
|
||
| void KURL::parse( const char * _url ) | ||
| { | ||
| QString url(_url); | ||
| url.detach(); | ||
| malformed = FALSE; | ||
|
|
||
| if ( _url[0] == '/' ) | ||
| url.sprintf( "file:%s", _url ); | ||
|
|
||
| // We need a : somewhere to determine the protocol | ||
| int pos = url.find( ":" ); | ||
| if ( pos == -1 ) | ||
| { | ||
| malformed = TRUE; | ||
| return; | ||
| } | ||
| protocol_part = url.left( pos ); | ||
|
|
||
| if ( protocol_part == "info" || protocol_part == "mailto" || protocol_part == "man" ) | ||
| { | ||
| path_part = url.mid( pos + 1, url.length() ); | ||
| detach(); | ||
| return; | ||
| } | ||
|
|
||
| if ( (int)url.length() < pos + 2 ) | ||
| { | ||
| malformed = TRUE; | ||
| return; | ||
| } | ||
|
|
||
| if ( strncmp( url.data() + pos, ":/", 2 ) != 0 ) | ||
| { | ||
| malformed = TRUE; | ||
| return; | ||
| } | ||
| pos += 2; | ||
| int pos2; | ||
| // Is it a local file or what | ||
| if( url.data()[pos] == '/') | ||
| { | ||
| pos2 = url.find( '/', pos + 1); | ||
| if ( pos2 == -1 ) | ||
| { | ||
| host_part = url.mid( pos + 1, url.length() ); | ||
| pos2 = url.length(); | ||
| } | ||
| else | ||
| host_part = url.mid( pos + 1, (( pos2 == -1)?url.length():pos2) - pos - 1); | ||
| } | ||
| else | ||
| { | ||
| host_part = ""; | ||
| // Go back to the '/' | ||
| pos2 = pos - 1; | ||
| } | ||
|
|
||
| if ( host_part.length() > 0 ) | ||
| { | ||
| int j = host_part.find( "@" ); | ||
| if ( j != -1 ) | ||
| { | ||
| int i = host_part.find( ":" ); | ||
| if ( i != -1 && i < j ) | ||
| { | ||
| user_part = host_part.left( i ); | ||
| passwd_part = host_part.mid( i + 1, j - i - 1 ); | ||
| host_part = host_part.mid( j + 1, host_part.length() ); | ||
| } | ||
| else | ||
| { | ||
| user_part = host_part.left( j ); | ||
| passwd_part = ""; | ||
| host_part = host_part.mid( j + 1, host_part.length() ); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| passwd_part = ""; | ||
| user_part = ""; | ||
| } | ||
| } | ||
| else | ||
| { | ||
| passwd_part = ""; | ||
| user_part = ""; | ||
| } | ||
|
|
||
| // Find the path | ||
| if( pos2 < (int)url.length() && pos2 != -1) | ||
| { | ||
| int pos3 = url.find( '#', pos2 ); | ||
| // Is there a reference ? | ||
| if ( pos3 == -1 ) | ||
| path_part = url.mid( pos2, url.length() ); | ||
| else | ||
| { | ||
| path_part = url.mid( pos2, pos3 - pos2 ); | ||
| ref_part = url.mid( pos3 + 1, url.length() ); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| path_part = "/"; | ||
| ref_part = ""; | ||
| } | ||
|
|
||
| /* ip-schemepart, login, see RFC1738 */ | ||
| /* Syntax [<user>[":"<password>]"@"]<host>[":"<port>]] */ | ||
| /* Note that both user and password may be encoded. */ | ||
| // login -> [userpart@]hostpart | ||
| // hostpart -> Host[:Port] | ||
| // userpart -> User[:Pass] | ||
| detach(); | ||
| } | ||
|
|
||
| KURL::KURL( const char* _protocol, const char* _host, | ||
| const char* _path, const char* _ref) | ||
| { | ||
| protocol_part = _protocol; | ||
| host_part = _host; | ||
| path_part = _path; | ||
| ref_part = _ref; | ||
| malformed = FALSE; | ||
| detach(); | ||
| cleanURL(); | ||
| } | ||
|
|
||
| const char* KURL::directory( bool _trailing ) | ||
| { | ||
| // Calculate only on demand | ||
| if ( path_part.right( 1 ) == "/" ) | ||
| dir_part = path_part.data(); | ||
| else | ||
| { | ||
| QString p = path_part; | ||
| if ( !_trailing ) | ||
| if ( p.right( 1 ) == "/" ) | ||
| p = p.left( p.length() - 1 ); | ||
| int i = p.findRev( "/" ); | ||
| if ( i == -1 ) | ||
| // Should never happen | ||
| dir_part = "/"; | ||
| else | ||
| dir_part = p.left( i + 1 ); | ||
| } | ||
|
|
||
| return dir_part.data(); | ||
| } | ||
|
|
||
| const char* KURL::directoryURL( bool _trailing ) | ||
| { | ||
| QString u = url(); | ||
|
|
||
| // Calculate only on demand | ||
| if ( u.right( 1 ) == "/" ) | ||
| dir_part = u.data(); | ||
| else | ||
| { | ||
| if ( !_trailing ) | ||
| if ( u.right( 1 ) == "/" ) | ||
| u = u.left( u.length() - 1 ); | ||
| int i = u.findRev( "/" ); | ||
| if ( i == -1 ) | ||
| // Should never happen | ||
| dir_part = "/"; | ||
| else | ||
| dir_part = u.left( i + 1 ); | ||
| } | ||
|
|
||
| return dir_part.data(); | ||
| } | ||
|
|
||
| QString | ||
| KURL::url() const | ||
| { | ||
| QString url( protocol_part.data()); | ||
| url.detach(); | ||
| if( !host_part.isNull() && host_part.data()[0] != 0) | ||
| { | ||
| url += "://"; | ||
| if ( !user_part.isNull() && user_part.data()[0] != 0 ) | ||
| { | ||
| url += user_part.data(); | ||
| if ( !passwd_part.isNull() && passwd_part.data()[0] != 0 ) | ||
| { | ||
| url += ":"; | ||
| url += passwd_part.data(); | ||
| } | ||
| url += "@"; | ||
| } | ||
| url += host_part; | ||
| } | ||
| else | ||
| url += ":"; | ||
|
|
||
| if( !path_part.isNull() && path_part.data()[0] != 0) | ||
| url += path_part; | ||
| if( !ref_part.isNull() && ref_part.data()[0] != 0) | ||
| url += "#" + ref_part; | ||
|
|
||
| return url; | ||
| } | ||
|
|
||
| static inline QString cleanPath( const char* filePath) | ||
| { | ||
| QString tmp( QDir::cleanDirPath( filePath) ); | ||
| if( tmp == "." || tmp == "/") | ||
| tmp = ""; | ||
| return tmp; | ||
| } | ||
|
|
||
| void | ||
| KURL::cleanURL() | ||
| { | ||
| path_part = cleanPath( path_part); | ||
| if( path_part.data()[0] != '/') | ||
| path_part.prepend("/"); | ||
| protocol_part = cleanPath( protocol_part); | ||
| host_part = cleanPath( host_part); | ||
| ref_part = cleanPath( ref_part); | ||
| } | ||
|
|
||
| const char* KURL::filename( bool _isReference ) | ||
| { | ||
| if ( _isReference ) | ||
| { | ||
| int pos = ref_part.findRev( "/" ); | ||
| return ref_part.data() + pos + 1; | ||
| } | ||
|
|
||
| if ( path_part.data()[0] == 0 ) | ||
| return ""; | ||
|
|
||
| if ( path_part.data()[0] == '/' && path_part.data()[1] == 0 ) | ||
| return ""; | ||
|
|
||
| int pos = path_part.findRev( "/" ); | ||
| return path_part.data() + pos + 1; | ||
| } | ||
|
|
||
| bool | ||
| KURL::cdRef( const char* _ref, bool acceptAbsPath) | ||
| { | ||
| // We cant have a referece if we have no path (other than /) | ||
| if( path_part.isNull() || path_part.data()[0] == 0 | ||
| || path_part.data()[0] == '/') | ||
| return false; | ||
| if( _ref[0] == '/' && acceptAbsPath) { | ||
| ref_part = _ref + 1; | ||
| } else { | ||
| if( ref_part.data()[0] != 0 | ||
| && ref_part.data()[ref_part.length()] != '/') | ||
| ref_part += "/"; | ||
| ref_part += _ref; | ||
| } | ||
| cleanURL(); | ||
| return true; | ||
| } | ||
|
|
||
| bool KURL::cdPath( const char* _dir, bool acceptAbsPath, bool zapRef) | ||
| { | ||
| if ( !_dir ) | ||
| return FALSE; | ||
|
|
||
| if( _dir[0] == '/' && acceptAbsPath ) | ||
| { | ||
| path_part = _dir; | ||
| } | ||
| else if ( _dir[0] == '~' ) | ||
| { | ||
| path_part = QDir::homeDirPath(); | ||
| path_part.detach(); | ||
| path_part += _dir + 1; | ||
| } | ||
| else | ||
| { | ||
| path_part += "/"; | ||
| path_part += _dir; | ||
| } | ||
| if( zapRef ) | ||
| setReference( "" ); | ||
| cleanURL(); | ||
| return true; | ||
| } | ||
|
|
||
| bool | ||
| KURL::setReference( const char* _ref) | ||
| { | ||
| // We cant have a referece if we have no path (other than /) | ||
| if( path_part.isNull() || path_part.data()[0] == 0 ) | ||
| return false; | ||
| ref_part = _ref; | ||
| return true; | ||
| } | ||
| bool | ||
| KURL::cd( const char* dir, bool acceptAbsPath, bool isReference) | ||
| { | ||
| if( isReference) | ||
| return cdRef( dir, acceptAbsPath); | ||
| else | ||
| return cdPath( dir, acceptAbsPath); | ||
| } | ||
|
|
||
| KURL& | ||
| KURL::operator=( const KURL &u) | ||
| { | ||
| malformed = u.malformed; | ||
| protocol_part = u.protocol_part; | ||
| host_part = u.host_part; | ||
| path_part = u.path_part; | ||
| ref_part = u.ref_part; | ||
| detach(); | ||
| return *this; | ||
| } | ||
|
|
||
| KURL& KURL::operator=( const char *_url ) | ||
| { | ||
| parse( _url ); | ||
| return *this; | ||
| } |
| @@ -0,0 +1,276 @@ | ||
| #ifndef KURL_H | ||
| #define KURL_H | ||
|
|
||
| // -*-C++-*- | ||
| // KURL header | ||
| // | ||
| // Mon Nov 25 10:07:17 1996 -- Steffen Hansen | ||
|
|
||
| #include <qstring.h> | ||
| #include <qdir.h> | ||
|
|
||
| //Why the h... hasn't DCC on SGI true and false defined | ||
| //const bool true = 1; | ||
| //const bool false = 0; | ||
|
|
||
| /// KDE URL objects | ||
| /** The KURL class deals with uniform resource locators in a | ||
| protocol independent way. It works on {\tt file:}-type URL's | ||
| much like QDir does on normal directories; but KURL extends | ||
| the directory operations to work on general URL's. In fact, the | ||
| part of KURL that only deals with syntax doesn't care about | ||
| the protocol at all, so feel free to use it to format any | ||
| URL-like string. NOTE: KURL doesn't support URL's that don't | ||
| look like files (for example {\tt mailto:someone@somewhere}). | ||
| [If URL's like this were OK, there were noreason for | ||
| isMalformed() since any string with a {\tt :} would be a valid URL. | ||
| Comments please.] | ||
| */ | ||
|
|
||
| class KURL : private QDir { | ||
| public: | ||
| //@Man: Constructors | ||
| //@{ | ||
| /// Construct a KURL object. | ||
| /** Construct a KURL object.*/ | ||
| KURL() { malformed = true; protocol_part = ""; | ||
| host_part = ""; path_part = ""; ref_part = ""; } | ||
|
|
||
| /// Construct a KURL object from _url. | ||
| /** Construct a KURL object from _url. | ||
| A KURL object is always constructed, but if you | ||
| plan to use it, you should check it with isMalformed(). | ||
| */ | ||
| KURL( const char* _url); | ||
|
|
||
| /// Construct a KURL object from its components. | ||
| /** Construct a KURL object from its components. */ | ||
| KURL( const char* _protocol, const char* _host, | ||
| const char* _path, const char* _ref); | ||
|
|
||
| /// Constructs a URL. | ||
| /** | ||
| The second argument may be a relative URL, like '/home/weis/test.txt'. | ||
| If for example the first parameter is 'http://uni-frankfurt/pub/incoming' then | ||
| the result will be 'http://uni-frankfurt/home/weis/test.txt'. Of course the | ||
| second argument may be a complete URL, too. | ||
| */ | ||
| KURL( KURL & _base_url, const char* _rel_url ); | ||
| //@} | ||
|
|
||
| //@Man: URL information members | ||
| //@{ | ||
| /// Tells wether the URL has the right syntax. | ||
| /** Returns true if the URL is not a valid URL. This is only | ||
| syntax-checking -- it is not tested if the URL exists. | ||
| {\bf NOTE:} Syntax checking is only done when constructing a | ||
| KURL from a string. | ||
| */ | ||
| bool isMalformed() const { return malformed; } | ||
|
|
||
| /// Returns the URL. | ||
| /** Returns the URL. */ | ||
| QString url() const; | ||
|
|
||
| /// Returns the protocol. | ||
| /** The function returns the protocolname up to, but not | ||
| including the {\tt :}. | ||
| */ | ||
| char* protocol() const { if (protocol_part.isNull()) return ""; | ||
| else return protocol_part.data(); } | ||
|
|
||
| /// Returns the host. | ||
| /** This function returns the host. If there is no host (i.e. | ||
| the URL refers to a local file) this function returns "". | ||
| */ | ||
| char* host() const { if (host_part.isNull()) return ""; | ||
| else return host_part.data(); } | ||
|
|
||
| /// Returns the path. | ||
| /** This function returns the path-part of the URL, for example | ||
| path() on {\tt tar://ftp.foo.org/bar/stuff.tar.gz\#tex/doc.tex}. | ||
| returns #/bar/stuff.tar.gz#. | ||
| */ | ||
| char* path() const { if (path_part.isNull()) return ""; | ||
| else return path_part.data(); } | ||
|
|
||
| /// Returns the reference. | ||
| /** This function returns the reference. If the URL is | ||
| {\tt http://www.nowhere/path/file.html\#toc} | ||
| this function will return #toc#. If there is no | ||
| reference it returns "". | ||
| */ | ||
| char* reference() const { if (ref_part.isNull()) return ""; | ||
| else return ref_part.data(); } | ||
|
|
||
| /// Returns the user name | ||
| /** | ||
| This function returns the user name or an empty string if | ||
| no user has been specified. | ||
| */ | ||
| const char* user() { if (user_part.isNull()) return ""; | ||
| else return user_part.data(); } | ||
|
|
||
| /// Returns the password | ||
| /** | ||
| This function returns the password or an empty string if | ||
| no password has been specified. | ||
| */ | ||
| const char* passwd() { if (passwd_part.isNull()) return ""; | ||
| else return passwd_part.data(); } | ||
|
|
||
| /// Returns the directory only | ||
| /** | ||
| If for example the URL is "file:/tmp/weis/file.html", then this call | ||
| will return "/tmp/weis/". If you pass "file:/tmp/weis/" to this | ||
| function, you will get "/tmp/weis/", because you already passed a directory. | ||
| Turning the '_traling' flag off, causes the traling '/' to be ignored. | ||
| "file:/tmp/weis/file.html" will result in "/tmp/weis/", too, but | ||
| "file:/tmp/weis/" will lead to "/tmp/". As you see, this is | ||
| a smart method to get the parent directory of a file/directory. | ||
| This function is supplied for convenience only. | ||
| */ | ||
| const char * directory( bool _trailing = TRUE ); | ||
| /// Returns the URL with the directory only | ||
| /** | ||
| If for example the URL is "file:/tmp/weis/file.html", then this call | ||
| will return "file:/tmp/weis/". For more details look at 'directory(...)' | ||
| */ | ||
| const char * directoryURL( bool _trailing = TRUE ); | ||
|
|
||
| //@} | ||
|
|
||
| //@Man: URL modifying members | ||
| //@{ | ||
|
|
||
| /// Parse a string | ||
| void parse( const char *_url ); | ||
|
|
||
| /// Set protocol. | ||
| /** Sets the protocol to newProto. Useful for example if an app hits | ||
| {\tt file:/tmp/interesting.zip}, then it might do | ||
| setProtocol( "{\tt zip}"). | ||
| */ | ||
| void setProtocol( const char* newProto) { protocol_part = newProto; } | ||
|
|
||
| /// Set reference. | ||
| /** Set reference. Convenience function to set the reference. | ||
| A reference may be removed with setRef( ""). The function | ||
| returns false if it could not make a reference (if there were | ||
| no path to reference from) and true on succes. | ||
| */ | ||
| bool setReference( const char* _ref); | ||
|
|
||
| /// Clean up URL | ||
| /** This function cleans up the URL, so that it doesn't contain | ||
| {\tt /./}, {\tt /../} or {\tt bla//bla} type stuff. | ||
| */ | ||
| void cleanURL(); | ||
|
|
||
| /// Change directory | ||
| /** Changes directory by descending into the given directory. If | ||
| dir starts with a {\tt /} and acceptAbsPath is true the | ||
| current URL will be {\tt protocol://host/dir} otherwise dir will | ||
| be appended to the path, even if it starts with a {\tt /}. | ||
| If isReference is true, cd will make a reference unless | ||
| there already is one, then cd will append {\tt /dir} to the reference. | ||
| KURL u( {\tt tar:/tmp/file.tar.gz\#foo}); cd( "{\tt ..}"); is legal, | ||
| but it doesn't make much sense, since the result is {\tt tar:/tmp\#foo}. | ||
| cd( "{\tt /}", true, true) will remove the reference if there is one. | ||
| {\bf NOTE:} If the cd is done on the path-part of the URL, the | ||
| reference is lost -- this is normally desirable. | ||
| */ | ||
| bool cd( const char* _dir, bool acceptAbsPath = true, | ||
| bool isReference = false); | ||
|
|
||
| /// Change directory path | ||
| /** Change directory path. Same as cd with isReference = false. When | ||
| zapRef is false, the reference is untouched by the | ||
| operation. | ||
| */ | ||
| bool cdPath( const char* _dir, bool acceptAbsPath = true, | ||
| bool zapRef = true); | ||
|
|
||
| /// Change reference path | ||
| /** Change reference path. Same as cd with isReference = true */ | ||
| bool cdRef( const char* _ref, bool acceptAbsPath = true); | ||
|
|
||
| /// Go to parent dir. | ||
| /** Go to parent dir. If zapRef is true, the reference is removed, | ||
| otherwise it stays, but normally no one would want that. | ||
| */ | ||
| bool cdUp( bool zapRef = true) { if( zapRef) setReference(""); | ||
| return cd( ".."); } | ||
|
|
||
| /// Returns the filename or directory name of the URL | ||
| /** If 'file:/home/weis/test.txt' is the URL, the result will be 'test.txt' | ||
| If the URL us 'tar:/home/weis/test.tgz#foo/myfile' and isReference is TRUE, | ||
| the function will return 'myfile' | ||
| */ | ||
| const char *filename( bool isReference = false ); | ||
|
|
||
| //@} | ||
| //@Man: Operators | ||
| //@{ | ||
| /// Copy | ||
| /** Makes a copy of a URL | ||
| */ | ||
| KURL &operator=( const KURL &); | ||
|
|
||
| /// Initialize the URL with the given string. | ||
| /** | ||
| '_url' must be a valid URL. | ||
| */ | ||
| KURL &operator=( const char* _url ); | ||
|
|
||
| /// Compare URL's. | ||
| /** Returns true if to URL's are equal, false otherwise. | ||
| */ | ||
| bool operator==( const KURL &_url) const { return _url.url() == url(); } | ||
| //@} | ||
|
|
||
| //@Man: Directory list members | ||
| //@{ | ||
| /// Like in QDir. | ||
| /** Like in QDir, but still unimplemented */ | ||
| const QStrList* entryList(int filterSpec = DefaultFilter, | ||
| int sortSpec = DefaultSort) const; | ||
| /// Like in QDir. | ||
| /** Like in QDir, but still unimplemented */ | ||
| const QStrList* entryList (const char* nameFilter, | ||
| int filterSpec = DefaultFilter, | ||
| int sortSpec = DefaultSort) const; | ||
| /// Like in QDir. | ||
| /** Like in QDir, but still unimplemented */ | ||
| const QFileInfoList* entryInfoList (int filterSpec = DefaultFilter, | ||
| int sortSpec = DefaultSort) const; | ||
| /// Like in QDir. | ||
| /** Like in QDir, but still unimplemented */ | ||
| const QFileInfoList* entryInfoList (const char* nameFilter, | ||
| int filterSpec = DefaultFilter, | ||
| int sortSpec = DefaultSort) const; | ||
|
|
||
| //@} | ||
| protected: | ||
| bool malformed; | ||
|
|
||
| QString protocol_part; | ||
| QString host_part; | ||
| QString path_part; | ||
| QString ref_part; | ||
| /// This variable is only valid after calling 'directory'. | ||
| QString dir_part; | ||
| QString user_part; | ||
| QString passwd_part; | ||
|
|
||
| private: | ||
| void detach(); | ||
| }; | ||
|
|
||
| /* TODO: Implement entryList, entryInfoList, exists(), | ||
| isReadable(), isDir() and isFile() and and and ... | ||
| */ | ||
|
|
||
| #endif |
| @@ -0,0 +1,23 @@ | ||
| #ifdef HAVE_ALLOCA_H | ||
| #include <alloca.h> | ||
| #endif | ||
|
|
||
| #include <string.h> | ||
| #include <stdlib.h> | ||
|
|
||
| int setenv(const char *name, const char *value, int overwrite) { | ||
| int i; | ||
| char * a; | ||
|
|
||
| if (!overwrite && getenv(name)) return 0; | ||
|
|
||
| i = strlen(name) + strlen(value) + 2; | ||
| a = (char*)malloc(i); | ||
| if (!a) return 1; | ||
|
|
||
| strcpy(a, name); | ||
| strcat(a, "="); | ||
| strcat(a, value); | ||
|
|
||
| return putenv(a); | ||
| } |
| @@ -0,0 +1,39 @@ | ||
| Matthias Kalle Dalheimer <kalle@kde.org>: | ||
| classes KConfig, KTextStream, KColorSet, | ||
| automake, autoconf, maintenance | ||
|
|
||
| Richard Moore <moorer@cs.man.ac.uk>: | ||
| KLedLamp class | ||
|
|
||
| Martynas Kunigelis <algikun@santaka.ktu.lt>: | ||
| KProgress class | ||
|
|
||
| Steffen Hansen <stefh@dit.ou.dk>: | ||
| KURL class | ||
|
|
||
| Torben Weis <weis@stud.uni-frankfurt.de> | ||
| DnD stuff, KSocket and KServerSocket classes, KPixmap | ||
|
|
||
| Alexander Sanda <alex@darkstar.ping.at> | ||
| Read and write numerical config entries, KPanner, KTabControl, | ||
| KPopupMenu, KMessageBox, KEdit widgets. | ||
|
|
||
| Martin Jones <mjones@powerup.com.au> | ||
| Bugfixes in KPixmap and KURL, KColorDialog, KSelector | ||
|
|
||
| Keith Brown <kbrown@pdq.net> | ||
| KTreeList class | ||
|
|
||
| Bernd Johannes Wuebben <wuebben@math.cornell.edu> | ||
| KFontDialog class | ||
|
|
||
| Tim D. Gilman <tdgilman@best.com> | ||
| KDatePicker, KDateTable class | ||
|
|
||
| Nicolas Hadacek <hadacek@via.ecp.fr> | ||
| Key configuration classes, bug fixes | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
| @@ -0,0 +1,35 @@ | ||
| ## KDE/src/lib/ui/test/Makefile.am | ||
| ## | ||
| ## (C) 1996 Matthias Kalle Dalheimer | ||
| ## (C) 1997 Stephan Kulow | ||
|
|
||
| MOC = @MOC@ | ||
| INCLUDES= -I@qt_includes@ -I@x_includes@ -I../kdecore | ||
| EXTRA_DIST = error.xpm exclamation.xpm info.xpm stopsign.xpm | ||
| CLEANFILES = *.moc | ||
| SUFFIXES = .moc | ||
|
|
||
| lib_LTLIBRARIES = libkdeui.la | ||
| libkdeui_la_LDFLAGS = -version-info 0:7 -rpath $(libdir) | ||
|
|
||
| include_HEADERS = kledlamp.h kprogress.h kpanner.h kcolordlg.h kselect.h \ | ||
| dither.h kdatepik.h kdatetbl.h kedit.h keditconstants.h \ | ||
| kfontdialog.h kmsgbox.h kpopmenu.h ktabctl.h\ | ||
| ktreelist.h | ||
|
|
||
|
|
||
| libkdeui_la_SOURCES = kledlamp.cpp kprogress.cpp kpanner.cpp kcolordlg.cpp\ | ||
| kselect.cpp dither.cpp kdatepik.cpp kdatetbl.cpp kedit.cpp \ | ||
| kfontdialog.cpp kmsgbox.cpp kpopmenu.cpp ktabctl.cpp\ | ||
| ktreelist.cpp | ||
|
|
||
| BUILT_SOURCES = kledlamp.moc kprogress.moc kpanner.moc kcolordlg.moc\ | ||
| kselect.moc ktabctl.moc kdatepik.moc kedit.moc\ | ||
| kmsgbox.moc kpopmenu.moc ktreelist.moc kdatetbl.moc\ | ||
| kfontdialog.moc | ||
|
|
||
| data_DATA = error.xpm exclamation.xpm info.xpm stopsign.xpm | ||
|
|
||
| %.moc: %.h | ||
| $(MOC) $< -o $@ | ||
|
|