Qt 4.8
Public Functions | Public Variables | Protected Variables | List of all members
QClassFactory Class Reference
Inheritance diagram for QClassFactory:

Public Functions

unsigned long WINAPI AddRef ()
 
HRESULT WINAPI CreateInstance (IUnknown *pUnkOuter, REFIID iid, void **ppObject)
 
HRESULT WINAPI CreateInstanceHelper (IUnknown *pUnkOuter, REFIID iid, void **ppObject)
 
HRESULT WINAPI CreateInstanceLic (IUnknown *pUnkOuter, IUnknown *pUnkReserved, REFIID iid, BSTR bKey, PVOID *ppObject)
 
HRESULT WINAPI GetLicInfo (LICINFO *pLicInfo)
 
HRESULT WINAPI LockServer (BOOL fLock)
 
 QClassFactory (CLSID clsid)
 
HRESULT WINAPI QueryInterface (REFIID iid, LPVOID *iface)
 
unsigned long WINAPI Release ()
 
HRESULT WINAPI RequestLicKey (DWORD, BSTR *pKey)
 
 ~QClassFactory ()
 

Public Variables

QString className
 

Protected Variables

QString classKey
 
bool licensed
 
unsigned long ref
 
CRITICAL_SECTION refCountSection
 

Detailed Description

Definition at line 842 of file qaxserverbase.cpp.

Constructors and Destructors

◆ QClassFactory()

QClassFactory::QClassFactory ( CLSID  clsid)
inline

Definition at line 845 of file qaxserverbase.cpp.

846  : ref(0), licensed(false)
847  {
848  InitializeCriticalSection(&refCountSection);
849 
850  // COM only knows the CLSID, but QAxFactory is class name based...
852  for (QStringList::Iterator key = keys.begin(); key != keys.end(); ++key) {
853  if (qAxFactory()->classID(*key) == clsid) {
854  className = *key;
855  break;
856  }
857  }
858 
859  const QMetaObject *mo = qAxFactory()->metaObject(className);
860  if (mo) {
861  classKey = QLatin1String(mo->classInfo(mo->indexOfClassInfo("LicenseKey")).value());
863  }
864  }
QAxFactory * qAxFactory()
Definition: qaxserver.cpp:81
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
QMetaClassInfo classInfo(int index) const
Returns the meta-data for the item of class information with the given index.
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
virtual QStringList featureList() const =0
Reimplement this function to return a list of the widgets (class names) supported by this factory...
QStringList keys
iterator Iterator
Qt-style synonym for QList::iterator.
Definition: qlist.h:278
CRITICAL_SECTION refCountSection
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:270
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
unsigned long ref
int key
virtual const QMetaObject * metaObject(const QString &key) const =0
Reimplement this function to return the QMetaObject corresponding to key, or 0 if this factory doesn'...
int indexOfClassInfo(const char *name) const
Finds class information item name and returns its index; otherwise returns -1.
virtual QUuid classID(const QString &key) const
Reimplement this function to return the class identifier for each key returned by the featureList() i...
Definition: qaxfactory.cpp:191

◆ ~QClassFactory()

QClassFactory::~QClassFactory ( )
inline

Definition at line 866 of file qaxserverbase.cpp.

867  {
868  DeleteCriticalSection(&refCountSection);
869  }
CRITICAL_SECTION refCountSection

Functions

◆ AddRef()

unsigned long WINAPI QClassFactory::AddRef ( )
inline

Definition at line 872 of file qaxserverbase.cpp.

873  {
874  EnterCriticalSection(&refCountSection);
875  unsigned long r = ++ref;
876  LeaveCriticalSection(&refCountSection);
877  return ++r;
878  }
CRITICAL_SECTION refCountSection
unsigned long ref

◆ CreateInstance()

HRESULT WINAPI QClassFactory::CreateInstance ( IUnknown *  pUnkOuter,
REFIID  iid,
void **  ppObject 
)
inline

Definition at line 955 of file qaxserverbase.cpp.

956  {
957  // class is licensed
958  if (licensed && !qAxFactory()->validateLicenseKey(className, QString()))
959  return CLASS_E_NOTLICENSED;
960 
961  return CreateInstanceHelper(pUnkOuter, iid, ppObject);
962  }
QAxFactory * qAxFactory()
Definition: qaxserver.cpp:81
The QString class provides a Unicode character string.
Definition: qstring.h:83
HRESULT WINAPI CreateInstanceHelper(IUnknown *pUnkOuter, REFIID iid, void **ppObject)

◆ CreateInstanceHelper()

HRESULT WINAPI QClassFactory::CreateInstanceHelper ( IUnknown *  pUnkOuter,
REFIID  iid,
void **  ppObject 
)
inline

Definition at line 907 of file qaxserverbase.cpp.

908  {
909  if (pUnkOuter) {
910  if (iid != IID_IUnknown)
911  return CLASS_E_NOAGGREGATION;
912  const QMetaObject *mo = qAxFactory()->metaObject(className);
913  if (mo && !qstricmp(mo->classInfo(mo->indexOfClassInfo("Aggregatable")).value(), "no"))
914  return CLASS_E_NOAGGREGATION;
915  }
916 
917  // Make sure a QApplication instance is present (inprocess case)
918  if (!qApp) {
920  qax_ownQApp = true;
921  int argc = 0;
922  QApplication *app = new QApplication(argc, 0);
923  }
924  qApp->setQuitOnLastWindowClosed(false);
925 
926  if (qAxOutProcServer)
928  else
929  QApplication::instance()->d_func()->in_exec = true;
930 
931  // hook into eventloop; this allows a server to create his own QApplication object
932  if (!qax_hhook && qax_ownQApp) {
933  qax_hhook = SetWindowsHookEx(WH_GETMESSAGE, axs_FilterProc, 0, GetCurrentThreadId());
934  }
935 
936  HRESULT res;
937  // Create the ActiveX wrapper - aggregate if requested
938  if (pUnkOuter) {
939  QAxServerAggregate *aggregate = new QAxServerAggregate(className, pUnkOuter);
940  res = aggregate->QueryInterface(iid, ppObject);
941  if (FAILED(res))
942  delete aggregate;
943  } else {
944  QAxServerBase *activeqt = new QAxServerBase(className, pUnkOuter);
945  res = activeqt->QueryInterface(iid, ppObject);
946  if (FAILED(res))
947  delete activeqt;
948  else
949  activeqt->registerActiveObject((IUnknown*)(IDispatch*)activeqt);
950  }
951  return res;
952  }
QAxFactory * qAxFactory()
Definition: qaxserver.cpp:81
HRESULT WINAPI QueryInterface(REFIID iid, void **iface)
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
The QApplication class manages the GUI application's control flow and main settings.
Definition: qapplication.h:99
HHOOK qax_hhook
bool qax_winEventFilter(void *message)
static QAbstractEventDispatcher * instance(QThread *thread=0)
Returns a pointer to the event dispatcher object for the specified thread.
QMetaClassInfo classInfo(int index) const
Returns the meta-data for the item of class information with the given index.
HRESULT WINAPI QueryInterface(REFIID iid, void **iface)
void qWinMsgHandler(QtMsgType t, const char *str)
void registerActiveObject(IUnknown *object)
#define qApp
long HRESULT
LRESULT QT_WIN_CALLBACK axs_FilterProc(int nCode, WPARAM wParam, LPARAM lParam)
static QCoreApplication * instance()
Returns a pointer to the application's QCoreApplication (or QApplication) instance.
QtMsgHandler qInstallMsgHandler(QtMsgHandler h)
Definition: qglobal.cpp:2698
EventFilter setEventFilter(EventFilter filter)
Replaces the event filter function for this QAbstractEventDispatcher with filter and returns the repl...
bool qAxOutProcServer
Definition: qaxserver.cpp:68
bool qax_ownQApp
virtual const QMetaObject * metaObject(const QString &key) const =0
Reimplement this function to return the QMetaObject corresponding to key, or 0 if this factory doesn'...
Q_CORE_EXPORT int qstricmp(const char *, const char *)
int indexOfClassInfo(const char *name) const
Finds class information item name and returns its index; otherwise returns -1.

◆ CreateInstanceLic()

HRESULT WINAPI QClassFactory::CreateInstanceLic ( IUnknown *  pUnkOuter,
IUnknown *  pUnkReserved,
REFIID  iid,
BSTR  bKey,
PVOID *  ppObject 
)
inline

Definition at line 1005 of file qaxserverbase.cpp.

1006  {
1007  QString licenseKey = QString::fromWCharArray(bKey);
1008  if (!qAxFactory()->validateLicenseKey(className, licenseKey))
1009  return CLASS_E_NOTLICENSED;
1010  return CreateInstanceHelper(pUnkOuter, iid, ppObject);
1011  }
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
Definition: qstring.cpp:1019
QAxFactory * qAxFactory()
Definition: qaxserver.cpp:81
The QString class provides a Unicode character string.
Definition: qstring.h:83
HRESULT WINAPI CreateInstanceHelper(IUnknown *pUnkOuter, REFIID iid, void **ppObject)

◆ GetLicInfo()

HRESULT WINAPI QClassFactory::GetLicInfo ( LICINFO *  pLicInfo)
inline

Definition at line 988 of file qaxserverbase.cpp.

989  {
990  if (!pLicInfo)
991  return E_POINTER;
992  pLicInfo->cbLicInfo = sizeof(LICINFO);
993 
994  // class specific license key?
995  const QMetaObject *mo = qAxFactory()->metaObject(className);
996  const char *key = mo->classInfo(mo->indexOfClassInfo("LicenseKey")).value();
997  pLicInfo->fRuntimeKeyAvail = key && key[0];
998 
999  // machine fully licensed?
1000  pLicInfo->fLicVerified = qAxFactory()->validateLicenseKey(className, QString());
1001 
1002  return S_OK;
1003  }
QAxFactory * qAxFactory()
Definition: qaxserver.cpp:81
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
QMetaClassInfo classInfo(int index) const
Returns the meta-data for the item of class information with the given index.
The QString class provides a Unicode character string.
Definition: qstring.h:83
virtual bool validateLicenseKey(const QString &key, const QString &licenseKey) const
Reimplement this function to return true if licenseKey is a valid license for the class key...
Definition: qaxfactory.cpp:282
int key
virtual const QMetaObject * metaObject(const QString &key) const =0
Reimplement this function to return the QMetaObject corresponding to key, or 0 if this factory doesn'...
int indexOfClassInfo(const char *name) const
Finds class information item name and returns its index; otherwise returns -1.

◆ LockServer()

HRESULT WINAPI QClassFactory::LockServer ( BOOL  fLock)
inline

Definition at line 963 of file qaxserverbase.cpp.

964  {
965  if (fLock)
966  qAxLock();
967  else
968  qAxUnlock();
969 
970  return S_OK;
971  }
unsigned long qAxUnlock()
Definition: qaxserver.cpp:166
unsigned long qAxLock()
Definition: qaxserver.cpp:158

◆ QueryInterface()

HRESULT WINAPI QClassFactory::QueryInterface ( REFIID  iid,
LPVOID *  iface 
)
inline

Definition at line 891 of file qaxserverbase.cpp.

Referenced by GetClassObject().

892  {
893  *iface = 0;
894  if (iid == IID_IUnknown)
895  *iface = (IUnknown*)this;
896  else if (iid == IID_IClassFactory)
897  *iface = (IClassFactory*)this;
898  else if (iid == IID_IClassFactory2 && licensed)
899  *iface = (IClassFactory2*)this;
900  else
901  return E_NOINTERFACE;
902 
903  AddRef();
904  return S_OK;
905  }
unsigned long WINAPI AddRef()

◆ Release()

unsigned long WINAPI QClassFactory::Release ( )
inline

Definition at line 879 of file qaxserverbase.cpp.

880  {
881  EnterCriticalSection(&refCountSection);
882  unsigned long r = --ref;
883  LeaveCriticalSection(&refCountSection);
884 
885  if (!r) {
886  delete this;
887  return 0;
888  }
889  return r;
890  }
CRITICAL_SECTION refCountSection
unsigned long ref

◆ RequestLicKey()

HRESULT WINAPI QClassFactory::RequestLicKey ( DWORD  ,
BSTR *  pKey 
)
inline

Definition at line 974 of file qaxserverbase.cpp.

975  {
976  if (!pKey)
977  return E_POINTER;
978  *pKey = 0;
979 
980  // This of course works only on fully licensed machines
981  if (!qAxFactory()->validateLicenseKey(className, QString()))
982  return CLASS_E_NOTLICENSED;
983 
984  *pKey = QStringToBSTR(classKey);
985  return S_OK;
986  }
QAxFactory * qAxFactory()
Definition: qaxserver.cpp:81
The QString class provides a Unicode character string.
Definition: qstring.h:83
static BSTR QStringToBSTR(const QString &str)
Definition: qaxtypes.h:76

Properties

◆ classKey

QString QClassFactory::classKey
protected

Definition at line 1019 of file qaxserverbase.cpp.

◆ className

QString QClassFactory::className

Definition at line 1013 of file qaxserverbase.cpp.

Referenced by GetClassObject().

◆ licensed

bool QClassFactory::licensed
protected

Definition at line 1018 of file qaxserverbase.cpp.

◆ ref

unsigned long QClassFactory::ref
protected

Definition at line 1017 of file qaxserverbase.cpp.

◆ refCountSection

CRITICAL_SECTION QClassFactory::refCountSection
protected

Definition at line 1016 of file qaxserverbase.cpp.


The documentation for this class was generated from the following file: