]> andersk Git - moira.git/blobdiff - clients/moira/pobox.c
Dribbles of missing EXCHANGE support. This should probably look up the
[moira.git] / clients / moira / pobox.c
index b60f6dc91b06e20e5630ec7ff61cf846a83f8acf..ea55de52e6b807ce5ff0580ddec1e332a07ac08c 100644 (file)
@@ -149,7 +149,8 @@ static char *GetNewLocalPOBox(char *local_user)
 
 static int InsertSortedImapPart(int argc, char **argv, void *arg)
 {
-  struct mqelem *new, *elem, *prev, **parts = arg;
+  struct mqelem *new = NULL;
+  struct mqelem *elem, *prev, **parts = arg;
   int avail = atoi(argv[NFS_SIZE]) - atoi(argv[NFS_ALLOC]);
 
   /* Dup the argv into a new mqelem. */
@@ -205,7 +206,7 @@ static int AddImapPartitions(char *server, struct mqelem **parts)
 char *CreateImapBox(char *user)
 {
   int status;
-  struct mqelem *elem, *servers = NULL, *partitions = NULL;
+  struct mqelem *elem = NULL, *servers = NULL, *partitions = NULL;
   char *server = NULL, *partition = NULL;
   char *argv[11], *fsname, temp_buf[BUFSIZ];
   static char *default_imap_quota = NULL;
@@ -333,6 +334,7 @@ char *CreateImapBox(char *user)
              char **pargv = elem->q_data;
              if (!strcmp(partition, pargv[NFS_DIR]))
                break;
+             elem = elem->q_forw;
            }
          if (!elem)
            {
@@ -395,7 +397,6 @@ int SetUserPOBox(int argc, char **argv)
 {
   int status;
   char *type, temp_buf[BUFSIZ], *local_user, *args[10], *box;
-  char *temp_box;
   struct mqelem *top = NULL;
 
   local_user = argv[1];
@@ -444,7 +445,7 @@ int SetUserPOBox(int argc, char **argv)
            }
          /* Fall through from MR_MACHINE case. */
        case FALSE:
-         type = strdup("POP");
+         type = strdup("IMAP");
          if (GetValueFromUser("Kind of Local PO Box?", &type) == SUB_ERROR)
            {
              free(type);
@@ -461,8 +462,25 @@ int SetUserPOBox(int argc, char **argv)
            {
              free(type);
              type = "IMAP";
-             if ((box = CreateImapBox(local_user)) == (char *) SUB_ERROR)
-               return DM_NORMAL;
+             switch (YesNoQuestion("Create IMAP filesystem (y/n)", TRUE))
+               {
+               case TRUE:
+                 if ((box = CreateImapBox(local_user)) == (char *) SUB_ERROR)
+                   return DM_NORMAL;
+                 break;
+               case FALSE:
+                 box = malloc(strlen(local_user) + 4);
+                 sprintf(box, "%s.po", local_user);
+                 break;
+               default:
+                 return DM_NORMAL;
+               }
+           }
+         else if (!strcasecmp(type, "EXCHANGE"))
+           {
+             free(type);
+             type = "EXCHANGE";
+             box = "EXCHANGE.MIT.EDU";
            }
          else
            {
@@ -486,7 +504,11 @@ int SetUserPOBox(int argc, char **argv)
            return DM_NORMAL;
          if (mrcl_validate_pobox_smtp(local_user, temp_buf, &box) !=
              MRCL_SUCCESS)
-           return DM_NORMAL;
+           {
+             if (mrcl_get_message())
+               Put_message(mrcl_get_message());
+             return DM_NORMAL;
+           }
          break;
        case FALSE:
        default:
@@ -512,6 +534,46 @@ int SetUserPOBox(int argc, char **argv)
   return DM_NORMAL;
 }
 
+/*     Function Name: SplitUserPOBox
+ *     Description: Splits the user's PO Box between local and SMTP
+ *     Arguments: argc, argv - name of user in argv[1].
+ *     Returns: DM_NORMAL.
+ */
+
+int SplitUserPOBox(int argc, char **argv)
+{
+  char temp_buf[BUFSIZ], *args[3], *box;
+  int status;
+
+  if (!ValidName(argv[1]))
+    return DM_NORMAL;
+
+  if (!Prompt_input("Foreign PO Box for this user? ", temp_buf, BUFSIZ))
+    return DM_NORMAL;
+  if (mrcl_validate_pobox_smtp(argv[1], temp_buf, &box) !=
+      MRCL_SUCCESS)
+    {
+      if (mrcl_get_message())
+       Put_message(mrcl_get_message());
+      return DM_NORMAL;
+    }
+
+  args[0] = argv[1];
+  args[1] = "SPLIT";
+  args[2] = box;
+
+  status = do_mr_query("set_pobox", 3, args, NULL, NULL);
+  if (status == MR_MACHINE)
+    Put_message("User has no local PO Box--PO Box unchanged.");
+  else if (status)
+    com_err(program_name, status, " in SplitUserPOBox");
+  else
+    Put_message("PO Box split.");
+  free(box);
+
+  return DM_NORMAL;
+}
+
 /*     Function Name: RemoveUserPOBox
  *     Description: Removes this users POBox.
  *     Arguments: argc, argv - name of user in argv[1].
This page took 0.038738 seconds and 4 git commands to generate.