//--------------------------------------------------------------------------- // TSrvMediaSettings //--------------------------------------------------------------------------- __fastcall TSrvMediaSettings::TSrvMediaSettings(TSrvResponse* Response, UnicodeString MediaName, bool DefaultMedia, UnicodeString DefaultExts) { this->FCategories = new TCollection(__classid(TSrvCategory)); this->FAllowExts = NULL; this->FNativeExts = new TStringList; this->FFormats = new TStringList; this->FAllNative = false; this->FExternalOnly = false; //Parse server info //MaxFileSize this->FMaxFileSize = Response->ReadInt( TSrvResponseValID(L"MaxFileSize", MediaName, DefaultMedia), CFG_DEFAULT_MAXFILESIZE); if (this->FMaxFileSize < 0) { throw ESrvResponseError(L"Negative numbers not allowed for MaxFileSize."); } /* #ifdef DEMO_MAX_FILESIZE if(this->FMaxFileSize > DEMO_MAX_FILESIZE) { this->FMaxFileSize = DEMO_MAX_FILESIZE; } #endif */ //AllowExtensions this->FAllowExts = Response->ReadList( TSrvResponseValID(L"AllowExtensions", MediaName, DefaultMedia), DefaultExts); //Categories UnicodeString search = MediaName + L"-Category "; UnicodeString name; for (int i = 0; i < Response->Count; i++) { name = Response->Names[i]; if (StartsStr(search, name) || (DefaultMedia && StartsStr(L"Category ", name))) { TSrvCategory* obj = (TSrvCategory*)this->Categories->Add(); UnicodeString id = StrExtract(name, L" "); if (id.IsEmpty()) throw ESrvResponseError(L"Invalid Category value. No ID found."); try { obj->ID = StrToInt(id); } catch (EConvertError& e) { throw ESrvResponseError(UnicodeString(L"Invalid Category value. Cannot read ID: ") + e.Message); } obj->Label = Response->ValueFromIndex[i]; } } if (this->Categories->Count == 0) throw ESrvResponseError(L"No categories for " + MediaName + " found."); }
//--------------------------------------------------------------------------- UnicodeString __fastcall TGenerateUrlDialog::GenerateUrl(UnicodeString Path) { UnicodeString Url = FData->GenerateSessionUrl( FLAGMASK(WinSCPSpecificCheck->Checked, sufSpecific) | FLAGMASK(UserNameCheck->Enabled && UserNameCheck->Checked, sufUserName) | FLAGMASK(PasswordCheck->Enabled && PasswordCheck->Checked, sufPassword) | FLAGMASK(HostKeyCheck->Enabled && HostKeyCheck->Checked, sufHostKey)); if ((RemoteDirectoryCheck->Enabled && RemoteDirectoryCheck->Checked) || (FPaths != NULL)) { if (StartsStr(L"/", Path)); { Path.Delete(1, 1); } Url += EncodeUrlPath(Path); } if (SaveExtensionCheck->Enabled && SaveExtensionCheck->Checked) { Url += UnicodeString(UrlParamSeparator) + UrlSaveParamName; } return Url; }