Back to index

lightning-sunbird  0.9+nobinonly
nsMsgGroupRecord.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 // This class should only be used by the subscribe UI and by newshost.cpp.
00039 // And, well, a bit by the category code.  Everyone else should use the stuff
00040 // in newshost.h.
00041 
00042 #ifndef _nsMsgGroupRecord_h_
00043 #define _nsMsgGroupRecord_h__
00044 
00045 #include "msgCore.h"
00046 #include "prtypes.h"
00047 #include "nsISupports.h"
00048 
00049 class nsIMAPGroupRecord;
00050 
00051 class NS_MSG_BASE nsMsgGroupRecord {
00052 public:
00053        static nsMsgGroupRecord* Create(nsMsgGroupRecord* parent,
00054                                                            const char* partname,
00055                                    PRInt64 m_addtime,
00056                                                            PRInt32 uniqueid,
00057                                                            PRInt32 fileoffset);
00058        static nsMsgGroupRecord* Create(nsMsgGroupRecord* parent,
00059                                                            const char* saveline,
00060                                                            PRInt32 savelinelength,
00061                                                            PRInt32 fileoffset);
00062 
00063 
00064        virtual void  InitializeSibling();
00065        virtual PRBool IsIMAPGroupRecord() { return PR_FALSE; }
00066        virtual nsIMAPGroupRecord *GetIMAPGroupRecord() { return 0; }
00067        
00068        // This is just like PL_strcmp(), except it works on news group names.
00069        // A container groupname is always less than any contained groups.
00070        // So, "netscape.devs-client-technical" > "netscape.devs.directory", even
00071        // though PL_strcmp says otherwise.  (YICK!)
00072        static int GroupNameCompare(const char* name1,
00073                                                         const char* name2,
00074                                                         char delimiter = '.',
00075                                                         PRBool caseInsensitive = PR_FALSE);
00076 
00077 
00078        virtual ~nsMsgGroupRecord();
00079 
00080        nsMsgGroupRecord* FindDescendant(const char* name);
00081 
00082        nsMsgGroupRecord* GetParent() {return m_parent;}
00083        nsMsgGroupRecord* GetChildren() {return m_children;}
00084        nsMsgGroupRecord* GetSibling() {return m_sibling;}
00085        nsMsgGroupRecord* GetSiblingOrAncestorSibling();
00086        nsMsgGroupRecord* GetNextAlphabetic();
00087 
00088        nsMsgGroupRecord* GetNextAlphabeticNoCategories();
00089 
00090        const char* GetPartName() {return m_partname;}
00091 
00092        // The resulting string must be free'd using delete[].
00093        char* GetFullName();
00094 
00095        const char* GetPrettyName() {return m_prettyname;}
00096        int SetPrettyName(const char* prettyname);
00097 
00098        PRInt64 GetAddTime() {return m_addtime;}
00099 
00100        virtual PRBool IsCategory();
00101        virtual PRBool IsCategoryContainer();
00102        virtual int SetIsCategoryContainer(PRBool value);
00103 
00104        nsMsgGroupRecord* GetCategoryContainer();
00105 
00106        // Get/Set whether this is a virtual newsgroup.
00107        nsresult IsVirtual(PRBool *retval);
00108     nsresult SetIsVirtual(PRBool value);
00109 
00110        // Get/Set whether this is really a newsgroup (and not just a container
00111        // for newsgroups).
00112        virtual PRBool IsGroup();
00113        int SetIsGroup(PRBool value);
00114 
00115        PRBool IsDescendentsLoaded();
00116        int SetIsDescendentsLoaded(PRBool value);
00117 
00118        PRBool IsExpanded();
00119        int SetIsExpanded(PRBool value);
00120 
00121        PRBool IsHTMLOKGroup();
00122        int SetIsHTMLOKGroup(PRBool value);
00123 
00124        PRBool IsHTMLOKTree();
00125        int SetIsHTMLOKTree(PRBool value);
00126 
00127        PRBool NeedsExtraInfo();
00128        int SetNeedsExtraInfo(PRBool value);
00129 
00130        PRBool DoesNotExistOnServer();
00131        int SetDoesNotExistOnServer(PRBool value);
00132 
00133        PRInt32 GetUniqueID() {return m_uniqueId;}
00134 
00135        PRInt32 GetFileOffset() {return m_fileoffset;}
00136        int SetFileOffset(PRInt32 value) {m_fileoffset = value; return 0;}
00137 
00138        // Get the number of descendents (not including ourself) that are
00139        // really newsgroups.
00140        PRInt32 GetNumKids();
00141 
00142        // Gets the string that represents this group in the save file.  The
00143        // resulting string must be free'd with PR_Free().
00144        char* GetSaveString();
00145 
00146        PRBool IsDirty();                  // Whether this record has had changes made
00147                                                         // to it.  Cleared by calls to GetSaveString().
00148 
00149        PRInt32 GetDepth();                // Returns how deep in the heirarchy we are.
00150                                                         // Basically, the number of dots in the full
00151                                                         // newsgroup name, plus 1.
00152        virtual char GetHierarchySeparator() { return '.'; }
00153 
00154 protected:
00155        nsMsgGroupRecord(nsMsgGroupRecord* parent,
00156                                                            const char* partname,
00157                                                            PRInt64 m_addtime,
00158                                                            PRInt32 uniqueid,
00159                                                            PRInt32 fileoffset,
00160                                                            char delimiter = '.');
00161        int TweakFlag(PRUint32 flagbit, PRBool value);
00162        char* SuckInName(char* ptr);
00163 
00164        char* m_partname;
00165        char* m_prettyname;
00166        nsMsgGroupRecord* m_parent;
00167        nsMsgGroupRecord* m_children;
00168        nsMsgGroupRecord* m_sibling;
00169        PRUint32 m_flags;
00170        PRInt64 m_addtime;
00171        PRInt32 m_uniqueId;
00172        PRInt32 m_fileoffset;
00173        char m_delimiter;
00174 };
00175 
00176 
00177 
00178 
00179 #endif /* _grec_h_ */