PTLib  Version 2.18.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
httpform.h
Go to the documentation of this file.
1 /*
2  * httpform.h
3  *
4  * Forms management using HTTP User Interface.
5  *
6  * Portable Windows Library
7  *
8  * Copyright (c) 1993-2002 Equivalence Pty. Ltd.
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Portable Windows Library.
21  *
22  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23  *
24  * Contributor(s): ______________________________________.
25  */
26 
27 #ifndef PTLIB_HTTPFORM_H
28 #define PTLIB_HTTPFORM_H
29 
30 #ifdef P_USE_PRAGMA
31 #pragma interface
32 #endif
33 
34 #if P_HTTPFORMS
35 
36 #include <ptclib/http.h>
37 #include <ptclib/html.h>
38 #include <ptclib/pjson.h>
39 
40 
42 // PHTTPField
43 
47 class PHTTPField : public PObject
48 {
50  public:
51  PHTTPField(
52  const char * bname, // base name (identifier) for the field.
53  const char * title, // Title text for field (defaults to name).
54  const char * help // Help text for the field.
55  );
56  // Create a new field in a HTTP form.
57 
63  virtual Comparison Compare(
64  const PObject & obj
65  ) const;
66 
72  const PCaselessString & GetName() const { return m_fullName; }
73 
79  const PCaselessString & GetBaseName() const { return m_baseName; }
80 
83  virtual void SetName(
84  const PString & newName // New name for field
85  );
86 
92  virtual const PHTTPField * LocateName(
93  const PString & name // Full field name to locate
94  ) const;
95 
101  const PString & GetTitle() const { return m_title; }
102 
108  const PString & GetHelp() const { return m_help; }
109 
110  void SetHelp(
111  const PString & text // Help text.
112  ) { m_help = text; }
113  void SetHelp(
114  const PString & hotLinkURL, // URL for link to help page.
115  const PString & linkText // Help text in the link.
116  );
117  void SetHelp(
118  const PString & hotLinkURL, // URL for link to help page.
119  const PString & imageURL, // URL for image to be displayed in link.
120  const PString & imageText // Text in the link when image unavailable.
121  );
122  // Set the help text for the field.
123 
129  virtual PHTTPField * NewField() const = 0;
130 
131  virtual void ExpandFieldNames(PString & text, PINDEX start, PINDEX & finish) const;
132  // Splice expanded macro substitutions into text string
133 
136  virtual void GetHTMLTag(
137  PHTML & html // HTML to receive the fields HTML tag.
138  ) const = 0;
139 
142  virtual PString GetHTMLInput(
143  const PString & input // Source HTML text for input tag.
144  ) const;
145 
148  virtual PString GetHTMLSelect(
149  const PString & selection // Source HTML text for input tag.
150  ) const;
151 
154  virtual void GetHTMLHeading(
155  PHTML & html // HTML to receive the field info.
156  ) const;
157 
163  virtual PString GetValue(PBoolean dflt = false) const = 0;
164 
167  virtual void SetValue(
168  const PString & newValue // New value for the field.
169  ) = 0;
170 
175  virtual bool LoadFromConfig(
176  PConfig & cfg // Configuration for value transfer.
177  );
178 
182  virtual void SaveToConfig(
183  PConfig & cfg // Configuration for value transfer.
184  ) const;
185 
190  virtual void LoadFromJSON(
191  const PJSON::Base & json // JSON for value transfer.
192  );
193 
197  virtual void SaveToJSON(
198  PJSON::Base & json // JSON for value transfer.
199  ) const;
200 
206  virtual PBoolean Validated(
207  const PString & newVal, // Proposed new value for the field.
208  PStringStream & msg // Stream to take error HTML if value not valid.
209  ) const;
210 
211 
217  virtual void GetAllNames(PStringArray & names) const;
218 
221  virtual void SetAllValues(
222  const PStringToString & data // New value for the field.
223  );
224 
230  virtual PBoolean ValidateAll(
231  const PStringToString & data, // Proposed new value for the field.
232  PStringStream & msg // Stream to take error HTML if value not valid.
233  ) const;
234 
235 
236  PBoolean NotYetInHTML() const { return m_notInHTML; }
237  void SetInHTML() { m_notInHTML = false; }
238 
239  protected:
245 };
246 
247 
248 PARRAY(PHTTPFields, PHTTPField);
249 
250 
252 {
254  public:
256 
257  virtual PHTTPField * NewField() const;
258  virtual void GetHTMLTag(PHTML & html) const;
259  virtual PString GetValue(PBoolean dflt = false) const;
260  virtual void SetValue(const PString & newValue);
261  virtual void SaveToConfig(PConfig & cfg) const;
262  virtual void SaveToJSON(PJSON::Base & json) const;
263 };
264 
265 
267 {
269  public:
271  const char * name, // Name (identifier) for the field.
272  const char * title = NULL, // Title text for field (defaults to name).
273  const char * help = NULL, // Help text for the field.
274  bool includeHeaders = false // Make a sub-table and put headers on HTML fields.
275  );
276 
277  virtual void SetName(
278  const PString & name // New name for field
279  );
280 
281  virtual const PHTTPField * LocateName(
282  const PString & name // Full field name to locate
283  ) const;
284 
285  virtual PHTTPField * NewField() const;
286 
287  virtual void ExpandFieldNames(PString & text, PINDEX start, PINDEX & finish) const;
288 
289  virtual void GetHTMLTag(
290  PHTML & html // HTML to receive the field info.
291  ) const;
292 
293  virtual PString GetHTMLInput(
294  const PString & input // Source HTML text for input tag.
295  ) const;
296 
297  virtual void GetHTMLHeading(
298  PHTML & html // HTML to receive the field info.
299  ) const;
300 
301  virtual PString GetValue(PBoolean dflt = false) const;
302 
303  virtual void SetValue(
304  const PString & newValue // New value for the field.
305  );
306 
307  virtual bool LoadFromConfig(
308  PConfig & cfg // Configuration for value transfer.
309  );
310  virtual void SaveToConfig(
311  PConfig & cfg // Configuration for value transfer.
312  ) const;
313 
314  virtual void LoadFromJSON(
315  const PJSON::Base & json // JSON for value transfer.
316  );
317  virtual void SaveToJSON(
318  PJSON::Base & json // JSON for value transfer.
319  ) const;
320 
321  virtual void GetAllNames(PStringArray & names) const;
322  virtual void SetAllValues(
323  const PStringToString & data // New value for the field.
324  );
325 
326  virtual PBoolean ValidateAll(
327  const PStringToString & data, // Proposed new value for the field.
328  PStringStream & msg // Stream to take error HTML if value not valid.
329  ) const;
330 
331 
339  virtual PINDEX GetSize() const;
340 
341  void Append(PHTTPField * fld);
342  PHTTPField & operator[](PINDEX idx) const { return m_fields[idx]; }
343  void RemoveAt(PINDEX idx) { m_fields.RemoveAt(idx); }
344  void RemoveAll() { m_fields.RemoveAll(); }
345 
346  protected:
347  PHTTPFields m_fields;
349 };
350 
351 
353 {
355  public:
356  PHTTPSubForm(
357  const PString & subFormName, // URL for the sub-form
358  const char * name, // Name (identifier) for the field.
359  const char * title = NULL, // Title text for field (defaults to name).
360  PINDEX primaryField = 0, // Pimary field whove value is in hot link
361  PINDEX secondaryField = P_MAX_INDEX // Seconary field next to hotlink
362  );
363 
364  PHTTPField * NewField() const;
365  void GetHTMLTag(PHTML & html) const;
366  void GetHTMLHeading(PHTML & html) const;
367 
368  protected:
370  PINDEX m_primary;
371  PINDEX m_secondary;
372 };
373 
374 
376 {
378  public:
380  PHTTPField * baseField,
381  PBoolean ordered,
382  PINDEX fixedSize = 0
383  );
384 
386 
387 
388  virtual PHTTPField * NewField() const;
389 
390  virtual void ExpandFieldNames(PString & text, PINDEX start, PINDEX & finish) const;
391 
392  virtual void GetHTMLTag(
393  PHTML & html // HTML to receive the field info.
394  ) const;
395 
396  virtual bool LoadFromConfig(
397  PConfig & cfg // Configuration for value transfer.
398  );
399  virtual void SaveToConfig(
400  PConfig & cfg // Configuration for value transfer.
401  ) const;
402 
403  virtual void LoadFromJSON(
404  const PJSON::Base & json // JSON for value transfer.
405  );
406  virtual void SaveToJSON(
407  PJSON::Base & json // JSON for value transfer.
408  ) const;
409 
410 
411  virtual void SetAllValues(
412  const PStringToString & data // New value for the field.
413  );
414 
415  virtual PINDEX GetSize() const;
416  void SetSize(PINDEX newSize);
417 
419  PConfig & cfg,
420  const PStringArray & defaultValues
421  );
422 
423  void SetStrings(
424  PConfig & cfg,
425  const PStringArray & values
426  );
427 
428  protected:
429  void AddBlankField();
430  void AddArrayControlBox(PHTML & html, PINDEX fld) const;
431  void SetArrayFieldName(PINDEX idx) const;
433 
437 };
438 
439 
441 {
443  public:
445  const char * name,
446  PINDEX maxLength,
447  const char * initVal = NULL,
448  const char * help = NULL,
449  int rows = 0, // 0=auto, 1=InputText, >1=TextArea
450  int columns = 0
451  );
453  const char * name,
454  const char * title,
455  PINDEX maxLength,
456  const char * initVal = NULL,
457  const char * help = NULL,
458  int rows = 0, // 0=auto, 1=InputText, >1=TextArea
459  int columns = 0
460  );
461 
462  virtual PHTTPField * NewField() const;
463 
464  virtual void GetHTMLTag(
465  PHTML & html
466  ) const;
467 
468  virtual PString GetValue(PBoolean dflt = false) const;
469 
470  virtual void SetValue(
471  const PString & newVal
472  );
473 
474 
475  protected:
478  PINDEX m_maxLength;
479  int m_rows;
481 };
482 
483 
485 {
487  public:
489  const char * name,
490  PINDEX size,
491  const char * initVal = NULL,
492  const char * help = NULL
493  );
495  const char * name,
496  const char * title,
497  PINDEX size,
498  const char * initVal = NULL,
499  const char * help = NULL
500  );
501 
502  virtual PHTTPField * NewField() const;
503 
504  virtual void GetHTMLTag(
505  PHTML & html
506  ) const;
507 
508  virtual PString GetValue(PBoolean dflt = false) const;
509 
510  virtual void SetValue(
511  const PString & newVal
512  );
513 
514  static PString Decrypt(const PString & pword);
515  static PString Encrypt(const PString & clear);
516 };
517 
518 
520 {
522  public:
524  const char * name,
525  const PTime & initVal = PTime(0),
527  );
528 
529  virtual PHTTPField * NewField() const;
530 
531  virtual void SetValue(
532  const PString & newValue
533  );
534 
535  virtual PBoolean Validated(
536  const PString & newValue,
537  PStringStream & msg
538  ) const;
539 
540  protected:
542 };
543 
544 
546 {
548  public:
550  const char * name,
551  int low, int high,
552  int initVal = 0,
553  const char * units = NULL,
554  const char * help = NULL
555  );
557  const char * name,
558  const char * title,
559  int low, int high,
560  int initVal = 0,
561  const char * units = NULL,
562  const char * help = NULL
563  );
564 
565  virtual PHTTPField * NewField() const;
566 
567  virtual void GetHTMLTag(
568  PHTML & html
569  ) const;
570 
571  virtual PString GetValue(PBoolean dflt = false) const;
572 
573  virtual void SetValue(
574  const PString & newVal
575  );
576 
577  virtual bool LoadFromConfig(
578  PConfig & cfg
579  );
580  virtual void SaveToConfig(
581  PConfig & cfg
582  ) const;
583 
584  virtual void LoadFromJSON(
585  const PJSON::Base & json // JSON for value transfer.
586  );
587  virtual void SaveToJSON(
588  PJSON::Base & json // JSON for value transfer.
589  ) const;
590 
591  virtual PBoolean Validated(
592  const PString & newVal,
593  PStringStream & msg
594  ) const;
595 
596 
597  protected:
601 };
602 
603 
605 {
607  public:
609  const char * name,
610  PBoolean initVal = false,
611  const char * help = NULL
612  );
614  const char * name,
615  const char * title,
616  PBoolean initVal = false,
617  const char * help = NULL
618  );
619 
620  virtual PHTTPField * NewField() const;
621 
622  virtual void GetHTMLTag(
623  PHTML & html
624  ) const;
625 
626  virtual PString GetHTMLInput(
627  const PString & input
628  ) const;
629 
630  virtual PString GetValue(PBoolean dflt = false) const;
631 
632  virtual void SetValue(
633  const PString & newVal
634  );
635 
636  virtual bool LoadFromConfig(
637  PConfig & cfg
638  );
639  virtual void SaveToConfig(
640  PConfig & cfg
641  ) const;
642 
643  virtual void LoadFromJSON(
644  const PJSON::Base & json // JSON for value transfer.
645  );
646  virtual void SaveToJSON(
647  PJSON::Base & json // JSON for value transfer.
648  ) const;
649 
650 
651  protected:
653 };
654 
655 
657 {
659  public:
661  const char * name,
662  const PStringArray & valueArray,
663  PINDEX initVal = 0,
664  const char * help = NULL
665  );
667  const char * name,
668  const PStringArray & valueArray,
669  const PStringArray & titleArray,
670  PINDEX initVal = 0,
671  const char * help = NULL
672  );
674  const char * name,
675  PINDEX count,
676  const char * const * valueStrings,
677  PINDEX initVal = 0,
678  const char * help = NULL
679  );
681  const char * name,
682  PINDEX count,
683  const char * const * valueStrings,
684  const char * const * titleStrings,
685  PINDEX initVal = 0,
686  const char * help = NULL
687  );
689  const char * name,
690  const char * groupTitle,
691  const PStringArray & valueArray,
692  PINDEX initVal = 0,
693  const char * help = NULL
694  );
696  const char * name,
697  const char * groupTitle,
698  const PStringArray & valueArray,
699  const PStringArray & titleArray,
700  PINDEX initVal = 0,
701  const char * help = NULL
702  );
704  const char * name,
705  const char * groupTitle,
706  PINDEX count,
707  const char * const * valueStrings,
708  PINDEX initVal = 0,
709  const char * help = NULL
710  );
712  const char * name,
713  const char * groupTitle,
714  PINDEX count,
715  const char * const * valueStrings,
716  const char * const * titleStrings,
717  PINDEX initVal = 0,
718  const char * help = NULL
719  );
720 
721  virtual PHTTPField * NewField() const;
722 
723  virtual void GetHTMLTag(
724  PHTML & html
725  ) const;
726 
727  virtual PString GetHTMLInput(
728  const PString & input
729  ) const;
730 
731  virtual PString GetValue(PBoolean dflt = false) const;
732 
733  virtual void SetValue(
734  const PString & newVal
735  );
736 
737 
738  protected:
743 };
744 
745 
747 {
749  public:
751  const char * name,
752  const PStringArray & valueArray,
753  PINDEX initVal = 0,
754  const char * help = NULL,
755  bool enumeration = false
756  );
758  const char * name,
759  PINDEX count,
760  const char * const * valueStrings,
761  PINDEX initVal = 0,
762  const char * help = NULL,
763  bool enumeration = false
764  );
766  const char * name,
767  const char * title,
768  const PStringArray & valueArray,
769  PINDEX initVal = 0,
770  const char * help = NULL,
771  bool enumeration = false
772  );
774  const char * name,
775  const char * title,
776  PINDEX count,
777  const char * const * valueStrings,
778  PINDEX initVal = 0,
779  const char * help = NULL,
780  bool enumeration = false
781  );
782 
783  virtual PHTTPField * NewField() const;
784 
785  virtual void GetHTMLTag(
786  PHTML & html
787  ) const;
788 
789  virtual PString GetValue(PBoolean dflt = false) const;
790 
791  virtual void SetValue(
792  const PString & newVal
793  );
794 
795  protected:
796  void Construct(PINDEX initVal, bool enumeration);
797 
802 };
803 
804 
805 template <typename Enumeration, Enumeration InitVal = (Enumeration)0>
807 {
809  public:
811  const char * name,
812  const PStringArray & valueArray,
813  Enumeration initVal = InitVal,
814  const char * help = NULL
815  ) : PHTTPSelectField(name, valueArray, initVal, help, true) { }
817  const char * name,
818  PINDEX count,
819  const char * const * valueStrings,
820  Enumeration initVal = InitVal,
821  const char * help = NULL
822  ) : PHTTPSelectField(name, count, valueStrings, initVal, help, true) { }
824  const char * name,
825  const char * title,
826  const PStringArray & valueArray,
827  Enumeration initVal = InitVal,
828  const char * help = NULL
829  ) : PHTTPSelectField(name, title, valueArray, initVal, help, true) { }
831  const char * name,
832  const char * title,
833  PINDEX count,
834  const char * const * valueStrings,
835  Enumeration initVal = InitVal,
836  const char * help = NULL
837  ) : PHTTPSelectField(name, title, count, valueStrings, initVal, help, true) { }
838 
839  virtual PHTTPField * NewField() const { return new PHTTPEnumField(m_baseName, m_title, m_values, (Enumeration)m_initialValue, m_help); }
840 };
841 
842 
844 // PHTTPForm
845 
846 class PHTTPForm : public PHTTPString
847 {
849  public:
850  PHTTPForm(
851  const PURL & url
852  );
853  PHTTPForm(
854  const PURL & url,
855  const PHTTPAuthority & auth
856  );
857  PHTTPForm(
858  const PURL & url,
859  const PString & html
860  );
861  PHTTPForm(
862  const PURL & url,
863  const PString & html,
864  const PHTTPAuthority & auth
865  );
866 
867 
868  virtual void OnLoadedText(
869  PHTTPRequest & request,
870  PString & text
871  );
872  virtual PBoolean Post(
873  PHTTPRequest & request,
874  const PStringToString & data,
875  PHTML & replyMessage
876  );
877 
878 
879  PHTTPField * Add(
880  PHTTPField * fld
881  );
883  {
886  }
887 
892  };
893 
894  void BuildHTML(
895  const char * heading
896  );
897  void BuildHTML(
898  const PString & heading
899  );
900  void BuildHTML(
901  PHTML & html,
902  BuildOptions option = CompleteHTML
903  );
904 
905 
906 protected:
909 };
910 
911 
913 // PHTTPConfig
914 
915 class PHTTPConfig : public PHTTPForm
916 {
918  public:
919  PHTTPConfig(
920  const PURL & url,
921  const PString & section
922  );
923  PHTTPConfig(
924  const PURL & url,
925  const PString & section,
926  const PHTTPAuthority & auth
927  );
928  PHTTPConfig(
929  const PURL & url,
930  const PString & section,
931  const PString & html
932  );
933  PHTTPConfig(
934  const PURL & url,
935  const PString & section,
936  const PString & html,
937  const PHTTPAuthority & auth
938  );
939 
940  virtual void OnLoadedText(
941  PHTTPRequest & request,
942  PString & text
943  );
944  virtual PBoolean Post(
945  PHTTPRequest & request,
946  const PStringToString & data,
947  PHTML & replyMessage
948  );
949 
950 
953  void LoadFromConfig();
954 
957  void LoadFromJSON(
958  const PJSON & json // JSON for value transfer.
959  );
960 
963  void SaveToJSON(
964  PJSON & json // JSON for value transfer.
965  );
966 
972  const PString & GetConfigSection() const { return m_section; }
973 
975  const PString & sect
976  ) { m_section = sect; }
977  // Set the configuration file section.
978 
984  PHTTPField * sectionFld,
985  const char * prefix = NULL,
986  const char * suffix = NULL
987  );
988 
992  void AddNewKeyFields(
993  PHTTPField * keyFld,
994  PHTTPField * valFld
995  );
996 
1000  bool AddBooleanField(
1001  const char * name,
1002  bool defaultValue = false,
1003  const char * help = NULL
1004  );
1005 
1009  int AddIntegerField(
1010  const char * name,
1011  int low, int high,
1012  int defaultValue = 0,
1013  const char * units = NULL,
1014  const char * help = NULL
1015  );
1016 
1021  const char * name,
1022  PINDEX maxLength,
1023  const char * defaultValue = NULL,
1024  const char * help = NULL,
1025  int rows = 0, // 0=auto, 1=InputText, >1=TextArea
1026  int columns = 0
1027  );
1028 
1033  const char * name,
1034  bool sorted,
1035  PINDEX maxLength,
1036  const PStringArray & defaultValues,
1037  const char * help = NULL,
1038  int rows = 0, // 0=auto, 1=InputText, >1=TextArea
1039  int columns = 0
1040  );
1041 
1046  const char * name,
1047  const PStringArray & valueArray,
1048  const char * defaultValue = NULL,
1049  const char * help = NULL,
1050  bool enumeration = false
1051  );
1052 
1057  const char * name,
1058  bool sorted,
1059  const PStringArray & defaultValues,
1060  const PStringArray & possibleValues,
1061  const char * help = NULL,
1062  bool enumeration = false
1063  );
1064 
1065  protected:
1072 
1073  private:
1074  void Construct();
1075 };
1076 
1077 
1079 // PHTTPConfigSectionList
1080 
1082 {
1084  public:
1086  const PURL & url,
1087  const PHTTPAuthority & auth,
1088  const PString & sectionPrefix,
1089  const PString & additionalValueName,
1090  const PURL & editSection,
1091  const PURL & newSection,
1092  const PString & newSectionTitle,
1093  PHTML & heading
1094  );
1095 
1096  virtual void OnLoadedText(
1097  PHTTPRequest & request,
1098  PString & text
1099  );
1100  virtual PBoolean Post(
1101  PHTTPRequest & request,
1102  const PStringToString & data,
1103  PHTML & replyMessage
1104  );
1105 
1106  protected:
1112 };
1113 
1114 
1115 #endif // P_HTTPFORMS
1116 
1117 #endif // PTLIB_HTTPFORM_H
1118 
1119 
1120 // End Of File ///////////////////////////////////////////////////////////////
PString m_sectionSuffix
Definition: httpform.h:1068
virtual void GetAllNames(PStringArray &names) const
Retrieve all the names in the field and subfields.
Definition: httpform.h:545
PHTTPEnumField(const char *name, const char *title, const PStringArray &valueArray, Enumeration initVal=InitVal, const char *help=NULL)
Definition: httpform.h:823
virtual PINDEX GetSize() const
Get the number of sub-fields in the composite field.
virtual void SaveToConfig(PConfig &cfg) const
Set the value of the sub-field into the PConfig.
PString m_units
Definition: httpform.h:600
virtual PBoolean Post(PHTTPRequest &request, const PStringToString &data, PHTML &replyMessage)
Get a block of data (eg HTML) that the resource contains.
void RemoveAll()
Definition: httpform.h:344
PHTTPField(const char *bname, const char *title, const char *help)
virtual void SaveToJSON(PJSON::Base &json) const
Set the value of the sub-field into the JSON.
virtual void LoadFromJSON(const PJSON::Base &json)
Get the value of the JSON to the sub-field.
const PString & GetConfigSection() const
Get the configuration file section that the page will alter.
Definition: httpform.h:972
Definition: httpform.h:266
void AddArrayControlBox(PHTML &html, PINDEX fld) const
PHTTPPasswordField(const char *name, PINDEX size, const char *initVal=NULL, const char *help=NULL)
virtual void GetHTMLTag(PHTML &html) const
Convert the field to HTML form tag for inclusion into the HTTP page.
PHTTPField * m_sectionField
Definition: httpform.h:1069
virtual PString GetValue(PBoolean dflt=false) const
Get the string value of the field.
bool m_enumeration
Definition: httpform.h:799
PHTTPConfigSectionList(const PURL &url, const PHTTPAuthority &auth, const PString &sectionPrefix, const PString &additionalValueName, const PURL &editSection, const PURL &newSection, const PString &newSectionTitle, PHTML &heading)
PString m_subFormName
Definition: httpform.h:369
void AddNewKeyFields(PHTTPField *keyFld, PHTTPField *valFld)
Add fields to the HTTP form for adding a new key to the config file section.
void SetConfigSection(const PString &sect)
Definition: httpform.h:974
#define PCLASSINFO(cls, par)
Declare all the standard PTLib class information.
Definition: object.h:2164
PHTTPBooleanField(const char *name, PBoolean initVal=false, const char *help=NULL)
virtual void ExpandFieldNames(PString &text, PINDEX start, PINDEX &finish) const
PHTTPFields m_fields
Definition: httpform.h:347
PHTTPFieldArray(PHTTPField *baseField, PBoolean ordered, PINDEX fixedSize=0)
PHTTPField * NewField() const
Create a new field of the same class as the current field.
PHTTPEnumField(const char *name, const PStringArray &valueArray, Enumeration initVal=InitVal, const char *help=NULL)
Definition: httpform.h:810
This abstract class describes the authorisation mechanism for a Universal Resource Locator...
Definition: http.h:1452
This class defines an absolute time and date.
Definition: ptime.h:49
PString m_sectionPrefix
Definition: httpform.h:1067
Definition: httpform.h:251
int m_low
Definition: httpform.h:598
PHTTPDateField(const char *name, const PTime &initVal=PTime(0), PTime::TimeFormat fmt=PTime::ShortDate)
virtual void GetHTMLTag(PHTML &html) const
Convert the field to HTML form tag for inclusion into the HTTP page.
PHTTPCompositeField m_fields
Definition: httpform.h:907
virtual PBoolean Post(PHTTPRequest &request, const PStringToString &data, PHTML &replyMessage)
Get a block of data (eg HTML) that the resource contains.
A class representing a configuration for the application.
Definition: config.h:62
PString AddSelectField(const char *name, const PStringArray &valueArray, const char *defaultValue=NULL, const char *help=NULL, bool enumeration=false)
Add a string field.
This class is a standard C++ stream class descendent for reading or writing streamed data to or from ...
Definition: pstring.h:2188
PHTTPStringField(const char *name, PINDEX maxLength, const char *initVal=NULL, const char *help=NULL, int rows=0, int columns=0)
virtual void SaveToConfig(PConfig &cfg) const
Set the value of the sub-field into the PConfig.
PString m_editSectionLink
Definition: httpform.h:1111
virtual void ExpandFieldNames(PString &text, PINDEX start, PINDEX &finish) const
This is a dictionary collection class of PString objects, keyed by another string.
Definition: pstring.h:3151
PHTTPField * m_baseField
Definition: httpform.h:434
PStringArray m_values
Definition: httpform.h:739
virtual PString GetHTMLSelect(const PString &selection) const
Convert the field input to HTML for inclusion into the HTTP page.
virtual PHTTPField * NewField() const
Create a new field of the same class as the current field.
PCaselessString m_baseName
Definition: httpform.h:240
Comparison
Result of the comparison operation performed by the Compare() function.
Definition: object.h:2251
virtual PHTTPField * NewField() const
Create a new field of the same class as the current field.
BuildOptions
Definition: httpform.h:888
int AddIntegerField(const char *name, int low, int high, int defaultValue=0, const char *units=NULL, const char *help=NULL)
Add an integer field.
This class is a variation of a string that ignores case.
Definition: pstring.h:2012
PString m_section
Definition: httpform.h:1066
Definition: httpform.h:890
void GetHTMLHeading(PHTML &html) const
Convert the field to HTML for inclusion into the HTTP page.
virtual void OnLoadedText(PHTTPRequest &request, PString &text)
This is called after the text has been loaded and may be used to customise or otherwise mangle a load...
virtual Comparison Compare(const PObject &obj) const
Compare the fields using the field names.
Definition: httpform.h:484
PString m_help
Definition: httpform.h:243
Definition: httpform.h:519
Definition: pjson.h:33
virtual void GetHTMLTag(PHTML &html) const
Convert the field to HTML form tag for inclusion into the HTTP page.
void BuildHTML(const char *heading)
Definition: httpform.h:891
virtual bool LoadFromConfig(PConfig &cfg)
Get the value of the PConfig to the sub-field.
This is an array collection class of PString objects.
Definition: pstring.h:2365
void Construct(PINDEX initVal, bool enumeration)
Definition: httpform.h:440
virtual void SaveToConfig(PConfig &cfg) const
Set the value of the sub-field into the PConfig.
PString m_additionalValueName
Definition: httpform.h:1108
virtual PINDEX GetSize() const
Get the number of sub-fields in the composite field.
This object describes a HyperText Transport Protocol resource which is a string kept in memory...
Definition: http.h:2009
Definition: httpform.h:656
virtual void SaveToJSON(PJSON::Base &json) const
Set the value of the sub-field into the JSON.
void SetHelp(const PString &text)
Definition: httpform.h:110
void SaveToJSON(PJSON &json)
Set the value of the pages fields into the JSON.
virtual PString GetValue(PBoolean dflt=false) const =0
Get the string value of the field.
PTime::TimeFormat m_format
Definition: httpform.h:541
int m_rows
Definition: httpform.h:479
PHTTPSubForm(const PString &subFormName, const char *name, const char *title=NULL, PINDEX primaryField=0, PINDEX secondaryField=P_MAX_INDEX)
virtual PHTTPField * NewField() const =0
Create a new field of the same class as the current field.
PString m_value
Definition: httpform.h:801
virtual void RemoveAll()
Remove all of the elements in the collection.
TimeFormat
Standard time formats for string representations of a time and date.
Definition: ptime.h:433
virtual PString GetHTMLInput(const PString &input) const
Convert the field input to HTML for inclusion into the HTTP page.
virtual void LoadFromJSON(const PJSON::Base &json)
Get the value of the JSON to the sub-field.
virtual PHTTPField * NewField() const
Create a new field of the same class as the current field.
virtual PHTTPField * NewField() const
Create a new field of the same class as the current field.
virtual PString GetValue(PBoolean dflt=false) const
Get the string value of the field.
virtual void GetHTMLTag(PHTML &html) const
Convert the field to HTML form tag for inclusion into the HTTP page.
int m_columns
Definition: httpform.h:480
virtual void LoadFromJSON(const PJSON::Base &json)
Get the value of the JSON to the sub-field.
virtual void SetValue(const PString &newVal)
Set the value of the field.
virtual bool LoadFromConfig(PConfig &cfg)
Get the value of the PConfig to the sub-field.
virtual void SetAllValues(const PStringToString &data)
Set the value of the field in a list of fields.
virtual PHTTPField * NewField() const
Create a new field of the same class as the current field.
virtual void SetValue(const PString &newVal)
Set the value of the field.
PINDEX m_primary
Definition: httpform.h:370
bool AddBooleanField(const char *name, bool defaultValue=false, const char *help=NULL)
Add a boolean field.
int m_high
Definition: httpform.h:598
void LoadFromJSON(const PJSON &json)
Set the value of the JSON to the pages fields.
void SetStrings(PConfig &cfg, const PStringArray &values)
PString m_title
Definition: httpform.h:242
Definition: httpform.h:604
bool m_initialValue
Definition: httpform.h:652
virtual void SetValue(const PString &newVal)
Set the value of the field.
Definition: httpform.h:375
PString m_sectionPrefix
Definition: httpform.h:1107
virtual void GetHTMLTag(PHTML &html) const
Convert the field to HTML form tag for inclusion into the HTTP page.
void Append(PHTTPField *fld)
virtual bool LoadFromConfig(PConfig &cfg)
Get the value of the PConfig to the sub-field.
virtual void SetValue(const PString &newVal)
Set the value of the field.
PHTTPSelectField(const char *name, const PStringArray &valueArray, PINDEX initVal=0, const char *help=NULL, bool enumeration=false)
PString m_initialValue
Definition: httpform.h:742
PHTTPConfig(const PURL &url, const PString &section)
Date with numeric month and no time.
Definition: ptime.h:444
const PCaselessString & GetName() const
Get the identifier name of the field.
Definition: httpform.h:72
virtual void SetValue(const PString &newValue)=0
Set the value of the field.
virtual PString GetValue(PBoolean dflt=false) const
Get the string value of the field.
bool PBoolean
Definition: object.h:174
PINDEX m_maxLength
Definition: httpform.h:478
Definition: httpform.h:352
PStringArray GetStrings(PConfig &cfg, const PStringArray &defaultValues)
PString m_newSectionLink
Definition: httpform.h:1109
Definition: pjson.h:47
#define PARRAY(cls, T)
Declare an array to a specific type of object.
Definition: array.h:985
virtual PHTTPField * NewField() const
Create a new field of the same class as the current field.
#define P_MAX_INDEX
Definition: object.h:80
virtual void GetHTMLHeading(PHTML &html) const
Convert the field to HTML for inclusion into the HTTP page.
virtual PBoolean Validated(const PString &newVal, PStringStream &msg) const
Validate the new field value before SetValue() is called.
int m_value
Definition: httpform.h:598
const PCaselessString & GetBaseName() const
Get the identifier name of the field.
Definition: httpform.h:79
virtual void SaveToJSON(PJSON::Base &json) const
Set the value of the sub-field into the JSON.
virtual PHTTPField * NewField() const
Create a new field of the same class as the current field.
The character string class.
Definition: pstring.h:108
virtual void SaveToConfig(PConfig &cfg) const
Set the value of the sub-field into the PConfig.
bool m_notInHTML
Definition: httpform.h:244
virtual void SetName(const PString &newName)
Set the name for the field.
PHTTPField * m_valField
Definition: httpform.h:1071
This is a set collection class of PString objects.
Definition: pstring.h:2821
virtual PBoolean ValidateAll(const PStringToString &data, PStringStream &msg) const
Validate the new field value in a list before SetValue() is called.
virtual PBoolean Validated(const PString &newVal, PStringStream &msg) const
Validate the new field value before SetValue() is called.
PStringArray AddSelectArrayField(const char *name, bool sorted, const PStringArray &defaultValues, const PStringArray &possibleValues, const char *help=NULL, bool enumeration=false)
Add a string array field.
virtual void SetName(const PString &name)
Set the name for the field.
virtual void SaveToJSON(PJSON::Base &json) const
Set the value of the sub-field into the JSON.
void RemoveAt(PINDEX idx)
Definition: httpform.h:343
virtual void SetValue(const PString &newValue)
Set the value of the field.
virtual PBoolean ValidateAll(const PStringToString &data, PStringStream &msg) const
Validate the new field value in a list before SetValue() is called.
PINDEX m_initialValue
Definition: httpform.h:800
virtual PHTTPField * NewField() const
Create a new field of the same class as the current field.
virtual void SaveToConfig(PConfig &cfg) const
Set the value of the sub-field into the PConfig.
virtual PString GetHTMLInput(const PString &input) const
Convert the field input to HTML for inclusion into the HTTP page.
Definition: httpform.h:1081
Definition: httpform.h:889
PString m_newSectionTitle
Definition: httpform.h:1110
void GetHTMLTag(PHTML &html) const
Convert the field to HTML form tag for inclusion into the HTTP page.
PHTTPField * AddSectionField(PHTTPField *sectionFld, const char *prefix=NULL, const char *suffix=NULL)
Add a field that will determine the name opf the secontion into which the other fields are to be adde...
static PString Decrypt(const PString &pword)
virtual void SetValue(const PString &newVal)
Set the value of the field.
bool m_includeHeaders
Definition: httpform.h:348
PStringSet m_fieldNames
Definition: httpform.h:908
PHTTPEnumField(const char *name, const char *title, PINDEX count, const char *const *valueStrings, Enumeration initVal=InitVal, const char *help=NULL)
Definition: httpform.h:830
const PString & GetHelp() const
Get the title of the field.
Definition: httpform.h:108
PHTTPEnumField(const char *name, PINDEX count, const char *const *valueStrings, Enumeration initVal=InitVal, const char *help=NULL)
Definition: httpform.h:816
virtual PString GetHTMLInput(const PString &input) const
Convert the field input to HTML for inclusion into the HTTP page.
virtual const PHTTPField * LocateName(const PString &name) const
Locate the field naem, recusing down for composite fields.
virtual PString GetHTMLInput(const PString &input) const
Convert the field input to HTML for inclusion into the HTTP page.
virtual PString GetValue(PBoolean dflt=false) const
Get the string value of the field.
PBoolean NotYetInHTML() const
Definition: httpform.h:236
This class describes a HyperText markup Language string as used by the World Wide Web and the PURL an...
Definition: html.h:45
PHTTPCompositeField(const char *name, const char *title=NULL, const char *help=NULL, bool includeHeaders=false)
static PString Encrypt(const PString &clear)
virtual void SetValue(const PString &newVal)
Set the value of the field.
virtual void GetHTMLTag(PHTML &html) const
Convert the field to HTML form tag for inclusion into the HTTP page.
virtual void SetValue(const PString &newValue)
Set the value of the field.
PHTTPForm(const PURL &url)
virtual PBoolean Validated(const PString &newValue, PStringStream &msg) const
Validate the new field value before SetValue() is called.
PString m_value
Definition: httpform.h:476
virtual void GetHTMLHeading(PHTML &html) const
Convert the field to HTML for inclusion into the HTTP page.
PHTTPField * Add(PHTTPField *fld)
This class is the abstract base class for fields in a PHTTPForm resource type.
Definition: httpform.h:47
virtual void OnLoadedText(PHTTPRequest &request, PString &text)
This is called after the text has been loaded and may be used to customise or otherwise mangle a load...
PINDEX m_secondary
Definition: httpform.h:371
virtual PHTTPField * NewField() const
Create a new field of the same class as the current field.
virtual PHTTPField * NewField() const
Create a new field of the same class as the current field.
void LoadFromConfig()
Load all of the values for the resource from the configuration.
const PString & GetTitle() const
Get the title of the field.
Definition: httpform.h:101
PStringArray m_values
Definition: httpform.h:798
Definition: httpform.h:746
PString m_initialValue
Definition: httpform.h:477
void RemoveAllFields()
Definition: httpform.h:882
virtual void LoadFromJSON(const PJSON::Base &json)
Get the value of the JSON to the sub-field.
virtual void GetHTMLTag(PHTML &html) const
Convert the field to HTML form tag for inclusion into the HTTP page.
virtual PBoolean Post(PHTTPRequest &request, const PStringToString &data, PHTML &replyMessage)
Get a block of data (eg HTML) that the resource contains.
PStringArray m_titles
Definition: httpform.h:740
virtual void SaveToJSON(PJSON::Base &json) const
Set the value of the sub-field into the JSON.
void SetSize(PINDEX newSize)
void AddBlankField()
PString GetFieldNameForJSON() const
virtual PString GetValue(PBoolean dflt=false) const
Get the string value of the field.
PStringArray AddStringArrayField(const char *name, bool sorted, PINDEX maxLength, const PStringArray &defaultValues, const char *help=NULL, int rows=0, int columns=0)
Add a string array field.
virtual PString GetValue(PBoolean dflt=false) const
Get the string value of the field.
virtual void SetAllValues(const PStringToString &data)
Set the value of the field in a list of fields.
PString AddStringField(const char *name, PINDEX maxLength, const char *defaultValue=NULL, const char *help=NULL, int rows=0, int columns=0)
Add a string field.
virtual void OnLoadedText(PHTTPRequest &request, PString &text)
This is called after the text has been loaded and may be used to customise or otherwise mangle a load...
PHTTPField * m_keyField
Definition: httpform.h:1070
virtual PHTTPField * NewField() const
Create a new field of the same class as the current field.
Definition: httpform.h:839
PHTTPIntegerField(const char *name, int low, int high, int initVal=0, const char *units=NULL, const char *help=NULL)
virtual void SetValue(const PString &newValue)
Set the value of the field.
virtual bool LoadFromConfig(PConfig &cfg)
Get the value of the PConfig to the sub-field.
Definition: httpform.h:846
virtual void LoadFromJSON(const PJSON::Base &json)
Get the value of the JSON to the sub-field.
virtual void GetHTMLTag(PHTML &html) const
Convert the field to HTML form tag for inclusion into the HTTP page.
virtual void GetHTMLTag(PHTML &html) const =0
Convert the field to HTML form tag for inclusion into the HTTP page.
PCaselessString m_fullName
Definition: httpform.h:241
This object describes a HyperText Transport Protocol request.
Definition: http.h:1417
Ultimate parent class for all objects in the class library.
Definition: object.h:2204
virtual void GetAllNames(PStringArray &names) const
Retrieve all the names in the field and subfields.
virtual void SetAllValues(const PStringToString &data)
Set the value of the field in a list of fields.
This class describes a Universal Resource Locator.
Definition: url.h:56
bool m_value
Definition: httpform.h:652
Definition: httpform.h:806
PHTTPField & operator[](PINDEX idx) const
Definition: httpform.h:342
virtual void SaveToConfig(PConfig &cfg) const
Set the value of the sub-field into the PConfig.
virtual PString GetValue(PBoolean dflt=false) const
Get the string value of the field.
virtual void GetHTMLTag(PHTML &html) const
Convert the field to HTML form tag for inclusion into the HTTP page.
PString m_value
Definition: httpform.h:741
void SetArrayFieldName(PINDEX idx) const
void SetInHTML()
Definition: httpform.h:237
bool m_orderedArray
Definition: httpform.h:435
virtual const PHTTPField * LocateName(const PString &name) const
Locate the field naem, recusing down for composite fields.
virtual void ExpandFieldNames(PString &text, PINDEX start, PINDEX &finish) const
PHTTPRadioField(const char *name, const PStringArray &valueArray, PINDEX initVal=0, const char *help=NULL)
virtual void SaveToJSON(PJSON::Base &json) const
Set the value of the sub-field into the JSON.
virtual bool LoadFromConfig(PConfig &cfg)
Get the value of the PConfig to the sub-field.
virtual PString GetValue(PBoolean dflt=false) const
Get the string value of the field.
Definition: httpform.h:915
int m_initialValue
Definition: httpform.h:599
bool m_canAddElements
Definition: httpform.h:436