Browse Source

AppX message

(cherry picked from commit 6bd7a832986d81506fdaf3bd00894b55412eb5e5)

# Conflicts:
#	source/forms/ScpCommander.cpp
#	source/forms/ScpExplorer.cpp

Source commit: 44a5dae54100a54f8fe213a8e9521a24e44baaef
Martin Prikryl 7 years ago
parent
commit
4c7e8e4899

+ 19 - 0
source/core/Common.cpp

@@ -2702,6 +2702,25 @@ bool __fastcall IsWine()
     (GetProcAddress(NtDll, "wine_get_version") != NULL);
 }
 //---------------------------------------------------------------------------
+int GIsUWP = -1;
+//---------------------------------------------------------------------------
+bool __fastcall IsUWP()
+{
+  if (GIsUWP < 0)
+  {
+    HINSTANCE Kernel32 = GetModuleHandle(kernel32);
+    typedef LONG WINAPI (* GetPackageFamilyNameProc)(HANDLE hProcess, UINT32 *packageFamilyNameLength, PWSTR packageFamilyName);
+    GetPackageFamilyNameProc GetPackageFamilyName =
+      (GetPackageFamilyNameProc)GetProcAddress(Kernel32, "GetPackageFamilyName");
+    UINT32 Len = 0;
+    bool Result =
+      (GetPackageFamilyName != NULL) &&
+      (GetPackageFamilyName(GetCurrentProcess(), &Len, NULL) == ERROR_INSUFFICIENT_BUFFER);
+    GIsUWP = (Result ? 1 : 0);
+  }
+  return (GIsUWP > 0);
+}
+//---------------------------------------------------------------------------
 LCID __fastcall GetDefaultLCID()
 {
   return GetUserDefaultLCID();

+ 1 - 0
source/core/Common.h

@@ -127,6 +127,7 @@ bool __fastcall IsWin7();
 bool __fastcall IsWin8();
 bool __fastcall IsWin10();
 bool __fastcall IsWine();
+bool __fastcall IsUWP();
 TLibModule * __fastcall FindModule(void * Instance);
 __int64 __fastcall Round(double Number);
 bool __fastcall TryRelativeStrToDateTime(UnicodeString S, TDateTime & DateTime, bool Add);

+ 20 - 1
source/forms/CustomScpExplorer.cpp

@@ -4801,6 +4801,20 @@ bool __fastcall TCustomScpExplorerForm::GetComponentVisible(Byte Component)
   }
 }
 //---------------------------------------------------------------------------
+bool __fastcall TCustomScpExplorerForm::IsComponentPossible(Byte Component)
+{
+  bool Result;
+  if ((Component == fcExplorerUpdatesBand) || (Component == fcCommanderUpdatesBand))
+  {
+    Result = !IsUWP();
+  }
+  else
+  {
+    Result = true;
+  }
+  return Result;
+}
+//---------------------------------------------------------------------------
 void __fastcall TCustomScpExplorerForm::FixControlsPlacement()
 {
   if (RemoteDirView->ItemFocused != NULL)
@@ -7889,7 +7903,12 @@ void __fastcall TCustomScpExplorerForm::StartUpdates()
   else if ((double(Updates.Period) > 0) &&
            (Now() - Updates.LastCheck >= Updates.Period))
   {
-    StartUpdateThread(UpdatesChecked);
+    TThreadMethod OnUpdatesChecked = NULL;
+    if (!IsUWP())
+    {
+      OnUpdatesChecked = UpdatesChecked;
+    }
+    StartUpdateThread(OnUpdatesChecked);
   }
 }
 //---------------------------------------------------------------------------

+ 1 - 0
source/forms/CustomScpExplorer.h

@@ -706,6 +706,7 @@ public:
   bool __fastcall CanConsole();
   bool __fastcall CanChangePassword();
   void __fastcall ChangePassword();
+  bool __fastcall IsComponentPossible(Byte Component);
 
   __property bool ComponentVisible[Byte Component] = { read = GetComponentVisible, write = SetComponentVisible };
   __property bool EnableFocusedOperation[TOperationSide Side] = { read = GetEnableFocusedOperation, index = 0 };

+ 4 - 0
source/forms/Login.cpp

@@ -1219,6 +1219,10 @@ void __fastcall TLoginDialog::ActionListUpdate(TBasicAction * BasicAction,
   {
     Action->Checked = (FSiteSearch == ssSite);
   }
+  else if (Action == CheckForUpdatesAction)
+  {
+    Action->Visible = !IsUWP();
+  }
   Handled = true;
 
   // to update buttons visibility

+ 2 - 0
source/forms/NonVisual.cpp

@@ -42,6 +42,7 @@ TNonVisualDataModule *NonVisualDataModule;
 #define UPDACT(HandleAction, Command) \
   EXE(HandleAction, ((TCustomAction *)Action)->Enabled = true; Command)
 #define UPDCOMP(COMP) if (Action == COMP ## Action) { COMP ## Action->Enabled = true; \
+  COMP ## Action->Visible = ScpExplorer->IsComponentPossible(fc ## COMP); \
   COMP ## Action->Checked = ScpExplorer->ComponentVisible[fc ## COMP]; Handled = true; } else
 #define EXECOMP(COMP) EXE(COMP ## Action, \
   ScpExplorer->ComponentVisible[fc ## COMP] = !ScpExplorer->ComponentVisible[fc ## COMP] )
@@ -1614,6 +1615,7 @@ void __fastcall TNonVisualDataModule::ShowUpdatesUpdate()
         ((Updates.Results.Version > CurrentCompoundVer) ||
          !Updates.Results.Message.IsEmpty())))) ? 80 :
      ((int(Updates.Period) <= 0) ? 81 : 63));
+  CheckForUpdatesAction->Visible = !IsUWP();
 }
 //---------------------------------------------------------------------------
 void __fastcall TNonVisualDataModule::PreferencesDialog(TPreferencesMode APreferencesMode)

+ 5 - 3
source/forms/Preferences.cpp

@@ -93,7 +93,7 @@ __fastcall TPreferencesDialog::TPreferencesDialog(
   CustomCommandsView->WindowProc = CustomCommandsViewWindowProc;
 
   ComboAutoSwitchInitialize(UpdatesBetaVersionsCombo);
-  EnableControl(UpdatesBetaVersionsCombo, !WinConfiguration->IsBeta);
+  EnableControl(UpdatesBetaVersionsCombo, !WinConfiguration->IsBeta && !IsUWP());
   EnableControl(UpdatesBetaVersionsLabel, UpdatesBetaVersionsCombo->Enabled);
 
   HintLabel(LogFileNameHintText, LoadStr(LOG_FILE_HINT3));
@@ -1243,6 +1243,7 @@ void __fastcall TPreferencesDialog::UpdateControls()
     // updates
     EnableControl(UpdatesAuthenticationEmailEdit, FAutomaticUpdatesPossible);
     EnableControl(UpdatesAuthenticationEmailLabel, UpdatesAuthenticationEmailEdit->Enabled);
+    EnableControl(UpdatesShowOnStartup, !IsUWP());
     EnableControl(UsageViewButton, CollectUsageCheck->Checked);
     EnableControl(UpdatesProxyHostEdit, UpdatesProxyCheck->Checked);
     EnableControl(UpdatesProxyHostLabel, UpdatesProxyHostEdit->Enabled);
@@ -1270,7 +1271,7 @@ void __fastcall TPreferencesDialog::UpdateControls()
     EnableControl(TelnetForFtpInPuttyCheck,
       AnyPuttyPath && !IsSiteCommand);
     EnableControl(PuttyRegistryStorageKeyEdit,
-      AnyPuttyPath && !IsSiteCommand);
+      AnyPuttyPath && !IsSiteCommand && !IsUWP());
     EnableControl(PuttyRegistryStorageKeyLabel, PuttyRegistryStorageKeyEdit->Enabled);
 
     EnableControl(SetMasterPasswordButton, WinConfiguration->UseMasterPassword);
@@ -1286,8 +1287,9 @@ void __fastcall TPreferencesDialog::UpdateControls()
       AutoWorkspaceCombo->Enabled);
 
     // integration
+    EnableControl(ShellIconsGroup, !IsUWP());
     // There's no quick launch in Windows 7
-    EnableControl(QuickLaunchIconButton, !IsWin7());
+    EnableControl(QuickLaunchIconButton, ShellIconsGroup->Enabled && !IsWin7());
     MakeDefaultHandlerItem->Visible = IsWinVista();
 
     // languages

+ 4 - 0
source/forms/ScpCommander.cpp

@@ -158,6 +158,10 @@ void __fastcall TScpCommanderForm::RestoreParams()
   TCustomScpExplorerForm::RestoreParams();
   LeftPanelWidth = WinConfiguration->ScpCommander.LocalPanelWidth;
   LoadToolbarsLayoutStr(WinConfiguration->ScpCommander.ToolbarsLayout);
+  if (IsUWP())
+  {
+    UpdatesToolbar->Visible = false;
+  }
   SessionsPageControl->Visible = WinConfiguration->ScpCommander.SessionsTabs;
   StatusBar->Visible = WinConfiguration->ScpCommander.StatusBar;
 

+ 4 - 0
source/forms/ScpExplorer.cpp

@@ -96,6 +96,10 @@ void __fastcall TScpExplorerForm::RestoreParams()
   }
 
   LoadToolbarsLayoutStr(WinConfiguration->ScpExplorer.ToolbarsLayout);
+  if (IsUWP())
+  {
+    UpdatesToolbar->Visible = false;
+  }
   SessionsPageControl->Visible = WinConfiguration->ScpExplorer.SessionsTabs;
   RemoteStatusBar->Visible = WinConfiguration->ScpExplorer.StatusBar;
   RemoteDriveView->Visible = WinConfiguration->ScpExplorer.DriveView;

+ 76 - 55
source/windows/GUITools.cpp

@@ -93,75 +93,96 @@ void __fastcall OpenSessionInPutty(const UnicodeString PuttyPath,
 
     if (!RemoteCustomCommand.IsSiteCommand(AParams))
     {
-      UnicodeString SessionName;
-      TRegistryStorage * Storage = NULL;
-      TSessionData * ExportData = NULL;
-      TRegistryStorage * SourceStorage = NULL;
-      try
+      if (IsUWP())
       {
-        Storage = new TRegistryStorage(Configuration->PuttySessionsKey);
-        Storage->AccessMode = smReadWrite;
-        // make it compatible with putty
-        Storage->MungeStringValues = false;
-        Storage->ForceAnsi = true;
-        if (Storage->OpenRootKey(true))
+        if ((SessionData->FSProtocol == fsFTP) && GUIConfiguration->TelnetForFtpInPutty)
         {
-          if (Storage->KeyExists(SessionData->StorageKey))
-          {
-            SessionName = SessionData->SessionName;
-          }
-          else
+          AddToList(PuttyParams, L"-telnet", L" ");
+          // PuTTY  does not allow -pw for telnet
+          Password = L"";
+        }
+        AddToList(PuttyParams, EscapePuttyCommandParam(SessionData->HostName), L" ");
+        if (!SessionData->UserName.IsEmpty())
+        {
+          AddToList(PuttyParams, FORMAT(L"-l %s", (EscapePuttyCommandParam(SessionData->UserName))), L" ");
+        }
+        if ((SessionData->FSProtocol != fsFTP) && (SessionData->PortNumber != SshPortNumber))
+        {
+          AddToList(PuttyParams, FORMAT(L"-P %d", (SessionData->PortNumber)), L" ");
+        }
+      }
+      else
+      {
+        UnicodeString SessionName;
+        TRegistryStorage * Storage = NULL;
+        TSessionData * ExportData = NULL;
+        TRegistryStorage * SourceStorage = NULL;
+        try
+        {
+          Storage = new TRegistryStorage(Configuration->PuttySessionsKey);
+          Storage->AccessMode = smReadWrite;
+          // make it compatible with putty
+          Storage->MungeStringValues = false;
+          Storage->ForceAnsi = true;
+          if (Storage->OpenRootKey(true))
           {
-            SourceStorage = new TRegistryStorage(Configuration->PuttySessionsKey);
-            SourceStorage->MungeStringValues = false;
-            SourceStorage->ForceAnsi = true;
-            if (SourceStorage->OpenSubKey(StoredSessions->DefaultSettings->Name, false) &&
-                Storage->OpenSubKey(GUIConfiguration->PuttySession, true))
+            if (Storage->KeyExists(SessionData->StorageKey))
             {
-              Storage->Copy(SourceStorage);
-              Storage->CloseSubKey();
+              SessionName = SessionData->SessionName;
             }
-
-            ExportData = new TSessionData(L"");
-            ExportData->Assign(SessionData);
-            ExportData->Modified = true;
-            ExportData->Name = GUIConfiguration->PuttySession;
-            ExportData->WinTitle = SessionData->SessionName;
-            ExportData->Password = L"";
-
-            if (SessionData->FSProtocol == fsFTP)
+            else
             {
-              if (GUIConfiguration->TelnetForFtpInPutty)
+              SourceStorage = new TRegistryStorage(Configuration->PuttySessionsKey);
+              SourceStorage->MungeStringValues = false;
+              SourceStorage->ForceAnsi = true;
+              if (SourceStorage->OpenSubKey(StoredSessions->DefaultSettings->Name, false) &&
+                  Storage->OpenSubKey(GUIConfiguration->PuttySession, true))
               {
-                ExportData->PuttyProtocol = PuttyTelnetProtocol;
-                ExportData->PortNumber = TelnetPortNumber;
-                // PuTTY  does not allow -pw for telnet
-                Password = L"";
+                Storage->Copy(SourceStorage);
+                Storage->CloseSubKey();
               }
-              else
+
+              ExportData = new TSessionData(L"");
+              ExportData->Assign(SessionData);
+              ExportData->Modified = true;
+              ExportData->Name = GUIConfiguration->PuttySession;
+              ExportData->WinTitle = SessionData->SessionName;
+              ExportData->Password = L"";
+
+              if (SessionData->FSProtocol == fsFTP)
               {
-                ExportData->PuttyProtocol = PuttySshProtocol;
-                ExportData->PortNumber = SshPortNumber;
+                if (GUIConfiguration->TelnetForFtpInPutty)
+                {
+                  ExportData->PuttyProtocol = PuttyTelnetProtocol;
+                  ExportData->PortNumber = TelnetPortNumber;
+                  // PuTTY  does not allow -pw for telnet
+                  Password = L"";
+                }
+                else
+                {
+                  ExportData->PuttyProtocol = PuttySshProtocol;
+                  ExportData->PortNumber = SshPortNumber;
+                }
               }
-            }
 
-            ExportData->Save(Storage, true);
-            SessionName = GUIConfiguration->PuttySession;
+              ExportData->Save(Storage, true);
+              SessionName = GUIConfiguration->PuttySession;
+            }
           }
         }
-      }
-      __finally
-      {
-        delete Storage;
-        delete ExportData;
-        delete SourceStorage;
-      }
+        __finally
+        {
+          delete Storage;
+          delete ExportData;
+          delete SourceStorage;
+        }
 
-      UnicodeString LoadSwitch = L"-load";
-      int P = Params.LowerCase().Pos(LoadSwitch + L" ");
-      if ((P == 0) || ((P > 1) && (Params[P - 1] != L' ')))
-      {
-        AddToList(PuttyParams, FORMAT(L"%s %s", (LoadSwitch, EscapePuttyCommandParam(SessionName))), L" ");
+        UnicodeString LoadSwitch = L"-load";
+        int P = Params.LowerCase().Pos(LoadSwitch + L" ");
+        if ((P == 0) || ((P > 1) && (Params[P - 1] != L' ')))
+        {
+          AddToList(PuttyParams, FORMAT(L"%s %s", (LoadSwitch, EscapePuttyCommandParam(SessionName))), L" ");
+        }
       }
     }
 

+ 1 - 0
source/windows/WinMain.cpp

@@ -630,6 +630,7 @@ bool __fastcall ShowUpdatesIfAvailable()
   int CurrentCompoundVer = Configuration->CompoundVersion;
   bool NoPopup = true;
   bool Result =
+    !IsUWP() &&
     Updates.ShowOnStartup &&
     Updates.HaveValidResultsForVersion(CurrentCompoundVer) &&
     !Updates.Results.Disabled &&