1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * browserclass.cpp --
|
---|
4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
5 | *
|
---|
6 | * A component of the Greenstone digital library software
|
---|
7 | * from the New Zealand Digital Library Project at the
|
---|
8 | * University of Waikato, New Zealand.
|
---|
9 | *
|
---|
10 | * This program is free software; you can redistribute it and/or modify
|
---|
11 | * it under the terms of the GNU General Public License as published by
|
---|
12 | * the Free Software Foundation; either version 2 of the License, or
|
---|
13 | * (at your option) any later version.
|
---|
14 | *
|
---|
15 | * This program is distributed in the hope that it will be useful,
|
---|
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
18 | * GNU General Public License for more details.
|
---|
19 | *
|
---|
20 | * You should have received a copy of the GNU General Public License
|
---|
21 | * along with this program; if not, write to the Free Software
|
---|
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
23 | *
|
---|
24 | * $Id: browserclass.cpp 668 1999-10-14 22:59:35Z sjboddie $
|
---|
25 | *
|
---|
26 | *********************************************************************/
|
---|
27 |
|
---|
28 | /*
|
---|
29 | $Log$
|
---|
30 | Revision 1.2 1999/10/14 22:59:33 sjboddie
|
---|
31 | finished off browser classes
|
---|
32 |
|
---|
33 | Revision 1.1 1999/10/10 08:14:03 sjboddie
|
---|
34 | - metadata now returns mp rather than array
|
---|
35 | - redesigned browsing support (although it's not finished so
|
---|
36 | won't currently work ;-)
|
---|
37 |
|
---|
38 | */
|
---|
39 |
|
---|
40 |
|
---|
41 | #include "browserclass.h"
|
---|
42 | #include <assert.h>
|
---|
43 |
|
---|
44 |
|
---|
45 | browserclass::browserclass () {
|
---|
46 | }
|
---|
47 |
|
---|
48 | browserclass::~browserclass () {
|
---|
49 | }
|
---|
50 |
|
---|
51 | // configure should be called once for each configuration line
|
---|
52 | // the default version does nothing
|
---|
53 | void browserclass::configure (const text_t &/*key*/, const text_tarray &/*cfgline*/) {
|
---|
54 | }
|
---|
55 |
|
---|
56 | // init should be called after all the configuration is done but
|
---|
57 | // before any other methods are called
|
---|
58 | bool browserclass::init (ostream &/*logout*/) {
|
---|
59 | return true;
|
---|
60 | }
|
---|
61 |
|
---|
62 | // returns the name that specifies the browserclass type
|
---|
63 | text_t browserclass::get_browser_name () {
|
---|
64 | return "";
|
---|
65 | }
|
---|
66 |
|
---|
67 | void browserclass::processOID (cgiargsclass &/*args*/, recptproto */*collectproto*/, ostream &/*logout*/) {
|
---|
68 | }
|
---|
69 |
|
---|
70 | void browserclass::load_metadata_defaults (text_tset &/*metadata*/) {
|
---|
71 | }
|
---|
72 |
|
---|
73 | text_t browserclass::get_default_formatstring () {
|
---|
74 | return "<td>[link][icon][/link]</td><td>[highlight]{Or}{[Title],Untitled}[/highlight]</td>";
|
---|
75 | }
|
---|
76 |
|
---|
77 | int browserclass::output_section_group (ResultDocInfo_t &/*section*/, cgiargsclass &/*args*/,
|
---|
78 | int /*colnumber*/, format_t */*formatlistptr*/,
|
---|
79 | bool /*use_table*/, text_tset &/*metadata*/, bool &/*getParents*/,
|
---|
80 | recptproto */*collectproto*/, displayclass &/*disp*/,
|
---|
81 | outconvertclass &/*outconvert*/, ostream &/*textout*/, ostream &/*logout*/) {
|
---|
82 | return 0;
|
---|
83 | }
|
---|
84 |
|
---|
85 | int browserclass::output_section_group (FilterResponse_t &/*sections*/, cgiargsclass &/*args*/,
|
---|
86 | int /*colnumber*/, format_t */*formatlistptr*/,
|
---|
87 | bool /*use_table*/, text_tset &/*metadata*/, bool &/*getParents*/,
|
---|
88 | recptproto */*collectproto*/, displayclass &/*disp*/,
|
---|
89 | outconvertclass &/*outconvert*/, ostream &/*textout*/, ostream &/*logout*/) {
|
---|
90 | return 0;
|
---|
91 | }
|
---|
92 |
|
---|
93 | bool operator==(const browserptr &x, const browserptr &y) {
|
---|
94 | return (x.b == y.b);
|
---|
95 | }
|
---|
96 |
|
---|
97 | bool operator<(const browserptr &x, const browserptr &y) {
|
---|
98 | return (x.b < y.b);
|
---|
99 | }
|
---|
100 |
|
---|
101 | // thebrowserclass remains the property of the calling code but
|
---|
102 | // should not be deleted until it is removed from this list.
|
---|
103 | void browsermapclass::addbrowser (browserclass *thebrowserclass) {
|
---|
104 | // can't add a null browserclass
|
---|
105 | assert (thebrowserclass != NULL);
|
---|
106 | if (thebrowserclass == NULL) return;
|
---|
107 |
|
---|
108 | // can't add a browserclass with no name
|
---|
109 | assert (!(thebrowserclass->get_browser_name()).empty());
|
---|
110 | if ((thebrowserclass->get_browser_name()).empty()) return;
|
---|
111 |
|
---|
112 | browserptr aptr;
|
---|
113 | aptr.b = thebrowserclass;
|
---|
114 | browserptrs[thebrowserclass->get_browser_name()] = aptr;
|
---|
115 | }
|
---|
116 |
|
---|
117 | // getbrowser will return the default browser if the browser
|
---|
118 | // could not be found
|
---|
119 | browserclass *browsermapclass::getbrowser (const text_t &key) {
|
---|
120 | // can't find a browser with no name
|
---|
121 | if (key.empty()) return get_default_browser();
|
---|
122 |
|
---|
123 | iterator here = browserptrs.find (key);
|
---|
124 | if (here == browserptrs.end()) return get_default_browser();
|
---|
125 |
|
---|
126 | return (*here).second.b;
|
---|
127 | }
|
---|
128 |
|
---|
129 | void browsermapclass::setdefaultbrowser (const text_t &browsername) {
|
---|
130 | defaultbrowser = browsername;
|
---|
131 | }
|
---|
132 |
|
---|
133 | browserclass *browsermapclass::get_default_browser () {
|
---|
134 |
|
---|
135 | iterator here = browserptrs.find (defaultbrowser);
|
---|
136 | if (here == browserptrs.end())
|
---|
137 | // we'll just take the first in the list if
|
---|
138 | // no valid default was set
|
---|
139 | here = browserptrs.begin();
|
---|
140 | return (*here).second.b;
|
---|
141 | }
|
---|