This forum has been archived. All content is frozen. Please use KDE Discuss instead.

how to implement kwallet into console application

Tags: None
(comma "," separated)
deadeyes
Registered Member
Posts
34
Karma
0
Hi all,

I am writing a console app in Qt for KDE. However I need credentials for a service. For this I want to use KWallet. While I can use the openWallet function if my class is derived from QDialog, I can't use it when I derive from QObject because I can't use the winId() function.

What would be the proper way of doing this?
Do I just have to derive from QDialog (QWidget) and don't use the show() function? Or is there another way to use Kwallets openWallet function with deriving from QObject instead?

Thanks in advance!
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
According to the API documentation of KWallet::Wallet, it should be possible to do this.
Please see http://api.kde.org/4.8-api/kdelibs-apid ... 7568854a28

In short, just pass 0 instead of a proper window ID.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
deadeyes
Registered Member
Posts
34
Karma
0
First of all thank you for helping me out!

I tried with a 0 and with a WId type of variable as well (as that is what winId() returns).

I uploaded a small part of the code that is relevant:

http://pastebin.com/sDyNStMU
http://pastebin.com/eTmsKpdx

I get the following while running make:
Code: Select all
CMakeFiles/connect-kwallet.dir/connect-kwallet.o: In function `ConnectKwallet':
/home/gvm/projects/connect-kwallet/connect-kwallet.cpp:10: undefined reference to `KWallet::Wallet::NetworkWallet()'
/home/gvm/projects/connect-kwallet/connect-kwallet.cpp:10: undefined reference to `KWallet::Wallet::openWallet(QString const&, unsigned long, KWallet::Wallet::OpenType)'
/home/gvm/projects/connect-kwallet/connect-kwallet.cpp:10: undefined reference to `KWallet::Wallet::NetworkWallet()'
/home/gvm/projects/connect-kwallet/connect-kwallet.cpp:10: undefined reference to `KWallet::Wallet::openWallet(QString const&, unsigned long, KWallet::Wallet::OpenType)'
collect2: ld returned 1 exit status
make[2]: *** [connect-kwallet] Error 1
make[1]: *** [CMakeFiles/connect-kwallet.dir/all] Error 2
make: *** [all] Error 2


So this might be a CMakeLists.txt file issue?
Code: Select all
project(connect-kwallet)
cmake_minimum_required(VERSION 2.6)
find_package(KDE4 REQUIRED)

include_directories(${KDE4_INCLUDES} ${KDE4_INCLUDE_DIR} ${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR})

set(connect-kwallet_SRCS connect-kwallet.cpp main.cpp)
qt4_automoc(${connect-kwallet_SRCS})
add_executable(connect-kwallet ${connect-kwallet_SRCS})
target_link_libraries(connect-kwallet ${QT_QTCORE_LIBRARY})


I really hope you can spot the issue!
deadeyes
Registered Member
Posts
34
Karma
0
Just for clarity adding another body...

I fixed it! I was just thinking about that it is a linker error so probably an issue with the librarie settings in the CMakeLists.txt
I compared with another KDE project and changed the last line:
Code: Select all
target_link_libraries(connect-kwallet ${QT_QTCORE_LIBRARY} ${KDE4_KDECORE_LIBS} ${KDE4_KPARTS_LIBS} ${KDE4_KDEUI_LIBS})

Probably I can make this shorter but it might give someone else a clue! :)

Thanks again!
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Looks like you might have an include problem. Do you have the KWallet libraries included into your source code file?


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
deadeyes
Registered Member
Posts
34
Karma
0
bcooksley wrote:Looks like you might have an include problem. Do you have the KWallet libraries included into your source code file?


Note that I marked the topic as solved;)
It was indeed a libraries include issue :)

Thanks anyway for checking out my thread!


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rockscient