diff -cr wmpop3-0.5.6a/wmpop3/wmpop3.c wmpop3-0.5.6a-ma/wmpop3/wmpop3.c
*** wmpop3-0.5.6a/wmpop3/wmpop3.c	Sat Aug 14 00:56:19 1999
--- wmpop3-0.5.6a-ma/wmpop3/wmpop3.c	Thu Feb  7 01:56:09 2002
***************
*** 46,59 ****
  #define SEC_IN_MIN 60
  #define YES 1
  #define NO 0
  
  char *ProgName;
  
  char mailclient[32]   = "pine";
! char password[32];
! char username[32];
! char popserver[128];
! int  serverport       = 110;
  int  mailCheckDelay   = 10;  /* default */
  int  autoChecking     = YES; /* default */
  int  newMessagesOnly  = YES; /* default */
--- 46,60 ----
  #define SEC_IN_MIN 60
  #define YES 1
  #define NO 0
+ #define MAXACOUNTS 8
  
  char *ProgName;
  
  char mailclient[32]   = "pine";
! char password[MAXACOUNTS][32];
! char username[MAXACOUNTS][32];
! char popserver[MAXACOUNTS][128];
! int  serverport[MAXACOUNTS];
  int  mailCheckDelay   = 10;  /* default */
  int  autoChecking     = YES; /* default */
  int  newMessagesOnly  = YES; /* default */
***************
*** 127,153 ****
  
  void wmCheckMail_routine(int argc, char **argv){
  
!     int    mailWaiting    = 0;
!     int    totalMessages  = 0;
      long   startTime      = 0;
      long   nextCheckTime  = 0;
!     int    forcedCheck    = NO;
  	int	   buttonStatus   =-1;
      int	   i;
  	XEvent Event;
!     Pop3   pc;
  
      if( !strcmp( config_file, "not-defined") )
          sprintf(config_file, "%s/.wmpop3rc", getenv("HOME"));
  
!     if( readConfigFile(config_file) == -1){
          exit(0);
      }
!     pc =pop3Create();     /* initialize Pop3 ADT */
  
      /* Set up timer for checking mail */
      startTime     = time(0);  
!     nextCheckTime = 0; /* Make 0, so it checks for mail on start */
  
      
  	createXBMfromXPM(wminet_mask_bits, wmpop3_xpm
--- 128,167 ----
  
  void wmCheckMail_routine(int argc, char **argv){
  
!     int    accounts , checkingAccount = 0;
!     int    mailWaiting[MAXACOUNTS];
!     int    mailWaitingAll=0;
!     int    totalMessages[MAXACOUNTS];
!     int    totalMessagesAll=0;
      long   startTime      = 0;
      long   nextCheckTime  = 0;
!     int    forcedCheck    = YES;
!     int    checkAll       = YES;
!     int    showingAccount = -1;
  	int	   buttonStatus   =-1;
      int	   i;
+     int    ifErr = NO;
  	XEvent Event;
!     Pop3   pc[MAXACOUNTS];
! 
!     for(i=0;i<MAXACOUNTS;i++){
!        mailWaiting[i]=0;
!        totalMessages[i]=0;
!     }
  
      if( !strcmp( config_file, "not-defined") )
          sprintf(config_file, "%s/.wmpop3rc", getenv("HOME"));
  
!     if((accounts = readConfigFile(config_file)) == -1){
          exit(0);
      }
! 
!     for(i=0;i<=accounts;i++)
!       pc[i] =pop3Create();     /* initialize Pop3 ADT */
  
      /* Set up timer for checking mail */
      startTime     = time(0);  
!     nextCheckTime = time(0) + (mailCheckDelay * SEC_IN_MIN);
  
      
  	createXBMfromXPM(wminet_mask_bits, wmpop3_xpm
***************
*** 165,218 ****
      /* Check if Autochecking is on or off */
      if(autoChecking == NO ){
          copyXPMArea(67, 7 ,4 ,4 ,52 ,7 ); 
      }
  
      RedrawWindow();
  
      
      while (1){
!         if( (((time(0) > nextCheckTime) || (nextCheckTime == 0))
!                             && ( autoChecking == YES)) 
                              || (forcedCheck == YES)){ 
!             if(pop3MakeConnection(pc,popserver,serverport) == -1){
!                 mailWaiting = -1;
              }
!             else if( pop3Login(pc, username,password) == -1 ){
!                 mailWaiting = -1;
              }
  
!             else if( (pop3CheckMail(pc)) == -1){
!                 mailWaiting = -1;
              }
              else{
!                 mailWaiting = pop3GetNumberOfUnreadMessages(pc);
!                 totalMessages = pop3GetTotalNumberOfMessages(pc);
              }
!             if( forcedCheck == YES )
                  forcedCheck = NO;
!             pop3Quit(pc);
              nextCheckTime = time(0) + (mailCheckDelay * SEC_IN_MIN);
          }
  
  		waitpid(0, NULL, WNOHANG);
  
!         if( mailWaiting == -1 ){
              /* Error connecting to pop server */
!             BlitString("::error::", 5, (11*(4-1)) + 5);
!         }
!         else{
!             if( newMessagesOnly == YES ){
!                 /* Show unread messages only */
!                 BlitString("mesg :   ", 5, (11*(4-1)) + 5);
!                 BlitNum(mailWaiting, 45, (11*(4-1)) + 5);
!             }else{
!                 /* Show unread Mesaages and Read messages */
                  BlitString("    /    ", 5, (11*(4-1)) + 5);
!                 BlitNum(mailWaiting, 15, (11*(4-1)) + 5);
!                 BlitNum(totalMessages, 39, (11*(4-1)) + 5);
!             }
!         }
!         if( mailWaiting == 0)
              copyXPMArea(72, 33, 45, 28, 4, 4 );
          else
              copyXPMArea(72, 2, 45, 28, 4, 4 );
--- 179,261 ----
      /* Check if Autochecking is on or off */
      if(autoChecking == NO ){
          copyXPMArea(67, 7 ,4 ,4 ,52 ,7 ); 
+         forcedCheck = NO;
      }
  
      RedrawWindow();
  
      
      while (1){
!         if( ((time(0) > nextCheckTime) && (autoChecking == YES))
                              || (forcedCheck == YES)){ 
! 
!             if(pop3MakeConnection(pc[checkingAccount],popserver[checkingAccount],serverport[checkingAccount]) == -1){
!                 mailWaiting[checkingAccount] = -1;
              }
!             else if( pop3Login(pc[checkingAccount], username[checkingAccount],password[checkingAccount]) == -1 ){
!                 mailWaiting[checkingAccount] = -1;
              }
  
!             else if( (pop3CheckMail(pc[checkingAccount])) == -1){
!                 mailWaiting[checkingAccount] = -1;
              }
              else{
!                 mailWaiting[checkingAccount] = pop3GetNumberOfUnreadMessages(pc[checkingAccount]);
!                 totalMessages[checkingAccount] = pop3GetTotalNumberOfMessages(pc[checkingAccount]);
              }
!             if((forcedCheck == YES)&&((checkAll == NO)||(checkingAccount == accounts)))
                  forcedCheck = NO;
!             pop3Quit(pc[checkingAccount]);
              nextCheckTime = time(0) + (mailCheckDelay * SEC_IN_MIN);
+             if(mailWaiting[checkingAccount] != -1){
+                 mailWaitingAll = 0;
+                 totalMessagesAll = 0;
+                 for(i=0;i<=accounts;i++){
+                   if(mailWaiting[i] != -1){
+                     mailWaitingAll += mailWaiting[i];
+                     totalMessagesAll += totalMessages[i];
+                   }
+                 }
+             }
+             checkingAccount ++;
+             if(checkingAccount > accounts)
+                 checkingAccount = 0;
          }
  
  		waitpid(0, NULL, WNOHANG);
  
!           for(i=0;i<=accounts;i++){
!             if(mailWaiting[i] == -1){
!               ifErr = YES;
!               break;
!             }
!             ifErr = NO;
!           }
! 
!           if((ifErr == YES) && (showingAccount == -1)){
              /* Error connecting to pop server */
!             BlitString("e", 52,23);
!           }
!           else
!             BlitString(" ", 52,23);
! 
!              if(showingAccount == -1){
                  BlitString("    /    ", 5, (11*(4-1)) + 5);
!                 BlitNum(mailWaitingAll, 15, (11*(4-1)) + 5);
!                 BlitNum(totalMessagesAll, 39, (11*(4-1)) + 5);
!              }
!              else{
!                 BlitString("ac   :   ", 5, (11*(4-1)) + 5);
!                 BlitNum(showingAccount+1,20, (11*(4-1)) + 5);
!                 if(mailWaiting[showingAccount] == -1)
!                   BlitString("er", 45, (11*(4-1)) + 5);
!                 else if(newMessagesOnly == YES)
!                   BlitNum(mailWaiting[showingAccount], 45, (11*(4-1)) + 5);
!                 else
!                   BlitNum(totalMessages[showingAccount], 45, (11*(4-1)) + 5);
!              }
! 
!         if( mailWaitingAll == 0)
              copyXPMArea(72, 33, 45, 28, 4, 4 );
          else
              copyXPMArea(72, 2, 45, 28, 4, 4 );
***************
*** 239,256 ****
                      switch (buttonStatus){
                          case 0 : /* Middle button pressed */
                               copyXPMArea(128,29 ,27 ,8 ,18 ,49 );
-                              nextCheckTime = 0;
                              break;
                          case 1 : /* Left button pressed */
                              copyXPMArea(128,16 ,11 ,8 ,6 ,49 );
                              break;
                          case 2: /* right button pressed */
                              copyXPMArea(128,2 ,11 ,8 ,46 ,49 );
-                             /* change view on # of messages */
-                             if( newMessagesOnly == YES )
-                                 newMessagesOnly = NO;
-                             else
-                                 newMessagesOnly = YES;
                              break;
                          case 3:
                              execCommand(mailclient);
--- 282,293 ----
***************
*** 270,275 ****
--- 307,320 ----
                      switch (buttonStatus){
                          case 0 :   /* Middle button */
                              copyXPMArea(128,39 ,27 ,8 ,18 ,49 );
+                                 if(showingAccount == -1){
+                                   checkAll = YES;
+                                   checkingAccount = 0;
+                                 }
+                                 else{
+                                   checkAll = NO;
+                                   checkingAccount = showingAccount;
+                                 }
                                  forcedCheck = YES;
                              break;
                          case 1 :   /* Left Button */
***************
*** 286,291 ****
--- 331,339 ----
                               break;
                          case 2:  /* Right Button */
                              copyXPMArea(144,3 ,11 ,8 ,46 ,49 );
+                             showingAccount ++ ;
+                             if(showingAccount > accounts)
+                               showingAccount = -1;
                              break;
                          case 3:
                              break;
***************
*** 388,502 ****
      
  
  int  readConfigFile( char *filename ){
!     char buf[256];
!     char temp[32];
!     char *ptr = 0;
!     FILE *fp;
! 
      if( (fp = fopen( filename, "r")) == 0 ){
!         sprintf(config_file, "%s/.wmpop3rc", getenv("HOME"));
!         printf("-Config file does not exit : %s\n",config_file);
!         printf("+Trying to create new config file.\n");
!         if((fp = fopen(config_file,"w")) == 0){
!             printf("-Error creating new config file\n");
!             return -1;
!         }
!         fprintf(fp,"# Replace all < > with appropriate data\n#\n");
!         fprintf(fp,"popserver          < pop3 server name >\n");
!         fprintf(fp,"port               110    # default port\n");
!         fprintf(fp,"username           < pop3 login name  >\n");
!         fprintf(fp,"password           < pop3 password   >\n");
!         fprintf(fp,"autochecking       0      # 1 enables, 0 disables\n");
!         fprintf(fp,"mailcheckdelay     10     # default mail check time in minutes\n");
!         fprintf(fp,"viewallmessages    0      # 0 Shows both read and unread messages\n");
!         fprintf(fp,"#                           and 1 shows only unread messages\n");
!         fprintf(fp,"mailclient         pine  # default mail client\n");
!         printf("+New config file created : ~/.wmpop3rc\n\n");
!         printf("+ ~/.wmpop3rc must be configured before running wmpop3.\n");
!         fclose(fp);
!         return -1;
      }
  
!     while( fgets(buf, 256, fp) != 0){
  
!         ptr = strtok( buf," \n" );
  
!         if( ( ptr != 0) && (ptr[0] != '#') ){
!             if( !strcmp(ptr, "username") ){
!                 ptr = strtok( 0, " \n");
!                 if( ptr == 0){
!                     printf("Invalid UserName.\n");
!                     return -1;
!                 }
!                 strcpy(username, ptr); 
!             }
!             else if( !strcmp( ptr, "password") ){
!                 ptr = strtok( 0, " \n");
!                 if( ptr == 0){
!                     printf("Invalid password.\n");
!                     return -1;
!                 }
!                 strcpy(password, ptr); 
!             }
!             else if( !strcmp( ptr, "popserver") ){
!                 ptr = strtok( 0, " \n");
!                 if( ptr == 0){
!                     printf("Invalid popserver address.\n");
!                     return -1;
!                 }
!                 strcpy(popserver, ptr); 
!             }
!             else if( !strcmp( ptr, "mailclient") ){
!                 ptr = strtok( 0, " \n");
!                 if( ptr == 0){
!                     printf("Invalid mailclient.\n");
!                     return -1;
!                 }
!                 strcpy(mailclient, ptr); 
!             }
!             else if( !strcmp( ptr, "port") ){
!                 ptr = strtok( 0, " \n");
!                 if( ptr == 0){
!                     printf("Invalid popserver port number.\n");
!                     return -1;
!                 }
!                 if( sscanf(ptr,"%[0123456789]",temp) == 0)
!                     serverport = 110;
!                 else
!                     serverport = atoi(temp);
!             }
!             else if( !strcmp( ptr, "viewallmessages") ){
!                 ptr = strtok( 0, " \n");
!                 if( ptr == 0){
!                     printf("Invalid number. ( viewallmessages )\n");
!                     return -1;
!                 }
!                 if( sscanf(ptr,"%[0123456789]",temp) != 0)
!                     newMessagesOnly = atoi(temp);
!             }
!             else if( !strcmp( ptr, "mailcheckdelay") ){
!                 ptr = strtok( 0, " \n");
!                 if( ptr == 0){
!                     printf("Invalid delay time.\n");
!                     return -1;
!                 }
!                 if( sscanf(ptr,"%[0123456789]",temp) != 0)
!                     mailCheckDelay = atoi(temp);
!             }
!             else if( !strcmp( ptr, "autochecking") ){
!                 ptr = strtok( 0, " \n");
!                 if( ptr == 0){
!                     printf("Invalid value.\n");
!                     return -1;
!                 }
!                 if( sscanf(ptr,"%[0123456789]",temp) != 0)
!                     autoChecking = atoi(temp);
!             }
!             else
!                 printf("Unknown indenifier : %s\n",ptr);
          }
      }
!     fclose(fp);
!     return 0;
! }
  
--- 436,588 ----
      
  
  int  readConfigFile( char *filename ){
!   int i;
!   char buf[256];
!   char temp[32];
!   char *ptr = 0;
!   FILE *fp;
! 
!   for(i=0;i<MAXACOUNTS;i++)
!     serverport[i]=110;
! 
!   if( (fp = fopen( filename, "r")) == 0 ){
!     printf("-Config file does not exit : %s\n",config_file);
!     printf("+Trying to use default config file.\n");
!     sprintf(config_file, "%s/.wmpop3rc", getenv("HOME"));
!     sprintf(filename, config_file);
      if( (fp = fopen( filename, "r")) == 0 ){
!       printf("-Config file does not exit : %s\n",config_file);
!       printf("+Trying to create new config file.\n");
!       if((fp = fopen(config_file,"w")) == 0){
! 	printf("-Error creating new config file\n");
! 	return -1;
!       }
!       fprintf(fp,"# Replace all < > with appropriate data\n#\n");
!       fprintf(fp,"# Apprication settings\n");
!       fprintf(fp,"mailclient         pine  # default mail client\n");
!       fprintf(fp,"autochecking       0      # 1 enables, 0 disables\n");
!       fprintf(fp,"mailcheckdelay     2      # default mail check time in minutes\n");
!       fprintf(fp,"viewallmessages    1      # 0 Shows both read and unread messages\n");
!       fprintf(fp,"#                           and 1 shows only unread messages\n");
!       fprintf(fp,"#                           when showing each account\n");
!       fprintf(fp,"#\n# Server settings\n");
!       fprintf(fp,"# You can define %d or less accounts.\n{\n",MAXACOUNTS);
!       fprintf(fp,"popserver          < pop3 server name >\n");
!       fprintf(fp,"port               110    # default port\n");
!       fprintf(fp,"username           < pop3 login name  >\n");
!       fprintf(fp,"password           < pop3 password   >\n}\n{\n");
!       fprintf(fp,"popserver          < pop3 server name >\n");
!       fprintf(fp,"port               110    # default port\n");
!       fprintf(fp,"username           < pop3 login name  >\n");
!       fprintf(fp,"password           < pop3 password   >\n}\n");
!       printf("+New config file created : ~/.wmpop3rc\n\n");
!       printf("+ ~/.wmpop3rc must be configured before running wmpop3.\n");
!       fclose(fp);
!       return -1;
      }
+   }
  
!   while((fgets(buf, 256, fp) != 0)&&(buf[0] != '{')){
  
!     ptr = strtok( buf," \n" );
  
!     if( ( ptr != 0) && (ptr[0] != '#') ){
!       if( !strcmp( ptr, "mailclient") ){
! 	ptr = strtok( 0, " \n");
! 	if( ptr == 0){
! 	  printf("Invalid mailclient.\n");
! 	  return -1;
! 	}
! 	strcpy(mailclient, ptr); 
!       }
!       else if( !strcmp( ptr, "viewallmessages") ){
!   	ptr = strtok( 0, " \n");
!   	if( ptr == 0){
!   	  printf("Invalid number. ( viewallmessages )\n");
!   	  return -1;
!   	}
!   	if( sscanf(ptr,"%[0123456789]",temp) != 0)
!   	  newMessagesOnly = atoi(temp);
          }
+       else if( !strcmp( ptr, "mailcheckdelay") ){
+ 	ptr = strtok( 0, " \n");
+ 	if( ptr == 0){
+ 	  printf("Invalid delay time.\n");
+ 	  return -1;
+ 	}
+ 	if( sscanf(ptr,"%[0123456789]",temp) != 0)
+ 	  mailCheckDelay = atoi(temp);
+       }
+       else if( !strcmp( ptr, "autochecking") ){
+ 	ptr = strtok( 0, " \n");
+ 	if( ptr == 0){
+ 	  printf("Invalid value.\n");
+ 	  return -1;
+ 	}
+ 	if( sscanf(ptr,"%[0123456789]",temp) != 0)
+ 	  autoChecking = atoi(temp);
+       }
+       else
+ 	printf("Unknown indenifier : %s\n",ptr);
      }
!   }
! 
!   i = -1;
! 
!   do {
! 
!     ptr = strtok( buf," \n" );
! 
!     if( ( ptr != 0) && (ptr[0] != '#') ){
!       if( !strcmp(ptr, "username") ){
! 	ptr = strtok( 0, " \n");
! 	if( ptr == 0){
! 	  printf("Invalid UserName.\n");
! 	  return -1;
! 	}
! 	strcpy(username[i], ptr); 
!       }
!       else if( !strcmp( ptr, "password") ){
! 	ptr = strtok( 0, " \n");
! 	if( ptr == 0){
! 	  printf("Invalid password.\n");
! 	  return -1;
! 	}
! 	strcpy(password[i], ptr); 
!       }
!       else if( !strcmp( ptr, "popserver") ){
! 	ptr = strtok( 0, " \n");
! 	if( ptr == 0){
! 	  printf("Invalid popserver address.\n");
! 	  return -1;
! 	}
! 	strcpy(popserver[i], ptr); 
!       }
!       else if( !strcmp( ptr, "port") ){
! 	ptr = strtok( 0, " \n");
! 	if( ptr == 0){
! 	  printf("Invalid popserver port number.\n");
! 	  return -1;
! 	}
! 	if( sscanf(ptr,"%[0123456789]",temp) == 0)
! 	  serverport[i] = 110;
! 	else
! 	  serverport[i] = atoi(temp);
!       }
!       else if( !strcmp( ptr, "}") ){
!       }
!       else if( !strcmp( ptr, "{") ){
! 	i++;
! 	if(i >= MAXACOUNTS){
! 	  printf("Too much accounts.\n");
! 	  return -1;
! 	}
!       }
!       else
! 	printf("Unknown indenifier : %s\n",ptr);
!     }
!   } while(fgets(buf, 256, fp) != 0);
  
+   fclose(fp);
+   return i;
+ }
diff -cr wmpop3-0.5.6a/wmpop3/wmpop3rc wmpop3-0.5.6a-ma/wmpop3/wmpop3rc
*** wmpop3-0.5.6a/wmpop3/wmpop3rc	Sat Aug 14 00:56:19 1999
--- wmpop3-0.5.6a-ma/wmpop3/wmpop3rc	Thu Feb  7 01:56:29 2002
***************
*** 1,11 ****
  # Replace all < > with appropriate data
! 
! popserver         < pop3 server name > 
! port              110    # default port
! username          < pop3 login name  > 
! password          < pop3 password    >
! viewallmessages   0      # 0 Shows unread and read messages
! #                          1 Shows only unread messages    
! autochecking      1      # 1 enables, 0 disables
! mailcheckdelay    10     # default mail check time in minutes
! mailclient        kmail  # default mail client
--- 1,24 ----
  # Replace all < > with appropriate data
! #
! # Apprication settings
! mailclient         pine  # default mail client
! autochecking       0      # 1 enables, 0 disables
! mailcheckdelay     2      # default mail check time in minutes
! viewallmessages    1      # 0 Shows both read and unread messages
! #                           and 1 shows only unread messages
! #                           when showing each account
! #
! # Server settings
! # You can define 8 or less accounts.
! {
! popserver          < pop3 server name >
! port               110    # default port
! username           < pop3 login name  >
! password           < pop3 password   >
! }
! {
! popserver          < pop3 server name >
! port               110    # default port
! username           < pop3 login name  >
! password           < pop3 password   >
! }
