secure_n_one._pike
Go to the documentation of this file.
1 /* Copyright (C) 2000-2004 Thomas Bopp, Thorsten Hampel, Ludger Merkens
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * $Id: secure_n_one.pike,v 1.1 2008/03/31 13:39:57 exodusd Exp $
18  */
19 inherit "/kernel/module";
20 inherit "/kernel/db_n_one";
21 #include <macros.h>
22 #include <events.h>
23 class secure_n_one : public module,db_n_one{
24 public:
25 
26 
27 
28 
29 
30 /**
31  * called to initiate the database connection connected to this table.
32  *
33  * @param
34  * @return
35  * @see
36  */
37 protected:
38  void load_module()
39 {
40  load_db_mapping();
41  LOG("connected "+get_object_id()+"with "+tablename());
42 }
43 
44 public:
45 
46 /**
47  * look up a user object from the sTeam database by username.
48  *
49  * @param string - username
50  * @return object - proxy associated with the user.
51  * @see register_user
52  */
53 object lookup(string key)
54 {
55  object res;
56  try_event(EVENT_DB_QUERY, CALLER, key);
57  res = get_value(key);
58  run_event(EVENT_DB_QUERY, CALLER, key);
59  return res;
60 }
61 
62 /**
63  * removes a key from the key lookup table, called on deletion of a key.
64  * @param string key - the name the key is registered with
65  * @return (0|1)
66  * @see
67  */
68 int unregister(string key)
69 {
70  int res;
71  try_event(EVENT_DB_UNREGISTER, CALLER, key);
72  res = delete(key);
73  run_event(EVENT_DB_UNREGISTER, CALLER, key);
74  return res;
75 }
76 
77 /**
78  * registers a key in the sTeam database with it's keyname.
79  *
80  * @param string - uname (name to register with)
81  * @param object - key (the (proxy) object to register)
82  * @return (1|0)
83  * @see lookup_key
84  */
85 int register(string uname, object key)
86 {
87  int res;
88  try_event(EVENT_DB_REGISTER, CALLER, uname, key);
89  ::set_value(uname, key);
90  res = ::get_value(uname) == key;
91  run_event(EVENT_DB_REGISTER, CALLER, uname, key);
92  return res;
93 }
94 
95 // int get_object_id()
96 // {
97 // return __module::get_object_id();
98 // }
99 
100 // {
101 // }
102 
103 mixed list() {
104  mixed res;
105  try_event(EVENT_DB_QUERY, CALLER);
106  res = index();
107  run_event(EVENT_DB_QUERY, CALLER);
108  return res;
109 }
110 
111 
112 };