File: mw_srvc_store.h

package info (click to toggle)
meanwhile 1.0.2-5
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,732 kB
  • ctags: 3,503
  • sloc: ansic: 13,856; sh: 8,360; makefile: 145
file content (196 lines) | stat: -rw-r--r-- 6,047 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196

/*
  Meanwhile - Unofficial Lotus Sametime Community Client Library
  Copyright (C) 2004  Christopher (siege) O'Brien
  
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Library General Public
  License as published by the Free Software Foundation; either
  version 2 of the License, or (at your option) any later version.
  
  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Library General Public License for more details.
  
  You should have received a copy of the GNU Library General Public
  License along with this library; if not, write to the Free
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

#ifndef _MW_SRVC_STORE_H
#define _MW_SRVC_STORE_H


#include <glib.h>
#include "mw_common.h"


#ifdef __cplusplus
extern "C" {
#endif


/** Type identifier for the storage service */
#define mwService_STORAGE  0x00000018


/** @struct mwServiceStorage
    @see mwServiceStorage_new

    Instance of the storage service */
struct mwServiceStorage;


/** @struct mwStorage

    Unit Represents information intended for loading from or saving to
    the storage service */
struct mwStorageUnit;


/** The upper limit of reserved Lotus keys */
#define LOTUS_RESERVED_LIMIT  0x186a0


/** Check if a key is in the range of Lotus reserved keys */
#define KEY_IS_LOTUS_RESERVED(key) \
  (((guint32) key) <= (LOTUS_RESERVED_LIMIT))


/** Some common keys storage keys. Anything in the range 0x00 to
    0x186a0 (100000) is reserved for use by the Lotus
    clients. */
enum mwStorageKey {

  /** The buddy list, in the Sametime .dat file format. String */
  mwStore_AWARE_LIST      = 0x00000000,

  /** Default text for chat invitations. String */
  mwStore_INVITE_CHAT     = 0x00000006,

  /** Default text for meeting invitations. String */
  mwStore_INVITE_MEETING  = 0x0000000e,

  /** Last five Away messages, separated by semicolon. String */
  mwStore_AWAY_MESSAGES   = 0x00000050,

  /** Last five Busy (DND) messages, separated by semicolon. String */
  mwStore_BUSY_MESSAGES   = 0x0000005a,

  /** Last five Active messages, separated by semicolon. String */
  mwStore_ACTIVE_MESSAGES = 0x00000064,
};


/** Appropriate function type for load and store callbacks.
    @param srvc       the storage service
    @param result     the result value of the load or store call
    @param item       the storage unit loaded or saved
    @param data       optional user data
*/
typedef void (*mwStorageCallback)
     (struct mwServiceStorage *srvc,
      guint32 result, struct mwStorageUnit *item,
      gpointer data);


/** Allocates and initializes a storage service instance for use on
    the passed session. */
struct mwServiceStorage *mwServiceStorage_new(struct mwSession *);


/** create an empty storage unit */
struct mwStorageUnit *mwStorageUnit_new(guint32 key);


/** creates a storage unit with the passed key, and a copy of data. */
struct mwStorageUnit *mwStorageUnit_newOpaque(guint32 key,
					      struct mwOpaque *data);


/** creates a storage unit with the passed key, and an encapsulated
    boolean value */
struct mwStorageUnit *mwStorageUnit_newBoolean(guint32 key,
					       gboolean val);


struct mwStorageUnit *mwStorageUnit_newInteger(guint32 key,
					       guint32 val);


/** creates a storage unit with the passed key, and an encapsulated
    string value. */
struct mwStorageUnit *mwStorageUnit_newString(guint32 key,
					      const char *str);


/** get the key for the given storage unit */
guint32 mwStorageUnit_getKey(struct mwStorageUnit *);


/** attempts to obtain a boolean value from a storage unit. If the
    unit is empty, or does not contain the type in a recongnizable
    format, val is returned instead */
gboolean mwStorageUnit_asBoolean(struct mwStorageUnit *, gboolean val);


/** attempts to obtain a guint32 value from a storage unit. If the
    unit is empty, or does not contain the type in a recognizable
    format, val is returned instead */
guint32 mwStorageUnit_asInteger(struct mwStorageUnit *, guint32 val);


/** attempts to obtain a string value from a storage unit. If the unit
    is empty, or does not contain the type in a recognizable format,
    NULL is returned instead. Note that the string returned is a copy,
    and will need to be deallocated at some point. */
char *mwStorageUnit_asString(struct mwStorageUnit *);


/** direct access to the opaque data backing the storage unit */
struct mwOpaque *mwStorageUnit_asOpaque(struct mwStorageUnit *);


/** clears and frees a storage unit */
void mwStorageUnit_free(struct mwStorageUnit *);

      
/** Initiates a load call to the storage service. If the service is
    not currently available, the call will be cached and processed
    when the service is started.

    @param srvc       the storage service
    @param item       storage unit to load
    @param cb         callback function when the load call completes
    @param data       user data for callback
    @param data_free  optional cleanup function for user data
*/
void mwServiceStorage_load(struct mwServiceStorage *srvc,
			   struct mwStorageUnit *item,
			   mwStorageCallback cb,
			   gpointer data, GDestroyNotify data_free);


/** Initiates a store call to the storage service. If the service is
    not currently available, the call will be cached and processed
    when the service is started.

    @param srvc       the storage service
    @param item       storage unit to save
    @param cb         callback function when the load call completes
    @param data       optional user data for callback
    @param data_free  optional cleanup function for user data
 */
void mwServiceStorage_save(struct mwServiceStorage *srvc,
			   struct mwStorageUnit *item,
			   mwStorageCallback cb,
			   gpointer data, GDestroyNotify data_free);


#ifdef __cplusplus
}
#endif


#endif /* _MW_SRVC_STORE_H */