aboutsummaryrefslogtreecommitdiffstats
path: root/storage.c
diff options
context:
space:
mode:
authorSven Moritz Hallberg <pesco@khjk.org>2009-03-12 20:10:06 +0100
committerSven Moritz Hallberg <pesco@khjk.org>2009-03-12 20:10:06 +0100
commit823de9d44f262ea2364ac8ec6a1e18e0f7dab658 (patch)
treebfe64e4fafbcd13aaef6a436cab6ad91619e2821 /storage.c
parent9b55485a6f9d72334b372e6fb6b60bbde943170d (diff)
commit updates by ashish shukla <wahjava@gmail.com>
Diffstat (limited to 'storage.c')
-rw-r--r--storage.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/storage.c b/storage.c
index 6a62af83..0ff2d34d 100644
--- a/storage.c
+++ b/storage.c
@@ -103,36 +103,52 @@ storage_status_t storage_check_pass (const char *nick, const char *password)
return STORAGE_NO_SUCH_USER;
}
-storage_status_t storage_load (const char *nick, const char *password, irc_t * irc)
+storage_status_t storage_load (irc_t * irc, const char *password)
{
GList *gl;
+ if (irc && irc->status & USTATUS_IDENTIFIED)
+ return STORAGE_OTHER_ERROR;
+
/* Loop until we don't get NO_SUCH_USER */
for (gl = global.storage; gl; gl = gl->next) {
storage_t *st = gl->data;
storage_status_t status;
- status = st->load(nick, password, irc);
+ status = st->load(irc, password);
if (status == STORAGE_OK) {
- irc_setpass(irc, password);
- otr_load(irc); /* load our OTR userstate */
+ otr_load(irc);
return status;
}
- if (status != STORAGE_NO_SUCH_USER) {
+ if (status != STORAGE_NO_SUCH_USER)
return status;
- }
}
return STORAGE_NO_SUCH_USER;
}
-storage_status_t storage_save (irc_t *irc, int overwrite)
+storage_status_t storage_save (irc_t *irc, char *password, int overwrite)
{
storage_status_t st;
+ if (password != NULL) {
+ /* Should only use this in the "register" command. */
+ if (irc->password || overwrite)
+ return STORAGE_OTHER_ERROR;
+
+ irc_setpass(irc, password);
+ } else if ((irc->status & USTATUS_IDENTIFIED) == 0) {
+ return STORAGE_NO_SUCH_USER;
+ }
+
otr_save(irc);
st = ((storage_t *)global.storage->data)->save(irc, overwrite);
+
+ if (password != NULL) {
+ irc_setpass(irc, NULL);
+ }
+
return st;
}
@@ -149,8 +165,7 @@ storage_status_t storage_remove (const char *nick, const char *password)
storage_status_t status;
status = st->remove(nick, password);
- if (status != STORAGE_NO_SUCH_USER &&
- status != STORAGE_OK)
+ if (status != STORAGE_NO_SUCH_USER && status != STORAGE_OK)
ret = status;
}
if (ret == STORAGE_OK) {
@@ -160,6 +175,9 @@ storage_status_t storage_remove (const char *nick, const char *password)
return ret;
}
+#if 0
+Not using this yet. Test thoroughly before adding UI hooks to this function.
+
storage_status_t storage_rename (const char *onick, const char *nnick, const char *password)
{
storage_status_t status;
@@ -201,3 +219,4 @@ storage_status_t storage_rename (const char *onick, const char *nnick, const cha
return STORAGE_OK;
}
+#endif