2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
24 /*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
25 /*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
26 /*%% (c) Copyright 1993, 1994 Novell, Inc. */
27 /*%% $XConsortium: tt_db_file.h /main/3 1995/10/23 10:02:07 rswiston $ */
29 * tt_db_file.h - Declare the TT DB server file class. This class defines the
30 * file properties interface to the DB server.
32 * Copyright (c) 1992 by Sun Microsystems, Inc.
38 #include "util/tt_object.h"
39 #include "util/tt_string.h"
40 #include "db/tt_db_hostname_global_map_ref.h"
41 #include "db/tt_db_access_utils.h"
42 #include "db/tt_db_property_utils.h"
43 #if defined(OPT_BUG_HPUX) || defined(OPT_BUG_AIX)
47 class _Tt_db_file : public _Tt_object {
51 // If the file already exists in the DB on its partition, then
52 // the DB is connected to when it needs to be. If the file
53 // does not exist on the database, the file entry is created
55 _Tt_db_file (const _Tt_string &file);
56 _Tt_db_file (const _Tt_string &file,
57 const _Tt_db_property_list_ptr &properties,
58 const _Tt_db_access_ptr &access);
61 // Sets and gets the access mode of this file.
62 void setCurrentAccess (const _Tt_db_access_ptr &access);
63 _Tt_db_access_ptr getCurrentAccess () const;
65 // Removes the file and all of its objects from the database. Once this is
66 // called this particular object instantiation is useless until "setFile" has
68 _Tt_db_results remove ();
70 // Copies the file to the new file name
71 _Tt_db_results copy (const _Tt_string &new_file);
73 // Moves the file to the new file name
74 _Tt_db_results move (const _Tt_string &new_file);
76 // Gets the local path of the file. Regardless of what path was specified
77 // in the object constructor, getLocalPath always returns the real path
78 // (the result of _tt_realpath).
79 const _Tt_string& getLocalPath () const
84 // Gets the network absolute path of the file. The path is in the
89 const _Tt_string& getNetworkPath () const
91 return dbFileNetworkPath;
94 // Gets the network absolute path of the file argument. The path
99 static _Tt_string getNetworkPath (const _Tt_string &file);
101 // Returns the hostname of the machine the file is located on.
102 _Tt_string getHostname ();
104 // Writes the specified file property to the database. All values of the
105 // the file property with the same name are overwritten. If the value of
106 // the property is NULL, this deletes all properties with the same name
107 // from the database.
108 _Tt_db_results setProperty (const _Tt_db_property_ptr &property);
110 // Writes the specified file properties to the database. All values of the
111 // the file properties with the same names are overwritten. If the value of
112 // some of the properties are NULL, this deletes all properties with the same
113 // name from the database.
114 _Tt_db_results setProperties (const _Tt_db_property_list_ptr &properties);
116 // Adds a file property to the list of values of the file property
117 // with the same name. If the property does not already exist, then
118 // the property is created. If the "unique" argument is TRUE, then
119 // the property name and value combination is guaranteed to be unique
120 // and will not be added to the list of values if the combination already
122 _Tt_db_results addProperty (const _Tt_db_property_ptr &property,
123 bool_t unique=FALSE);
125 // Deletes the file property value with the same name and value. If
126 // the value is left empty, then all values of the property are deleted.
127 _Tt_db_results deleteProperty (const _Tt_db_property_ptr &property);
129 // Gets the values of the file property with the specified name.
130 _Tt_db_property_ptr getProperty (const _Tt_string &name);
132 // Gets a list of all of the file properties.
133 _Tt_db_property_list_ptr getProperties ();
135 // Returns a list of all of the object IDs for the specified file.
136 _Tt_string_list_ptr getObjects ();
138 // Sets and gets the access mode of the specified file.
139 _Tt_db_results setAccess (const _Tt_db_access_ptr &access);
140 _Tt_db_access_ptr getAccess ();
142 // Add a session to the file
143 _Tt_db_results addSession (const _Tt_string &session);
145 // Delete a session from the file
146 _Tt_db_results deleteSession (const _Tt_string &session);
148 // Get a list of sessions that have joined this file
149 _Tt_string_list_ptr getSessions ();
151 // For this file, queues the message and the list of ptypes
152 // that the message is addressed to.
153 _Tt_db_results queueMessage (const _Tt_string_list_ptr &ptypes,
154 const _Tt_message_ptr &message);
156 // For this file, returns a list of messages that are addressed
157 // the specified ptypes. If there are no other ptypes that this message
158 // is addressed to, the message is deleted from the database.
159 _Tt_db_results dequeueMessages (const _Tt_string_list_ptr &ptypes,
160 _Tt_message_list_ptr &messages);
162 // Gets the results of the last database operation made with this object.
163 _Tt_db_results getDBResults () const
169 bool_t checkedDatabase;
170 bool_t directoryFlag;
172 _Tt_db_access_ptr dbFileAccess;
173 _Tt_db_access_ptr dbFileCurrentAccess;
174 _Tt_db_client_ptr dbFileDatabase;
175 _Tt_string dbFileHostname;
176 _Tt_string dbFileNetworkPath;
177 _Tt_string_list_ptr dbFileObjects;
178 int dbFileObjectsCacheLevel;
179 _Tt_string dbFilePartition;
180 _Tt_db_property_list_ptr dbFileProperties;
181 int dbFilePropertiesCacheLevel;
182 _Tt_string_list_ptr dbFilePtypes;
183 _Tt_db_hostname_global_map_ref dbHostnameGlobalMapRef;
184 _Tt_db_results dbResults;
186 // Sets the file in the database that the object is operating on.
187 // If the file already exists in the DB on its partition, then
188 // the DB is connected to when it needs to be. If the file
189 // does not exist on the database, the file entry is created
191 _Tt_db_results setTtDBFileDefaults (const _Tt_string&,
192 const _Tt_db_property_list_ptr&,
193 const _Tt_db_access_ptr&);
195 _Tt_db_results createDBFile ();
196 bool_t isFileInDatabase ();
199 // Does some special results processing for any public member functions
200 // that do some database server operations. It should be used to get
201 // the final results for all such member functions. Member functions
202 // that are not public or that only work on the memory copy of the
203 // object should not call processDBResults.
205 _Tt_db_results processDBResults ();
207 void setCurrentDBAccess ()
209 if (!dbFileDatabase.is_null()) {
210 dbFileDatabase->setCurrentAccess(dbFileCurrentAccess);
215 #endif // _TT_DB_FILE_H