On Saturday 13 July 2013 11:54:26 Kevin Krammer wrote: > On Friday, 2013-07-12, Pali Rohár wrote: > > On Friday 12 July 2013 19:38:50 Thomas Lübking wrote: > > > Yes, and the kwallet dialog is gonna be removed (by > > > default) as it implies security that is absolutely not > > > present. So it's not really important to have a very > > > special "Application Name" here - you can just pass > > > "Trojita", as long as you keep it, there should be no > > > problem. > > > > Problem is that I do not know how to pass "Trojita" string > > to kwallet open wallet confirm dialog :-( > > > > Kevin, can you help me? How to tell kwallet that application > > "Trojita" wants to open wallet and not "unknown" > > application? > > > > I did not find nothing in api on: > > http://api.kde.org/4.10-api/kdelibs-apidocs/kdeui/html/class > > KWallet_1_1Wall et.html > > I'll have to check the code but my guess is that it gets the > name from KComponentData which every KDE application or part > has in some way or the other. > > Cheers, > Kevin
Finally I found it.
KWallet code which determinate application name is in file
kdeui/util/kwallet.cpp function static QString appid():
static QString appid()
{
if (KGlobal::hasMainComponent()) {
KComponentData cData = KGlobal::mainComponent();
if (cData.isValid()) {
const KAboutData* aboutData = cData.aboutData();
if (aboutData) {
return aboutData->programName();
}
return cData.componentName();
}
}
return qApp->applicationName();
}
In our case (in Trojita), we have KGlobal::hasMainComponent(),
cData.isValid() and aboutData. So KWallet will use application
name from string aboutData->programName(). And this string is
empty, so it default to some KDE name.
And because we cannot replace internal static kwallet function
and also it is not possible to replace KGlobal::mainComponent()
once it is inilialized, the only way is to force aboutData object
to change current name from empty string.
So the only solution to remove "const" is const_cast operator...
Here is commit which doing it (look at NOTE):
http://quickgit.kde.org/?p=clones/trojita/pali/trojita.git&a=commitdiff&h=e037720ed983ac6cbfc84cca39f1915d542d613b&hp=880c6aea46dea54a9f4e662c0c5baf206ac8f288
What other developers think? Will you accept above const_cast
hack or not? I tested that code and working fine. KWallet show
name Trojita in all widgets. Without that patch KWallet will show
empty KDE name.
--
Pali Rohár
[email protected]
signature.asc
Description: This is a digitally signed message part.
