Changeset 7909


Ignore:
Timestamp:
May 12, 2014 9:08:54 AM (7 months ago)
Author:
tboeckel
Message:
  • mui/FolderEditWindow.c: restructured the safety checks before saving the folder's configuration. Especially the mailing list options have been reworked to avoid invalid settings which might cause problems later. This refs #555.
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r7882 r7909  
    55$Id$ 
    66$URL$ 
     7 
     82014-05-12 Thore Böckelmann <tboeckel@gmx.de> 
     9 
     10  * mui/FolderEditWindow.c: restructured the safety checks before saving the 
     11    folder's configuration. Especially the mailing list options have been 
     12    reworked to avoid invalid settings which might cause problems later. This 
     13    refs #555. 
    714 
    8152014-05-11 Thore Böckelmann <tboeckel@gmx.de> 
  • trunk/locale/YAM.pot

    r7884 r7909  
    52015201msgstr "The specified folder name is empty or already exists.\nPlease enter a valid folder name before you proceed." 
    52025202 
    5203 msgctxt "MSG_FO_FOLDERPATHINVALID (1472//)" 
    5204 msgid "You haven't specified a valid path for the new folder." 
    5205 msgstr "You haven't specified a valid path for the new folder." 
    5206  
    52075203msgctxt "MSG_MA_CTX_DEFWIDTH_THIS (1476//)" 
    52085204msgid "Default width: this" 
     
    99379933msgid "Understood" 
    99389934msgstr "Understood" 
     9935 
     9936msgctxt "MSG_FO_PATH_INVALID (2554//)" 
     9937msgid "The path must be non-empty." 
     9938msgstr "The path must be non-empty." 
     9939 
     9940msgctxt "MSG_FO_MLPATTERN_INVALID (2555//)" 
     9941msgid "The pattern (To:/CC:) must be non-empty and no 'catch all'." 
     9942msgstr "The pattern (To:/CC:)  must be non-empty and no 'catch all'." 
     9943 
     9944msgctxt "MSG_FO_MLADDRESS_INVALID (2556//)" 
     9945msgid "The destination address (To:) must be non-empty." 
     9946msgstr "The destination address (To:) must be non-empty." 
  • trunk/src/mui/FolderEditWindow.c

    r7624 r7909  
    168168      break; 
    169169 
    170     if(passwd[0] != '\0' && StringRequest(passwd2, SIZE_PASSWORD, tr(MSG_Folder), tr(MSG_CO_RetypePass), tr(MSG_Okay), NULL, tr(MSG_Cancel), TRUE, obj) == 0) 
     170    if(IsStrEmpty(passwd) == FALSE && StringRequest(passwd2, SIZE_PASSWORD, tr(MSG_Folder), tr(MSG_CO_RetypePass), tr(MSG_Okay), NULL, tr(MSG_Cancel), TRUE, obj) == 0) 
    171171      break; 
    172172 
     
    200200  SHOWSTRING(DBF_FOLDER, folder.Name); 
    201201 
    202   // check if something has changed and if not we exit here immediately 
    203   if(CompareFolders(&folder, data->oldFolder) == FALSE) 
    204   { 
    205     BOOL nameChanged = (strcasecmp(data->oldFolder->Name, folder.Name) != 0); 
    206     BOOL pathChanged = (strcasecmp(data->oldFolder->Path, folder.Path) != 0); 
    207  
    208     // first check for a valid folder name 
    209     // it is invalid if: 
    210     // - the folder name is empty, or 
    211     // - it was changed and the new name already exists 
    212     if(folder.Name[0] == '\0' || (nameChanged == TRUE && FO_GetFolderByName(folder.Name, NULL) != NULL)) 
     202  do 
     203  { 
     204 
     205    // check if something has changed and if not we exit here immediately 
     206    if(CompareFolders(&folder, data->oldFolder) == FALSE) 
    213207    { 
    214       MUI_Request(_app(obj), obj, MUIF_NONE, NULL, tr(MSG_OkayReq), tr(MSG_FO_FOLDERNAMEINVALID)); 
    215       goto out; 
     208      BOOL nameChanged = (strcasecmp(data->oldFolder->Name, folder.Name) != 0); 
     209      BOOL pathChanged = (strcasecmp(data->oldFolder->Path, folder.Path) != 0); 
     210      BOOL modeChanged = FALSE; 
     211 
     212      // first check for a valid folder name 
     213      // it is invalid if: 
     214      // - the folder name is empty, or 
     215      // - it was changed and the new name already exists 
     216      if(IsStrEmpty(folder.Name) == TRUE || (nameChanged == TRUE && FO_GetFolderByName(folder.Name, NULL) != NULL)) 
     217      { 
     218        MUI_Request(_app(obj), obj, MUIF_NONE, NULL, tr(MSG_OkayReq), tr(MSG_FO_FOLDERNAMEINVALID)); 
     219        set(obj, MUIA_Window_ActiveObject, data->ST_FNAME); 
     220        break; 
     221      } 
     222 
     223      // check for an empty path 
     224      if(IsStrEmpty(folder.Path) == TRUE) 
     225      { 
     226        MUI_Request(_app(obj), obj, MUIF_NONE, NULL, tr(MSG_OkayReq), tr(MSG_FO_PATH_INVALID)); 
     227        set(obj, MUIA_Window_ActiveObject, data->ST_FPATH); 
     228        break; 
     229      } 
     230 
     231      if(folder.MLSupport == TRUE) 
     232      { 
     233        // check for empty and "catch all" patterns 
     234        if(IsStrEmpty(folder.MLPattern) == TRUE || strcmp(folder.MLPattern, "#?") == 0 || strcmp(folder.MLPattern, "*") == 0) 
     235        { 
     236          MUI_Request(_app(obj), obj, MUIF_NONE, NULL, tr(MSG_OkayReq), tr(MSG_FO_MLPATTERN_INVALID)); 
     237          set(obj, MUIA_Window_ActiveObject, data->ST_MLPATTERN); 
     238          break; 
     239        } 
     240 
     241        // check for an empty To: address 
     242        if(IsStrEmpty(folder.MLAddress) == TRUE) 
     243        { 
     244          MUI_Request(_app(obj), obj, MUIF_NONE, NULL, tr(MSG_OkayReq), tr(MSG_FO_MLADDRESS_INVALID)); 
     245          set(obj, MUIA_Window_ActiveObject, data->ST_MLADDRESS); 
     246          break; 
     247        } 
     248      } 
     249 
     250      if(nameChanged == TRUE) 
     251      { 
     252        // check if the filter name has changed and if it is part of 
     253        // an active filter and if so rename it in the filter definition 
     254        // as well. 
     255        if(FolderIsUsedByFilters(data->oldFolder) == TRUE) 
     256          RenameFolderInFilters(data->oldFolder, &folder); 
     257 
     258        // copy the new folder name 
     259        strlcpy(data->oldFolder->Name, folder.Name, sizeof(data->oldFolder->Name)); 
     260 
     261        // trigger a change of the main window's folder listtree 
     262        set(G->MA->GUI.LT_FOLDERS, MUIA_MainFolderListtree_TreeChanged, TRUE); 
     263      } 
     264 
     265      // if the folderpath string has changed 
     266      if(pathChanged == TRUE) 
     267      { 
     268        LONG result; 
     269 
     270        // ask the user whether to perform the move or not 
     271        result = MUI_Request(_app(obj), obj, MUIF_NONE, NULL, tr(MSG_YesNoReq), tr(MSG_FO_MOVEFOLDERTO), data->oldFolder->Fullpath, folder.Fullpath); 
     272        if(result == 1) 
     273        { 
     274          // first unload the old folder image to make it moveable/deletable 
     275          FO_UnloadFolderImage(data->oldFolder); 
     276 
     277          if(Rename(data->oldFolder->Fullpath, folder.Fullpath) == FALSE) 
     278          { 
     279            if(CreateDirectory(folder.Fullpath) == FALSE || FO_MoveFolderDir(&folder, data->oldFolder) == FALSE) 
     280            { 
     281              ER_NewError(tr(MSG_ER_MOVEFOLDERDIR), folder.Name, folder.Fullpath); 
     282              break; 
     283            } 
     284          } 
     285 
     286          // now reload the image from the new path 
     287          if(FO_LoadFolderImage(&folder) == TRUE) 
     288          { 
     289            // remember the newly obtained image pointer 
     290            data->oldFolder->imageObject = folder.imageObject; 
     291          } 
     292        } 
     293        else 
     294        { 
     295          break; 
     296        } 
     297      } 
     298 
     299      strlcpy(data->oldFolder->Path,             folder.Path, sizeof(data->oldFolder->Path)); 
     300      strlcpy(data->oldFolder->Fullpath,         folder.Fullpath, sizeof(data->oldFolder->Fullpath)); 
     301      strlcpy(data->oldFolder->WriteIntro,       folder.WriteIntro, sizeof(data->oldFolder->WriteIntro)); 
     302      strlcpy(data->oldFolder->WriteGreetings,   folder.WriteGreetings, sizeof(data->oldFolder->WriteGreetings)); 
     303      strlcpy(data->oldFolder->MLReplyToAddress, folder.MLReplyToAddress, sizeof(data->oldFolder->MLReplyToAddress)); 
     304      strlcpy(data->oldFolder->MLAddress,        folder.MLAddress, sizeof(data->oldFolder->MLAddress)); 
     305      strlcpy(data->oldFolder->MLPattern,        folder.MLPattern, sizeof(data->oldFolder->MLPattern)); 
     306      data->oldFolder->MLIdentity   = folder.MLIdentity; 
     307      data->oldFolder->MLSignature  = folder.MLSignature; 
     308      data->oldFolder->Sort[0]      = folder.Sort[0]; 
     309      data->oldFolder->Sort[1]      = folder.Sort[1]; 
     310      data->oldFolder->MaxAge       = folder.MaxAge; 
     311      data->oldFolder->ExpireUnread = folder.ExpireUnread; 
     312      data->oldFolder->Stats        = folder.Stats; 
     313      data->oldFolder->JumpToUnread = folder.JumpToUnread; 
     314      data->oldFolder->JumpToRecent = folder.JumpToRecent; 
     315      data->oldFolder->MLSupport    = folder.MLSupport; 
     316 
     317      if(xget(data->CY_FTYPE, MUIA_Disabled) == FALSE) 
     318      { 
     319        enum FolderMode oldmode = data->oldFolder->Mode; 
     320        enum FolderMode newmode = folder.Mode; 
     321 
     322        if(oldmode == newmode || (newmode > FM_SIMPLE && XpkBase == NULL)) 
     323        { 
     324          modeChanged = FALSE; 
     325        } 
     326        else if(isProtectedFolder(&folder) == FALSE && isProtectedFolder(data->oldFolder) == TRUE && 
     327                data->oldFolder->LoadedMode != LM_VALID) 
     328        { 
     329          if((modeChanged = MA_PromptFolderPassword(&folder, obj)) == FALSE) 
     330            break; 
     331        } 
     332        else if(isProtectedFolder(&folder) == TRUE && isProtectedFolder(data->oldFolder) == FALSE) 
     333        { 
     334          if((modeChanged = EnterPassword(obj, &folder)) == FALSE) 
     335            break; 
     336        } 
     337 
     338        if(isProtectedFolder(&folder) == TRUE && isProtectedFolder(data->oldFolder) == TRUE) 
     339           strlcpy(folder.Password, data->oldFolder->Password, sizeof(folder.Password)); 
     340 
     341        if(modeChanged == TRUE) 
     342        { 
     343          if(isProtectedFolder(&folder) == FALSE) 
     344            folder.Password[0] = '\0'; 
     345 
     346          if(folder.Mode != oldmode) 
     347          { 
     348            struct BusyNode *busy; 
     349            struct MailNode *mnode; 
     350            ULONG i; 
     351 
     352            busy = BusyBegin(BUSY_PROGRESS); 
     353            BusyText(busy, tr(MSG_BusyUncompressingFO), ""); 
     354 
     355            LockMailListShared(folder.messages); 
     356 
     357            i = 0; 
     358            ForEachMailNode(folder.messages, mnode) 
     359            { 
     360              BusyProgress(busy, ++i, folder.Total); 
     361              RepackMailFile(mnode->mail, folder.Mode, folder.Password); 
     362            } 
     363 
     364            UnlockMailList(folder.messages); 
     365 
     366            BusyEnd(busy); 
     367 
     368            data->oldFolder->Mode = newmode; 
     369          } 
     370 
     371          strlcpy(data->oldFolder->Password, folder.Password, sizeof(data->oldFolder->Password)); 
     372        } 
     373        data->oldFolder->Type = folder.Type; 
     374      } 
     375 
     376      if(FO_SaveConfig(data->oldFolder) == TRUE) 
     377        success = TRUE; 
     378 
     379      // if everything went well and either the folder's name or path 
     380      // has changed we must save the folder tree, too 
     381      if(success == TRUE && (nameChanged == TRUE || pathChanged == TRUE)) 
     382        FO_SaveTree(); 
    216383    } 
    217  
    218     if(nameChanged == TRUE) 
     384    else 
    219385    { 
    220       // check if the filter name has changed and if it is part of 
    221       // an active filter and if so rename it in the filter definition 
    222       // as well. 
    223       if(FolderIsUsedByFilters(data->oldFolder) == TRUE) 
    224         RenameFolderInFilters(data->oldFolder, &folder); 
    225  
    226       // copy the new folder name 
    227       strlcpy(data->oldFolder->Name, folder.Name, sizeof(data->oldFolder->Name)); 
    228  
    229       // trigger a change of the main window's folder listtree 
    230       set(G->MA->GUI.LT_FOLDERS, MUIA_MainFolderListtree_TreeChanged, TRUE); 
     386      // nothing changed 
     387      success = TRUE; 
    231388    } 
    232  
    233     // if the folderpath string has changed 
    234     if(pathChanged == TRUE) 
    235     { 
    236       LONG result; 
    237  
    238       // ask the user whether to perform the move or not 
    239       result = MUI_Request(_app(obj), obj, MUIF_NONE, NULL, tr(MSG_YesNoReq), tr(MSG_FO_MOVEFOLDERTO), data->oldFolder->Fullpath, folder.Fullpath); 
    240       if(result == 1) 
    241       { 
    242         // first unload the old folder image to make it moveable/deletable 
    243         FO_UnloadFolderImage(data->oldFolder); 
    244  
    245         if(Rename(data->oldFolder->Fullpath, folder.Fullpath) == FALSE) 
    246         { 
    247           if(CreateDirectory(folder.Fullpath) == FALSE || FO_MoveFolderDir(&folder, data->oldFolder) == FALSE) 
    248           { 
    249             ER_NewError(tr(MSG_ER_MOVEFOLDERDIR), folder.Name, folder.Fullpath); 
    250             goto out; 
    251           } 
    252         } 
    253  
    254         // now reload the image from the new path 
    255         if(FO_LoadFolderImage(&folder) == TRUE) 
    256         { 
    257           // remember the newly obtained image pointer 
    258           data->oldFolder->imageObject = folder.imageObject; 
    259         } 
    260       } 
    261       else 
    262       { 
    263         goto out; 
    264       } 
    265     } 
    266  
    267     strlcpy(data->oldFolder->Path,             folder.Path, sizeof(data->oldFolder->Path)); 
    268     strlcpy(data->oldFolder->Fullpath,         folder.Fullpath, sizeof(data->oldFolder->Fullpath)); 
    269     strlcpy(data->oldFolder->WriteIntro,       folder.WriteIntro, sizeof(data->oldFolder->WriteIntro)); 
    270     strlcpy(data->oldFolder->WriteGreetings,   folder.WriteGreetings, sizeof(data->oldFolder->WriteGreetings)); 
    271     strlcpy(data->oldFolder->MLReplyToAddress, folder.MLReplyToAddress, sizeof(data->oldFolder->MLReplyToAddress)); 
    272     strlcpy(data->oldFolder->MLAddress,        folder.MLAddress, sizeof(data->oldFolder->MLAddress)); 
    273     strlcpy(data->oldFolder->MLPattern,        folder.MLPattern, sizeof(data->oldFolder->MLPattern)); 
    274     data->oldFolder->MLIdentity   = folder.MLIdentity; 
    275     data->oldFolder->MLSignature  = folder.MLSignature; 
    276     data->oldFolder->Sort[0]      = folder.Sort[0]; 
    277     data->oldFolder->Sort[1]      = folder.Sort[1]; 
    278     data->oldFolder->MaxAge       = folder.MaxAge; 
    279     data->oldFolder->ExpireUnread = folder.ExpireUnread; 
    280     data->oldFolder->Stats        = folder.Stats; 
    281     data->oldFolder->JumpToUnread = folder.JumpToUnread; 
    282     data->oldFolder->JumpToRecent = folder.JumpToRecent; 
    283     data->oldFolder->MLSupport    = folder.MLSupport; 
    284  
    285     if(xget(data->CY_FTYPE, MUIA_Disabled) == FALSE) 
    286     { 
    287       enum FolderMode oldmode = data->oldFolder->Mode; 
    288       enum FolderMode newmode = folder.Mode; 
    289       BOOL changed = TRUE; 
    290  
    291       if(oldmode == newmode || (newmode > FM_SIMPLE && XpkBase == NULL)) 
    292       { 
    293         changed = FALSE; 
    294       } 
    295       else if(isProtectedFolder(&folder) == FALSE && isProtectedFolder(data->oldFolder) == TRUE && 
    296               data->oldFolder->LoadedMode != LM_VALID) 
    297       { 
    298         if((changed = MA_PromptFolderPassword(&folder, obj)) == FALSE) 
    299           goto out; 
    300       } 
    301       else if(isProtectedFolder(&folder) == TRUE && isProtectedFolder(data->oldFolder) == FALSE) 
    302       { 
    303         if((changed = EnterPassword(obj, &folder)) == FALSE) 
    304           goto out; 
    305       } 
    306  
    307       if(isProtectedFolder(&folder) == TRUE && isProtectedFolder(data->oldFolder) == TRUE) 
    308          strlcpy(folder.Password, data->oldFolder->Password, sizeof(folder.Password)); 
    309  
    310       if(changed == TRUE) 
    311       { 
    312         if(isProtectedFolder(&folder) == FALSE) 
    313           folder.Password[0] = '\0'; 
    314  
    315         if(folder.Mode != oldmode) 
    316         { 
    317           struct BusyNode *busy; 
    318           struct MailNode *mnode; 
    319           ULONG i; 
    320  
    321           busy = BusyBegin(BUSY_PROGRESS); 
    322           BusyText(busy, tr(MSG_BusyUncompressingFO), ""); 
    323  
    324           LockMailListShared(folder.messages); 
    325  
    326           i = 0; 
    327           ForEachMailNode(folder.messages, mnode) 
    328           { 
    329             BusyProgress(busy, ++i, folder.Total); 
    330             RepackMailFile(mnode->mail, folder.Mode, folder.Password); 
    331           } 
    332  
    333           UnlockMailList(folder.messages); 
    334  
    335           BusyEnd(busy); 
    336  
    337           data->oldFolder->Mode = newmode; 
    338         } 
    339  
    340         strlcpy(data->oldFolder->Password, folder.Password, sizeof(data->oldFolder->Password)); 
    341       } 
    342       data->oldFolder->Type = folder.Type; 
    343     } 
    344  
    345     if(FO_SaveConfig(data->oldFolder) == TRUE) 
    346       success = TRUE; 
    347  
    348     // if everything went well and either the folder's name or path 
    349     // has changed we must save the folder tree, too 
    350     if(success == TRUE && (nameChanged == TRUE || pathChanged == TRUE)) 
    351       FO_SaveTree(); 
    352   } 
    353   else 
    354   { 
    355     // nothing changed 
    356     success = TRUE; 
    357   } 
    358  
    359 out: 
     389  } 
     390  while(FALSE); 
     391 
    360392  RETURN(success); 
    361393  return success; 
     
    377409  if((folder.messages = CreateMailList()) != NULL) 
    378410  { 
    379     LONG result; 
    380  
    381411    DoMethod(obj, MUIM_FolderEditWindow_GUIToFolder, &folder); 
    382412    SHOWSTRING(DBF_FOLDER, folder.Name); 
    383413 
    384     // first check for a valid folder name 
    385     // it is invalid if: 
    386     // - the folder name is empty, or 
    387     // - the new name already exists 
    388     if(folder.Name[0] == '\0' || FO_GetFolderByName(folder.Name, NULL) != NULL) 
     414    do 
    389415    { 
    390       MUI_Request(_app(obj), obj, MUIF_NONE, NULL, tr(MSG_OkayReq), tr(MSG_FO_FOLDERNAMEINVALID)); 
    391       result = 0; 
    392     } 
    393     else 
    394       result = 1; 
    395  
    396     if(result == 1) 
    397     { 
    398       // lets check if entered folder path is valid or not 
    399       if(folder.Path[0] == '\0') 
    400       { 
    401         MUI_Request(_app(obj), obj, MUIF_NONE, NULL, tr(MSG_OkayReq), tr(MSG_FO_FOLDERPATHINVALID)); 
    402         result = 0; 
    403       } 
    404       else if(FileExists(folder.Fullpath) == TRUE) // check if the combined full path already exists 
    405       { 
    406         result = MUI_Request(_app(obj), obj, MUIF_NONE, NULL, tr(MSG_YesNoReq), tr(MSG_FO_FOLDER_ALREADY_EXISTS), folder.Fullpath); 
    407       } 
    408       else 
    409       { 
    410         result = 1; 
    411       } 
    412     } 
    413  
    414     // only if the user want to proceed we go on. 
    415     if(result == 1) 
    416     { 
     416      // first check for a valid folder name 
     417      // it is invalid if: 
     418      // - the folder name is empty, or 
     419      // - the new name already exists 
     420      if(IsStrEmpty(folder.Name) == TRUE || FO_GetFolderByName(folder.Name, NULL) != NULL) 
     421      { 
     422        MUI_Request(_app(obj), obj, MUIF_NONE, NULL, tr(MSG_OkayReq), tr(MSG_FO_FOLDERNAMEINVALID)); 
     423        break; 
     424      } 
     425 
     426      // check for an empty path 
     427      if(IsStrEmpty(folder.Path) == TRUE) 
     428      { 
     429        MUI_Request(_app(obj), obj, MUIF_NONE, NULL, tr(MSG_OkayReq), tr(MSG_FO_PATH_INVALID)); 
     430        set(obj, MUIA_Window_ActiveObject, data->ST_FPATH); 
     431        break; 
     432      } 
     433 
     434      // check if the combined full path already exists 
     435      if(FileExists(folder.Fullpath) == TRUE) 
     436      { 
     437        MUI_Request(_app(obj), obj, MUIF_NONE, NULL, tr(MSG_YesNoReq), tr(MSG_FO_FOLDER_ALREADY_EXISTS), folder.Fullpath); 
     438        set(obj, MUIA_Window_ActiveObject, data->ST_FPATH); 
     439        break; 
     440      } 
     441 
     442      if(folder.MLSupport == TRUE) 
     443      { 
     444        // check for empty and "catch all" patterns 
     445        if(IsStrEmpty(folder.MLPattern) == TRUE || strcmp(folder.MLPattern, "#?") == 0 || strcmp(folder.MLPattern, "*") == 0) 
     446        { 
     447          MUI_Request(_app(obj), obj, MUIF_NONE, NULL, tr(MSG_OkayReq), tr(MSG_FO_MLPATTERN_INVALID)); 
     448          set(obj, MUIA_Window_ActiveObject, data->ST_MLPATTERN); 
     449          break; 
     450        } 
     451 
     452        // check for an empty To: address 
     453        if(IsStrEmpty(folder.MLAddress) == TRUE) 
     454        { 
     455          MUI_Request(_app(obj), obj, MUIF_NONE, NULL, tr(MSG_OkayReq), tr(MSG_FO_MLADDRESS_INVALID)); 
     456          set(obj, MUIA_Window_ActiveObject, data->ST_MLADDRESS); 
     457          break; 
     458        } 
     459      } 
     460 
    417461      if(isProtectedFolder(&folder) == FALSE || EnterPassword(obj, &folder) == TRUE) 
    418462      { 
     
    480524      } 
    481525    } 
     526    while(FALSE); 
    482527  } 
    483528 
     
    858903  folder->JumpToUnread = GetMUICheck(data->CH_JUMPTOUNREAD); 
    859904  folder->JumpToRecent = GetMUICheck(data->CH_JUMPTORECENT); 
    860   folder->MLSupport = GetMUICheck(data->CH_MLSUPPORT); 
    861905 
    862906  GetMUIString(folder->WriteIntro, data->ST_HELLOTEXT, sizeof(folder->WriteIntro)); 
    863907  GetMUIString(folder->WriteGreetings, data->ST_BYETEXT, sizeof(folder->WriteGreetings)); 
    864908 
    865   GetMUIString(folder->MLPattern, data->ST_MLPATTERN, sizeof(folder->MLPattern)); 
    866  
    867   // resolve the addresses first, in case someone entered an alias 
    868   DoMethod(data->ST_MLADDRESS, MUIM_RecipientString_Resolve, MUIF_NONE); 
    869   DoMethod(data->ST_MLREPLYTOADDRESS, MUIM_RecipientString_Resolve, MUIF_NONE); 
    870  
    871   GetMUIString(folder->MLAddress, data->ST_MLADDRESS, sizeof(folder->MLAddress)); 
    872   GetMUIString(folder->MLReplyToAddress, data->ST_MLREPLYTOADDRESS, sizeof(folder->MLReplyToAddress)); 
    873  
    874   folder->MLSignature = (struct SignatureNode *)xget(data->CY_MLSIGNATURE, MUIA_SignatureChooser_Signature); 
    875   folder->MLIdentity = (struct UserIdentityNode *)xget(data->CY_MLIDENTITY, MUIA_IdentityChooser_Identity); 
     909  folder->MLSupport = GetMUICheck(data->CH_MLSUPPORT); 
     910  if(folder->MLSupport == FALSE || isDefaultFolder(folder) || isArchiveFolder(folder)) 
     911  { 
     912    // make sure we don't keep any trash settings for folders without ML support 
     913    folder->MLPattern[0] = '\0'; 
     914    folder->MLAddress[0] = '\0'; 
     915    folder->MLReplyToAddress[0] = '\0'; 
     916    folder->MLSignature = NULL; 
     917    folder->MLIdentity = NULL; 
     918  } 
     919  else 
     920  { 
     921    GetMUIString(folder->MLPattern, data->ST_MLPATTERN, sizeof(folder->MLPattern)); 
     922 
     923    // resolve the addresses first, in case someone entered an alias 
     924    DoMethod(data->ST_MLADDRESS, MUIM_RecipientString_Resolve, MUIF_NONE); 
     925    DoMethod(data->ST_MLREPLYTOADDRESS, MUIM_RecipientString_Resolve, MUIF_NONE); 
     926 
     927    GetMUIString(folder->MLAddress, data->ST_MLADDRESS, sizeof(folder->MLAddress)); 
     928    GetMUIString(folder->MLReplyToAddress, data->ST_MLREPLYTOADDRESS, sizeof(folder->MLReplyToAddress)); 
     929 
     930    folder->MLSignature = (struct SignatureNode *)xget(data->CY_MLSIGNATURE, MUIA_SignatureChooser_Signature); 
     931    folder->MLIdentity = (struct UserIdentityNode *)xget(data->CY_MLIDENTITY, MUIA_IdentityChooser_Identity); 
     932  } 
    876933 
    877934  RETURN(0); 
     
    10301087        if(takePattern == TRUE) 
    10311088        { 
    1032           if(strlen(toPattern) >= 2 && !(toPattern[0] == '#' && toPattern[1] == '?')) 
     1089          if(strlen(toPattern) >= 2 && strncmp(toPattern, "#?", 2) == 0) 
    10331090          { 
    10341091            if(res != NULL) 
     
    10741131 
    10751132          // Now we set the new pattern & address values to the string gadgets 
    1076           setstring(data->ST_MLPATTERN, takePattern == TRUE && toPattern[0] != '\0' ? toPattern : tr(MSG_FO_NOTRECOGNIZED)); 
     1133          setstring(data->ST_MLPATTERN, takePattern == TRUE && IsStrEmpty(toPattern) == FALSE ? toPattern : tr(MSG_FO_NOTRECOGNIZED)); 
    10771134          setstring(data->ST_MLADDRESS, takeAddress == TRUE ? toAddress : tr(MSG_FO_NOTRECOGNIZED)); 
    10781135        } 
Note: See TracChangeset for help on using the changeset viewer.