]> code.citadel.org Git - citadel.git/blobdiff - citadel/context.c
Moved BumpNewMailCounter() into context.c because it manipulates contexts.
[citadel.git] / citadel / context.c
index 3122e5c06b102dd55cc63fc2ef996e25ab18e0f2..c7902af980ad2fb743d8927f7529b3074e72fbfa 100644 (file)
@@ -129,6 +129,32 @@ int CtdlIsSingleUser(void)
 
 
 
+/*
+ * Check to see if the user who we just sent mail to is logged in.  If yes,
+ * bump the 'new mail' counter for their session.  That enables them to
+ * receive a new mail notification without having to hit the database.
+ */
+void BumpNewMailCounter(long which_user) 
+{
+       CtdlBumpNewMailCounter(which_user);
+}
+
+void CtdlBumpNewMailCounter(long which_user)
+{
+       CitContext *ptr;
+
+       begin_critical_section(S_SESSION_TABLE);
+
+       for (ptr = ContextList; ptr != NULL; ptr = ptr->next) {
+               if (ptr->user.usernum == which_user) {
+                       ptr->newmail += 1;
+               }
+       }
+
+       end_critical_section(S_SESSION_TABLE);
+}
+
+
 /*
  * Check to see if a user is currently logged in
  * Take care with what you do as a result of this test.
@@ -151,6 +177,32 @@ int CtdlIsUserLoggedIn (char *user_name)
        return ret;
 }
 
+
+
+/*
+ * Check to see if a user is currently logged in.
+ * Basically same as CtdlIsUserLoggedIn() but uses the user number instead.
+ * Take care with what you do as a result of this test.
+ * The user may not have been logged in when this function was called BUT
+ * because of threading the user might be logged in before you test the result.
+ */
+int CtdlIsUserLoggedInByNum (long usernum)
+{
+       CitContext *cptr;
+       int ret = 0;
+
+       begin_critical_section(S_SESSION_TABLE);
+       for (cptr = ContextList; cptr != NULL; cptr = cptr->next) {
+               if (cptr->user.usernum == usernum) {
+                       ret = 1;
+               }
+       }
+       end_critical_section(S_SESSION_TABLE);
+       return ret;
+}
+
+
+
 /*
  * Return a pointer to the CitContext structure bound to the thread which
  * called this function.  If there's no such binding (for example, if it's