[Spambayes-checkins] spambayes/Outlook2000 msgstore.py,1.62,1.63
Mark Hammond
mhammond at users.sourceforge.net
Thu Aug 21 01:02:42 EDT 2003
Update of /cvsroot/spambayes/spambayes/Outlook2000
In directory sc8-pr-cvs1:/tmp/cvs-serv9971
Modified Files:
msgstore.py
Log Message:
* Fix a bug in GetParent(), where the wrong name was used.
* Add CreateFolder() method to the Folder object.
* Add GetFQName() method to the Folder object.
* Add YieldReceiveFolders() to get all folders in the profile that
MAPI delivers messages to.
Index: msgstore.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/msgstore.py,v
retrieving revision 1.62
retrieving revision 1.63
diff -C2 -d -r1.62 -r1.63
*** msgstore.py 8 Aug 2003 02:52:01 -0000 1.62
--- msgstore.py 21 Aug 2003 07:02:39 -0000 1.63
***************
*** 326,329 ****
--- 326,351 ----
return MAPIMsgStoreMsg(self, data)
+ def YieldReceiveFolders(self, msg_class = "IPM.Note"):
+ # Get the main receive folder for each message store.
+ tab = self.session.GetMsgStoresTable(0)
+ rows = mapi.HrQueryAllRows(tab,
+ (PR_ENTRYID,), # columns to retrieve
+ None, # all rows
+ None, # any sort order is fine
+ 0) # any # of results is fine
+ for row in rows:
+ # get first entry, a (property_tag, value) pair, for PR_ENTRYID
+ eid_tag, store_eid = row[0]
+ try:
+ store = self._GetMessageStore(store_eid)
+ folder_eid, ret_class = store.GetReceiveFolder(msg_class, 0)
+ hex_folder_eid = mapi.HexFromBin(folder_eid)
+ hex_store_eid = mapi.HexFromBin(store_eid)
+ yield self.GetFolder((hex_store_eid, hex_folder_eid))
+ except pythoncom.com_error, details:
+ if not IsNotAvailableCOMException(details):
+ print "ERROR enumerating a receive folder -", details
+ # but we just continue
+
_MapiTypeMap = {
type(0.0): PT_DOUBLE,
***************
*** 396,399 ****
--- 418,437 ----
return mapi.HexFromBin(self.id[0]), mapi.HexFromBin(self.id[1])
+ def GetFQName(self):
+ parts = []
+ parent = self
+ while parent is not None:
+ parts.insert(0, parent.name)
+ parent = parent.GetParent()
+ return "/".join(parts)
+
+ def _FolderFromMAPIFolder(self, mapifolder):
+ # Finally get the display name.
+ hr, data = mapifolder.GetProps((PR_ENTRYID, PR_DISPLAY_NAME_A,), 0)
+ eid = self.id[0], data[0][1]
+ name = data[1][1]
+ count = mapifolder.GetContentsTable(0).GetRowCount(0)
+ return MAPIMsgStoreFolder(self.msgstore, eid, name, count)
+
def GetParent(self):
# return a folder object with the parent, or None
***************
*** 410,417 ****
parent = self.msgstore._OpenEntry(parent_id)
# Finally get the display name.
! hr, data = folder.GetProps((PR_DISPLAY_NAME_A,), 0)
! name = data[0][1]
! count = parent.GetContentsTable(0).GetRowCount(0)
! return MAPIMsgStoreFolder(self.msgstore, parent_id, name, count)
def OpenEntry(self, iid = None, flags = None):
--- 448,452 ----
parent = self.msgstore._OpenEntry(parent_id)
# Finally get the display name.
! return self._FolderFromMAPIFolder(parent)
def OpenEntry(self, iid = None, flags = None):
***************
*** 490,493 ****
--- 525,536 ----
eid, ret_class = mapi_store.GetReceiveFolder(msg_class, 0)
return mapi_store.CompareEntryIDs(eid, self.id[1])
+
+ def CreateFolder(self, name, comments = None, type = None, flags = None):
+ if type is None: type = mapi.FOLDER_GENERIC
+ if flags is None: flags = 0
+ folder = self.OpenEntry()
+ ret = folder.CreateFolder(type, name, comments, None, flags)
+ return self._FolderFromMAPIFolder(ret)
+
class MAPIMsgStoreMsg(MsgStoreMsg):
More information about the Spambayes-checkins
mailing list