summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFredrik Orderud <fredrik.orderud@ge.com>2018-09-25 10:38:47 +0200
committerFredrik Orderud <forderud@gmail.com>2018-09-26 11:54:28 +0000
commit60fbd8540c162447868fe03895bb8d45a1ea4a0b (patch)
treea5a0b99724fdf437d080a62f7415f1e6350fcbe0
parent6f056965f67f3d34271efe12b36e04faa9c550f4 (diff)
Extend QAxBase with classContext and setClassContext methods
Affects the "dwClsContext" argument when calling CoCreateInstance. This can be used to control in-proc vs. out-of-proc startup for controls supporting both alternatives. Also, it can be used to modify/reduce control permissions when used with CLSCTX_ENABLE_CLOAKING and an impersonation token. Task-number: QTBUG-70744 Change-Id: Ibc97648df3a79e1300aff6ff0aa73ddd4e469a7a Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--src/activeqt/container/qaxbase.cpp33
-rw-r--r--src/activeqt/container/qaxbase.h3
2 files changed, 35 insertions, 1 deletions
diff --git a/src/activeqt/container/qaxbase.cpp b/src/activeqt/container/qaxbase.cpp
index 722a389..6a55c6d 100644
--- a/src/activeqt/container/qaxbase.cpp
+++ b/src/activeqt/container/qaxbase.cpp
@@ -595,6 +595,7 @@ public:
QAxBasePrivate()
: useEventSink(true), useMetaObject(true), useClassInfo(true),
cachedMetaObject(false), initialized(false), tryCache(false),
+ classContext(CLSCTX_SERVER),
ptr(0), disp(0), metaobj(0)
{
// protect initialization
@@ -638,6 +639,7 @@ public:
uint cachedMetaObject :1;
uint initialized :1;
uint tryCache :1;
+ unsigned long classContext;
IUnknown *ptr;
mutable IDispatch *disp;
@@ -989,6 +991,8 @@ QAxMetaObject *QAxBase::internalMetaObject() const
The control's read function always returns the control's UUID, if provided including the license
key, and the name of the server, but not including the username, the domain or the password.
+
+ \sa setClassContext()
*/
bool QAxBase::setControl(const QString &c)
{
@@ -1067,6 +1071,33 @@ void QAxBase::disableEventSink()
}
/*!
+ \since 5.13
+
+ \return the context the ActiveX control will run in (default CLSCTX_SERVER).
+*/
+unsigned long QAxBase::classContext() const
+{
+ return d->classContext;
+}
+
+/*!
+ \since 5.13
+
+ Sets the context the ActiveX control will run in to \a classContext
+
+ Affects the "dwClsContext" argument when calling CoCreateInstance.
+ This can be used to control in-proc vs. out-of-proc startup for controls
+ supporting both alternatives. Also, it can be used to modify/reduce control
+ permissions when used with CLSCTX_ENABLE_CLOAKING and an impersonation token.
+
+ Note that this function should be called before setControl().
+*/
+void QAxBase::setClassContext(unsigned long classContext)
+{
+ d->classContext = classContext;
+}
+
+/*!
Disables the meta object generation for this ActiveX container.
This also disables the event sink and class info generation. If
you don't intend to use the Qt meta object implementation call
@@ -1237,7 +1268,7 @@ bool QAxBase::initialize(IUnknown **ptr)
res = initializeFromFile(ptr);
if (!res) { // standard
- HRESULT hres = CoCreateInstance(QUuid(ctrl), 0, CLSCTX_SERVER, IID_IUnknown,
+ HRESULT hres = CoCreateInstance(QUuid(ctrl), 0, d->classContext, IID_IUnknown,
reinterpret_cast<void **>(ptr));
res = S_OK == hres;
#ifndef QT_NO_DEBUG
diff --git a/src/activeqt/container/qaxbase.h b/src/activeqt/container/qaxbase.h
index 78203f7..740fd6d 100644
--- a/src/activeqt/container/qaxbase.h
+++ b/src/activeqt/container/qaxbase.h
@@ -136,6 +136,9 @@ public:
void disableClassInfo();
void disableEventSink();
+ unsigned long classContext() const;
+ void setClassContext(unsigned long classContext);
+
protected:
virtual bool initialize(IUnknown** ptr);
bool initializeRemote(IUnknown** ptr);