summaryrefslogtreecommitdiffstats
path: root/kio
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-02 21:21:15 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-02 21:21:15 +0000
commit96900dbce3aaa1fcac74a07a71482c5c6fcd3cab (patch)
treebf3fc68d0dcc660fce0e21171373a2d4e2395707 /kio
parent5f99bff82d3413803bcc652999f4f631058179d6 (diff)
downloadtdelibs-96900dbce3aaa1fcac74a07a71482c5c6fcd3cab.tar.gz
tdelibs-96900dbce3aaa1fcac74a07a71482c5c6fcd3cab.zip
* Large set of SuSE patches to fix bugs and add functionality
* kdemm is included but not used by knotify as it does not work out of the box git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1171141 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kio')
-rw-r--r--kio/kfile/kfiledialog.cpp6
-rw-r--r--kio/kfile/kfilesharedlg.cpp59
-rw-r--r--kio/kfile/kfilesharedlg.h3
-rw-r--r--kio/kfile/kurlbar.cpp13
-rw-r--r--kio/kio/kdirwatch.cpp3
-rw-r--r--kio/kio/kfileshare.cpp74
-rw-r--r--kio/kio/kfileshare.h24
-rw-r--r--kio/kio/kmimetype.cpp10
-rw-r--r--kio/kio/kremoteencoding.cpp6
-rw-r--r--kio/kio/kservice.cpp15
-rw-r--r--kio/kio/kservicegroup.cpp10
-rw-r--r--kio/kio/netaccess.cpp2
-rw-r--r--kio/kssl/kopenssl.cc22
-rw-r--r--kio/kssl/kopenssl.h16
-rw-r--r--kio/kssl/ksmimecrypto.cc2
-rw-r--r--kio/kssl/ksslcertificate.cc32
-rw-r--r--kio/misc/kwalletd/kwalletd.cpp38
-rw-r--r--kio/misc/kwalletd/kwalletd.h6
18 files changed, 278 insertions, 63 deletions
diff --git a/kio/kfile/kfiledialog.cpp b/kio/kfile/kfiledialog.cpp
index f206a4887..0c9364943 100644
--- a/kio/kfile/kfiledialog.cpp
+++ b/kio/kfile/kfiledialog.cpp
@@ -1165,6 +1165,12 @@ void KFileDialog::urlEntered(const KURL& url)
d->pathCombo->setURL( url );
}
+ if (url.protocol()=="beagle" && url.path()=="/") {
+ d->pathCombo->setEditText("beagle:/<"+i18n("search term")+">");
+ d->pathCombo->lineEdit()->setSelection(8,255);
+ d->pathCombo->setFocus();
+ }
+
locationEdit->blockSignals( true );
locationEdit->setCurrentItem( 0 );
if ( d->keepLocation )
diff --git a/kio/kfile/kfilesharedlg.cpp b/kio/kfile/kfilesharedlg.cpp
index 788edee51..329bd19dc 100644
--- a/kio/kfile/kfilesharedlg.cpp
+++ b/kio/kfile/kfilesharedlg.cpp
@@ -24,6 +24,7 @@
#include <tqradiobutton.h>
#include <tqbuttongroup.h>
#include <tqlayout.h>
+#include <tqlineedit.h>
#include <kprocess.h>
#include <kprocio.h>
#include <klocale.h>
@@ -47,6 +48,7 @@ public:
KProcess *m_configProc;
bool m_bAllShared;
bool m_bAllUnshared;
+ bool m_bAllReadOnly;
};
KFileSharePropsPlugin::KFileSharePropsPlugin( KPropertiesDialog *_props )
@@ -98,8 +100,10 @@ void KFileSharePropsPlugin::init()
delete m_widget;
m_rbShare = 0L;
m_rbUnShare = 0L;
+ m_rbSharerw = 0L;
m_widget = new TQWidget( d->m_vBox );
TQVBoxLayout * vbox = new TQVBoxLayout( m_widget );
+ //TQHBoxLayout * hbox = new TQHBoxLayout( vbox );
switch ( KFileShare::authorization() ) {
case KFileShare::Authorized:
@@ -110,18 +114,29 @@ void KFileSharePropsPlugin::init()
home += '/';
bool ok = true;
KFileItemList items = properties->items();
- // We have 3 possibilities: all shared, all unshared, or mixed.
+ // We have 3 possibilities: all shared, all unshared (ro,rw), or mixed.
d->m_bAllShared = true;
d->m_bAllUnshared = true;
+ d->m_bAllReadOnly = true;
KFileItemListIterator it( items );
for ( ; it.current() && ok; ++it ) {
TQString path = (*it)->url().path();
+ // 0 => not shared
+ // 1 => shared read only
+ // 3 => shared writeable
+ int dirStatus = KFileShare::isDirectoryShared( path );
if ( !path.startsWith( home ) )
ok = false;
- if ( KFileShare::isDirectoryShared( path ) )
+ if ( dirStatus == 1 ) {
d->m_bAllUnshared = false;
- else
- d->m_bAllShared = false;
+ }
+ else if ( dirStatus == 3 ) {
+ d->m_bAllUnshared = false;
+ d->m_bAllReadOnly = false;
+ }
+ else {
+ d->m_bAllReadOnly = false;
+ }
}
if ( !ok )
{
@@ -141,16 +156,31 @@ void KFileSharePropsPlugin::init()
vbox->addWidget( m_rbUnShare, 0 );
rbGroup->insert( m_rbUnShare );
- m_rbShare = new TQRadioButton( i18n("Shared"), m_widget );
+ m_rbShare = new TQRadioButton( i18n("Shared - read only for others"), m_widget );
connect( m_rbShare, TQT_SIGNAL( toggled(bool) ), TQT_SIGNAL( changed() ) );
vbox->addWidget( m_rbShare, 0 );
rbGroup->insert( m_rbShare );
+ m_rbSharerw = new TQRadioButton( i18n("Shared - writeable for others"), m_widget );
+ connect( m_rbSharerw, TQT_SIGNAL( toggled(bool) ), TQT_SIGNAL( changed() ) );
+ vbox->addWidget( m_rbSharerw, 0 );
+ rbGroup->insert( m_rbSharerw );
+
+ //TQLabel *testlabel1 = new TQLabel(i18n("Enter Samba Share Name here"),m_widget);
+ //m_leSmbShareName = new TQLineEdit(m_widget);
+ //m_leSmbShareName->setMaxLength(12);
+
+ //hbox->addWidget( testlabel1, 0 );
+ //hbox->addWidget( m_leSmbShareName );
+ //vbox->addLayout( hbox );
+
// Activate depending on status
if ( d->m_bAllShared )
- m_rbShare->setChecked(true);
+ m_rbSharerw->setChecked(true);
if ( d->m_bAllUnshared )
m_rbUnShare->setChecked(true);
+ if ( d->m_bAllReadOnly )
+ m_rbShare->setChecked(true);
// Some help text
TQLabel *label = new TQLabel( i18n("Sharing this folder makes it available under Linux/UNIX (NFS) and Windows (Samba).") , m_widget );
@@ -167,6 +197,9 @@ void KFileSharePropsPlugin::init()
vbox->addWidget( m_pbConfig, 0, Qt::AlignHCenter );
vbox->addStretch( 10 );
+
+ if( !KFileShare::sambaActive() && !KFileShare::nfsActive())
+ m_widget->setEnabled( false );
}
}
break;
@@ -228,7 +261,7 @@ void KFileSharePropsPlugin::slotConfigureFileSharingDone()
void KFileSharePropsPlugin::applyChanges()
{
kdDebug() << "KFileSharePropsPlugin::applyChanges" << endl;
- if ( m_rbShare && m_rbUnShare )
+ if ( m_rbShare && m_rbUnShare && m_rbSharerw )
{
bool share = m_rbShare->isChecked();
@@ -242,7 +275,7 @@ void KFileSharePropsPlugin::applyChanges()
bool ok = true;
for ( ; it.current() && ok; ++it ) {
TQString path = (*it)->url().path();
- ok = setShared( path, share );
+ ok = SuSEsetShared( path, share, m_rbSharerw->isChecked() );
if (!ok) {
if (share)
KMessageBox::detailedError(properties,
@@ -269,8 +302,14 @@ void KFileSharePropsPlugin::applyChanges()
bool KFileSharePropsPlugin::setShared( const TQString& path, bool shared )
{
- kdDebug() << "KFileSharePropsPlugin::setShared " << path << "," << shared << endl;
- return KFileShare::setShared( path, shared );
+ return SuSEsetShared( path, shared, true );
+}
+
+bool KFileSharePropsPlugin::SuSEsetShared( const TQString& path, bool shared, bool readonly )
+{
+ kdDebug() << "KFileSharePropsPlugin::setShared " << path << ","
+ << shared << readonly << endl;
+ return KFileShare::SuSEsetShared( path, shared, readonly );
}
TQWidget* KFileSharePropsPlugin::page() const
diff --git a/kio/kfile/kfilesharedlg.h b/kio/kfile/kfilesharedlg.h
index 25fbc7f67..54876f12a 100644
--- a/kio/kfile/kfilesharedlg.h
+++ b/kio/kfile/kfilesharedlg.h
@@ -55,10 +55,13 @@ protected slots:
private:
void init();
bool setShared( const TQString&path, bool shared );
+ bool SuSEsetShared( const TQString&path, bool shared, bool readonly );
TQWidget *m_widget;
TQRadioButton *m_rbShare;
+ TQRadioButton *m_rbSharerw;
TQRadioButton *m_rbUnShare;
+ //TQLineEdit *m_leSmbShareName;
TQPushButton *m_pbConfig;
class Private;
Private *d;
diff --git a/kio/kfile/kurlbar.cpp b/kio/kfile/kurlbar.cpp
index 5c2b167c0..08dd36656 100644
--- a/kio/kfile/kurlbar.cpp
+++ b/kio/kfile/kurlbar.cpp
@@ -605,8 +605,19 @@ void KURLBar::readItem( int i, KConfig *config, bool applicationLocal )
if ( !url.isValid() || !KProtocolInfo::isKnownProtocol( url ))
return; // nothing we could do.
+ TQString description = config->readEntry( TQString("Description_") + number );
+
+ if (description.isEmpty() && url.protocol()=="beagle") {
+ KIO::UDSEntry uds;
+ const KURL kurl("beagle:?beagled-status");
+ if (!KIO::NetAccess::stat(kurl, uds))
+ return;
+
+ description = i18n("Desktop Search");
+ }
+
insertItem( url,
- config->readEntry( TQString("Description_") + number ),
+ description,
applicationLocal,
config->readEntry( TQString("Icon_") + number ),
static_cast<KIcon::Group>(
diff --git a/kio/kio/kdirwatch.cpp b/kio/kio/kdirwatch.cpp
index 08ab25b89..38cd8f866 100644
--- a/kio/kio/kdirwatch.cpp
+++ b/kio/kio/kdirwatch.cpp
@@ -725,7 +725,8 @@ bool KDirWatchPrivate::useINotify( Entry* e )
bool KDirWatchPrivate::useStat(Entry* e)
{
- if (KIO::probably_slow_mounted(e->path))
+ if ( e->path.startsWith("/media/") || (e->path == "/media")
+ || (KIO::probably_slow_mounted(e->path)) )
useFreq(e, m_nfsPollInterval);
else
useFreq(e, m_PollInterval);
diff --git a/kio/kio/kfileshare.cpp b/kio/kio/kfileshare.cpp
index 6b9bf361d..1f6dca285 100644
--- a/kio/kio/kfileshare.cpp
+++ b/kio/kio/kfileshare.cpp
@@ -20,6 +20,7 @@
#include "kfileshare.h"
#include <tqdir.h>
#include <tqfile.h>
+#include <tqregexp.h>
#include <kprocess.h>
#include <kprocio.h>
#include <klocale.h>
@@ -35,8 +36,10 @@
#include <kuser.h>
KFileShare::Authorization KFileShare::s_authorization = NotInitialized;
-TQStringList* KFileShare::s_shareList = 0L;
-static KStaticDeleter<TQStringList> sdShareList;
+//TQStringList* KFileShare::s_shareList = 0L;
+//static KStaticDeleter<TQStringList> sdShareList;
+TQMap<TQString,TQString>* KFileShare::s_shareMap = 0L;
+static KStaticDeleter<TQMap<TQString,TQString> > sdShareMap;
KFileShare::ShareMode KFileShare::s_shareMode;
bool KFileShare::s_sambaEnabled;
@@ -165,10 +168,10 @@ bool KFileShare::nfsEnabled() {
void KFileShare::readShareList()
{
KFileSharePrivate::self();
- if ( !s_shareList )
- sdShareList.setObject( s_shareList, new TQStringList );
+ if ( !s_shareMap )
+ sdShareMap.setObject( s_shareMap, new TQMap<TQString,TQString> );
else
- s_shareList->clear();
+ s_shareMap->clear();
// /usr/sbin on Mandrake, $PATH allows flexibility for other distributions
TQString exe = findExe( "filesharelist" );
@@ -186,29 +189,45 @@ void KFileShare::readShareList()
// Reading code shamelessly stolen from khostname.cpp ;)
TQString line;
+ TQString options;
+ TQString path;
int length;
+ TQRegExp rx_line("([^\\s]+)\\s+(.*)");
do {
length = proc.readln(line, true);
if ( length > 0 )
{
if ( line[length-1] != '/' )
line += '/';
- s_shareList->append(line);
+ if( rx_line.search( line ) != -1 ) {
+ options = rx_line.cap(1);
+ path = rx_line.cap(2);
+ (*s_shareMap)[path] = options;
+ }
kdDebug(7000) << "Shared dir:" << line << endl;
}
} while (length > -1);
}
-bool KFileShare::isDirectoryShared( const TQString& _path )
+int KFileShare::isDirectoryShared( const TQString& _path )
{
- if ( ! s_shareList )
+ int ret(0);
+
+ if ( ! s_shareMap )
readShareList();
TQString path( _path );
if ( path[path.length()-1] != '/' )
path += '/';
- return s_shareList && s_shareList->contains( path );
+ //return s_shareList && s_shareList->contains( path );
+ if( (*s_shareMap).contains(path) && !((*s_shareMap)[path].isEmpty()) ) {
+ ret+=1;
+ if( (*s_shareMap)[path].find("readwrite") != -1 )
+ ret+=2;
+ }
+
+ return ret;
}
KFileShare::Authorization KFileShare::authorization()
@@ -231,17 +250,30 @@ TQString KFileShare::findExe( const char* exeName )
bool KFileShare::setShared( const TQString& path, bool shared )
{
+ return SuSEsetShared( path, shared, false );
+}
+
+bool KFileShare::SuSEsetShared( const TQString& path, bool shared, bool rw )
+{
if (! KFileShare::sharingEnabled() ||
KFileShare::shareMode() == Advanced)
return false;
- kdDebug(7000) << "KFileShare::setShared " << path << "," << shared << endl;
TQString exe = KFileShare::findExe( "fileshareset" );
if (exe.isEmpty())
return false;
-
+
+ // we want to share, so we kick it first - just to be sure
KProcess proc;
proc << exe;
+ proc << "--remove";
+ proc << path;
+ proc.start( KProcess::Block );
+ proc.clearArguments();
+
+ proc << exe;
+ if( rw )
+ proc << "--rw";
if ( shared )
proc << "--add";
else
@@ -291,4 +323,24 @@ bool KFileShare::setShared( const TQString& path, bool shared )
return ok;
}
+bool KFileShare::sambaActive()
+{
+ // rcsmb is not executable by users, try ourselves
+ int status = system( "/sbin/checkproc -p /var/run/samba/smbd.pid /usr/sbin/smbd" );
+ return status != -1 && WIFEXITED( status ) && WEXITSTATUS( status ) == 0;
+}
+
+bool KFileShare::nfsActive()
+{
+ // rcnfsserver is not executable by users, try ourselves
+ int status = system( "/sbin/checkproc /usr/sbin/rpc.mountd" );
+ if( status != -1 && WIFEXITED( status ) && WEXITSTATUS( status ) == 0 )
+ {
+ status = system( "/sbin/checkproc -n nfsd" );
+ if( status != -1 && WIFEXITED( status ) && WEXITSTATUS( status ) == 0 )
+ return true;
+ }
+ return false;
+}
+
#include "kfileshare.moc"
diff --git a/kio/kio/kfileshare.h b/kio/kio/kfileshare.h
index 6753e055a..6fddebd65 100644
--- a/kio/kio/kfileshare.h
+++ b/kio/kio/kfileshare.h
@@ -67,7 +67,7 @@ public:
/**
* Call this to know if a directory is currently shared
*/
- static bool isDirectoryShared( const TQString& path );
+ static int isDirectoryShared( const TQString& path );
enum Authorization { NotInitialized, ErrorNotFound, Authorized, UserNotAllowed };
/**
@@ -85,7 +85,12 @@ public:
* @returns whether the perl script was successful
*/
static bool setShared( const TQString& path, bool shared );
-
+
+ /*
+ * SuSE only enhancement for now
+ */
+ static bool SuSEsetShared( const TQString& path, bool shared, bool ro );
+
/**
* The used share mode.
* Simple means that the simple sharing dialog is used and
@@ -131,10 +136,23 @@ public:
* Returns whether NFS is enabled
*/
static bool nfsEnabled();
+
+ /**
+ * Returns whether Samba is active (service is running)
+ * @internal
+ */
+ static bool sambaActive();
+
+ /**
+ * Returns whether NFS is active (service is running)
+ * @internal
+ */
+ static bool nfsActive();
private:
static Authorization s_authorization;
- static TQStringList* s_shareList;
+// static TQStringList* s_shareList;
+ static TQMap<TQString,TQString>* s_shareMap;
static ShareMode s_shareMode;
static bool s_sambaEnabled;
static bool s_nfsEnabled;
diff --git a/kio/kio/kmimetype.cpp b/kio/kio/kmimetype.cpp
index af4243a53..a698e7495 100644
--- a/kio/kio/kmimetype.cpp
+++ b/kio/kio/kmimetype.cpp
@@ -677,9 +677,8 @@ TQString KFolderType::comment( const KURL& _url, bool _is_local ) const
KURL u( _url );
u.addPath( ".directory" );
- KSimpleConfig cfg( u.path(), true );
- cfg.setDesktopGroup();
- TQString comment = cfg.readEntry( "Comment" );
+ KDesktopFile cfg( u.path(), true );
+ TQString comment = cfg.readComment();
if ( comment.isEmpty() )
return KMimeType::comment( _url, _is_local );
@@ -772,9 +771,8 @@ TQString KDEDesktopMimeType::comment( const KURL& _url, bool _is_local ) const
if ( !_is_local )
return KMimeType::comment( _url, _is_local );
- KSimpleConfig cfg( _url.path(), true );
- cfg.setDesktopGroup();
- TQString comment = cfg.readEntry( "Comment" );
+ KDesktopFile cfg( _url.path(), true );
+ TQString comment = cfg.readComment();
if ( comment.isEmpty() )
return KMimeType::comment( _url, _is_local );
diff --git a/kio/kio/kremoteencoding.cpp b/kio/kio/kremoteencoding.cpp
index ebd7fda74..632eeb8b2 100644
--- a/kio/kio/kremoteencoding.cpp
+++ b/kio/kio/kremoteencoding.cpp
@@ -53,7 +53,7 @@ TQCString KRemoteEncoding::encode(const TQString& name) const
TQCString result = codec->fromUnicode(name);
if (codec->toUnicode(result) != name)
return name.latin1();
-
+
return result;
}
@@ -80,11 +80,13 @@ void KRemoteEncoding::setEncoding(const char *name)
if (name)
codec = TQTextCodec::codecForName(name);
+ else
+ codec = TQTextCodec::codecForMib( 106 ); // fallback to UTF-8
if (codec == 0L)
codec = TQTextCodec::codecForMib(1);
- kdDebug() << k_funcinfo << "setting encoding " << codec->name()
+ kdDebug() << k_funcinfo << "setting encoding " << codec->name()
<< " for name=" << name << endl;
}
diff --git a/kio/kio/kservice.cpp b/kio/kio/kservice.cpp
index 2122010b2..299d91e90 100644
--- a/kio/kio/kservice.cpp
+++ b/kio/kio/kservice.cpp
@@ -115,7 +115,7 @@ KService::init( KDesktopFile *config )
return;
}
- m_strName = config->readEntry( "Name" );
+ m_strName = config->readName();
entryMap.remove("Name");
if ( m_strName.isEmpty() )
{
@@ -135,7 +135,7 @@ KService::init( KDesktopFile *config )
m_strName = m_strName.left(i);
}
- m_strType = config->readEntry( "Type" );
+ m_strType = config->readType();
entryMap.remove("Type");
if ( m_strType.isEmpty() )
{
@@ -224,11 +224,11 @@ KService::init( KDesktopFile *config )
entryMap.remove("Terminal");
m_strTerminalOptions = config->readEntry( "TerminalOptions" ); // should be a property IMHO
entryMap.remove("TerminalOptions");
- m_strPath = config->readPathEntry( "Path" );
+ m_strPath = config->readPath();
entryMap.remove("Path");
- m_strComment = config->readEntry( "Comment" );
+ m_strComment = config->readComment();
entryMap.remove("Comment");
- m_strGenName = config->readEntry( "GenericName" );
+ m_strGenName = config->readGenericName();
if (kde4application) {
m_strGenName += " [KDE4]";
}
@@ -275,7 +275,10 @@ KService::init( KDesktopFile *config )
m_bAllowAsDefault = config->readBoolEntry( "AllowDefault", true );
entryMap.remove("AllowDefault");
- m_initialPreference = config->readNumEntry( "InitialPreference", 1 );
+ m_initialPreference = config->readNumEntry( "X-KDE-InitialPreference", 1 );
+ entryMap.remove("X-KDE-InitialPreference");
+ if ( m_initialPreference == 1 )
+ m_initialPreference = config->readNumEntry( "InitialPreference", 1 );
entryMap.remove("InitialPreference");
// Store all additional entries in the property map.
diff --git a/kio/kio/kservicegroup.cpp b/kio/kio/kservicegroup.cpp
index 1531dc796..be093fc17 100644
--- a/kio/kio/kservicegroup.cpp
+++ b/kio/kio/kservicegroup.cpp
@@ -64,13 +64,11 @@ KServiceGroup::KServiceGroup( const TQString &configFile, const TQString & _relp
d->directoryEntryPath = cfg;
- KConfig config( cfg, true, false, "apps" );
+ KDesktopFile config( cfg, true, "apps" );
- config.setDesktopGroup();
-
- m_strCaption = config.readEntry( "Name" );
- m_strIcon = config.readEntry( "Icon" );
- m_strComment = config.readEntry( "Comment" );
+ m_strCaption = config.readName();
+ m_strIcon = config.readIcon();
+ m_strComment = config.readComment();
m_bDeleted = config.readBoolEntry( "Hidden", false );
d->m_bNoDisplay = config.readBoolEntry( "NoDisplay", false );
TQStringList tmpList;
diff --git a/kio/kio/netaccess.cpp b/kio/kio/netaccess.cpp
index 1c54afa74..5189b93d6 100644
--- a/kio/kio/netaccess.cpp
+++ b/kio/kio/netaccess.cpp
@@ -337,7 +337,7 @@ bool NetAccess::statInternal( const KURL & url, int details, bool source,
TQWidget* window )
{
bJobOK = true; // success unless further error occurs
- KIO::StatJob * job = KIO::stat( url, !url.isLocalFile() );
+ KIO::StatJob * job = KIO::stat( url, !url.isLocalFile() && !url.url().startsWith("beagle:?") );
job->setWindow (window);
job->setDetails( details );
job->setSide( source );
diff --git a/kio/kssl/kopenssl.cc b/kio/kssl/kopenssl.cc
index 9252bd223..ababf37a0 100644
--- a/kio/kssl/kopenssl.cc
+++ b/kio/kssl/kopenssl.cc
@@ -96,9 +96,14 @@ static int (*K_BIO_write) (BIO *b, const void *data, int len) = 0L;
static int (*K_PEM_ASN1_write_bio) (int (*)(),const char *,BIO *,char *,
const EVP_CIPHER *,unsigned char *,int ,
pem_password_cb *, void *) = 0L;
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+static int (*K_ASN1_item_i2d_fp)(ASN1_ITEM *,FILE *,unsigned char *) = 0L;
+static ASN1_ITEM *K_NETSCAPE_X509_it = 0L;
+#else
static ASN1_METHOD* (*K_X509_asn1_meth) (void) = 0L;
static int (*K_ASN1_i2d_fp)(int (*)(),FILE *,unsigned char *) = 0L;
static int (*K_i2d_ASN1_HEADER)(ASN1_HEADER *, unsigned char **) = 0L;
+#endif
static int (*K_X509_print_fp) (FILE *, X509*) = 0L;
static int (*K_i2d_PKCS12) (PKCS12*, unsigned char**) = 0L;
static int (*K_i2d_PKCS12_fp) (FILE *, PKCS12*) = 0L;
@@ -404,9 +409,14 @@ KConfig *cfg;
K_BIO_ctrl = (long (*) (BIO *,int,long,void *)) _cryptoLib->symbol("BIO_ctrl");
K_BIO_write = (int (*) (BIO *b, const void *data, int len)) _cryptoLib->symbol("BIO_write");
K_PEM_ASN1_write_bio = (int (*)(int (*)(), const char *,BIO*, char*, const EVP_CIPHER *, unsigned char *, int, pem_password_cb *, void *)) _cryptoLib->symbol("PEM_ASN1_write_bio");
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+ K_ASN1_item_i2d_fp = (int (*)(ASN1_ITEM *, FILE*, unsigned char *)) _cryptoLib->symbol("ASN1_item_i2d_fp");
+ K_NETSCAPE_X509_it = (ASN1_ITEM *) _cryptoLib->symbol("NETSCAPE_X509_it");
+#else
K_X509_asn1_meth = (ASN1_METHOD* (*)(void)) _cryptoLib->symbol("X509_asn1_meth");
K_ASN1_i2d_fp = (int (*)(int (*)(), FILE*, unsigned char *)) _cryptoLib->symbol("ASN1_i2d_fp");
K_i2d_ASN1_HEADER = (int (*)(ASN1_HEADER *, unsigned char **)) _cryptoLib->symbol("i2d_ASN1_HEADER");
+#endif
K_X509_print_fp = (int (*)(FILE*, X509*)) _cryptoLib->symbol("X509_print_fp");
K_i2d_PKCS12 = (int (*)(PKCS12*, unsigned char**)) _cryptoLib->symbol("i2d_PKCS12");
K_i2d_PKCS12_fp = (int (*)(FILE *, PKCS12*)) _cryptoLib->symbol("i2d_PKCS12_fp");
@@ -568,7 +578,7 @@ KConfig *cfg;
K_SSL_set_session = (int (*)(SSL*,SSL_SESSION*)) _sslLib->symbol("SSL_set_session");
K_d2i_SSL_SESSION = (SSL_SESSION* (*)(SSL_SESSION**,unsigned char**, long)) _sslLib->symbol("d2i_SSL_SESSION");
K_i2d_SSL_SESSION = (int (*)(SSL_SESSION*,unsigned char**)) _sslLib->symbol("i2d_SSL_SESSION");
- K_SSL_get_ciphers = (STACK *(*)(const SSL*)) _sslLib->symbol("SSL_get_ciphers");
+ K_SSL_get_ciphers = (STACK_OF(SSL_CIPHER) *(*)(const SSL*)) _sslLib->symbol("SSL_get_ciphers");
#endif
@@ -956,7 +966,13 @@ int KOpenSSLProxy::PEM_write_bio_X509(BIO *bp, X509 *x) {
else return -1;
}
-
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+int KOpenSSLProxy::ASN1_i2d_fp(FILE *out,unsigned char *x) {
+ if (K_ASN1_item_i2d_fp && K_NETSCAPE_X509_it)
+ return (K_ASN1_item_i2d_fp)(K_NETSCAPE_X509_it, out, x);
+ else return -1;
+}
+#else
ASN1_METHOD *KOpenSSLProxy::X509_asn1_meth(void) {
if (K_X509_asn1_meth) return (K_X509_asn1_meth)();
else return 0L;
@@ -968,7 +984,7 @@ int KOpenSSLProxy::ASN1_i2d_fp(FILE *out,unsigned char *x) {
return (K_ASN1_i2d_fp)((int (*)())K_i2d_ASN1_HEADER, out, x);
else return -1;
}
-
+#endif
int KOpenSSLProxy::X509_print(FILE *fp, X509 *x) {
if (K_X509_print_fp) return (K_X509_print_fp)(fp, x);
diff --git a/kio/kssl/kopenssl.h b/kio/kssl/kopenssl.h
index 68d6733cd..e4f6de0e8 100644
--- a/kio/kssl/kopenssl.h
+++ b/kio/kssl/kopenssl.h
@@ -48,6 +48,9 @@ class KOpenSSLProxyPrivate;
#include <openssl/stack.h>
#include <openssl/bn.h>
#undef crypt
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+#define STACK _STACK
+#endif
#endif
#include <kstaticdeleter.h>
@@ -446,12 +449,12 @@ public:
*/
int PEM_write_bio_X509(BIO *bp, X509 *x);
-
+#if OPENSSL_VERSION_NUMBER < 0x10000000L
/*
* X509_asn1_meth - used for netscape output
*/
ASN1_METHOD *X509_asn1_meth();
-
+#endif
/*
* ASN1_i2d_fp - used for netscape output
@@ -531,6 +534,9 @@ public:
*/
void sk_free(STACK *s);
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+ void sk_free(void *s) { return sk_free(reinterpret_cast<STACK*>(s)); }
+#endif
/*
* Number of elements in the stack
@@ -543,6 +549,9 @@ public:
*/
char *sk_value(STACK *s, int n);
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+ char *sk_value(void *s, int n) { return sk_value(reinterpret_cast<STACK*>(s), n); }
+#endif
/*
* Create a new stack
@@ -555,6 +564,9 @@ public:
*/
int sk_push(STACK *s, char *d);
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+ int sk_push(void *s, void *d) { return sk_push(reinterpret_cast<STACK*>(s), reinterpret_cast<char*>(d)); }
+#endif
/*
* Duplicate the stack
diff --git a/kio/kssl/ksmimecrypto.cc b/kio/kssl/ksmimecrypto.cc
index c96f9ec6d..1a9e37e60 100644
--- a/kio/kssl/ksmimecrypto.cc
+++ b/kio/kssl/ksmimecrypto.cc
@@ -87,7 +87,7 @@ KSMIMECryptoPrivate::KSMIMECryptoPrivate(KOpenSSLProxy *kossl): kossl(kossl) {
STACK_OF(X509) *KSMIMECryptoPrivate::certsToX509(TQPtrList<KSSLCertificate> &certs) {
- STACK_OF(X509) *x509 = sk_new(NULL);
+ STACK_OF(X509) *x509 = reinterpret_cast<STACK_OF(X509)*>(sk_new(NULL));
KSSLCertificate *cert = certs.first();
while(cert) {
sk_X509_push(x509, cert->getCert());
diff --git a/kio/kssl/ksslcertificate.cc b/kio/kssl/ksslcertificate.cc
index a76b235d7..73a8451ca 100644
--- a/kio/kssl/ksslcertificate.cc
+++ b/kio/kssl/ksslcertificate.cc
@@ -1003,17 +1003,31 @@ return qba;
TQByteArray KSSLCertificate::toNetscape() {
TQByteArray qba;
#ifdef KSSL_HAVE_SSL
-ASN1_HEADER ah;
-ASN1_OCTET_STRING os;
-KTempFile ktf;
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+ NETSCAPE_X509 nx;
+ ASN1_OCTET_STRING hdr;
+#else
+ ASN1_HEADER ah;
+ ASN1_OCTET_STRING os;
+#endif
+ KTempFile ktf;
- os.data = (unsigned char *)NETSCAPE_CERT_HDR;
- os.length = strlen(NETSCAPE_CERT_HDR);
- ah.header = &os;
- ah.data = (char *)getCert();
- ah.meth = d->kossl->X509_asn1_meth();
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+ hdr.data = (unsigned char *)NETSCAPE_CERT_HDR;
+ hdr.length = strlen(NETSCAPE_CERT_HDR);
+ nx.header = &hdr;
+ nx.cert = getCert();
- d->kossl->ASN1_i2d_fp(ktf.fstream(),(unsigned char *)&ah);
+ d->kossl->ASN1_i2d_fp(ktf.fstream(),(unsigned char *)&nx);
+#else
+ os.data = (unsigned char *)NETSCAPE_CERT_HDR;
+ os.length = strlen(NETSCAPE_CERT_HDR);
+ ah.header = &os;
+ ah.data = (char *)getCert();
+ ah.meth = d->kossl->X509_asn1_meth();
+
+ d->kossl->ASN1_i2d_fp(ktf.fstream(),(unsigned char *)&ah);
+#endif
ktf.close();
diff --git a/kio/misc/kwalletd/kwalletd.cpp b/kio/misc/kwalletd/kwalletd.cpp
index fd39f8487..069575710 100644
--- a/kio/misc/kwalletd/kwalletd.cpp
+++ b/kio/misc/kwalletd/kwalletd.cpp
@@ -355,6 +355,44 @@ int KWalletD::doTransactionOpen(const TQCString& appid, const TQString& wallet,
return rc;
}
+int KWalletD::tryOpen(const TQString& wallet, const TQCString& password)
+{
+ if (isOpen(wallet))
+ return 0;
+
+ if (_tryOpenBlocked.isActive()) {
+ kdDebug() << "tryOpen is active.." << endl;
+ return -1;
+ }
+
+ if (!KWallet::Backend::exists(wallet))
+ return -2;
+
+ KWallet::Backend *b = new KWallet::Backend(wallet, false /*isPath*/);
+ int rc = b->open(TQByteArray().duplicate(password, strlen(password)));
+ if (rc == 0) {
+ _wallets.insert(rc = generateHandle(), b);
+ _passwords[wallet] = password;
+ b->ref();
+ _tryOpenBlocked.stop();
+ TQByteArray data;
+ TQDataStream ds(data, IO_WriteOnly);
+ ds << wallet;
+ emitDCOPSignal("walletOpened(TQString)", data);
+ }
+ else {
+ delete b;
+ // make sure that we're not bombed with a dictionary attack
+ _tryOpenBlocked.start (30 * 1000, true /*single shot*/);
+ if (++_failed > 5) {
+ _failed = 0;
+ TQTimer::singleShot(0, this, TQT_SLOT(notifyFailures()));
+ }
+
+ rc = -1;
+ }
+ return rc;
+}
int KWalletD::internalOpen(const TQCString& appid, const TQString& wallet, bool isPath, WId w, bool modal) {
int rc = -1;
diff --git a/kio/misc/kwalletd/kwalletd.h b/kio/misc/kwalletd/kwalletd.h
index b426e7d5a..2aea371ba 100644
--- a/kio/misc/kwalletd/kwalletd.h
+++ b/kio/misc/kwalletd/kwalletd.h
@@ -26,6 +26,7 @@
#include <tqintdict.h>
#include <tqstring.h>
#include <tqwidget.h>
+#include <tqtimer.h>
#include <tqguardedptr.h>
#include "kwalletbackend.h"
@@ -51,8 +52,10 @@ class KWalletD : public KDEDModule {
// Open and unlock the wallet
virtual int open(const TQString& wallet, uint wId);
-
+ // Open and unlock the wallet
+ virtual int tryOpen(const TQString& wallet, const TQCString& passwd);
// Open and unlock the wallet with this path
+
virtual int openPath(const TQString& path, uint wId);
// Asynchronous open - must give the object to return the handle
@@ -186,6 +189,7 @@ class KWalletD : public KDEDModule {
int _idleTime;
TQMap<TQString,TQStringList> _implicitAllowMap, _implicitDenyMap;
KTimeout *_timeouts;
+ TQTimer _tryOpenBlocked;
TQPtrList<KWalletTransaction> _transactions;
TQGuardedPtr< TQWidget > activeDialog;