#include "mgutils.h"
#include "addrcache.h"
+#include "utils.h"
#define ID_TIME_OFFSET 998000000
#define ADDRCACHE_MAX_SEARCH_COUNT 1000
*/
static void addrcache_free_item_hash( GHashTable *table ) {
g_return_if_fail( table != NULL );
- g_hash_table_freeze( table );
g_hash_table_foreach_remove( table, addrcache_free_item_vis, NULL );
- g_hash_table_thaw( table );
}
/*
struct stat filestat;
retVal = TRUE;
if( path ) {
- if( 0 == lstat( path, &filestat ) ) {
+ if( 0 == g_stat( path, &filestat ) ) {
if( filestat.st_mtime == cache->modifyTime ) retVal = FALSE;
}
}
gboolean retVal = FALSE;
struct stat filestat;
if( path ) {
- if( 0 == lstat( path, &filestat ) ) {
+ if( 0 == g_stat( path, &filestat ) ) {
cache->modifyTime = filestat.st_mtime;
retVal = TRUE;
}
fprintf( stream, "cache id : %s\n", cache->cacheID );
fprintf( stream, "next id : %d\n", cache->nextID );
fprintf( stream, "name : %s\n", cache->name );
- fprintf( stream, "mod time : %ld\n", cache->modifyTime );
+ fprintf( stream, "mod time : %ld\n", (long int)cache->modifyTime );
fprintf( stream, "modified : %s\n", cache->modified ? "yes" : "no" );
fprintf( stream, "data read: %s\n", cache->dataRead ? "yes" : "no" );
}
return NULL;
}
-/*
-* Add person and address data to cache.
-* Enter: cache Cache.
-* folder Folder where to add person, or NULL for root folder.
-* name Common name.
-* address EMail address.
-* remarks Remarks.
-* Return: Person added. Do not *NOT* to use the addrbook_free_xxx() functions...
-* this will destroy the address book data.
-*/
-ItemPerson *addrcache_add_contact( AddressCache *cache, ItemFolder *folder, const gchar *name,
+/**
+ * Add person and address data to cache.
+ * \param cache Cache.
+ * \param folder Folder where to add person, or NULL for root folder.
+ * \param name Common name.
+ * \param address EMail address.
+ * \param remarks Remarks.
+ * \return Person added. Do not *NOT* to use the
+ * <code>addrbook_free_xxx()</code> functions...; this will destroy
+ * the address book data.
+ */
+ItemPerson *addrcache_add_contact(
+ AddressCache *cache, ItemFolder *folder, const gchar *name,
const gchar *address, const gchar *remarks )
{
ItemPerson *person = NULL;
return person;
}
+/**
+ * Create a new folder and add to address cache.
+ * \param cache Address cache.
+ * \param folder Parent folder where to add folder, or <i>NULL</i> for
+ * root folder.
+ * \return Folder that was created. This should <b>*NOT*</b> be
+ * <code>g_free()</code> when done.
+ */
+ItemFolder *addrcache_add_new_folder( AddressCache *cache, ItemFolder *parent )
+{
+ ItemFolder *folder;
+ ItemFolder *p = parent;
+
+ g_return_val_if_fail( cache != NULL, NULL );
+
+ if( !p ) p = cache->rootFolder;
+ folder = addritem_create_item_folder();
+ addrcache_id_folder( cache, folder );
+ if( addrcache_hash_add_folder( cache, folder ) ) {
+ p->listFolder = g_list_append( p->listFolder, folder );
+ ADDRITEM_PARENT(folder) = ADDRITEM_OBJECT(p);
+ addrcache_set_dirty( cache, TRUE );
+ }
+ else {
+ addritem_free_item_folder( folder );
+ folder = NULL;
+ }
+ return folder;
+}
+
/*
* End of Source.
*/