10969
|
1
|
|
2 /*
|
|
3 Meanwhile - Unofficial Lotus Sametime Community Client Library
|
|
4 Copyright (C) 2004 Christopher (siege) O'Brien
|
|
5
|
|
6 This library is free software; you can redistribute it and/or
|
|
7 modify it under the terms of the GNU Library General Public
|
|
8 License as published by the Free Software Foundation; either
|
|
9 version 2 of the License, or (at your option) any later version.
|
|
10
|
|
11 This library is distributed in the hope that it will be useful,
|
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
14 Library General Public License for more details.
|
|
15
|
|
16 You should have received a copy of the GNU Library General Public
|
|
17 License along with this library; if not, write to the Free
|
|
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
19 */
|
|
20
|
|
21 #ifndef _MW_SRVC_STORE_H
|
|
22 #define _MW_SRVC_STORE_H
|
|
23
|
|
24
|
|
25 #include <glib.h>
|
|
26 #include "mw_common.h"
|
|
27
|
|
28
|
|
29 /** Type identifier for the storage service */
|
|
30 #define SERVICE_STORAGE 0x00000018
|
|
31
|
|
32
|
|
33 /** @struct mwServiceStorage
|
|
34 @see mwServiceStorage_new
|
|
35
|
|
36 Instance of the storage service */
|
|
37 struct mwServiceStorage;
|
|
38
|
|
39
|
|
40 /** @struct mwStorage
|
|
41
|
|
42 Unit Represents information intended for loading from or saving to
|
|
43 the storage service */
|
|
44 struct mwStorageUnit;
|
|
45
|
|
46
|
|
47 /** The upper limit of reserved Lotus keys */
|
|
48 #define LOTUS_RESERVED_LIMIT 0x186a0
|
|
49
|
|
50
|
|
51 /** Check if a key is in the range of Lotus reserved keys */
|
|
52 #define KEY_IS_LOTUS_RESERVED(key) \
|
|
53 (((guint32) key) <= (LOTUS_RESERVED_LIMIT))
|
|
54
|
|
55
|
|
56 /** Some common keys storage keys. Anything in the range 0x00 to
|
|
57 0x186a0 (100000) is reserved for use by the Lotus
|
|
58 clients. */
|
|
59 enum mwStorageKey {
|
|
60
|
|
61 /** The buddy list, in the Sametime .dat file format. String */
|
|
62 mwStore_AWARE_LIST = 0x00000000,
|
|
63
|
|
64 /** Default text for chat invitations. String */
|
|
65 mwStore_INVITE_CHAT = 0x00000006,
|
|
66
|
|
67 /** Default text for meeting invitations. String */
|
|
68 mwStore_INVITE_MEETING = 0x0000000e,
|
|
69
|
|
70 /** Last five Away messages, separated by semicolon. String */
|
|
71 mwStore_AWAY_MESSAGES = 0x00000050,
|
|
72
|
|
73 /** Last five Busy (DND) messages, separated by semicolon. String */
|
|
74 mwStore_BUSY_MESSAGES = 0x0000005a,
|
|
75
|
|
76 /** Last five Active messages, separated by semicolon. String */
|
|
77 mwStore_ACTIVE_MESSAGES = 0x00000064,
|
|
78 };
|
|
79
|
|
80
|
|
81 /** Appropriate function type for load and store callbacks.
|
|
82 @param srvc the storage service
|
|
83 @param result the result value of the load or store call
|
|
84 @param item the storage unit loaded or saved
|
|
85 @param data optional user data
|
|
86 */
|
|
87 typedef void (*mwStorageCallback)
|
|
88 (struct mwServiceStorage *srvc,
|
|
89 guint32 result, struct mwStorageUnit *item,
|
|
90 gpointer data);
|
|
91
|
|
92
|
|
93 /** Allocates and initializes a storage service instance for use on
|
|
94 the passed session. */
|
|
95 struct mwServiceStorage *mwServiceStorage_new(struct mwSession *);
|
|
96
|
|
97
|
|
98 /** create an empty storage unit */
|
|
99 struct mwStorageUnit *mwStorageUnit_new(guint32 key);
|
|
100
|
|
101
|
|
102 /** creates a storage unit with the passed key, and a copy of data. */
|
|
103 struct mwStorageUnit *mwStorageUnit_newOpaque(guint32 key,
|
|
104 struct mwOpaque *data);
|
|
105
|
|
106
|
|
107 /** creates a storage unit with the passed key, and an encapsulated
|
|
108 boolean value */
|
|
109 struct mwStorageUnit *mwStorageUnit_newBoolean(guint32 key,
|
|
110 gboolean val);
|
|
111
|
|
112
|
|
113 struct mwStorageUnit *mwStorageUnit_newInteger(guint32 key,
|
|
114 guint32 val);
|
|
115
|
|
116
|
|
117 /** creates a storage unit with the passed key, and an encapsulated
|
|
118 string value. */
|
|
119 struct mwStorageUnit *mwStorageUnit_newString(guint32 key,
|
|
120 const char *str);
|
|
121
|
|
122
|
|
123 /** get the key for the given storage unit */
|
|
124 guint32 mwStorageUnit_getKey(struct mwStorageUnit *);
|
|
125
|
|
126
|
|
127 /** attempts to obtain a boolean value from a storage unit. If the
|
|
128 unit is empty, or does not contain the type in a recongnizable
|
|
129 format, val is returned instead */
|
|
130 gboolean mwStorageUnit_asBoolean(struct mwStorageUnit *, gboolean val);
|
|
131
|
|
132
|
|
133 /** attempts to obtain a guint32 value from a storage unit. If the
|
|
134 unit is empty, or does not contain the type in a recognizable
|
|
135 format, val is returned instead */
|
|
136 guint32 mwStorageUnit_asInteger(struct mwStorageUnit *, guint32 val);
|
|
137
|
|
138
|
|
139 /** attempts to obtain a string value from a storage unit. If the unit
|
|
140 is empty, or does not contain the type in a recognizable format,
|
|
141 NULL is returned instead. Note that the string returned is a copy,
|
|
142 and will need to be deallocated at some point. */
|
|
143 char *mwStorageUnit_asString(struct mwStorageUnit *);
|
|
144
|
|
145
|
|
146 /** direct access to the opaque data backing the storage unit */
|
|
147 struct mwOpaque *mwStorageUnit_asOpaque(struct mwStorageUnit *);
|
|
148
|
|
149
|
|
150 /** clears and frees a storage unit */
|
|
151 void mwStorageUnit_free(struct mwStorageUnit *);
|
|
152
|
|
153
|
|
154 /** Initiates a load call to the storage service. If the service is
|
|
155 not currently available, the call will be cached and processed
|
|
156 when the service is started.
|
|
157 @param item storage unit to load
|
|
158 @param cb callback function when the load call completes
|
|
159 @param data user data for callback
|
|
160 @param data_free optional cleanup function for user data
|
|
161 */
|
|
162 void mwServiceStorage_load(struct mwServiceStorage *srvc,
|
|
163 struct mwStorageUnit *item,
|
|
164 mwStorageCallback cb,
|
|
165 gpointer data, GDestroyNotify data_free);
|
|
166
|
|
167
|
|
168 /** Initiates a store call to the storage service. If the service is
|
|
169 not currently available, the call will be cached and processed
|
|
170 when the service is started.
|
|
171 @param item storage unit to save
|
|
172 @param cb callback function when the load call completes
|
|
173 @param data optional user data for callback
|
|
174 @param data_free optional cleanup function for user data
|
|
175 */
|
|
176 void mwServiceStorage_save(struct mwServiceStorage *srvc,
|
|
177 struct mwStorageUnit *item,
|
|
178 mwStorageCallback cb,
|
|
179 gpointer data, GDestroyNotify data_free);
|
|
180
|
|
181
|
|
182 #endif
|