summaryrefslogtreecommitdiff
path: root/plugins/messages-dummy.c
diff options
context:
space:
mode:
authorSlawomir Bochenski <lkslawek@gmail.com>2011-05-30 08:27:32 +0200
committerJohan Hedberg <johan.hedberg@intel.com>2011-05-30 15:38:37 +0300
commitaaedda68fb973f8cd7a17e945e944c0b6fb67f48 (patch)
treee03dfd570eb0057a23a7c300a80232a22ed2ff92 /plugins/messages-dummy.c
parent8b0d38793997b6f7e0cec49e98f8155761b1c959 (diff)
downloadobexd-aaedda68fb973f8cd7a17e945e944c0b6fb67f48.tar.gz
Add messages backend initialization and finalization
This adds functions for initializing and freeing resources used by message storage access backend and example implementation in the dummy (or rather - filesystem) backend. Dummy backend uses $MAP_ROOT (if set) and falls back to $HOME/map-messages for its message storage. This directory should at least contain basic folders required by the MAP specification. It represents the root as seen from the perspective of MAP client. You can prepare it as follows: $ mkdir -p "$MAP_ROOT/telecom/msg/inbox" $ mkdir "$MAP_ROOT/telecom/msg/sent" $ mkdir "$MAP_ROOT/telecom/msg/deleted" $ mkdir "$MAP_ROOT/telecom/msg/outbox"
Diffstat (limited to 'plugins/messages-dummy.c')
-rw-r--r--plugins/messages-dummy.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/plugins/messages-dummy.c b/plugins/messages-dummy.c
index a536d81..3af624d 100644
--- a/plugins/messages-dummy.c
+++ b/plugins/messages-dummy.c
@@ -26,16 +26,38 @@
#endif
#include <errno.h>
+#include <stdlib.h>
#include "messages.h"
+static char *root_folder = NULL;
+
int messages_init(void)
{
+ char *tmp;
+
+ if (root_folder)
+ return 0;
+
+ tmp = getenv("MAP_ROOT");
+ if (tmp) {
+ root_folder = g_strdup(tmp);
+ return 0;
+ }
+
+ tmp = getenv("HOME");
+ if (!tmp)
+ return -ENOENT;
+
+ root_folder = g_build_filename(tmp, "map-messages", NULL);
+
return 0;
}
void messages_exit(void)
{
+ g_free(root_folder);
+ root_folder = NULL;
}
int messages_connect(void **session)