示例#1
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);
}
示例#2
0
//---------------------------------------------------------------------------
int get_userpass_input(prompts_t * p, unsigned char * /*in*/, int /*inlen*/)
{
  assert(p != NULL);
  TSecureShell * SecureShell = reinterpret_cast<TSecureShell *>(p->frontend);
  assert(SecureShell != NULL);

  int Result;
  TStrings * Prompts = new TStringList();
  TStrings * Results = new TStringList();
  try
  {
    for (int Index = 0; Index < int(p->n_prompts); Index++)
    {
      prompt_t * Prompt = p->prompts[Index];
      Prompts->AddObject(Prompt->prompt, (TObject *)(FLAGMASK(Prompt->echo, pupEcho)));
      // this fails, when new passwords do not match on change password prompt,
      // and putty retries the prompt
      assert(Prompt->resultsize == 0);
      Results->Add(L"");
    }

    if (SecureShell->PromptUser(p->to_server, p->name, p->name_reqd,
          p->instruction, p->instr_reqd, Prompts, Results))
    {
      for (int Index = 0; Index < int(p->n_prompts); Index++)
      {
        prompt_t * Prompt = p->prompts[Index];
        prompt_set_result(Prompt, AnsiString(Results->Strings[Index]).c_str());
      }
      Result = 1;
    }
    else
    {
      Result = 0;
    }
  }
  __finally
  {
    delete Prompts;
    delete Results;
  }

  return Result;
}
示例#3
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;
    }
}
// ---------------------------------------------------------------------------
void __fastcall TFrPrintProductCatalog::LoadPicList(TStrings *NameUser,
	TStrings *Status, TStrings *Activities_KC, TStrings *ComboBox9)
{ // Загрузка нового листа выбора
	TStrings *S;
	AnsiString Sl;
	TField *F, *Fi;
	TADOQuery *Qi;
	Qi = Qw;

	if (Status != NULL) {
		S = Status;
		Qi->Close();
		Qi->SQL->Clear();
		Qi->SQL->Add
			("select -1,' ВСЕ' union select 0,' Не распределен' union select idn,iText from spl_LbText256 where iLvl=1156 and datedel is null Order by 2 "
			);
		Qi->Open();
		Fi = Qi->Fields->Fields[0];
		F = Qi->Fields->Fields[1];
		S->Clear();
		while (Qi->Eof == false) {
			S->AddObject(F->AsString, (TObject*)Fi->AsInteger);
			Qi->Next();
		}
		Qi->Close();
	}
	if (Activities_KC != NULL) {
		S = Activities_KC;
		Qi->Close();
		Qi->SQL->Clear();
		Qi->SQL->Add
			("select -1,' ВСЕ' union select Idn,iText from spl_LbText256 where iLvl=1199 and DateDel is null"
			);
		Qi->Open();
		Fi = Qi->Fields->Fields[0];
		F = Qi->Fields->Fields[1];
		S->Clear();
		while (Qi->Eof == false) {
			S->AddObject(F->AsString, (TObject*)Fi->AsInteger);
			Qi->Next();
		}
		Qi->Close();
	}
	if (ComboBox9 != NULL) {
		S = ComboBox9;
		Qi->Close();
		Qi->SQL->Clear();
		Qi->SQL->Add
			("select -1,' ВСЕ' union select 0,' Нет менеджера' union SELECT idManager,u.auFamIO FROM cch_CallManager LEFT JOIN aa_Users u on u.auId=idManager WHERE TypeM=0 ORDER BY 2 "
			);
		Qi->Open();
		Fi = Qi->Fields->Fields[0];
		F = Qi->Fields->Fields[1];
		S->Clear();
		while (Qi->Eof == false) {
			S->AddObject(F->AsString, (TObject*)Fi->AsInteger);
			Qi->Next();
		}
		Qi->Close();
	}

}
示例#5
0
static void _std getlog(log_header *log, void *extptr) {
   getloginfo *pli = (getloginfo*)extptr;
   int    puretext = (pli->flags&(LOGTF_DATE|LOGTF_TIME|LOGTF_LEVEL))==0;

   if (puretext) {
      spstr ltext;
      while (log->offset) {
         if ((log->flags&LOGIF_USED)!=0 && ((pli->flags&LOGTF_LEVEL)==0 ||
           (pli->flags&LOGTF_LEVELMASK)>=(log->flags&LOGIF_LEVELMASK)))
         {
            ltext+=(char*)(log+1);
         }
         log+=log->offset;
      }
      if (pli->flags&LOGTF_DOSTEXT) ltext.replace("\n","\r\n");
      // make copy a bit faster
      pli->rc = (char*)malloc(ltext.length()+1);
      memcpy(pli->rc, ltext(), ltext.length());
      pli->rc[ltext.length()] = 0;
   } else {
      TStrings    lst;
      struct tm    dt;
      u32t      pdtme = 0;
      time_t     ptme;

      while (log->offset) {
         if ((log->flags&LOGIF_USED)!=0 && ((pli->flags&LOGTF_LEVEL)==0 ||
           (pli->flags&LOGTF_LEVELMASK)>=(log->flags&LOGIF_LEVELMASK)))
         {
            if (pdtme!=log->dostime) {
               dostimetotm(pdtme=log->dostime,&dt);
               ptme = mktime(&dt);
            }
            spstr estr, astr;

            if (pli->flags&LOGTF_DATE)
               estr.sprintf("%02d.%02d.%02d ",dt.tm_mday,dt.tm_mon+1,dt.tm_year-100);
            if (pli->flags&LOGTF_TIME) {
               int sec = dt.tm_sec;
               if (log->flags&LOGIF_SECOND) sec++;
               astr.sprintf("%02d:%02d:%02d ",dt.tm_hour, dt.tm_min, sec);
               estr+=astr;
            }
            if (pli->flags&LOGTF_LEVEL) {
               if (pli->flags&LOGTF_FLAGS)
                  astr.sprintf("[%c%d%c] ",log->flags&LOGIF_REALMODE?'r':' ',
                     log->flags&LOGIF_LEVELMASK,log->flags&LOGIF_DELAY?'d':' ');
               else
                  astr.sprintf("[%d] ",log->flags&LOGIF_LEVELMASK);
               estr+=astr;
            }
            estr+=(char*)(log+1);
            if (estr.lastchar()=='\n') estr.dellast();
            lst.AddObject(estr,ptme);
         }
         log+=log->offset;
      }
      int ii,jj;
      const char *eol = pli->flags&LOGTF_DOSTEXT?"\r\n":"\n";

      log_it(2, "%d lines of log queried\n", lst.Count());

      for (ii=1;ii<lst.Count();ii++)
         // we`re can`t fill entire log for 3 seconds
         if (lst.Objects(ii-1)-lst.Objects(ii)>3) break;
      // re-order cyclic added lines
      if (ii<lst.Count()) {
         spstr t1 = lst.GetTextToStr(eol,ii),
               t2 = lst.GetTextToStr(eol,0,ii);
         pli->rc = (char*)malloc(t1.length()+t2.length()+1);
         memcpy(pli->rc, t1(), t1.length());
         memcpy(pli->rc+t1.length(), t2(), t2.length()+1);
      } else
         pli->rc = lst.GetText(eol);
   }
}