]> andersk Git - moira.git/commitdiff
make set_pobox and set_pobox_pop deal with imap_id.
authordanw <danw>
Tue, 16 Nov 1999 22:56:04 +0000 (22:56 +0000)
committerdanw <danw>
Tue, 16 Nov 1999 22:56:04 +0000 (22:56 +0000)
server/mr_server.h
server/qsetup.pc
server/qsupport.pc
server/queries2.c

index 518bd42a2a515fb8c44c90eba2749227df7e453d..30460129c0651743c73a63598f3638178b6fbcbc 100644 (file)
@@ -207,7 +207,6 @@ int prefetch_value(struct query *q, char *argv[], client *cl);
 int prefetch_filesys(struct query *q, char *argv[], client *cl);
 int setup_ausr(struct query *q, char *argv[], client *cl);
 int setup_dusr(struct query *q, char *argv[], client *cl);
-int setup_spop(struct query *q, char *argv[], client *cl);
 int setup_dpob(struct query *q, char *argv[], client *cl);
 int setup_dmac(struct query *q, char *argv[], client *cl);
 int setup_dclu(struct query *q, char *argv[], client *cl);
@@ -230,6 +229,7 @@ int setup_dpsv(struct query *q, char *argv[], client *cl);
 
 /* prototypes from qsupport.pc */
 int set_pobox(struct query *q, char *argv[], client *cl);
+int set_pobox_pop(struct query *q, char *argv[], client *cl);
 int add_member_to_list(struct query *q, char *argv[], client *cl);
 int delete_member_from_list(struct query *q, char *argv[], client *cl);
 int register_user(struct query *q, char *argv[], client *cl);
index 2baf45eca6c2e0037181fecdc072ed8d41d3de44..86b00c06ebe56a6caa3770e7d6b14fdccfab9195 100644 (file)
@@ -131,31 +131,6 @@ int setup_dusr(struct query *q, char *argv[], client *cl)
 }
 
 
-/* setup_spop: verify that there is already a valid POP machine_id in the
- * pop_id field.  Also take care of keeping track of the post office usage.
- */
-int setup_spop(struct query *q, char *argv[], client *cl)
-{
-  EXEC SQL BEGIN DECLARE SECTION;
-  int id, mid;
-  char type[USERS_POTYPE_SIZE];
-  EXEC SQL END DECLARE SECTION;
-
-  id = *(int *)argv[0];
-  EXEC SQL SELECT potype, pop_id INTO :type, :mid FROM users
-    WHERE users_id = :id;
-  if (sqlca.sqlerrd[2] == 0)
-    return MR_MACHINE;
-  EXEC SQL SELECT mach_id INTO :mid FROM machine
-    WHERE mach_id = :mid;
-  if (sqlca.sqlerrd[2] == 0)
-    return MR_MACHINE;
-  if (strcmp(strtrim(type), "POP"))
-    set_pop_usage(mid, 1);
-  return MR_SUCCESS;
-}
-
-
 /* setup_dpob:  Take care of keeping track of the post office usage.
  */
 int setup_dpob(struct query *q, char *argv[], client *cl)
index 40d0698a0fe7080df66bf4a15ab5791a46711b99..9ec1a33e40cb1dc329b32dad2e66010de7bef403 100644 (file)
@@ -39,11 +39,11 @@ int qualified_get(struct query *q, char *argv[],
 /* set_pobox - this does all of the real work.
  *      argv = user_id, type, box
  * if type is POP, then box should be a machine, and its ID should be put in
- * pop_id.  If type is SMTP, then box should be a string and its ID should
- * be put in box_id.  If type is NONE, then box doesn't matter.
+ * pop_id.  If type is IMAP, then box should be a filesys, and its ID should
+ * be put in pop_id.  If type is SMTP, then box should be a string and its
+ * ID should be put in box_id.  If type is NONE, then box doesn't matter.
  */
 
-
 int set_pobox(struct query *q, char **argv, client *cl)
 {
   EXEC SQL BEGIN DECLARE SECTION;
@@ -69,7 +69,7 @@ int set_pobox(struct query *q, char **argv, client *cl)
        return MR_MACHINE;
       else if (status)
        return status;
-      EXEC SQL UPDATE users SET potype = 'POP', pop_id = :id
+      EXEC SQL UPDATE users SET potype = 'POP', pop_id = :id, imap_id = 0
        WHERE users_id = :user;
       set_pop_usage(id, 1);
     }
@@ -87,12 +87,11 @@ int set_pobox(struct query *q, char **argv, client *cl)
     }
   else if (!strcmp(argv[1], "IMAP"))
     {
-      status = name_to_id(box, FILESYS_TABLE, &id);
-      if (status == MR_NO_MATCH)
+      EXEC SQL SELECT filsys_id INTO :id FROM filesys
+       WHERE label = :box AND type = 'IMAP';
+      if (sqlca.sqlcode)
        return MR_FILESYS;
-      else if (status)
-       return status;
-      EXEC SQL UPDATE users SET potype = 'IMAP', pop_id = :id
+      EXEC SQL UPDATE users SET potype = 'IMAP', imap_id = :id, pop_id = 0
        WHERE users_id = :user;
     }
   else /* argv[1] == "NONE" */
@@ -109,6 +108,50 @@ int set_pobox(struct query *q, char **argv, client *cl)
   return MR_SUCCESS;
 }
 
+/* set_pobox_pop: Revert to existing POP or IMAP pobox.
+ * Also take care of keeping track of the post office usage.
+ */
+int set_pobox_pop(struct query *q, char **argv, client *cl)
+{
+  EXEC SQL BEGIN DECLARE SECTION;
+  int id, pid, iid, mid;
+  char type[USERS_POTYPE_SIZE];
+  EXEC SQL END DECLARE SECTION;
+
+  id = *(int *)argv[0];
+  EXEC SQL SELECT potype, pop_id, imap_id INTO :type, :pid, :iid
+    FROM users WHERE users_id = :id;
+  if (sqlca.sqlerrd[2] == 0 || (pid == 0 && iid == 0))
+    return MR_MACHINE;
+
+  if (pid)
+    {
+      EXEC SQL SELECT mach_id INTO :mid FROM machine
+       WHERE mach_id = :pid;
+      if (sqlca.sqlerrd[2] == 0)
+       return MR_MACHINE;
+      EXEC SQL UPDATE users SET potype = 'POP' WHERE users_id = :id;
+      if (strcmp(strtrim(type), "POP"))
+       set_pop_usage(mid, 1);
+    }
+  else
+    {
+      EXEC SQL SELECT filsys_id INTO :mid FROM filesys
+       WHERE filsys_id = :iid;
+      if (sqlca.sqlerrd[2] == 0)
+       return MR_MACHINE;
+      EXEC SQL UPDATE users SET potype = 'IMAP' WHERE users_id = :id;
+    }
+
+  set_pobox_modtime(q, argv, cl);
+  EXEC SQL UPDATE tblstats SET updates = updates + 1, modtime = SYSDATE
+    WHERE table_name = 'users';
+  if (dbms_errno)
+    return mr_errcode;
+  return MR_SUCCESS;
+}
+
+
 /* Add_member_to_list: do list flattening as we go!  MAXLISTDEPTH is
  * how many different ancestors a member is allowed to have.
  */
index 565e6160e14901c6e70c09c138f75fc87d06f480..d6c7359696aae416373f1216b72827a2181b1ba1 100644 (file)
@@ -515,8 +515,8 @@ static struct validate spop_validate =      /* SET_POBOX_POP */
   0,
   0,
   access_user,
-  setup_spop,
-  set_pobox_modtime,
+  0,
+  set_pobox_pop,
 };
 
 static struct validate dpob_validate = /* DELETE_POBOX */
@@ -2882,7 +2882,7 @@ struct query Queries2[] = {
     RETRIEVE,
     "u",
     USERS_TABLE,
-    "login, potype, pop_id || ':' || box_id, TO_CHAR(pmodtime, 'DD-mon-YYYY HH24:MI:SS'), pmodby, pmodwith FROM users",
+    "login, potype, users_id, TO_CHAR(pmodtime, 'DD-mon-YYYY HH24:MI:SS'), pmodby, pmodwith FROM users",
     gpob_fields,
     6,
     "users_id = %d",
@@ -2914,7 +2914,7 @@ struct query Queries2[] = {
     RETRIEVE,
     "u",
     USERS_TABLE,
-    "login, potype, pop_id || ':' || box_id FROM users",
+    "login, potype, users_id FROM users",
     gpox_fields,
     3,
     "potype = 'POP'",
@@ -2930,7 +2930,7 @@ struct query Queries2[] = {
     RETRIEVE,
     "u",
     USERS_TABLE,
-    "login, potype, pop_id || ':' || box_id FROM users",
+    "login, potype, users_id FROM users",
     gpox_fields,
     3,
     "potype = 'SMTP'",
@@ -2962,11 +2962,11 @@ struct query Queries2[] = {
     UPDATE,
     "u",
     USERS_TABLE,
-    "users SET potype = 'POP'",
+    0,
     spob_fields,
     0,
-    "users_id = %d",
-    1,
+    NULL,
+    0,
     NULL,
     &spop_validate,
   },
This page took 0.06193 seconds and 5 git commands to generate.