[KDE/Mac] Review Request 120202: [OS X] improvements to the kwallet/OSX keychain integration
Ian Wadham
iandw.au at gmail.com
Wed Sep 24 02:36:40 UTC 2014
> On Sept. 18, 2014, 10:28 p.m., Albert Astals Cid wrote:
> > kdeui/util/kwallet.h, line 545
> > <https://git.reviewboard.kde.org/r/120202/diff/1/?file=312224#file312224line545>
> >
> > This is bad, slots in an ifdef are a bad idea.
> >
> > Is there any reason this slot has to be in KWallet and not some other object?
>
> René J.V. Bertin wrote:
> May I ask why slots in an #ifdef are a bad idea, worse than any other kind of code? I can see why platform-specific class members are not very elegant, but not why that would be different for slots.
>
> The slot has to have access to the Wallet instance, but it should be possible to move it into the KWalletPrivate class since I already added a pointer to the instance to that class. Would that be better?
>
> Albert Astals Cid wrote:
> An ifdef in a public class is horrible.
>
> As a user of the KWallet class when i should connect to it? Never? Then don't show me to me it exists.
>
> Thomas Lübking wrote:
> moc does not handle preprocessor statements.
> You'll likely get some error if the condition does not match because moc adds the slot unconditionally, but the function isn't available.
>
> That aside, #ifdef'ing functions in a public header (ie. exported API) is a bad idea in general, because it causes different ABI (not that much a problem of an architecure split) and usually confusion.
>
> -> preattyplease #ifdef the implementation instead.
>
> ```cpp
> void Foo::bar()
> {
> #if WANT_THIS
> fooBarFoo();
> #endif
> }
> ```
>
> @Albert
> tbf, there're quite some present slots tagged "internal" in that class and since they're all private slots, they're not available to user code anyway. The general approach is ok, because they don't affect the vtable.
>
> René J.V. Bertin wrote:
> Understood (and agreed). Not why moc doesn't take ifdefs into account, but that may be a design choice, and isn't relevant here.
>
> Albert Astals Cid wrote:
> @Thomas, i think last i checked you can still to connect to private slots, the only thing is that you can't call them directly, but the metaobject doesn't know about "private".
>
> Thomas Lübking wrote:
> Indeed (jaws wide open) - so moc doesn't even care about that attribute.
>
> Good to know, I foresee abuse >-)
>
> René J.V. Bertin wrote:
> OK, implementation question.
>
> How do I declare a slot in a private class that doesn't have a specific header file?
> Putting `private QSLOT` above the function definition makes things compile, but the runtime complains about a missing slot (curiously even expecting it in KWallet::Wallet). Yes, I did update the connect call to pass in the pointer to the parent class ....
>
> Albert Astals Cid wrote:
> Does the object you're adding the slot have a Q_OBJECT?
>
> René J.V. Bertin wrote:
> No, the WalletPrivate class didn't need one until now. I think I figured something out (see the updated diff I'll be uploading). I'm not perfectly happy with making `QOSXKeychain` inherit `QObject` and putting the slot declaration in that class (as a virtual), but the alternative would apparently have been to use multiple inheritance in WalletPrivate. I generally prefer to avoid multiple inheritance, and I'm also not sure to what extent moc would have been able to pick up the necessary bits when hidden in class that only exists in a cpp file .
Re this issue, I just found a problem building KWalletD from KDE 4 kde-runtime master. About a year and 2 weeks ago, Valentin Rusu, added a slot called connectToScreenSaver() to kwalletd.h and kwalletd.cpp, with an #ifdef Q_WS_X11 conditional wrapping the code in both files. This is now failing to build on my machine, using Clang:
In file included from /kdedev/kde4m/kdesrc/kde/kde-runtime/kwalletd/kwalletd.cpp:1670:
/kdedev/kde4m/kdesrc/build/kde/kde-runtime/kwalletd/kwalletd.moc:267:22: error:
no member named 'connectToScreenSaver' in 'KWalletD'
case 60: _t->connectToScreenSaver(); break;
~~ ^
In file included from /kdedev/kde4m/kdesrc/kde/kde-runtime/kwalletd/kwalletd.cpp:25:
/kdedev/kde4m/kdesrc/kde/kde-runtime/kwalletd/kwalletd.h:247:14: warning: private
field '_useGpg' is not used [-Wunused-private-field]
bool _useGpg;
^
1 warning and 1 error generated.
Any ideas on the "error"? Also the "warning" occurs on KDE 4.14, but not KDE 4.13.
The same "error" arose in my KDE 4.13 build setup after I "touched" kwalletd.h and kwalletd.cpp, but those files have always built OK previously. It is probably at least 2 months since I last compiled KWalletD on my KDE 4.13, so perhaps I now have a pickier compiler (installed by MacPorts) or maybe Automoc and MOC are doing something different.
- Ian
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/120202/#review66894
-----------------------------------------------------------
On Sept. 21, 2014, 4:40 p.m., René J.V. Bertin wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/120202/
> -----------------------------------------------------------
>
> (Updated Sept. 21, 2014, 4:40 p.m.)
>
>
> Review request for KDE Software on Mac OS X and kdelibs.
>
>
> Repository: kdelibs
>
>
> Description
> -------
>
> I'm still working on (the KDE4-based version of) my OS X keychain backend for kwallet. I'm at a point where I think I can present a work-in-progress in an RR because at least one feature has been improved enough to be of interest for everyone, and also because I could use feedback on how to proceed.
> I'm currently focussing on 2 settings that are configured in the kwallet KCM (SystemSettings), and for which I'm working on an implementation not requiring kwalletd and/or DBus.
>
> - idle time closing of wallets. This feature was not supported in the commited version presented in https://git.reviewboard.kde.org/r/119838/ The present patch adds an idleTimer and a shared lastAccessTime member. The idleTimer is reset each time a client performs one of a series of actions that I count as wallet accesses, and before resetting I update the idle timeout value from KConfig. When the timer fires, the elapsed time is compared to the shared last access time, and if it is >= the timeout, the wallet is closed. This applies only to "KDE keychains", so keychains used by OS X applications should not be affected.
>
> - "close when last application exits". This requires maintaining a "user list" which keeps track of what application has what wallet open. I've implemented an "internal" version of such a registry, mapping wallet name to application names and the list of wallets they have open (a list of wallet reference, pid per application name). The registry is functional, but I have not yet decided (read: figured out) how to make a distributed representation of it.
>
> So the work-in-progress concerns the distributed user registry. The idea would be to maintain the registry in shared memory, meaning it'd be reset (= disappear) when the last application exits, contrary to a file which can go stale. This would be simple if QSharedMemory objects could be resized, but apparently they cannot, so I'll have to look at other solutions possibly involving OS X frameworks (NSData and it's non-objectiveC version CFDataRef or CFMutableDataRef might be candidates). Suggestions welcome.
>
> Other work in progress concerns a less wheel-reinventing approach that builds on kwalletd and DBus. I don't see why the code used in `kwallet.cpp` wouldn't work, but I must still misunderstand its finer details. The present patch contains outcommented code that does indeed cause kwalletd to be launched and slots and signals to become visible e.g. in `qdbusviewer`. But they don't work, which in turn makes the whole kwallet layer dysfunctional. Here too feedback is welcome on how what I'm missing and/or how to get this to work.
> Once kwalletd works, wallet idle timeout closing and closing when the last client exits should work out-of-the-box, or at least I suppose.
>
>
> Diffs
> -----
>
> kdeui/util/kwallet.h d7f703f
> kdeui/util/kwallet_mac.cpp 8344ebb
> kdeui/util/qosxkeychain.h d0934e6
> kdeui/util/qosxkeychain.cpp 7cb9a22
>
> Diff: https://git.reviewboard.kde.org/r/120202/diff/
>
>
> Testing
> -------
>
> OS X 10.6.8, kdelibs 4.14.1 git/master, KDE/MacPorts 4.12.5 .
> Once finalised, all changes should port easily to KF5's kwallet_mac.cpp .
>
>
> Thanks,
>
> René J.V. Bertin
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-mac/attachments/20140924/4b870568/attachment-0001.html>
More information about the kde-mac
mailing list