* mu-msg-cache: add support for GSList* values
This commit is contained in:
@ -17,15 +17,17 @@
|
|||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <mu-msg-flags.h>
|
#include "mu-msg-flags.h"
|
||||||
#include <mu-msg-prio.h>
|
#include "mu-msg-prio.h"
|
||||||
|
|
||||||
#include "mu-msg-cache.h"
|
#include "mu-msg-cache.h"
|
||||||
|
#include "mu-str.h"
|
||||||
|
|
||||||
struct _MuMsgCache {
|
struct _MuMsgCache {
|
||||||
|
|
||||||
/* all string properties */
|
/* all string properties */
|
||||||
char *_str[MU_MSG_STRING_FIELD_ID_NUM];
|
char *_str[MU_MSG_STRING_FIELD_ID_NUM];
|
||||||
|
|
||||||
|
GSList *_refs;
|
||||||
|
|
||||||
time_t _timestamp, _date;
|
time_t _timestamp, _date;
|
||||||
size_t _size;
|
size_t _size;
|
||||||
@ -123,6 +125,49 @@ mu_msg_cache_str (MuMsgCache *cache, MuMsgFieldId mfid)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const GSList*
|
||||||
|
mu_msg_cache_set_str_list (MuMsgCache *self, MuMsgFieldId mfid,
|
||||||
|
GSList *lst, gboolean do_free)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail(self, NULL);
|
||||||
|
g_return_val_if_fail(mu_msg_field_is_string_list(mfid), NULL);
|
||||||
|
|
||||||
|
switch (mfid) {
|
||||||
|
case MU_MSG_FIELD_ID_REFS:
|
||||||
|
if (is_allocated(self, mfid))
|
||||||
|
mu_str_free_list (self->_refs);
|
||||||
|
self->_refs = lst;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
g_return_val_if_reached(NULL);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
set_cached (self, mfid);
|
||||||
|
|
||||||
|
if (do_free)
|
||||||
|
set_allocated (self, mfid);
|
||||||
|
else
|
||||||
|
reset_allocated (self, mfid);
|
||||||
|
|
||||||
|
return lst;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const GSList*
|
||||||
|
mu_msg_cache_str_list (MuMsgCache *self, MuMsgFieldId mfid)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (mu_msg_field_is_string_list(mfid), NULL);
|
||||||
|
|
||||||
|
switch (mfid) {
|
||||||
|
case MU_MSG_FIELD_ID_REFS:
|
||||||
|
return self->_refs;
|
||||||
|
default:
|
||||||
|
g_return_val_if_reached(NULL);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
gint64
|
gint64
|
||||||
mu_msg_cache_set_num (MuMsgCache *self, MuMsgFieldId mfid, gint64 val)
|
mu_msg_cache_set_num (MuMsgCache *self, MuMsgFieldId mfid, gint64 val)
|
||||||
|
|||||||
@ -84,6 +84,30 @@ const char* mu_msg_cache_str (MuMsgCache *cache, MuMsgFieldId mfid);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cache a string-list value
|
||||||
|
*
|
||||||
|
* @param self a mumsgcache
|
||||||
|
* @param mfid the MessageFieldId for a string-list value
|
||||||
|
* @param lst the list
|
||||||
|
* @param do_free whether the cache should free this value (i.e, take ownership)
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
const GSList* mu_msg_cache_set_str_list (MuMsgCache *self, MuMsgFieldId mfid,
|
||||||
|
GSList *lst, gboolean do_free);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get a string-list value from the cache
|
||||||
|
*
|
||||||
|
* @param cache a MuMsgCache
|
||||||
|
* @param mfid the MessageFieldId for string-list value
|
||||||
|
*
|
||||||
|
* @return a list, which should not be modified
|
||||||
|
*/
|
||||||
|
const GSList* mu_msg_cache_str_list (MuMsgCache *cache, MuMsgFieldId mfid);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add a numeric value to the cache
|
* add a numeric value to the cache
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user