winrtrunner: Display developer license dialog
authorAndrew Knight <andrew.knight@digia.com>
Thu, 6 Mar 2014 09:35:37 +0000 (11:35 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Thu, 6 Mar 2014 09:45:26 +0000 (10:45 +0100)
... when the license is expired. The installation can then continue.

Change-Id: I11bc13643406ad59611c53da22bdf32dfcd715e7
Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
src/winrtrunner/appxengine.cpp
src/winrtrunner/winrtrunner.pro

index d847017..678946a 100644 (file)
@@ -49,6 +49,7 @@
 #include <QtCore/QStandardPaths>
 
 #include <ShlObj.h>
+#include <wsdevlicensing.h>
 #include <AppxPackaging.h>
 #include <wrl.h>
 #include <windows.applicationmodel.h>
@@ -470,6 +471,17 @@ bool AppxEngine::install(bool removeFirst)
             qCWarning(lcWinRtRunner) << "Unable to register package:"
                                      << QString::fromWCharArray(WindowsGetStringRawBuffer(errorText, 0));
         }
+        if (HRESULT_CODE(errorCode) == ERROR_INSTALL_POLICY_FAILURE) {
+            // The user's license has expired. Give them the opportunity to renew it.
+            FILETIME expiration;
+            hr = AcquireDeveloperLicense(GetForegroundWindow(), &expiration);
+            if (FAILED(hr)) {
+                qCWarning(lcWinRtRunner) << "Unable to renew developer license:"
+                                         << qt_error_string(hr);
+            }
+            if (SUCCEEDED(hr))
+                return install(false);
+        }
         return false;
     }
 
index bda4d9d..a321d4a 100644 (file)
@@ -11,7 +11,7 @@ DEFINES += RTRUNNER_NO_APPX RTRUNNER_NO_XAP
 win32-msvc2012|win32-msvc2013 {
     SOURCES += appxengine.cpp
     HEADERS += appxengine.h
-    LIBS += -lruntimeobject
+    LIBS += -lruntimeobject -lwsclient
     DEFINES -= RTRUNNER_NO_APPX
 
     include(../shared/corecon/corecon.pri)