Exemplo n.º 1
0
//---------------------------------------------------------------------------
void __fastcall TSynchronizeController::SynchronizeFilter(TObject * /*Sender*/,
  const UnicodeString DirectoryName, bool & Add)
{
  if ((FOptions != NULL) && (FOptions->Filter != NULL))
  {
    if (IncludeTrailingBackslash(ExtractFilePath(DirectoryName)) ==
          IncludeTrailingBackslash(FSynchronizeParams.LocalDirectory))
    {
      int FoundIndex;
      Add = FOptions->Filter->Find(ExtractFileName(DirectoryName), FoundIndex);
    }
  }
  TFileMasks::TParams MaskParams; // size/time does not matter for directories
  Add = Add && FCopyParam.AllowTransfer(DirectoryName, osLocal, true, MaskParams);
}
Exemplo n.º 2
0
//---------------------------------------------------------------------------
__fastcall TConfiguration::TConfiguration()
{
  FCriticalSection = new TCriticalSection();
  FUpdating = 0;
  FStorage = stDetect;
  FDontSave = false;
  FApplicationInfo = NULL;
  FUsage = new TUsage(this);
  FDefaultCollectUsage = false;

  wchar_t Buf[10];
  UnicodeString RandomSeedPath;
  if (GetEnvironmentVariable(L"APPDATA", Buf, LENOF(Buf)) > 0)
  {
    RandomSeedPath = L"%APPDATA%";
  }
  else
  {
    RandomSeedPath = GetShellFolderPath(CSIDL_LOCAL_APPDATA);
    if (RandomSeedPath.IsEmpty())
    {
      RandomSeedPath = GetShellFolderPath(CSIDL_APPDATA);
    }
  }

  FDefaultRandomSeedFile = IncludeTrailingBackslash(RandomSeedPath) + L"winscp.rnd";
}
TRegistryStorage::TRegistryStorage(const UnicodeString & AStorage, HKEY ARootKey) :
  THierarchicalStorage(IncludeTrailingBackslash(AStorage)),
  FRegistry(nullptr),
  FFailed(0)
{
  Init();
  FRegistry->SetRootKey(ARootKey);
}
Exemplo n.º 4
0
//---------------------------------------------------------------------------
TConfiguration::TConfiguration() :
  FCriticalSection(nullptr),
  FDontSave(false),
  FChanged(false),
  FUpdating(0),
  FApplicationInfo(nullptr),
  FLogging(false),
  FPermanentLogging(false),
  FLogWindowLines(0),
  FLogFileAppend(false),
  FLogProtocol(0),
  FActualLogProtocol(0),
  FLogActions(false),
  FPermanentLogActions(false),
  FConfirmOverwriting(false),
  FConfirmResume(false),
  FAutoReadDirectoryAfterOp(false),
  FSessionReopenAuto(0),
  FSessionReopenBackground(0),
  FSessionReopenTimeout(0),
  FSessionReopenAutoStall(0),
  FProgramIniPathWrittable(0),
  FTunnelLocalPortNumberLow(0),
  FTunnelLocalPortNumberHigh(0),
  FCacheDirectoryChangesMaxSize(0),
  FShowFtpWelcomeMessage(false),
  FTryFtpWhenSshFails(false),
  FDisablePasswordStoring(false),
  FForceBanners(false),
  FDisableAcceptingHostKeys(false),
  FDefaultCollectUsage(false),
  FSessionReopenAutoMaximumNumberOfRetries(0)
{
  FCriticalSection = new TCriticalSection();
  FUpdating = 0;
  FStorage = stRegistry;
  FDontSave = false;
  FApplicationInfo = nullptr;
  // FUsage = new TUsage(this);
  // FDefaultCollectUsage = false;

  wchar_t Buf[10];
  UnicodeString RandomSeedPath;
  if (GetEnvironmentVariable(L"APPDATA", Buf, LENOF(Buf)) > 0)
  {
    RandomSeedPath = L"%APPDATA%";
  }
  else
  {
    RandomSeedPath = GetShellFolderPath(CSIDL_LOCAL_APPDATA);
    if (RandomSeedPath.IsEmpty())
    {
      RandomSeedPath = GetShellFolderPath(CSIDL_APPDATA);
    }
  }

  FDefaultRandomSeedFile = IncludeTrailingBackslash(RandomSeedPath) + L"winscp.rnd";
}
Exemplo n.º 5
0
//---------------------------------------------------------------------------
void __fastcall TCopyDialog::SetDirectory(UnicodeString value)
{
  if (!value.IsEmpty())
  {
    value = RemotePaths() ?
      UnicodeString(UnixIncludeTrailingBackslash(value)) : IncludeTrailingBackslash(value);
  }
  DirectoryEdit->Text = value + GetFileMask();
}
//---------------------------------------------------------------------------
// Operaciones previas y llamada a la función de descarga
//---------------------------------------------------------------------------
void __fastcall TMainForm::b_descargarClick(TObject *Sender)
{
    DWORD       bytes;
    AnsiString  url("http://" + cb_url->Text);
    AnsiString  destino(IncludeTrailingBackslash(m_opciones.m_destino));

    // buscar la extensión. La función ExtractFileExt también nos sirve para Urls, porque
    // lo único que hace el buscar el punto comenzando por el final.
    destino += "datos" + ExtractFileExt(cb_url->Text);

    Screen->Cursor = crHourGlass;

    e_localizacion->Text = "Descargando...";
    e_asociado->Text     = e_localizacion->Text;
    b_abrir->Enabled     = false;
    ts_archivo->Repaint();

    __try
    {
        lb_log->Items->Clear();
        lb_log->Repaint();

        bytes = Descargar(url.c_str(), destino.c_str(), &m_opciones, &DescargaCallback);
    }
    __finally
    {
        Screen->Cursor = crDefault;

        if ( DWORD(-1) == bytes )
        {
            e_localizacion->Text = "";
            e_asociado->Text     = "";

            lb_log->ItemIndex = MainForm->lb_log->Items->Add("Se ha producido un error descargando el recurso.");
        }
        else
        {
            char buff[256];

            FindExecutable(destino.c_str(), NULL, buff);
            e_localizacion->Text = destino;
            e_asociado->Text     = buff;
            b_abrir->Enabled     = true;
            m_vista->Lines->Clear();

            lb_log->ItemIndex = MainForm->lb_log->Items->Add("El recurso ha sido descargado en " +
                    destino + ". Tamaño total: " + IntToStr(bytes) + " bytes.");
        }
    }
}
Exemplo n.º 7
0
//---------------------------------------------------------------------------
extern "C" int _export PASCAL UIShowFolderSelectorForm(void *reserved, char *buf)
{
	TFolderSelectorForm *form = new TFolderSelectorForm(Application);
	form->ShellTreeView->Path = buf; // initial directory
	if(form->ShellTreeView->Selected)
	{
		form->ShellTreeView->Selected->Expanded = true;
		TTreeNode * topnode = form->ShellTreeView->Selected;
		if(topnode->Count >= 1)
		{
			TTreeNode * longestitem = NULL;
			int longesttextsize = -1;
			for(int i = 0; i < topnode->Count; i++)
			{
				TTreeNode *subnode = topnode->Item[i];
				TRect rect = subnode->DisplayRect(true);
				if(rect.right > longesttextsize)
				{
					longesttextsize = rect.right;
					longestitem = topnode->Item[i];
				}
			}
			if(longestitem)
				longestitem->MakeVisible();

//		form->ShellTreeView->Selected->MakeVisible();
// 		INT min, max;
//		::GetScrollRange(form->ShellTreeView->Handle, SB_HORZ, &min, &max);
//		::SetScrollPos(form->ShellTreeView->Handle, SB_HORZ, max, true);
//		form->ShellTreeView->Selected->MakeVisible();
//		TreeView_EnsureVisible(form->ShellTreeView->Selected->Handle,
//			form->ShellTreeView->Selected->ItemId);
		}
		form->ShellTreeView->TopItem = topnode;
		topnode->MakeVisible();
	}

	int res = form->ShowModal();
	if(res == mrOk)
	{
		if(DirectoryExists(form->Selected))
		{
			form->Selected = IncludeTrailingBackslash(form->Selected);
		}
		strcpy(buf, form->Selected.c_str());
	}
	delete form;
	return res;
}
Exemplo n.º 8
0
void __fastcall TMainFrm::FormCreate(TObject *Sender)
{
IndyVersionLabel->Caption=POP->Version;
  ReadConfiguration();
   //setup path to put attachments into
   FAttachPath = IncludeTrailingBackslash(ExtractFileDir(ParamStr(0))); //starting directory
   FAttachPath = FAttachPath + "Attach\\";
   if (!DirectoryExists(FAttachPath))
     ForceDirectories(FAttachPath);

   FMsgCount = 0;
   FMailBoxSize = 0;
   ShowBusy(false);

}
Exemplo n.º 9
0
//---------------------------------------------------------------------------
void __fastcall TSynchronizeChecklistDialog::CustomCommandsButtonClick(
  TObject * /*Sender*/)
{
  TStrings * LocalFileList = new TStringList();
  TStrings * RemoteFileList = new TStringList();
  try
  {
    TListItem * Item = ListView->Selected;
    assert(Item != NULL);

    while (Item != NULL)
    {
      const TSynchronizeChecklist::TItem * ChecklistItem =
        static_cast<const TSynchronizeChecklist::TItem *>(Item->Data);

      assert((ChecklistItem->Action == TSynchronizeChecklist::saUploadUpdate) ||
             (ChecklistItem->Action == TSynchronizeChecklist::saDownloadUpdate));
      assert(ChecklistItem->RemoteFile != NULL);

      UnicodeString LocalPath =
        IncludeTrailingBackslash(ChecklistItem->Local.Directory) +
        ChecklistItem->Local.FileName;

      LocalFileList->Add(LocalPath);

      UnicodeString RemotePath =
        UnixIncludeTrailingBackslash(ChecklistItem->Remote.Directory) +
        ChecklistItem->Remote.FileName;

      RemoteFileList->AddObject(RemotePath, ChecklistItem->RemoteFile);

      Item = ListView->GetNextItem(Item, sdAll, TItemStates() << isSelected);
    }
  }
  catch(...)
  {
    delete LocalFileList;
    delete RemoteFileList;
    throw;
  }

  assert(FOnCustomCommandMenu != NULL);
  FOnCustomCommandMenu(CustomCommandsButton,
    CalculatePopupRect(CustomCommandsButton), LocalFileList, RemoteFileList);
}
Exemplo n.º 10
0
	// 指定フォルダにある指定拡張子のプラグインから設定情報を読み込む
	void LoadPluginOptionDesc( tTVPCommandOptionList* coreopt, const std::wstring& path, const std::wstring& ext ) {
		std::wstring exename = ExePath();
		exename = IncludeTrailingBackslash(ExtractFileDir(exename));
		std::wstring filepath = exename + path;
		std::wstring mask = filepath + L"*." + ext;

		WIN32_FIND_DATA fd;
		HANDLE hSearch = ::FindFirstFile( mask.c_str(), &fd );
		if( hSearch != INVALID_HANDLE_VALUE ) {
			do {
				tTVPCommandOptionList* options = TVPGetPluginCommandDesc( (filepath + std::wstring(fd.cFileName) ).c_str() );
				if( options ) {
					TVPMargeCommandDesc( *coreopt, *options );
					delete options;
				}
			} while( FindNextFile( hSearch, &fd ) );
			::FindClose( hSearch );
		}
	}
Exemplo n.º 11
0
//---------------------------------------------------------------------
TStoredSessionList * __fastcall TGUIConfiguration::SelectFilezillaSessionsForImport(
  TStoredSessionList * Sessions)
{
  std::auto_ptr<TStoredSessionList> ImportSessionList(new TStoredSessionList(true));
  ImportSessionList->DefaultSettings = Sessions->DefaultSettings;

  UnicodeString AppDataPath = GetShellFolderPath(CSIDL_APPDATA);
  UnicodeString FilezillaSiteManagerFile =
    IncludeTrailingBackslash(AppDataPath) + L"FileZilla\\sitemanager.xml";

  if (FileExists(FilezillaSiteManagerFile))
  {
    ImportSessionList->ImportFromFilezilla(FilezillaSiteManagerFile);

    ImportSessionList->SelectSessionsToImport(Sessions, true);
  }

  return ImportSessionList.release();
}
Exemplo n.º 12
0
//---------------------------------------------------------------------------
void __fastcall TGUIConfiguration::Default()
{
  TConfiguration::Default();

  // reset before call to DefaultLocalized()
  FDefaultCopyParam.Default();

  FCopyParamListDefaults = true;
  DefaultLocalized();

  FIgnoreCancelBeforeFinish = TDateTime(0, 0, 3, 0);
  FContinueOnError = false;
  FConfirmCommandSession = true;
  FSynchronizeParams = TTerminal::spNoConfirmation | TTerminal::spPreviewChanges;
  FSynchronizeModeAuto = -1;
  FSynchronizeMode = TTerminal::smRemote;
  FMaxWatchDirectories = 500;
  FSynchronizeOptions = soRecurse | soSynchronizeAsk;
  FQueueTransfersLimit = 2;
  FQueueKeepDoneItems = true;
  FQueueKeepDoneItemsFor = 15;
  FQueueAutoPopup = true;
  FSessionRememberPassword = false;
  UnicodeString ProgramsFolder;
  SpecialFolderLocation(CSIDL_PROGRAM_FILES, ProgramsFolder);
  FDefaultPuttyPathOnly = IncludeTrailingBackslash(ProgramsFolder) + L"PuTTY\\" + OriginalPuttyExecutable;
  FDefaultPuttyPath = L"%PROGRAMFILES%\\PuTTY\\" + OriginalPuttyExecutable;
  FPuttyPath = FormatCommand(FDefaultPuttyPath, L"");
  PSftpPath = FormatCommand(L"%PROGRAMFILES%\\PuTTY\\psftp.exe", L"");
  FPuttyPassword = false;
  FTelnetForFtpInPutty = true;
  FPuttySession = L"WinSCP temporary session";
  FBeepOnFinish = false;
  FBeepOnFinishAfter = TDateTime(0, 0, 30, 0);
  FCopyParamCurrent = L"";
  FKeepUpToDateChangeDelay = 500;
  FChecksumAlg = L"md5";
  FSessionReopenAutoIdle = 9000;

  FNewDirectoryProperties.Default();
  FNewDirectoryProperties.Rights = TRights::rfDefault | TRights::rfExec;
}
Exemplo n.º 13
0
bool TBrowseForDirectory::Execute()
{
	// Make directory available for eccBrowseCallbackProc():
	FBfdSelectedDirectory = Directory;

	// Create and clear BROWSEINFO object:
	BROWSEINFO BrowsingInfo;
	memset(&BrowsingInfo, 0, sizeof(BROWSEINFO));
	char dir[MAX_PATH];

	BrowsingInfo.hwndOwner      = Handle;
	BrowsingInfo.pszDisplayName = dir;
	BrowsingInfo.ulFlags        = FFlags;
	BrowsingInfo.lpszTitle      = Title.c_str();
	BrowsingInfo.lpfn           = eccBrowseCallbackProc;

	// Do the browsing, BIF_NEWDIALOGSTYLE (part of BIF_USENEWUI) requires Ole(Un)Initialize:
	if (FFlags & BIF_NEWDIALOGSTYLE)
		OleInitialize(NULL);
	else
		CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
	LPITEMIDLIST pidl = SHBrowseForFolder(&BrowsingInfo);
	if (FFlags & BIF_NEWDIALOGSTYLE)
		OleUninitialize();
	else
		CoUninitialize();

	// Retrieve selected folder:
	if (pidl)
	{
		char path[MAX_PATH] = "";
		SHGetPathFromIDList(pidl, path);
		Directory = IncludeTrailingBackslash(path);
		return true;
	}
	else // Cancel is pressed:
	{
		Directory = "";
		return false;
	}
}
Exemplo n.º 14
0
//---------------------------------------------------------------------------
UnicodeString __fastcall TCopyDialog::GetDirectory()
{
  assert(DirectoryEdit);

  UnicodeString Result = DirectoryEdit->Text;
  if (RemotePaths())
  {
    Result = UnixExtractFilePath(Result);
    if (!Result.IsEmpty())
    {
      Result = UnixIncludeTrailingBackslash(Result);
    }
  }
  else
  {
    Result = ExtractFilePath(Result);
    if (!Result.IsEmpty())
    {
      Result = IncludeTrailingBackslash(Result);
    }
  }
  return Result;
}
Exemplo n.º 15
0
//---------------------------------------------------------------------------
bool __fastcall SelectDirectory(UnicodeString & Path, const UnicodeString Prompt,
  bool PreserveFileName)
{
  bool Result;
  unsigned int ErrorMode;
  ErrorMode = SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);

  try
  {
    UnicodeString Directory;
    UnicodeString FileName;
    if (!PreserveFileName || DirectoryExists(Path))
    {
      Directory = Path;
    }
    else
    {
      Directory = ExtractFilePath(Path);
      FileName = ExtractFileName(Path);
    }
    Result = SelectDirectory(Prompt, L"", Directory);
    if (Result)
    {
      Path = Directory;
      if (!FileName.IsEmpty())
      {
        Path = IncludeTrailingBackslash(Path) + FileName;
      }
    }
  }
  __finally
  {
    SetErrorMode(ErrorMode);
  }

  return Result;
}
Exemplo n.º 16
0
//---------------------------------------------------------------------------
void __fastcall Download(TTerminal * Terminal, const UnicodeString FileName,
                         bool UseDefaults)
{
    UnicodeString TargetDirectory;
    TGUICopyParamType CopyParam = GUIConfiguration->DefaultCopyParam;
    TStrings * FileList = NULL;

    try
    {
        FileList = new TStringList();
        TRemoteFile * File = Terminal->Files->FindFile(FileName);
        if (File == NULL)
        {
            throw Exception(FMTLOAD(FILE_NOT_EXISTS, (FileName)));
        }
        FileList->AddObject(FileName, File);
        UnicodeString LocalDirectory = ExpandFileName(Terminal->SessionData->LocalDirectory);
        if (LocalDirectory.IsEmpty())
        {
            LocalDirectory = GetPersonalFolder();
        }
        TargetDirectory = IncludeTrailingBackslash(LocalDirectory);

        int Options = coDisableQueue;
        int CopyParamAttrs = Terminal->UsableCopyParamAttrs(0).Download;
        if (UseDefaults ||
                DoCopyDialog(false, false, FileList, TargetDirectory, &CopyParam,
                             Options, CopyParamAttrs, NULL))
        {
            Terminal->CopyToLocal(FileList, TargetDirectory, &CopyParam, 0);
        }
    }
    __finally
    {
        delete FileList;
    }
}
Exemplo n.º 17
0
//---------------------------------------------------------------------------
void __fastcall TSynchronizeController::SynchronizeChange(
  TObject * /*Sender*/, const UnicodeString Directory, bool & SubdirsChanged)
{
  try
  {
    UnicodeString RemoteDirectory;
    UnicodeString RootLocalDirectory;
    RootLocalDirectory = IncludeTrailingBackslash(FSynchronizeParams.LocalDirectory);
    RemoteDirectory = UnixIncludeTrailingBackslash(FSynchronizeParams.RemoteDirectory);

    UnicodeString LocalDirectory = IncludeTrailingBackslash(Directory);

    assert(LocalDirectory.SubString(1, RootLocalDirectory.Length()) ==
      RootLocalDirectory);
    RemoteDirectory = RemoteDirectory +
      ToUnixPath(LocalDirectory.SubString(RootLocalDirectory.Length() + 1,
        LocalDirectory.Length() - RootLocalDirectory.Length()));

    SynchronizeLog(slChange, FMTLOAD(SYNCHRONIZE_CHANGE,
      (ExcludeTrailingBackslash(LocalDirectory))));

    if (FOnSynchronize != NULL)
    {
      // this is completelly wrong as the options structure
      // can contain non-root specific options in future
      TSynchronizeOptions * Options =
        ((LocalDirectory == RootLocalDirectory) ? FOptions : NULL);
      TSynchronizeChecklist * Checklist = NULL;
      FOnSynchronize(this, LocalDirectory, RemoteDirectory, FCopyParam,
        FSynchronizeParams, &Checklist, Options, false);
      if (Checklist != NULL)
      {
        try
        {
          if (FLAGSET(FSynchronizeParams.Options, soRecurse))
          {
            SubdirsChanged = false;
            assert(Checklist != NULL);
            for (int Index = 0; Index < Checklist->Count; Index++)
            {
              const TSynchronizeChecklist::TItem * Item = Checklist->Item[Index];
              // note that there may be action saDeleteRemote even if nothing has changed
              // so this is sub-optimal
              if (Item->IsDirectory)
              {
                if ((Item->Action == TSynchronizeChecklist::saUploadNew) ||
                    (Item->Action == TSynchronizeChecklist::saDeleteRemote))
                {
                  SubdirsChanged = true;
                  break;
                }
                else
                {
                  assert(false);
                }
              }
            }
          }
          else
          {
            SubdirsChanged = false;
          }
        }
        __finally
        {
          delete Checklist;
        }
      }
    }
  }
  catch(Exception & E)
  {
    SynchronizeAbort(dynamic_cast<EFatal*>(&E) != NULL);
  }
}
Exemplo n.º 18
0
void __fastcall TScreenSnapper::WndProc(TMessage &Msg)
{
	// User placed something on the clipboard
	if (Msg.Msg==WM_DRAWCLIPBOARD) {
		TClipboard *Clip=Clipboard();
		if (Clip->HasFormat(CF_BITMAP)) { // Clipboard has a bitmap, process it

			// Start processing, sound camera shutter click
			if (Main->SoundsCheck->Checked) PlaySound("Shutter",HInstance,SND_RESOURCE|SND_ASYNC);

			// Ensure folder exists
			if (!Main->EnsureSnapsFolder()) return;

			Clipboard()->Open();
			HBITMAP Hb=(HBITMAP)Clip->GetAsHandle(CF_BITMAP);
			if (Hb) {
				// UI
				Main->IntroMemo->Visible=false;
				Main->NameLab->Visible=true;
				Main->AllSheetShownBefore=false;

				Graphics::TBitmap *Bm=new Graphics::TBitmap();
				Bm->Handle=Hb;

				// Crop if necessary
				Main->Crop(Bm,Main->MonitorCombo->ItemIndex); // 'The Parameter is incorrect, OutOfResources exception

				/* Old crop code, didn't work very well for multi-monitor
				if (Main->CropCheck->Checked) {
					int LimitWidth=StrToIntDef(Main->CropWidthEdit->Text,0);
					int LimitHeight=StrToIntDef(Main->CropHeightEdit->Text,0);
					if (LimitWidth>0 && LimitHeight>0) {
						if (LimitWidth<Bm->Width) Bm->Width=LimitWidth;
						if (LimitHeight<Bm->Height) Bm->Height=LimitHeight;
						}
					}
				*/

				// Convert to editable format
				Bm->PixelFormat=pf24bit;

				AnsiString FontOverlayName="Arial";
				int FontSizeOverlay=24;
				TColor FontShadowColor=clBlack;
				TColor FontColor=TColor(RGB(255,192,0));

				// Overlay (fixed text at top)
				AnsiString S=Main->OverlayEdit->Text.Trim();
				if (S!="") {
					TCanvas *Can=Bm->Canvas;
					Can->Font->Name=FontOverlayName;
					Can->Font->Size=FontSizeOverlay;
					SetBkMode(Can->Handle,TRANSPARENT);
					// Shadow
					Can->Font->Color=FontShadowColor;
					Can->TextOut(16,16,S);
					// Text itself
					Can->Font->Color=FontColor;
					Can->TextOut(14,14,S);
					}

				// Find a free serial nr
				for (;;) {
					AnsiString Format=IncludeTrailingBackslash(Main->FolderEdit->Text)+Main->PrefixEdit->Text+"-"+JapanDatum()+"-%03d.jpg";
					Savename.printf(Format.c_str(),Nr++);
					if (!FileExists(Savename)) break;
					}

				// Save full size
				if (!Main->SaveHalfSizeCheck->Checked) {
					SaveToJpgFile(Bm,Savename,Main->JpgQualityBar->Position);
					/* Orig code
					TJPEGImage *Jpg=new TJPEGImage;
					Jpg->CompressionQuality=Main->JpgQualityBar->Position;
					Jpg->Assign(Bm);
					Jpg->SaveToFile(Savename);
					delete Jpg;
					*/
					}

				// Shrink bitmap for display purposes
				Graphics::TBitmap *Half=new Graphics::TBitmap();
				Graphics::TBitmap *Quart=new Graphics::TBitmap();
				AntiAlias(Bm,Half,false);

				// Save half size
				if (Main->SaveHalfSizeCheck->Checked) {
					SaveToJpgFile(Half,Savename,Main->JpgQualityBar->Position);
					/* Orig code
					TJPEGImage *Jpg=new TJPEGImage;
					Jpg->CompressionQuality=Main->JpgQualityBar->Position;
					Jpg->Assign(Half);
					Jpg->SaveToFile(Savename);
					delete Jpg;
					*/
					}
				AntiAlias(Half,Quart,false);
				Main->Img->Picture->Bitmap->Assign(Quart);
				Main->NameLab->Caption="Last saved: "+Savename;
				delete Half;
				delete Quart;
				delete Bm;

				// Done processing, sound camera transport
				if (Main->SoundsCheck->Checked) PlaySound("Transport",HInstance,SND_RESOURCE|SND_ASYNC);
				}
			Clipboard()->Close();
			}
		SendMessage(NextHandle,WM_DRAWCLIPBOARD,0,0);
		}

	
	// Standard response to clipboard chain management
	if (Msg.Msg==WM_CHANGECBCHAIN) {
		if ((HWND)Msg.WParam==NextHandle)
			NextHandle=(HWND)Msg.LParam;
		else
			SendMessage(NextHandle,WM_CHANGECBCHAIN,Msg.WParam,Msg.LParam);
		}

	TForm::WndProc(Msg);
}
Exemplo n.º 19
0
//---------------------------------------------------------------------------
void __fastcall TSynchronizeChecklistDialog::LoadItem(TListItem * Item)
{
  UnicodeString S;
  const TSynchronizeChecklist::TItem * ChecklistItem = FChecklist->Item[Item->Index];
  Item->Data = const_cast<TSynchronizeChecklist::TItem *>(ChecklistItem);
  Item->Checked = ChecklistItem->Checked;
  if (ChecklistItem->ImageIndex >= 0)
  {
    Item->ImageIndex = ChecklistItem->ImageIndex;
  }
  else
  {
    Item->ImageIndex = FakeFileImageIndex(ChecklistItem->GetFileName(),
      FLAGMASK(ChecklistItem->IsDirectory, FILE_ATTRIBUTE_DIRECTORY));
  }

  S = ChecklistItem->GetFileName();
  if (ChecklistItem->IsDirectory)
  {
    S = IncludeTrailingBackslash(S);
  }
  Item->Caption = S;

  if (ChecklistItem->Action == TSynchronizeChecklist::saDeleteRemote)
  {
    Item->SubItems->Add(L"");
    Item->SubItems->Add(L"");
    Item->SubItems->Add(L"");
  }
  else
  {
    S = ChecklistItem->Local.Directory;
    if (AnsiSameText(FLocalDirectory, S.SubString(1, FLocalDirectory.Length())))
    {
      S[1] = L'.';
      S.Delete(2, FLocalDirectory.Length() - 1);
    }
    else
    {
      assert(false);
    }
    Item->SubItems->Add(S);
    if (ChecklistItem->Action == TSynchronizeChecklist::saDownloadNew)
    {
      Item->SubItems->Add(L"");
      Item->SubItems->Add(L"");
    }
    else
    {
      if (ChecklistItem->IsDirectory)
      {
        Item->SubItems->Add(L"");
      }
      else
      {
        Item->SubItems->Add(
          FormatBytes(ChecklistItem->Local.Size,
            WinConfiguration->FormatSizeBytes, WinConfiguration->FormatSizeBytes));
      }
      Item->SubItems->Add(UserModificationStr(ChecklistItem->Local.Modification,
        ChecklistItem->Local.ModificationFmt));
    }
  }

  Item->SubItems->Add(L"");

  if (ChecklistItem->Action == TSynchronizeChecklist::saDeleteLocal)
  {
    Item->SubItems->Add(L"");
    Item->SubItems->Add(L"");
    Item->SubItems->Add(L"");
  }
  else
  {
    S = ChecklistItem->Remote.Directory;
    if (AnsiSameText(FRemoteDirectory, S.SubString(1, FRemoteDirectory.Length())))
    {
      S[1] = L'.';
      S.Delete(2, FRemoteDirectory.Length() - 1);
    }
    else
    {
      assert(false);
    }
    Item->SubItems->Add(S);
    if (ChecklistItem->Action == TSynchronizeChecklist::saUploadNew)
    {
      Item->SubItems->Add(L"");
      Item->SubItems->Add(L"");
    }
    else
    {
      if (ChecklistItem->IsDirectory)
      {
        Item->SubItems->Add(L"");
      }
      else
      {
        Item->SubItems->Add(
          FormatBytes(ChecklistItem->Remote.Size,
            WinConfiguration->FormatSizeBytes, WinConfiguration->FormatSizeBytes));
      }
      Item->SubItems->Add(UserModificationStr(ChecklistItem->Remote.Modification,
        ChecklistItem->Remote.ModificationFmt));
    }
  }
}
Exemplo n.º 20
0
//---------------------------------------------------------------------------
UnicodeString __fastcall TConfiguration::GetIniFileStorageName(bool ReadingOnly)
{
  if (FIniFileStorageName.IsEmpty())
  {
    UnicodeString ProgramPath = ParamStr(0);

    UnicodeString ProgramIniPath = ChangeFileExt(ProgramPath, L".ini");

    UnicodeString IniPath;
    if (FileExists(ProgramIniPath))
    {
      IniPath = ProgramIniPath;
    }
    else
    {
      UnicodeString AppDataIniPath =
        IncludeTrailingBackslash(GetShellFolderPath(CSIDL_APPDATA)) +
        ExtractFileName(ProgramIniPath);
      if (FileExists(AppDataIniPath))
      {
        IniPath = AppDataIniPath;
      }
      else
      {
        // avoid expensive test if we are interested in existing files only
        if (!ReadingOnly && (FProgramIniPathWrittable < 0))
        {
          UnicodeString ProgramDir = ExtractFilePath(ProgramPath);
          FProgramIniPathWrittable = IsDirectoryWriteable(ProgramDir) ? 1 : 0;
        }

        // does not really matter what we return when < 0
        IniPath = (FProgramIniPathWrittable == 0) ? AppDataIniPath : ProgramIniPath;
      }
    }

    // BACKWARD COMPATIBILITY with 4.x
    if (FVirtualIniFileStorageName.IsEmpty() &&
        TPath::IsDriveRooted(IniPath))
    {
      UnicodeString LocalAppDataPath = GetShellFolderPath(CSIDL_LOCAL_APPDATA);
      // virtual store for non-system drives have a different virtual store,
      // do not bother about them
      if (TPath::IsDriveRooted(LocalAppDataPath) &&
          SameText(ExtractFileDrive(IniPath), ExtractFileDrive(LocalAppDataPath)))
      {
        FVirtualIniFileStorageName =
          IncludeTrailingBackslash(LocalAppDataPath) +
          L"VirtualStore\\" +
          IniPath.SubString(4, IniPath.Length() - 3);
      }
    }

    if (!FVirtualIniFileStorageName.IsEmpty() &&
        FileExists(FVirtualIniFileStorageName))
    {
      return FVirtualIniFileStorageName;
    }
    else
    {
      return IniPath;
    }
  }
  else
  {
    return FIniFileStorageName;
  }
}
Exemplo n.º 21
0
//---------------------------------------------------------------------------
__fastcall TsplashScreen::TsplashScreen(TComponent* Owner)
   : TForm(Owner)
{
   appPath = IncludeTrailingBackslash(ExtractFilePath( Application->ExeName ));
}
Exemplo n.º 22
0
TRegistryStorage::TRegistryStorage(const UnicodeString & AStorage) :
  THierarchicalStorage(IncludeTrailingBackslash(AStorage)),
  FRegistry(nullptr)
{
  Init();
}
Exemplo n.º 23
0
//---------------------------------------------------------------------------
void __fastcall TPrefsForm::BackupPathChange(TObject* Sender) {
  BackupPath->Text = IncludeTrailingBackslash(BackupPath->Text);
  ApplyButton->Enabled = true;
}
Exemplo n.º 24
0
//---------------------------------------------------------------------------
void __fastcall TDM::ListaExterna(PHDataSource *DS, PHTable *Tabela, AnsiString CampoOrig, short Elemento,
                                  AnsiString CampoConsul, short Sistema)
{
  AnsiString Codigo = "";
  AnsiString Chave;
  AnsiString Diretorio;
  AnsiString NomeSistema;
  if(Sistema)
   {
    Diretorio = DadosEmpresa(EMPRESAS_LOCALSCPH,vg.EmpresaAtual,0);
    NomeSistema = "SCPH";
   }
  else
   {
    Diretorio = DadosEmpresa(EMPRESAS_LOCALEFPH,vg.EmpresaAtual,0);
    NomeSistema = "EFPH";
   }

  Diretorio = IncludeTrailingBackslash(Diretorio);
  if(Diretorio != "")
   {
    PHDataSource *_PHDS1;
    try
     {
      _PHDS1 = new PHDataSource(NULL);
      _PHDS1->Name = "DSListaExterna";
      _PHDS1->Tabela = Tabela;
      if(_PHDS1->Tabela->DiretorioTipo == tdPrincipal)
       {
       Diretorio = DiretorioPrincipal(Diretorio);
       }

      _PHDS1->DiretorioTipo = tdsExplicito;
      _PHDS1->Diretorio = Diretorio;

      TLista *L1 = new TLista(this);
      try
       {
        L1->Caption = "Lista: " + _PHDS1->Tabela->NomeOpcao;
        L1->PHDS->Tabela = _PHDS1->Tabela;
        L1->PHDS->DiretorioTipo = _PHDS1->DiretorioTipo;
        L1->PHDS->Diretorio = _PHDS1->Diretorio;
        L1->PHDS->IndiceNome = _PHDS1->Tabela->IndiceConsulta;
        L1->PHDS->FiltrVis = true;
        L1->PHDS->FiltroExpr = _PHDS1->FiltroExpr;
        L1->PHDS->Filtrado = _PHDS1->Filtrado;
        L1->PHDS->FiltrVis = true;
        L1->PHDS->DestaqueExpr = _PHDS1->DestaqueExpr;
        L1->PHDS->Destacado = _PHDS1->Destacado;
        L1->PHDS->DiaNomeArq = _PHDS1->DiaNomeArq;
        L1->PHDS->MesNomeArq = _PHDS1->MesNomeArq;
        L1->PHDS->AnoNomeArq = _PHDS1->AnoNomeArq;
        if(_PHDS1->OnFiltro)
         {
         L1->PHDS->OnFiltro = _PHDS1->OnFiltro;
         }

        L1->PHDS->Open(true);

        int CR = L1->PHDS->CountReg() + 1;
        if(CR >= 2)
         {
         L1->PHGrid1->RowCount = CR;
         }
        else
         {
         throw Exception("Não foi possível montar Lista para Consulta. Verifique o 'Local " +
                          NomeSistema +
                          "' no Cadastro de Empresas.");
         }

        L1->PHGrid1->AjustaColunas(0);
        L1->PHGrid1->Row = 1;
        Chave = DS->GT(CampoOrig,Elemento);
        if(Chave.Trim() != "")
         {
          L1->PHDS->BuscaKeyBD(CampoConsul,Chave,true,true);
          L1->PHGrid1->Row = L1->PHDS->Ponteiro + 1;
         }

        L1->ShowModal();
        if(L1->Retorno)
         {
          Codigo = L1->PHDS->GV(CampoConsul);
          if(Codigo.Trim() != "")
           {
            DS->Edit();
            DS->SV(CampoOrig,Elemento,Codigo);
           }
         }
       }

      __finally
       {
        L1->PHDS->Close();
        if(L1)
         {
         delete L1;
         }

        L1 = NULL;
       }
     }

    __finally
     {
      _PHDS1->Close();
      delete _PHDS1;
     }
   }
Exemplo n.º 25
0
void TVPBeforeSystemInit()
{
	RegisterDllLoadHook();
		// register DLL delayed import hook to support _inmm.dll

	TVPInitProgramArgumentsAndDataPath(false); // ensure command line

#ifdef TVP_REPORT_HW_EXCEPTION
	__dee_hacked_set_getExceptionObjectHook(TVP__dee_hacked_getExceptionObjectHook);
		// register hook function for hardware exceptions
#endif

	Application->HintHidePause = 24*60*60*1000;
		// not to hide tool tip hint immediately
	Application->ShowHint = false;
	Application->ShowHint = true;
		// to ensure assigning new HintWindow Class defined in HintWindow.cpp 


	// randomize
	TVPInitRandomGenerator();

	// memory usage
	{
		MEMORYSTATUS status;
		status.dwLength = sizeof(status);
		GlobalMemoryStatus(&status);

		TVPPushEnvironNoise(&status, sizeof(status));

		TVPTotalPhysMemory = status.dwTotalPhys;

		TVPAddImportantLog(TJS_W("(info) Total physical memory : ") +
			ttstr((int)TVPTotalPhysMemory) );

		tTJSVariant opt;
		if(TVPGetCommandLine(TJS_W("-memusage"), &opt))
		{
			ttstr str(opt);
			if(str == TJS_W("low"))
				TVPTotalPhysMemory = 0; // assumes zero
		}

		if(TVPTotalPhysMemory <= 36*1024*1024)
		{
			// very very low memory, forcing to assume zero memory
			TVPTotalPhysMemory = 0;
		}

		if(TVPTotalPhysMemory < 48*1024*1024)
		{
			// extra low memory
			if(TJSObjectHashBitsLimit > 0)
				TJSObjectHashBitsLimit = 0;
			TVPSegmentCacheLimit = 0;
			TVPFreeUnusedLayerCache = true; // in LayerIntf.cpp
		}
		else if(TVPTotalPhysMemory < 64*1024*1024)
		{
			// low memory
			if(TJSObjectHashBitsLimit > 4)
				TJSObjectHashBitsLimit = 4;
		}
	}


	char buf[MAX_PATH];
	bool bufset = false;
	bool nosel = false;
	bool forcesel = false;

	bool forcedataxp3 = GetSystemSecurityOption("forcedataxp3") != 0;
	bool acceptfilenameargument = GetSystemSecurityOption("acceptfilenameargument") != 0;

	if(!forcedataxp3 && !acceptfilenameargument)
	{
		if(TVPGetCommandLine(TJS_W("-nosel")) || TVPGetCommandLine(TJS_W("-about")))
		{
			nosel = true;
		}
		else
		{
			for(tjs_int i = 1; i<_argc; i++)
			{
				if(_argv[i][0] == '-' &&
					_argv[i][1] == '-' && _argv[i][2] == 0)
					break;

				if(_argv[i][0] != '-')
				{
					// TODO: set the current directory
					strncpy(buf, _argv[i], MAX_PATH-1);
					buf[MAX_PATH-1] = '\0';
					if(DirectoryExists(buf)) // is directory?
						strcat(buf, "\\");

					TVPProjectDirSelected = true;
					bufset = true;
					nosel = true;
				}
			}
		}
	}

	// check "-sel" option, to force show folder selection window
	if(!forcedataxp3 && TVPGetCommandLine(TJS_W("-sel")))
	{
		// sel option was set
		if(bufset)
		{
			char path[MAX_PATH];
			char *dum = 0;
			GetFullPathName(buf, MAX_PATH-1, path, &dum);
			strcpy(buf, path);
			TVPProjectDirSelected = false;
			bufset = true;
		}
		nosel = true;
		forcesel = true;
	}

	// check "content-data" directory
	if(!forcedataxp3 && !nosel)
	{
		char tmp[MAX_PATH];
		strcpy(tmp, IncludeTrailingBackslash(ExtractFileDir(ParamStr(0))).c_str());
		strcat(tmp, "content-data");
		if(DirectoryExists(tmp))
		{
			strcat(tmp, "\\");
			strcpy(buf, tmp);
			TVPProjectDirSelected = true;
			bufset = true;
			nosel = true;
		}
	}

	// check "data.xp3" archive
 	if(!nosel)
	{
		char tmp[MAX_PATH];
		strcpy(tmp, IncludeTrailingBackslash(ExtractFileDir(ParamStr(0))).c_str());
		strcat(tmp, "data.xp3");
		if(FileExists(tmp))
		{
			strcpy(buf, tmp);
			TVPProjectDirSelected = true;
			bufset = true;
			nosel = true;
		}
	}

	// check "data.exe" archive
 	if(!nosel)
	{
		char tmp[MAX_PATH];
		strcpy(tmp, IncludeTrailingBackslash(ExtractFileDir(ParamStr(0))).c_str());
		strcat(tmp, "data.exe");
		if(FileExists(tmp))
		{
			strcpy(buf, tmp);
			TVPProjectDirSelected = true;
			bufset = true;
			nosel = true;
		}
	}

	// check self combined xpk archive
	if(!nosel)
	{
		if(TVPIsXP3Archive(TVPNormalizeStorageName(ParamStr(0))))
		{
			strcpy(buf, ParamStr(0).c_str());
			TVPProjectDirSelected = true;
			bufset = true;
			nosel = true;
		}
	}


	// check "data" directory
	if(!forcedataxp3 && !nosel)
	{
		char tmp[MAX_PATH];
		strcpy(tmp, IncludeTrailingBackslash(ExtractFileDir(ParamStr(0))).c_str());
		strcat(tmp, "data");
		if(DirectoryExists(tmp))
		{
			strcat(tmp, "\\");
			strcpy(buf, tmp);
			TVPProjectDirSelected = true;
			bufset = true;
			nosel = true;
		}
	}

	// decide a directory to execute or to show folder selection
	if(!bufset)
	{
		if(forcedataxp3) throw EAbort("Aborted");
		strcpy(buf, ExtractFileDir(ParamStr(0)).c_str());
		int curdirlen = strlen(buf);
		if(buf[curdirlen-1] != '\\') buf[curdirlen] = '\\', buf[curdirlen+1] = 0;
	}

	if(!forcedataxp3 && (!nosel || forcesel))
	{
		// load krdevui.dll ( TVP[KiRikiri] Development User Interface )
		HMODULE krdevui = LoadLibrary("krdevui.dll");
		if(!krdevui)
		{
			AnsiString toolspath = (IncludeTrailingBackslash(
					ExtractFilePath(ParamStr(0))) + "tools\\krdevui.dll");
			krdevui = LoadLibrary(toolspath.c_str());
		}

		if(!krdevui)
		{
			// cannot locate the dll
			throw Exception(
				ttstr(TVPCannnotLocateUIDLLForFolderSelection).AsAnsiString());
		}

		typedef int PASCAL (*UIShowFolderSelectorForm_t)(void *reserved, char *buf);
		typedef void PASCAL (*UIGetVersion_t)(DWORD *hi, DWORD *low);

		UIShowFolderSelectorForm_t	UIShowFolderSelectorForm;
		UIGetVersion_t				UIGetVersion;

		UIShowFolderSelectorForm =
			(UIShowFolderSelectorForm_t)GetProcAddress(krdevui, "UIShowFolderSelectorForm");
		UIGetVersion =
			(UIGetVersion_t)GetProcAddress(krdevui, "UIGetVersion");

		if(!UIShowFolderSelectorForm || !UIGetVersion)
		{
			FreeLibrary(krdevui);
			throw Exception(ttstr(TVPInvalidUIDLL).AsAnsiString());
		}

		DWORD h, l;
		UIGetVersion(&h, &l);
		if(h != TVP_NEED_UI_VERSION)
		{
			FreeLibrary(krdevui);
			throw Exception(ttstr(TVPInvalidUIDLL).AsAnsiString());
		}


		int result = UIShowFolderSelectorForm(Application->Handle, buf);

//		FreeLibrary(krdevui);
		// FIXME: the library should be freed as soon as finishing to use it.

		if(result == mrAbort)
		{
			// display the main window
		}
		else
		if(result == mrCancel)
		{
			// cancel
			throw EAbort("Canceled");
		}
		else
		if(result == mrOk)
		{
			// ok, prepare to execute the script
			TVPProjectDirSelected = true;
		}
	}

	// check project dir and store some environmental variables
	if(TVPProjectDirSelected)
	{
		Application->ShowMainForm=false;
	}

	tjs_int buflen = strlen(buf);
	if(buflen >= 1)
	{
		if(buf[buflen-1] != '\\') buf[buflen] = TVPArchiveDelimiter, buf[buflen+1] = 0;
	}

	TVPProjectDir = TVPNormalizeStorageName(buf);
	TVPSetCurrentDirectory(TVPProjectDir);
	TVPNativeProjectDir = buf;

	if(TVPProjectDirSelected)
	{
		TVPAddImportantLog(TJS_W("(info) Selected project directory : ") +
			TVPProjectDir);
	}
}
Exemplo n.º 26
0
UnicodeString IncludeTrailingPathDelimiter(const UnicodeString & Str)
{
  return IncludeTrailingBackslash(Str);
}
Exemplo n.º 27
0
//---------------------------------------------------------------------------
AnsiString __fastcall GetRelativeName( AnsiString FullName, AnsiString DirPart)
// Breaks full file name on two parts - DirPart and Relative Name
{
  return ExtractRelativePath( IncludeTrailingBackslash(DirPart), FullName);
}