dslinux/user/pixil/packages/viewml/viewml/kfmlib Makefile.am Makefile.in kfm.cpp kfm.h kfmclient_ipc.cpp kfmclient_ipc.h kfmclient_ipc2.cpp kfmipc.cpp kfmipc.h
amadeus
dslinux_amadeus at user.in-berlin.de
Tue Oct 3 13:26:39 CEST 2006
Update of /cvsroot/dslinux/dslinux/user/pixil/packages/viewml/viewml/kfmlib
In directory antilope:/tmp/cvs-serv11916/packages/viewml/viewml/kfmlib
Added Files:
Makefile.am Makefile.in kfm.cpp kfm.h kfmclient_ipc.cpp
kfmclient_ipc.h kfmclient_ipc2.cpp kfmipc.cpp kfmipc.h
Log Message:
adding pristine copy of pixil to HEAD so I can branch from it
--- NEW FILE: kfmipc.h ---
/* This file is part of the KDE libraries
Copyright (C) 1997 Torben Weis (weis at kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef ipc_h
#define ipc_h
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
struct stringList
{
int elements;
char **list;
};
struct intList
{
int elements;
int *list;
};
struct doubleList
{
int elements;
double *list;
};
struct charList
{
int elements;
char *list;
};
#define boolList charList
#define write_bool write_char
#define read_bool read_char
#define free_bool free_char
#define free_boolList free_charList
#define len_bool len_char
#define len_boolList len_boolList
void write_int( int _fd, int _value );
void write_double( int _fd, double _value );
void write_char( int _fd, char _value );
void write_string( int _fd, const char* _value );
void write_intList( int _fd, intList* _list );
void write_doubleList( int _fd, doubleList* _list );
void write_charList( int _fd, charList* _list );
void write_stringList( int _fd, stringList* _list );
char* read_string( char *_data, int &_pos, int _len );
int read_int( char *_data, int &_pos, int _len );
char read_char( char *_data, int &_pos, int _len );
double read_double( char *_data, int &_pos, int _len );
void read_stringList( char *_data, int &_pos, int _len, stringList *_list );
void read_intList( char *_data, int &_pos, int _len, intList *_list );
void read_doubleList( char *_data, int &_pos, int _len, doubleList *_list );
void read_charList( char *_data, int &_pos, int _len, charList *_list );
#define free_int( x ); ;
#define free_char( x ); ;
#define free_double( x ); ;
void free_string( char *_str );
void free_stringList( stringList *_list );
void free_intList( intList *_list );
void free_doubleList( doubleList *_list );
void free_charList( charList *_list );
int len_int( int _value );
int len_double( double _value );
int len_char( char _value );
int len_string( const char *_str );
int len_stringList( stringList *_list );
int len_intList( intList *_list );
int len_doubleList( doubleList *_list );
int len_charList( charList *_list );
#endif
--- NEW FILE: kfmipc.cpp ---
/* This file is part of the KDE libraries
Copyright (C) 1997 Torben Weis (weis at kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "kfmipc.h"
void write_int( int _fd, int _value )
{
char buffer[10];
sprintf( buffer, "%i ", _value );
write( _fd, (const char*)buffer, strlen(buffer) );
}
void write_double( int _fd, double _value )
{
char buffer[10];
sprintf( buffer, "%f ", _value );
write( _fd, (const char*)buffer, strlen(buffer) );
}
void write_char( int _fd, char _value )
{
write( _fd, (const char*)&_value, sizeof(char) );
}
void write_string( int _fd, const char* _value )
{
if ( _value == 0L )
{
write_int( _fd, -1 );
return;
}
int len = strlen( _value );
write_int( _fd, len );
write( _fd, (const char*)_value, strlen(_value) );
}
void write_intList( int _fd, intList* _list )
{
int len = _list->elements * sizeof(int);
write( _fd, (const char*)&(_list->elements), sizeof(int) );
write( _fd, (const char*)(_list->list), len );
}
void write_doubleList( int _fd, doubleList* _list )
{
int len = _list->elements * sizeof(double);
write( _fd, (const char*)&(_list->elements), sizeof(int) );
write( _fd, (const char*)(_list->list), len );
}
void write_charList( int _fd, charList* _list )
{
int len = _list->elements * sizeof(char);
write( _fd, (const char*)&(_list->elements), sizeof(int) );
write( _fd, (const char*)(_list->list), len );
}
void write_stringList( int _fd, stringList* _list )
{
write( _fd, (const char*)&(_list->elements), sizeof(int) );
for( int i = 0; i < _list->elements; i++ )
{
write_string( _fd, _list->list[i] );
}
}
char* read_string( char *_data, int &_pos, int _len )
{
int tmp = read_int( _data, _pos, _len );
if ( tmp == -1 )
return 0L;
char *str = (char*)malloc(tmp + 1);
strncpy( str, _data + _pos, tmp);
_pos += tmp;
str[tmp] = 0;
return str;
}
int read_int( char *_data, int &_pos, int _len )
{
int i = _pos;
while ( _data[ _pos ] != ' ' )
{
_pos++;
if ( _pos == _len )
return 0;
}
_pos++;
return atoi( _data + i );
}
char read_char( char *_data, int &_pos, int )
{
char tmp = *((char*)_data + _pos);
_pos += sizeof(char);
return tmp;
}
double read_double( char *_data, int &_pos, int _len )
{
int i = _pos;
while ( _data[ _pos ] != ' ' )
{
_pos++;
if ( _pos == _len )
return 0;
}
_pos++;
return atof( _data + i );
}
void read_stringList( char *_data, int &_pos, int _len, stringList *_list )
{
int tmp = *((int*)_data + _pos);
_list->elements = tmp;
_pos += sizeof(int);
_list->list = (char**)malloc( tmp * sizeof(char*) );
for( int i = 0; i < tmp; i++ )
{
_list->list[i] = read_string( _data, _pos, _len );
}
}
void read_intList( char *_data, int &_pos, int _len, intList *_list )
{
int tmp = *((int*)_data + _pos);
_list->elements = tmp;
_pos += sizeof(int);
_list->list = (int*)malloc( tmp * sizeof(int) );
for( int i = 0; i < tmp; i++ )
{
_list->list[i] = read_int( _data, _pos, _len );
}
}
void read_doubleList( char *_data, int &_pos, int _len, doubleList *_list )
{
int tmp = *((int*)_data + _pos);
_list->elements = tmp;
_pos += sizeof(int);
_list->list = (double*)malloc( tmp * sizeof(double) );
for( int i = 0; i < tmp; i++ )
{
_list->list[i] = read_double( _data, _pos, _len );
}
}
void read_charList( char *_data, int &_pos, int _len, charList *_list )
{
int tmp = *((int*)_data + _pos);
_list->elements = tmp;
_pos += sizeof(int);
_list->list = (char*)malloc( tmp * sizeof(char) );
for( int i = 0; i < tmp; i++ )
{
_list->list[i] = read_char( _data, _pos, _len );
}
}
void free_string( char *_str )
{
if ( _str != 0L )
free( _str );
}
void free_stringList( stringList *_list )
{
for( int i = 0; i < _list->elements; i++ )
{
free ( _list->list[i] );
}
free ( _list->list );
}
void free_intList( intList *_list )
{
free ( _list->list );
}
void free_doubleList( doubleList *_list )
{
free ( _list->list );
}
void free_charList( charList *_list )
{
free ( _list->list );
}
int len_int( int _value )
{
char buffer[ 20 ];
sprintf( buffer, "%i", _value );
return strlen(buffer) + 1;
}
int len_double( double _value )
{
char buffer[ 20 ];
sprintf( buffer, "%f", _value );
return strlen(buffer) + 1;
}
int len_char( char )
{
return 1;
}
int len_string( const char *_str )
{
if ( _str == 0L )
// The '-1' takes 2 characters + 1 space
return 3;
int len = strlen( _str );
return len + len_int( len );
}
int len_stringList( stringList *_list )
{
int len = sizeof(int);
for( int i = 0; i < _list->elements; i++ )
{
len += len_string( _list->list[i] );
}
return len;
}
int len_intList( intList *_list )
{
return ( sizeof(int) + _list->elements * sizeof(int) );
}
int len_doubleList( doubleList *_list )
{
return ( sizeof(int) + _list->elements * sizeof(double) );
}
int len_charList( charList *_list )
{
return ( sizeof(int) + _list->elements * sizeof(char) );
}
--- NEW FILE: Makefile.am ---
# This file is part of the KDE libraries
# Copyright (C) 1997 Stephan Kulow (coolo at kde.org)
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
# You should have received a copy of the GNU Library General Public License
# along with this library; see the file COPYING.LIB. If not, write to
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
INCLUDES = -I$(top_srcdir)/kdecore $(QT_INCLUDES) $(X_INCLUDES)
libkfm_la_METASOURCES = kfm.moc kfmclient_ipc.moc
lib_LTLIBRARIES = libkfm.la
libkfm_la_LDFLAGS = -version-info 2:0
libkfm_la_SOURCES = kfm.cpp kfmclient_ipc.cpp kfmclient_ipc2.cpp kfmipc.cpp
include_HEADERS = kfm.h kfmclient_ipc.h kfmipc.h
--- NEW FILE: kfmclient_ipc.h ---
/* This file is part of the KDE libraries
Copyright (C) 1997 Torben Weis (weis at kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
// This file has been created by ipcc.pl.
// (c) Torben Weis
// weis at stud.uni-frankfurt.de
#ifndef KfmIpc_h
#define KfmIpc_h
#include <ctype.h>
#include <ksock.h>
#include <qobject.h>
#include "kfmipc.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
class KfmIpc : public QObject
{
Q_OBJECT
public:
KfmIpc( char * _path );
~KfmIpc();
bool isConnected();
public slots:
void refreshDesktop();
public slots:
void refreshDirectory(const char* _url);
public slots:
void openURL(const char* _url);
public slots:
void openProperties(const char* _url);
public slots:
void list(const char* _url);
public slots:
void exec(const char* _url, const char* _binding);
public slots:
void copy(const char* _src, const char* _dest);
public slots:
void move(const char* _src, const char* _dest);
public slots:
void moveClient(const char* _src, const char* _dest);
public slots:
void copyClient(const char* _src, const char* _dest);
public slots:
void sortDesktop();
public slots:
void configure();
public slots:
void auth(const char* _password);
public slots:
void selectRootIcons(int _x, int _y, int _w, int _h, bool _add);
signals:
void finished();
private:
void parse_finished( char *_data, int _len );
signals:
void error(int _kerror, const char* _text);
private:
void parse_error( char *_data, int _len );
signals:
void dirEntry(const char* _name, const char* _access, const char* _owner, const char* _group, const char* _date, int _size);
private:
void parse_dirEntry( char *_data, int _len );
public slots:
void readEvent( KSocket * );
void closeEvent( KSocket * );
private:
void parse( char *_data, int _len );
KSocket *sock;
bool connected;
char headerBuffer[11];
int cHeader;
bool bHeader;
char *pBody;
int cBody;
int bodyLen;
};
#endif
--- NEW FILE: Makefile.in ---
# Makefile.in generated automatically by automake 1.4 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
# This file is part of the KDE libraries
# Copyright (C) 1997 Stephan Kulow (coolo at kde.org)
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
# You should have received a copy of the GNU Library General Public License
# along with this library; see the file COPYING.LIB. If not, write to
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_alias = @build_alias@
build_triplet = @build@
host_alias = @host_alias@
host_triplet = @host@
target_alias = @target_alias@
target_triplet = @target@
AS = @AS@
CC = @CC@
CPP = @CPP@
CXX = @CXX@
CXXCPP = @CXXCPP@
DLLTOOL = @DLLTOOL@
GLINC = @GLINC@
GLLIB = @GLLIB@
GMSGFMT = @GMSGFMT@
IDL = @IDL@
KDE_EXTRA_RPATH = @KDE_EXTRA_RPATH@
KDE_INCLUDES = @KDE_INCLUDES@
KDE_LDFLAGS = @KDE_LDFLAGS@
KDE_RPATH = @KDE_RPATH@
LD = @LD@
LIBCOMPAT = @LIBCOMPAT@
LIBCRYPT = @LIBCRYPT@
LIBDL = @LIBDL@
LIBJPEG = @LIBJPEG@
LIBMICO = @LIBMICO@
LIBOBJS = @LIBOBJS@
LIBPNG = @LIBPNG@
LIBPTHREAD = @LIBPTHREAD@
LIBPYTHON = @LIBPYTHON@
LIBQIMGIO = @LIBQIMGIO@
LIBSOCKET = @LIBSOCKET@
LIBTIFF = @LIBTIFF@
LIBTOOL = @LIBTOOL@
LIBUCB = @LIBUCB@
LIBZ = @LIBZ@
LIB_KAB = @LIB_KAB@
LIB_KDECORE = @LIB_KDECORE@
LIB_KDEUI = @LIB_KDEUI@
LIB_KDEUTIL = @LIB_KDEUTIL@
LIB_KFILE = @LIB_KFILE@
LIB_KFM = @LIB_KFM@
LIB_KHTML = @LIB_KHTML@
LIB_KHTMLW = @LIB_KHTMLW@
LIB_KIMGIO = @LIB_KIMGIO@
LIB_KIO = @LIB_KIO@
LIB_MEDIATOOL = @LIB_MEDIATOOL@
LIB_QT = @LIB_QT@
LIB_X11 = @LIB_X11@
LN_S = @LN_S@
MAKEINFO = @MAKEINFO@
MICO_INCLUDES = @MICO_INCLUDES@
MICO_LDFLAGS = @MICO_LDFLAGS@
MOC = @MOC@
MSGFMT = @MSGFMT@
NM = @NM@
PACKAGE = @PACKAGE@
PAMINC = @PAMINC@
PAMLIBPATHS = @PAMLIBPATHS@
PAMLIBS = @PAMLIBS@
PYTHONINC = @PYTHONINC@
PYTHONLIB = @PYTHONLIB@
QKEYCODE_H = @QKEYCODE_H@
QT_INCLUDES = @QT_INCLUDES@
QT_LDFLAGS = @QT_LDFLAGS@
RANLIB = @RANLIB@
TOPSUBDIRS = @TOPSUBDIRS@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
XGETTEXT = @XGETTEXT@
XPMINC = @XPMINC@
XPMLIB = @XPMLIB@
X_EXTRA_LIBS = @X_EXTRA_LIBS@
X_INCLUDES = @X_INCLUDES@
X_LDFLAGS = @X_LDFLAGS@
all_includes = @all_includes@
all_libraries = @all_libraries@
install_root = @install_root@
kde_appsdir = @kde_appsdir@
kde_bindir = @kde_bindir@
kde_cgidir = @kde_cgidir@
kde_confdir = @kde_confdir@
kde_datadir = @kde_datadir@
kde_htmldir = @kde_htmldir@
kde_icondir = @kde_icondir@
kde_includes = @kde_includes@
kde_libraries = @kde_libraries@
kde_locale = @kde_locale@
kde_mimedir = @kde_mimedir@
kde_minidir = @kde_minidir@
kde_partsdir = @kde_partsdir@
kde_sounddir = @kde_sounddir@
kde_toolbardir = @kde_toolbardir@
kde_wallpaperdir = @kde_wallpaperdir@
qt_includes = @qt_includes@
qt_libraries = @qt_libraries@
topdir = @topdir@
x_includes = @x_includes@
x_libraries = @x_libraries@
INCLUDES = -I$(top_srcdir)/kdecore $(QT_INCLUDES) $(X_INCLUDES)
libkfm_la_METASOURCES = kfm.moc kfmclient_ipc.moc
lib_LTLIBRARIES = libkfm.la
libkfm_la_LDFLAGS = -version-info 2:0
libkfm_la_SOURCES = kfm.cpp kfmclient_ipc.cpp kfmclient_ipc2.cpp kfmipc.cpp
include_HEADERS = kfm.h kfmclient_ipc.h kfmipc.h
mkinstalldirs = $(SHELL) $(top_srcdir)/admin/mkinstalldirs
CONFIG_HEADER = ../config.h
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(lib_LTLIBRARIES)
DEFS = @DEFS@ -I. -I$(srcdir) -I..
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
libkfm_la_LIBADD =
libkfm_la_OBJECTS = kfm.lo kfmclient_ipc.lo kfmclient_ipc2.lo kfmipc.lo
CXXFLAGS = @CXXFLAGS@
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
HEADERS = $(include_HEADERS)
DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
GZIP_ENV = --best
SOURCES = $(libkfm_la_SOURCES)
OBJECTS = $(libkfm_la_OBJECTS)
all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .cpp .lo .o .s
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --foreign --include-deps kfmlib/Makefile
cd $(top_srcdir) && perl admin/automoc kfmlib/Makefile.in
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
mostlyclean-libLTLIBRARIES:
clean-libLTLIBRARIES:
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
distclean-libLTLIBRARIES:
maintainer-clean-libLTLIBRARIES:
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(libdir)
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
if test -f $$p; then \
echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p"; \
$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p; \
else :; fi; \
done
uninstall-libLTLIBRARIES:
@$(NORMAL_UNINSTALL)
list='$(lib_LTLIBRARIES)'; for p in $$list; do \
$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \
done
.c.o:
$(COMPILE) -c $<
.s.o:
$(COMPILE) -c $<
.S.o:
$(COMPILE) -c $<
mostlyclean-compile:
-rm -f *.o core *.core
clean-compile:
distclean-compile:
-rm -f *.tab.c
maintainer-clean-compile:
.c.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
.s.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
.S.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
maintainer-clean-libtool:
libkfm.la: $(libkfm_la_OBJECTS) $(libkfm_la_DEPENDENCIES)
$(CXXLINK) -rpath $(libdir) $(libkfm_la_LDFLAGS) $(libkfm_la_OBJECTS) $(libkfm_la_LIBADD) $(LIBS)
.cpp.o:
$(CXXCOMPILE) -c $<
.cpp.lo:
$(LTCXXCOMPILE) -c $<
install-includeHEADERS: $(include_HEADERS)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(includedir)
@list='$(include_HEADERS)'; for p in $$list; do \
if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \
echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p"; \
$(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p; \
done
uninstall-includeHEADERS:
@$(NORMAL_UNINSTALL)
list='$(include_HEADERS)'; for p in $$list; do \
rm -f $(DESTDIR)$(includedir)/$$p; \
done
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP)
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
here=`pwd` && cd $(srcdir) \
&& mkid -f$$here/ID $$unique $(LISP)
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
mostlyclean-tags:
clean-tags:
distclean-tags:
-rm -f TAGS ID
maintainer-clean-tags:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = kfmlib
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am: install-libLTLIBRARIES
install-exec: install-exec-am
install-data-am: install-includeHEADERS
install-data: install-data-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am: uninstall-libLTLIBRARIES uninstall-includeHEADERS
uninstall: uninstall-am
all-am: Makefile $(LTLIBRARIES) $(HEADERS)
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
$(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir)
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
mostlyclean-am: mostlyclean-libLTLIBRARIES mostlyclean-compile \
mostlyclean-libtool mostlyclean-tags \
mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-libLTLIBRARIES clean-compile clean-libtool clean-tags \
clean-generic mostlyclean-am
clean: clean-am
distclean-am: distclean-libLTLIBRARIES distclean-compile \
distclean-libtool distclean-tags distclean-generic \
clean-am
-rm -f libtool
distclean: distclean-metasources distclean-am
maintainer-clean-am: maintainer-clean-libLTLIBRARIES \
maintainer-clean-compile maintainer-clean-libtool \
maintainer-clean-tags maintainer-clean-generic \
distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am
.PHONY: mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \
clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \
uninstall-libLTLIBRARIES install-libLTLIBRARIES mostlyclean-compile \
distclean-compile clean-compile maintainer-clean-compile \
mostlyclean-libtool distclean-libtool clean-libtool \
maintainer-clean-libtool uninstall-includeHEADERS \
install-includeHEADERS tags mostlyclean-tags distclean-tags clean-tags \
maintainer-clean-tags distdir info-am info dvi-am dvi check check-am \
installcheck-am installcheck install-exec-am install-exec \
install-data-am install-data install-am install uninstall-am uninstall \
all-redirect all-am all installdirs mostlyclean-generic \
distclean-generic clean-generic maintainer-clean-generic clean \
mostlyclean distclean maintainer-clean
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
$(srcdir)/kfm.cpp: kfm.moc
kfm.moc: $(srcdir)/kfm.h
$(MOC) $(srcdir)/kfm.h -o kfm.moc
$(srcdir)/kfmclient_ipc.cpp: kfmclient_ipc.moc
kfmclient_ipc.moc: $(srcdir)/kfmclient_ipc.h
$(MOC) $(srcdir)/kfmclient_ipc.h -o kfmclient_ipc.moc
distclean-metasources:
-rm -f kfm.moc kfmclient_ipc.moc
# DO_NOT_USE_AUTOMOC
--- NEW FILE: kfmclient_ipc.cpp ---
/* This file is part of the KDE libraries
Copyright (C) 1997 Torben Weis (weis at kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
// This file has been created by ipcc.pl.
// (c) Torben Weis
// weis at stud.uni-frankfurt.de
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "kfmipc.h"
#include "kfmclient_ipc.h"
KfmIpc::KfmIpc( char * _path )
{
bHeader = TRUE;
cHeader = 0;
pBody = 0L;
sock = new KSocket( _path );
connect( sock, SIGNAL( readEvent(KSocket*) ), this, SLOT( readEvent(KSocket*) ) );
connect( sock, SIGNAL( closeEvent(KSocket*) ), this, SLOT( closeEvent(KSocket*) ) );
sock->enableRead( TRUE );
connected = (sock->socket() > 0);
}
KfmIpc::~KfmIpc()
{
delete sock;
if (pBody != 0)
free(pBody);
}
bool KfmIpc::isConnected()
{
return connected;
}
void KfmIpc::closeEvent( KSocket * )
{
connected = FALSE;
}
void KfmIpc::readEvent( KSocket * )
{
if ( bHeader )
{
int n;
n = read( sock->socket(), headerBuffer + cHeader, 1 );
if ( headerBuffer[ cHeader ] == ' ' )
{
bHeader = FALSE;
cHeader = 0;
bodyLen = atoi( headerBuffer );
cBody = 0;
if ( bodyLen <= 0 )
{
printf("ERROR: Invalid header\n");
delete this;
return;
}
if ( pBody != 0L )
free( pBody );
pBody = (char*)malloc( bodyLen + 1 );
}
else if ( cHeader + n == 10 )
{
printf("ERROR: Too long header\n");
delete this;
return;
}
else
{
if ( !isdigit( headerBuffer[ cHeader ] ) )
{
printf("ERROR: Header must be an int\n");
delete this;
return;
}
cHeader += n;
return;
}
}
int n;
n = read( sock->socket(), pBody + cBody, bodyLen - cBody );
if ( n + cBody == bodyLen )
{
pBody[bodyLen] = 0;
bHeader = TRUE;
parse( pBody, bodyLen );
return;
}
cBody += n;
}
void KfmIpc::parse( char *_data, int _len )
{
int pos = 0;
char *name = read_string( _data, pos, _len );
if ( name == 0L )
return;
_data += pos;
_len -= pos;
if ( strcmp( name, "finished" ) == 0 )
{ parse_finished( _data, _len ); }
else
if ( strcmp( name, "error" ) == 0 )
{ parse_error( _data, _len ); }
else
if ( strcmp( name, "dirEntry" ) == 0 )
{ parse_dirEntry( _data, _len ); }
else
{ printf("Unknown command '%s'\n",name); }
free(name);
}
#include "kfmclient_ipc.moc"
--- NEW FILE: kfmclient_ipc2.cpp ---
/* This file is part of the KDE libraries
Copyright (C) 1997 Torben Weis (weis at kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
// This file has been created by ipcc.pl.
#include "kfmclient_ipc.h"
void KfmIpc::refreshDesktop()
{
int len = 0;
len += len_string("refreshDesktop");
write_int( sock->socket(), len );
write_string( sock->socket(), "refreshDesktop" );
}
void KfmIpc::refreshDirectory(const char* _url)
{
int len = 0;
len += len_string( _url );
len += len_string("refreshDirectory");
write_int( sock->socket(), len );
write_string( sock->socket(), "refreshDirectory" );
write_string( sock->socket(), _url );
}
void KfmIpc::openURL(const char* _url)
{
int len = 0;
len += len_string( _url );
len += len_string("openURL");
write_int( sock->socket(), len );
write_string( sock->socket(), "openURL" );
write_string( sock->socket(), _url );
}
void KfmIpc::openProperties(const char* _url)
{
int len = 0;
len += len_string( _url );
len += len_string("openProperties");
write_int( sock->socket(), len );
write_string( sock->socket(), "openProperties" );
write_string( sock->socket(), _url );
}
void KfmIpc::list(const char* _url)
{
int len = 0;
len += len_string( _url );
len += len_string("list");
write_int( sock->socket(), len );
write_string( sock->socket(), "list" );
write_string( sock->socket(), _url );
}
void KfmIpc::exec(const char* _url, const char* _binding)
{
int len = 0;
len += len_string( _url );
len += len_string( _binding );
len += len_string("exec");
write_int( sock->socket(), len );
write_string( sock->socket(), "exec" );
write_string( sock->socket(), _url );
write_string( sock->socket(), _binding );
}
void KfmIpc::copy(const char* _src, const char* _dest)
{
int len = 0;
len += len_string( _src );
len += len_string( _dest );
len += len_string("copy");
write_int( sock->socket(), len );
write_string( sock->socket(), "copy" );
write_string( sock->socket(), _src );
write_string( sock->socket(), _dest );
}
void KfmIpc::move(const char* _src, const char* _dest)
{
int len = 0;
len += len_string( _src );
len += len_string( _dest );
len += len_string("move");
write_int( sock->socket(), len );
write_string( sock->socket(), "move" );
write_string( sock->socket(), _src );
write_string( sock->socket(), _dest );
}
void KfmIpc::moveClient(const char* _src, const char* _dest)
{
int len = 0;
len += len_string( _src );
len += len_string( _dest );
len += len_string("moveClient");
write_int( sock->socket(), len );
write_string( sock->socket(), "moveClient" );
write_string( sock->socket(), _src );
write_string( sock->socket(), _dest );
}
void KfmIpc::copyClient(const char* _src, const char* _dest)
{
int len = 0;
len += len_string( _src );
len += len_string( _dest );
len += len_string("copyClient");
write_int( sock->socket(), len );
write_string( sock->socket(), "copyClient" );
write_string( sock->socket(), _src );
write_string( sock->socket(), _dest );
}
void KfmIpc::sortDesktop()
{
int len = 0;
len += len_string("sortDesktop");
write_int( sock->socket(), len );
write_string( sock->socket(), "sortDesktop" );
}
void KfmIpc::configure()
{
int len = 0;
len += len_string("configure");
write_int( sock->socket(), len );
write_string( sock->socket(), "configure" );
}
void KfmIpc::auth(const char* _password)
{
int len = 0;
len += len_string( _password );
len += len_string("auth");
write_int( sock->socket(), len );
write_string( sock->socket(), "auth" );
write_string( sock->socket(), _password );
}
void KfmIpc::selectRootIcons(int _x, int _y, int _w, int _h, bool _add)
{
int len = 0;
len += len_int( _x );
len += len_int( _y );
len += len_int( _w );
len += len_int( _h );
len += len_bool( _add );
len += len_string("selectRootIcons");
write_int( sock->socket(), len );
write_string( sock->socket(), "selectRootIcons" );
write_int( sock->socket(), _x );
write_int( sock->socket(), _y );
write_int( sock->socket(), _w );
write_int( sock->socket(), _h );
write_bool( sock->socket(), _add );
}
void KfmIpc::parse_finished( char *, int )
{
// int pos = 0;
// Calling function
emit finished( );
}
void KfmIpc::parse_error( char *_data, int _len )
{
int pos = 0;
// Parsing int
int _kerror;
_kerror = read_int( _data, pos, _len );
// Parsing string
const char* _text;
_text = read_string( _data, pos, _len );
// Calling function
emit error( _kerror, _text );
free( (void*)_text );
}
void KfmIpc::parse_dirEntry( char *_data, int _len )
{
int pos = 0;
// Parsing string
const char* _name;
_name = read_string( _data, pos, _len );
// Parsing string
const char* _access;
_access = read_string( _data, pos, _len );
// Parsing string
const char* _owner;
_owner = read_string( _data, pos, _len );
// Parsing string
const char* _group;
_group = read_string( _data, pos, _len );
// Parsing string
const char* _date;
_date = read_string( _data, pos, _len );
// Parsing int
int _size;
_size = read_int( _data, pos, _len );
// Calling function
emit dirEntry( _name, _access, _owner, _group, _date, _size );
free( (void*)_name );
free( (void*)_access );
free( (void*)_owner );
free( (void*)_group );
free( (void*)_date );
}
--- NEW FILE: kfm.cpp ---
/* This file is part of the KDE libraries
Copyright (C) 1997 Torben Weis (weis at kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <qdir.h>
#include <qstring.h>
#include <qmessagebox.h>
#include <qapplication.h>
#include "kfm.h"
#include <kapp.h>
#include <kstring.h>
QString displayName()
{
// note: We can not rely on DISPLAY. If KDE is started by
// KDM, DISPLAY will be something like ":0", but this is
// not unique if we start KDE several times in a network
QString d = QString(getenv("DISPLAY"));
int i = d.find( ':' );
if ( i != -1 )
d[i] = '_';
if (i==0)
{
// we are running local, so add the hostname
char name[25];
if (gethostname(name, 25) == 0)
d = name + d;
}
if ( d.find( '.' ) == -1 )
d += ".0";
return d;
}
KFM::KFM()
{
flag = 0;
ok = FALSE;
ipc = 0L;
allowRestart = FALSE;
modal_hack_widget = 0;
init();
}
KFM::~KFM()
{
if ( ipc )
delete ipc;
}
bool KFM::download(const QString & src, QString & target){
KURL u (src);
if (u.isLocalFile() && !u.hasSubProtocol()){
// file protocol. We do not need the network
target = u.path();
return true;
}
KFM* kfm = new KFM;
bool result = kfm->downloadInternal(src,target);
delete kfm;
return result;
}
QStrList* KFM::tmpfiles = 0;
void KFM::removeTempFile(const QString & name){
if (!tmpfiles)
return;
if (tmpfiles->contains(name)){
unlink(name);
tmpfiles->remove(name);
}
}
bool KFM::downloadInternal(const QString & src, QString & target){
if (target.isEmpty()){
target = tmpnam(0);
if (!tmpfiles)
tmpfiles = new QStrList;
tmpfiles->append(qstrdup(target.data()));
}
download_state = true; // success
/* this is a bit tricky. We use a faked modal dialog to be able to
process the download syncronious. For the user it will look
(almost) as if the kfm-dialog is the modal dialog of your
application. After show() we will also enter a local event loop
within Qt. The modal_hack_widget will be hidden and destroyed in
the finish slot. This will implictly exit the local event loop
in addition (Matthias)
*/
modal_hack_widget = new QWidget(0,0,WType_Modal);
modal_hack_widget->setGeometry(-10,-10,2,2);
copy(src, target);
modal_hack_widget->show();
qApp->enter_loop();
return download_state;
}
void KFM::init()
{
QString file = KApplication::localkdedir() + "/share/apps/kfm/pid";
file += displayName();
// Try to open the pid file
FILE *f = fopen( file.data(), "rb" );
if ( f == 0L )
{
// Did we already try to start a new kfm ?
if ( flag == 0 && allowRestart )
{
// Try to start a new kfm
system( "kfm -d &" );
// dont try twice
flag = 1;
sleep( 10 );
init();
return;
}
if (!silent) warning("ERROR: KFM is not running");
return;
}
// Read the PID
char buffer[ 1024 ];
buffer[0] = 0;
fgets( buffer, 1023, f );
int pid = atoi( buffer );
if ( pid <= 0 )
{
if (!silent) warning("ERROR: Invalid PID");
fclose( f );
return;
}
// Is the PID ok ?
if ( kill( pid, 0 ) != 0 )
{
// Did we already try to start a new kfm ?
if ( flag == 0 && allowRestart )
{
flag = 1;
// Try to start a new kfm
system( "kfm -d &" );
sleep( 10 );
fclose( f );
init();
return;
}
if (!silent) warning("ERROR: KFM crashed");
fclose( f );
return;
}
// Read the socket's name
buffer[0] = 0;
fscanf(f, "%s", buffer);
fclose( f );
char * slot = strdup( buffer );
if ( slot == (void *) 0 )
{
if (!silent) warning("ERROR: Invalid Slot");
return;
}
// Connect to KFM
ipc = new KfmIpc( slot );
free(slot);
connect( ipc, SIGNAL( finished() ), this, SLOT( slotFinished() ) );
connect( ipc, SIGNAL( error( int, const char* ) ),
this, SLOT( slotError( int, const char* ) ) );
connect( ipc, SIGNAL( dirEntry( const char*, const char*, const char*, const char*, const char*, int ) ),
this, SLOT( slotDirEntry( const char*, const char*, const char*, const char*, const char*, int ) ) );
// Read the password
QString fn = KApplication::localkdedir() + "/share/apps/kfm/magic";
f = fopen( fn.data(), "rb" );
if ( f == 0L )
{
QString ErrorMessage;
ksprintf(&ErrorMessage, i18n("You dont have the file %s\n"
"Could not do Authorization"), fn.data());
QMessageBox::message( i18n("KFM Error"), ErrorMessage );
return;
}
char *p = fgets( buffer, 1023, f );
fclose( f );
if ( p == 0L )
{
QString ErrorMessage;
ksprintf(&ErrorMessage, i18n("The file %s is corrupted\n"
"Could not do Authorization"), fn.data());
QMessageBox::message( i18n("KFM Error"), ErrorMessage );
return;
}
ipc->auth( buffer );
ok = TRUE;
}
void KFM::refreshDesktop()
{
if ( !test() )
return;
ipc->refreshDesktop();
}
void KFM::sortDesktop()
{
if ( !test() )
return;
ipc->sortDesktop();
}
void KFM::configure()
{
if ( !test() )
return;
ipc->configure();
}
void KFM::openURL()
{
if ( !test() )
return;
ipc->openURL( "" );
}
void KFM::openURL( const char *_url )
{
if ( !test() )
return;
ipc->openURL( _url );
}
void KFM::list( const char *_url )
{
if ( !test() )
return;
ipc->list( _url );
}
void KFM::refreshDirectory( const char *_url )
{
if ( !test() )
return;
ipc->refreshDirectory( _url );
}
void KFM::openProperties( const char *_url )
{
if ( !test() )
return;
ipc->openProperties( _url );
}
void KFM::exec( const char *_url, const char *_binding )
{
if ( !test() ) {
return;
}
ipc->exec( _url, _binding );
}
void KFM::copy( const char *_src, const char *_dest )
{
if ( !test() )
return;
ipc->copy( _src, _dest );
}
void KFM::move( const char *_src, const char *_dest )
{
if ( !test() )
return;
ipc->move( _src, _dest );
}
void KFM::copyClient( const char *_src, const char *_dest )
{
if ( !test() )
return;
ipc->copyClient( _src, _dest );
}
void KFM::moveClient( const char *_src, const char *_dest )
{
if ( !test() )
return;
ipc->moveClient( _src, _dest );
}
void KFM::selectRootIcons( int _x, int _y, int _w, int _h, bool _add )
{
//warning( "KFM call: selectRootIcons");
if ( !test() )
return;
//warning( "KFM doing call");
ipc->selectRootIcons( _x, _y, _w, _h, _add );
}
void KFM::slotFinished()
{
if (modal_hack_widget){
modal_hack_widget->close(true);
modal_hack_widget = 0;
qApp->exit_loop();
}
emit finished();
}
bool KFM::test()
{
if ( ( ipc == 0L || !ipc->isConnected() ) && allowRestart )
{
warning( "*********** KFM crashed **************" );
if ( ipc )
delete ipc;
ipc = 0L;
flag = 0;
ok = FALSE;
warning( "KFM recovery" );
init();
warning( "KFM recovery done" );
}
if ( ipc == 0L )
warning( "KFM NOT READY");
return ( ipc==0L?false:true );
}
void KFM::allowKFMRestart( bool _allow )
{
allowRestart = _allow;
}
bool KFM::isKFMRunning()
{
if ( ipc == 0L ) return FALSE;
if ( ipc->isConnected() )
return TRUE;
return FALSE;
}
void KFM::slotError( int _kerror, const char *_text )
{
download_state = false;
emit error( _kerror, _text );
}
void KFM::slotDirEntry(const char* _name, const char* _access, const char* _owner,
const char* _group, const char* _date, int _size)
{
entry.name = _name;
entry.access = _access;
entry.owner = _owner;
entry.group = _group;
entry.date = _date;
entry.size = _size;
emit dirEntry( entry );
}
//static
void KFM::setSilent(bool _silent) { silent = _silent; }
bool KFM::silent = false;
DlgLocation::DlgLocation( const char *_text, const char* _value, QWidget *parent )
: QDialog( parent, 0L, TRUE )
{
QLabel *label = new QLabel( _text , this );
label->adjustSize(); // depends on the text length
label->move(10,10);
edit = new QLineEdit( this, 0L );
connect( edit, SIGNAL(returnPressed()), SLOT(accept()) );
ok = new QPushButton( i18n("OK"), this );
connect( ok, SIGNAL(clicked()), SLOT(accept()) );
ok->adjustSize();
cancel = new QPushButton( i18n("Cancel"), this );
connect( cancel, SIGNAL(clicked()), SLOT(reject()) );
cancel->adjustSize();
edit->setText( _value );
edit->setFocus();
setMinimumSize ( 200, 40+edit->height()+10+ok->height()+10 );
setGeometry( x(), y(), label->width()+20, 110 );
}
void DlgLocation::resizeEvent(QResizeEvent *e)
{
QDialog::resizeEvent(e);
int w = rect().width();
int h = rect().height();
edit->setGeometry (10, 40, w-20, 20);
ok->move( 10, h-10-ok->height() );
cancel->move( w-10-cancel->width(), h-10-cancel->height() );
}
#include "kfm.moc"
--- NEW FILE: kfm.h ---
/* This file is part of the KDE libraries
Copyright (C) 1997 Torben Weis (weis at kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef kfm_h
#define kfm_h
#include <qobject.h>
#include <qdialog.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qlabel.h>
#include <qstring.h>
#include <kurl.h>
#include "kfmclient_ipc.h"
class KDirEntry
{
public:
QString name;
QString access;
QString date;
QString owner;
QString group;
int size;
};
class KFM : public QObject
{
Q_OBJECT
public:
/**
* This will not restart KFM if it is not running.
* You have to call @ref #allowKFMRestart before
* calling any other function. This will allow to
* restart KFM on demand.
*/
KFM();
~KFM();
/* Call setSilent(true) before you create a KFM instance
* if you don't want error messages on stderr
* (useful e.g. to simply test if KFM is running or not)
* Default behaviour is NOT silent.
*/
static void setSilent(bool _silent);
/* This function is probably what you are looking for. It can be
* used to download a file from an arbitrary URL (source) to a
* temporary file on the local filesystem (target). If the argument
* for target is an empty string, download will generate a
* unique temporary filename in /tmp. Since target is a reference
* to QString you can access this filename easily. Download will
* return true if the download was successful, otherwise false.
*
* Special case:
* If the url is of kind "file:" then no downloading is
* processed but the full filename returned in target.
* That means: you _have_ to take care about the target argument.
* (This is very comfortable, please see the example below.)
*
* Download is synchronous. That means you can use it like
* this, (assuming u is a string which represents a URL and your
* application has a loadFile function):
*
* QString s;
* if (KFM::download(u, s)){
* loadFile(s);
* KFM::removeTempFile(s);
* }
*
* Of course your user interface will still process exposure/repaint
* events during the download.
*
* (Matthias)
*/
static bool download(const QString & src, QString & target);
/* Remove the specified file if and only if it was created
* by KFM as temporary file for a former download.
* (Matthias)
*/
static void removeTempFile(const QString & name);
bool isOK() { return ok; }
void refreshDesktop();
void sortDesktop();
void configure();
void openURL();
void openURL( const char *_url );
void refreshDirectory( const char *_url );
void openProperties( const char *_url );
void exec( const char *_url, const char *_binding );
void copy( const char *_src, const char *_dest );
void move( const char *_src, const char *_dest );
void copyClient( const char *_src, const char *_dest );
void moveClient( const char *_src, const char *_dest );
void list( const char *_url );
// For KWM only
void selectRootIcons( int _x, int _y, int _w, int _h, bool _add );
/**
* Allows this class to restart KFM if it is not running.
*/
void allowKFMRestart( bool );
/**
* Tells wether a KFM is running.
*/
bool isKFMRunning();
signals:
void finished();
void error( int _kerror, const char *_text );
void dirEntry( KDirEntry& _entry );
public slots:
void slotFinished();
void slotError( int _kerror, const char *_text );
void slotDirEntry(const char* _name, const char* _access, const char* _owner,
const char* _group, const char* _date, int _size);
protected:
void init();
bool test();
char flag;
bool ok;
bool allowRestart;
KfmIpc *ipc;
KDirEntry entry;
private:
bool downloadInternal(const QString & src, QString & target);
QWidget* modal_hack_widget;
bool download_state; /* to indicate wether the download was successful */
static QStrList* tmpfiles;
static bool silent;
};
/// Asking for a location
/**
This class can be used to ask for a new filename or for
an URL.
*/
class DlgLocation : public QDialog
{
Q_OBJECT
public:
/// Constructor
/**
Create a dialog that asks for a single line of text. _value is the initial
value of the line. _text appears as label on top of the entry box.
*/
DlgLocation( const char *_text, const char *_value, QWidget *parent = 0L );
/// Return the value the user entered
const char * getText() { return edit->text(); }
/// The dialog is being resized
void resizeEvent(QResizeEvent *e);
protected:
/// The line edit widget and the two buttons
QLineEdit *edit;
QPushButton *ok;
QPushButton *cancel;
};
/**
* Return the name of the current display, usable for KFM's locking.
*/
QString displayName();
#endif
More information about the dslinux-commit
mailing list