How a non-KDE application access Kwallet

Suryanarayanan Rajaram srajaram at novell.com
Mon Mar 28 10:51:35 BST 2005


Hi George, 
  
Thanks for the answer. 
I am pasting here the stack trace for the crash when KApplication is not
used. 
Also please find the snippet of my code sequence below.. 
So is there no way for me to access kwallet secrets without linking to
Qt..? 
  
Thanks, 
Rajaram. 
  
Crash trace : 
  
Program received signal SIGSEGV, Segmentation fault. 
[Switching to Thread 1088626368 (LWP 18829)] 
0x40a4b062 in KInstance::dirs () from /opt/kde3/lib/libkdecore.so.4 
(gdb) 
(gdb) where 
#0  0x40a4b062 in KInstance::dirs () from /opt/kde3/lib/libkdecore.so.4 
#1  0x40a4b0f2 in KGlobal::dirs () from /opt/kde3/lib/libkdecore.so.4 
#2  0x40a75fc4 in KConfigBackEnd::changeFileName () from
/opt/kde3/lib/libkdecore.so.4 
#3  0x40a76287 in KConfigBackEnd::KConfigBackEnd () from
/opt/kde3/lib/libkdecore.so.4 
#4  0x40a77f8b in KConfig::KConfig () from /opt/kde3/lib/libkdecore.so.4

#5  0x4003cc54 in KWallet::Wallet::NetworkWallet () from
/opt/kde3/lib/libkwalletclient.so.1 
#6  0x0804a099 in DCOPDemoWidget::setKWalletSecret (this=0x8050968) at
mytest.cpp:51 
#7  0x0804a2a5 in main (argc=1, argv=0xbfffe894) at mytest.cpp:169 
(gdb) quit 
  
  
Code snippet : 
  
void DCOPDemoWidget::setKWalletSecret() 
{ 
  
Wallet *s_wallet; 
................... 
................... 
s_wallet =
Wallet::openWallet(Wallet::NetworkWallet(),0,Wallet::Synchronous); 
connect(s_wallet, SIGNAL(walletClosed()),this, SLOT(dump())); 
kp = s_wallet->setFolder(Passwords); 
..................... 
} 
  
int main( int argc, char **argv ) 
{ 
                                                                        
                                                     
    KCmdLineArgs::init( argc, argv, dcopifacedemo, , ); 
                                          
// If I just remove this comment, it is working.                        
                                                            
//  KApplication app;           
    DCOPDemoWidget *win = new DCOPDemoWidget(); 
    win->setKWalletSecret(); 
} 
  


>>>staikos at kde.org 03/24/05 3:29 pm >>>
On Thursday 24 March 2005 06:17, Suryanarayanan Rajaram wrote:
>I am trying to write an application which reads and writes secrets in
>kwallet.
>
>From the details I got through the web , I understand that we can do
>this by either of the following ways.
>
>1. Talk to the client APIs provided by the Kwallet::Wallet class
>2. Use the DCOP interface provided by the kwallet service.

  Correct.  In fact, they are both the same thing too.  The KWallet
client
API uses DCOP.

>For using method 2, my application needs to register as DCOP client and
>communicate to the kwallet service via DCOP.
>I tried using seemingly easier method 1 . But I see that my application
>needs to be a KDE application to talk to Kwallet::Wallet APIs. i.e I
had
>to use QObject related stuff and KApplication in my code. Otherwise I
>get some segmentation fault while trying to open a wallet.
>
>I would like to know if there is any way to write a simple application
>which doesnt need KApplication or QObject related things ( non-KDE )
and
>still can access kwallets.
>It would be helpful if anybody could provide me the details for this
and
>any related links.

  The fact remains that KWallet needs DCOP for synchronization purposes.

DCOP should still work without a KApplication, but it definitely
requires
linking to Qt.  If you can handle that, we can work to find out what the
problems are with not having a KApplication.  I suspect it has to do
with the
KConfig usage, and we can probably find workarounds to that for you.

  Do you have a stack trace for the crashes when you link Qt but don't
use a
KApplication?

--
George Staikos
KDE Developerhttp://www.kde.org/
Staikos Computing Services Inc.http://www.staikos.net/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20050328/a73cb1f5/attachment.htm>


More information about the kde-core-devel mailing list