Closed Bug 67608 Opened 25 years ago Closed 25 years ago

magic number 0x8000000 in folderProps.js which has something to do with "selectForDownload"

Categories

(SeaMonkey :: MailNews: Message Display, defect)

defect
Not set
normal

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: jruderman, Assigned: Bienvenu)

References

()

Details

I was trying to figure out what "select this folder for download" in the mail folder properties window meant (bug 67607), and got stuck while looking at lxr.mozilla.org/seamonkey/source/mailnews/base/resources/content/folderProps.js. That file has several statements like gMsgFolder.setFlag(0x8000000). Lxr returns too many results for 0x8000000 (aka 0x08000000!) for me to figure out what other files use the number. Please replace 0x8000000 with a symbolic constant in all files where it has the same meaning, and give the constant a leading zero to reduce ambiguity.
The folder flags are not available from js, unfortunately, which is why I had to use the "magic number". This is not the only place in the js code where we have to use magic numbers for folder flags. I can add a const but I don't think it's going to help you understand the functionality.
Also, I see no use of 0x0800000 in the mailnews code, so that part of this bug is invalid. (If code outside mailnews uses that, there's not much I can do about that).
If I understand what you're saying correctly, the problem is that C++ and JavaScript code need to share numerical constants. One way to partially solve that problem, and at least make the code more readable/maintainable, would be to use the same name (MSG_FOLDER_FLAG_OFFLINE) in C++ and JavaScript and put comments next to the definitions saying "if you change this value in the C++ code, be sure to change it in the JavaScript code too". Oen reason I prefer 0x08000000 over 0x8000000 is that it's easier to look at a list of numbers like 0x08000000 and say "All of my flags have distinct values". Actually, vertically aligning the values would probably be a better solution to that problem. (Are they aligned if you read the code with a text editor that recognizes the emacs "tabs" thing instead of with lxr?)
fix checked in - used a JS constant, and added a comment referring to corresponding nsMsgFolderFlag. Kept consistency in 0x style with nsMsgFolderFlags.h, i.e., did not add a 0x0 in front.
Status: NEW → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Jesse can you verify this for us? Thanks.
verified fixed using lxr.
Status: RESOLVED → VERIFIED
Product: Browser → Seamonkey
You need to log in before you can comment on or make changes to this bug.