From: Stas Z. <sta...@us...> - 2005-09-23 17:58:17
|
Update of /cvsroot/gmailagent/GA-libgmail2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10623 Added Files: ANNOUNCE CHANGELOG COPYING MANIFEST README lgconstants.py libgmail.py testlibgmail.py Log Message: Added the libgmail files --- NEW FILE: CHANGELOG --- == Version 0.1.4 == libgmail.py * Added some attributes to the message class: cc, bcc, sender. == Version 0.1.3.1 == libgmail.py * Fixed the problem that not all the messages from a thread were returnt. --SZ-- * Added a exception catch for a "500 server error" --SZ-- == Version 0.1.3 == libgmail.py * Fixed bugs that crashes libgmail when accessing an empty account --SZ-- * Fixed returning not all the messages in large accounts. --SZ-- == Version 0.1.2 == libgmail.py * Added a \r to the line endings in the VCard export function. This is done to comply with rfc2425 section 5.8.1 --SZ-- * Fixed a security bug in the page parser. --SZ-- == Version: 0.1.1 == All * Renamed the shabang to use the 'env' program in all executables. --SZ-- * Fixed the redirect bug caused by the changed Gmail login pages. --WD-- == Version: 0.1.0 == libgmail.py * Added contacts support. --WD-- * Added contacts test suite. --WD-- * Added finer-grained debugging control --WD-- * Applied patch that handles login redirect URL properly now Login now works. --WD-- * Removed fork message. It was a left over from the initial forking. --SZ-- constants.py * Renamed to lgconstants.py to avoid name conflicts --WD-- == Version: 0.0.8 (23 August 2004) == libgmail.py * Fixed login to work again after it was broken by a Gmail change. Centralised cookie extraction. Added debug-level logging of cookie extraction & storage. * Add trash/delete message thread functionality to account object. constants.py, libgmail.py, mkconstants.py * Add trash/delete single message functionality to account object. demos/gmailpopd.py * Initial rough POP3 proxy server demo. Works with Mail.app when I tried it... :-) Sometimes causes items to be downloaded even when they don't *really* need to be. Causes some items to be marked as read even if the client doesn't actually request them. * Refactored message retrieval from account snapshot to allow partial message retrieval (for TOP functionality). * Added POP3 TOP command functionality which is required by Mozilla as it (wrongly) doesn't work with the absolute minimum command set specified by the RFC and requires TOP. * Fixed copy/paste error to change 'ftp_QUIT' to 'pop_QUIT'. * Moved byte-stuffing and message massaging into separate functions. libgmail.py, demos/archive.py, demos/gmailftpd.py, demos/gmailpopd.py, demos/gmailsmtp.py, demos/sendmsg.py * Added `GmailLoginFailure` exception to enable tidier handling of login failures (which could be bad username/password or a Gmail change). * Updated demos to catch `GmailLoginFailure` exception. * Removed non-supported "LOGIN" authentication method in SMTP demo that was included in the server capability response in error. ANNOUNCE * Minor typo fix. == Version: 0.0.7 (03 August 2004) == constants.py, mkconstants.py * Added attachment related constants. libgmail.py, demos/gmailsmtp.py * Allow file data to be specified directly (rather than via an on- disk file) when specifying attachments (this allows using existing Message instance payloads mostly directly). Modify SMTP Proxy demo to handle sending attachments. demos/gmailftpd.py * Initial import of Gmail attachments FTP Proxy! libgmail.py * Corrected version info for previous release. * Added 'getMessagesByQuery' function. Added initial attachment retrieval handling. Clean up handling of references to parent objects & account objects. Version info update. * Handle sending attachments. Works, but implementation is extremely *cough* sub-optimal... * Don't try to attach files if there are none. == Version: 0.0.6 (15 July 2004) == demos/gmailsmtp.py * That was too easy, there oughta be a law! Thanks to Python's undocumented SMTP server module we can now send mail with a standard mail client via (E)SMTP. Extended standard SMTP class to handle ESMTP EHLO & AUTH PLAIN commands. libgmail.py * Added utility function '_retrieveJavascript' to 'GmailAccount' to help developers who want to look at it. (In theory also so you can regenerate 'constants.py' but the Javascript Gmail now uses isn't actually useful for that anymore...) (Added by request.) == Version: 0.0.5 (11 July 2004) == libgmail.py, demos/sendmsg.py * Added functionality to enable message sending. Modified automatic cookie handling. Added command line example to send a message. Enabled page requests to be either a URL or a Request instance. constants.py, mkconstants.py * Added more useful constants. == Version: 0.0.4 (11 July 2004) == constants.py, mkconstants.py * Include standard folder/search name constants. * Add more useful constants. constants.py, libgmail.py, mkconstants.py * Added category name retrieval. mkconstants.py * 'mkconstants' isn't really useful anymore with the new JS version. libgmail.py * Add ability to get number of unread messages. * Handle items that might be 'bunched' such as thread lists better. * Only warn about mismatched Javascript versions once module import. (Note: This may mean the Javascript version may change more than once in a session and the second change won't be warned, but that shouldn't be much of an issue...) * Refactor URL construction. Refactor query/search operation in preparation for adding searches. * More refactoring. Made thread search query more generic to allow use by (to come) label searches etc. Threads now belong to 'GmailSearchResult' instances rather than folders. Threads now retrieve their own messages rather than relying on their parent to do so. * We now refer to categories as labels, as the UI does. Enable retrieval by label. libgmail.py, demos/archive.py * Allow all pages of results to be returned for a 'getFolder' request. (Not tested much.) * Provide easy access to standard folder names. Added length property to folders. Examples now handle empty folders gracefully. * Now uses 'getMessagesByXXXXX' style method names for folders & labels. Now refer to original message source as 'source' & not 'body'. Enable demos to search by folder name or label name. == Version: 0.0.3 (8 July 2004) == libgmail.py * Allow username to be specified on the command line instead of prompting. * Rough special case handling of when more than one set of thread information data is present on a page (seemed to occur when using 'all' search after a certain number of items). TODO: Make this fix work at the page parsing level, but splitting all tuples into individual items. * Add cookie handling code to enable us to remove requirement for ClientCookie package. (Especially for Adrian... :-) ) demos/archive.py * *Extremely* rough mbox creation--turns out the mails retrieved had '\r' characters at the end of the headers. The mbox file appears to be successfully imported by OS X's Mail.app client. * Allow username to be specified on the command line instead of prompting. == Version: 0.0.2a (~6 July 2004) == * No code change, renamed to try to avoid SourceForge mirroring problems. == Version: 0.0.2 (5 July 2004) == constants.py * Useful constants from the Gmail Javascript code as Python module. * Update to match current live Javascript. * Fudge some enumerations that we need to start at 0. libgmail.py * Refactor to make use of Folder/Thread/Message model. Standardised some naming. Make use of imported Gmail constants. Centralise page retrieval & parsing. * Calculate number of messages in thread. * Refactor & reorganise code. Minor style edits. Refine design of folder, thread & message classes. Modify folders, threads & messages to be as lazy as possible when it comes to retrieving data from the net. Enable message instances to retrieve their original mail text. Add Gmail implementation notes. Hide password entry. Demo now displays threads & messages. * Version date change. mkconstants.py * Tool to make useful constants from the Gmail Javascript code available via a Python module. * Fudge some enumerations that we need to start at 0. demos/archive.py * Initial rough demo to archive all messages into text files. CHANGELOG * Added. == Version: 0.0.1 (2 July 2004) == libgmail.py * Initial import of version 0.0.1 (as posted in comp.lang.python). --- NEW FILE: MANIFEST --- COPYING README CHANGELOG lgconstants.py libgmail.py setup.py --- NEW FILE: testlibgmail.py --- #!/usr/bin/env python """ libgmail test suite Tests: Contacts """ import unittest from libgmail import * import getpass class ContactsTests(unittest.TestCase): """ Set of tests that exercise the contacts portion of libgmail """ def setUp(self): """ Delete all entries in the addressbook so we start fresh """ #print "Setting up!" contacts = account.getContacts().getAllContacts() for contact in contacts: # print "Removing", contact account.removeContact(contact) def tearDown(self): """ Delete all entries in the addressbook so we start fresh """ #print "Tearing down!" contacts = account.getContacts().getAllContacts() for contact in contacts: # print "Removing", contact account.removeContact(contact) def test1_BasicAddContact(self): """Create and retrieve an entry-level contact""" name = 'John Smith' email = 'joh...@gm...' notes = 'I am average' account.addContact(name, email, notes) myContacts = account.getContacts() contact = myContacts.getContactByName(name) self.assertEqual(contact.getName(), name, "Returned name isn't the one we created initially") self.assertEqual(contact.getEmail(), email, "Returned email isn't the one we created initially") self.assertEqual(contact.getNotes(), notes, "Returned note isn't the one we created initially") ## Coomented out by stas ## The multiline notes support is not yet implemented in libgmail ## def test2_AdvancedAddContact(self): ## """Create and retrieve a contact with a newline in the notes""" ## name = 'W4533m' ## email = 'fak...@gm...' ## notes = 'Is\nawesome' ## account.addContact(name, email, notes) ## myContacts = account.getContacts() ## contact = myContacts.getContactByName(name) ## self.assertEqual(contact.getName(), name, "Returned name isn't the one we created initially") ## self.assertEqual(contact.getEmail(), email, "Returned email isn't the one we created initially") ## ## print "Returned notes is: ", contact.getNotes() ## print "Desired notes was: " + notes ## ## self.assertEqual(contact.getNotes(), notes, "Returned note isn't the one we created initially") def test3_GmailContact(self): """Check that GmailContact equality and accessor methods work""" w = GmailContact('a','b','c','d') x = GmailContact('x','y','z') y = GmailContact('a','b','c','d') z = GmailContact('a','b','c','d') self.assertEqual(w,w, "%s doesn't equals %s" % (w,w)) self.assertEqual(x,x, "%s doesn't equals %s" % (x,x)) self.assertEqual(y,y, "%s doesn't equals %s" % (y,y)) self.assertEqual(z,z, "%s doesn't equals %s" % (z,z)) self.assertEqual(w,y, "%s doesn't equals %s" % (w,y)) self.assertEqual(y,z, "%s doesn't equals %s" % (y,z)) self.assertEqual(w,z, "%s doesn't equals %s" % (w,z)) self.assertEqual(z,w, "%s doesn't equals %s" % (z,w)) self.assertNotEqual(w,x, "%s shouldn't equals %s" % (w,x)) self.assertNotEqual(x,w, "%s shouldn't equals %s" % (x,w)) i,a,e,n = w.getId(),w.getName(),w.getEmail(),w.getNotes() self.assertEqual(i, 'a', "%s doesn't equals 'a'" % i) self.assertEqual(a, 'b', "%s doesn't equals 'b'" % a) self.assertEqual(e, 'c', "%s doesn't equals 'c'" % e) self.assertEqual(n, 'd', "%s doesn't equals 'd'" % n) self.assertEqual(x.getNotes(), '', "getNotes() should return ''") def test4_GetBy(self): """Get a contact by name, email, and id""" account.addContact('Waseem', 'wd...@gm...', 'Is awesome') myContacts = account.getContacts() waseem = myContacts.getContactByName('Waseem') self.assertEqual(waseem, myContacts.getContactByEmail('wd...@gm...')) self.assertEqual(waseem, myContacts.getContactById(waseem.getId())) def test5_GetByLists(self): """Get a contact list by name, email, and id""" account.addContact('Waseem', 'wd...@gm...', 'Is awesome') account.addContact('Daher', 'te...@fo...r') myContacts = account.getContacts() waseem = myContacts.getContactByName('Waseem') result = [waseem] obj = myContacts.getContactListByName('Waseem') self.assertEqual(result, obj, "%s doesn't equals %s" % (result,obj)) obj = myContacts.getContactListByEmail('wd...@gm...') self.assertEqual([waseem], obj,"%s doesn't equals %s" % (result,obj)) obj = myContacts.getContactListById(waseem.getId()) self.assertEqual([waseem], obj,"%s doesn't equals %s" % (result,obj)) def test6_SmallGetAndRemove(self): """Add one address and remove it again""" count = 1 # Add some for x in range(count): account.addContact(str(x), str(x)) myContactList = account.getContacts() self.assertEqual(myContactList.getCount(), count) # Now remove them all for x in range(count): self.assertEqual(True, account.removeContact(myContactList.getContactByName(str(x)))) myContactList = account.getContacts() self.assertEqual(myContactList.getCount(), 0) ## MediumGetAndRemove and LargeGetAndRemove pound ## gmail's servers faster than they'd like to be accessed, ## so this usually gets our account suspended, it seems. ## If you really want to test that these large gets/sets work, ## maybe insert a delay and run them? Doesn't really make ## sense to run them every time though # def test7_MediumGetAndRemove(self): # """Add 14 addresses and remove them again""" # count = 14 # for x in range(count): # account.addContact(str(x), str(x)) # myContactList = account.getContacts() # self.assertEqual(myContactList.getCount(), count) # # Now remove them all # for x in range(count): # self.assertTrue(account.removeContact(myContactList.getContactByName(str(x)))) # myContactList = account.getContacts() # self.assertEqual(myContactList.getCount(), 0) # def test8_LargeGetAndRemove(self): # """Add 25 addresses and remove them again""" # count = 25 # for x in range(count): # account.addContact(str(x), str(x)) # myContactList = account.getContacts() # self.assertEqual(myContactList.getCount(), count) # # Now remove them all # for x in range(count): # self.assertTrue(account.removeContact(myContactList.getContactByName(str(x)))) # myContactList = account.getContacts() # self.assertEqual(myContactList.getCount(), 0) ## Commented out by stas ## It fails due to wrong testing ? ## ## def test9_vCard(self): ## """Test vCard export""" ## waseem = GmailContact("0", "Waseem Daher", "wd...@mi...", "GmailAgent developer") ## vcard = waseem.getVCard() ## expectedVCard="""BEGIN:VCARD ##VERSION:3.0 ##NOTE:GmailAgent developer ##N:Daher;Waseem ##FN:Waseem Daher ##EMAIL;TYPE=INTERNET:wd...@mi... ##END:VCARD ## ##""" ## self.assertEqual(vcard, expectedVCard, "getVCard() did not export what we expected for Waseem") ## ## # Test multi-line NOTEs ## bob = GmailContact("0", "BillyJo", "bi...@jo...", "I like multilines\nwoo") ## bobvcard=bob.getVCard() ## bobexpectedVCard="""BEGIN:VCARD ##VERSION:3.0 ##NOTE:I like multilines\\nwoo ##N:BillyJo ##FN:BillyJo ##EMAIL;TYPE=INTERNET:bi...@jo... ##END:VCARD ##""" ## self.assertEqual(vcard, expectedVCard, "getVCard() didn't export what we expected for BillyJo") if __name__ == '__main__': #unittest.main() ## With this we get a better output print "\n==============================================" print "Start 'libgmail contacts' testsuite" print "------------------------------------------------\n" print "WARNING: THIS WILL DELETE/REARRANGE" print " YOUR ADDRESSBOOK/EMAILS" print " BE SURE TO RUN THIS TEST ONLY ON A 'test' ACCOUNT" name = raw_input("Gmail account name:") pw = getpass.getpass("Password: ") account = GmailAccount(name, pw) try: account.login() print "Login successful.\n" except GmailLoginFailure,e: print "\nLogin failed. (%s)" % e.message else: suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(ContactsTests)) unittest.TextTestRunner(verbosity=2).run(suite) --- NEW FILE: COPYING --- GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the program's name and a brief idea of what it does.> Copyright (C) <year> <name of author> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. <signature of Ty Coon>, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. --- NEW FILE: README --- libgmail is licensed under the GPL. See the file named COPYING for more information. Please refer to the libgmail website or project page at sourceforge if you encouter problems using libgmail. http://libgmail.sf.net http://sourceforge.net/projects/libgmail/ You can contact us by email: stas AT linux DOT isbeter DOT nl wdaher AT mit DOT edu follower AT myrealbox DOT com ----------------------------------------------- Possible usage: Run this: python libgmail.py When you have the demos package installed you could do this: python demos/archive.py or even this: python demos/sendmsg.py <account> <to address> <subject> <body> or perhaps this: python demos/gmailsmtp.py # (Then connect to SMTP proxy on local port 8025) or how about this: python demos/gmailftpd.py # (Then connect to FTP proxy on local port 8021, # after creating a label named 'ftp' and # applying it to some messages with attachments.) or maybe this: python demos/gmailpopd.py # (Then connect to POP3 proxy on local port 8110) for hours of fun!(*) (*) Note: Fun may not last for hours. Use at your own risk, blah, blah, etc... --- NEW FILE: ANNOUNCE --- ANN: libgmail 0.0.8 - Gmail access via Python - POP3 Proxy added! libgmail -- Python binding for Google's Gmail service <http://libgmail.sf.net/> The `libgmail` project is a pure Python binding to provide access to Google's Gmail web-mail service. The library currently ships with a demonstration utility to archive messages from a Gmail account into mbox files, suitable for importing into a local email client. Also includes a demonstration utility that acts as a SMTP proxy to allow mail to be sent from any standard mail client that uses SMTP (e.g. Mail.app, Mozilla etc). (Now handles attachments.) New demonstration utility acts as a POP3 proxy to allow mail to be retrieved from any standard mail client that uses POP3 (e.g. Mail.app, Mozilla etc). Features demonstration utility to provide access to Gmail message attachments via a download-only FTP proxy--this allows retrieval of suitably marked attachments by a standard FTP client. Utilize more of your Gmail space! License: GPL 2.0 (gmailftpd.py/gmailpopd.py are dual licensed with PSF) Major changes since 0.0.7: * Fixed login to work again after it was broken by a Gmail change. * Added trash/delete message thread & trash/delete single message functionality. (By request.) * POP3 proxy server demo. (By request.) * Added `GmailLoginFailure` exception to enable tidier handling of login failures (which could be bad username/password or a Gmail change). <p><a href="http://libgmail.sf.net/">libgmail 0.0.8</a> - The `libgmail` project is a pure Python binding to provide access to Google's Gmail web-mail service; includes SMTP, POP3 & FTP proxies. (23-Aug-04)</p> --- NEW FILE: libgmail.py --- #!/usr/bin/env python # # libgmail -- Gmail access via Python # ## To get the version number of the available libgmail version. ## Reminder: add date before next release. Version = '0.0.0' # (sep 2005) print "\n Be aware that your running a special 'Greg' version of libgmail\n" # Original author: fol...@my... # Maintainers: Waseem (wd...@mi...) and Stas Z (st...@li...) # # Contacts support added by wd...@mi... and Stas Z # (with massive initial help from # Adrian Holovaty's 'gmail.py' # and the Johnvey Gmail API) # # License: GPL 2.0 # [...1472 lines suppressed...] print "No threads found in `%s`." % name break tot = len(result._threads) i = 0 for thread in result: #print thread.id, len(thread), thread.subject for msg in thread: print "\n ", msg.id, msg.number, msg.author,msg.subject print " ", msg.cc, msg.bcc,msg.sender print "\nraw message:\n",msg._getSource() i += 1 print print "number of threads:",tot print "number of messages:",i except KeyboardInterrupt: break print "\n\nDone." --- NEW FILE: lgconstants.py --- # # Generated file -- DO NOT EDIT # # Note: This file is now edited! 2005-04-25 # # constants.py -- Useful constants extracted from Gmail Javascript code # # Source version: 44f09303f2d4f76f # # Generated: 2004-08-10 13:08 UTC # js_version = '44f09303f2d4f76f' D_VERSION = "v" D_QUOTA = "qu" D_DEFAULTSEARCH_SUMMARY = "ds" D_THREADLIST_SUMMARY = "ts" D_THREADLIST_END = "te" D_THREAD = "t" D_CONV_SUMMARY = "cs" D_CONV_END = "ce" D_MSGINFO = "mi" D_MSGBODY = "mb" D_MSGATT = "ma" D_COMPOSE = "c" D_CONTACT = "co" D_CATEGORIES = "ct" D_CATEGORIES_COUNT_ALL = "cta" D_ACTION_RESULT = "ar" D_SENDMAIL_RESULT = "sr" D_PREFERENCES = "p" D_PREFERENCES_PANEL = "pp" D_FILTERS = "fi" D_GAIA_NAME = "gn" D_INVITE_STATUS = "i" D_END_PAGE = "e" D_LOADING = "l" D_LOADED_SUCCESS = "ld" D_LOADED_ERROR = "le" D_QUICKLOADED = "ql" QU_SPACEUSED = 0 QU_QUOTA = 1 QU_PERCENT = 2 QU_COLOR = 3 TS_START = 0 TS_NUM = 1 TS_TOTAL = 2 TS_ESTIMATES = 3 TS_TITLE = 4 TS_TIMESTAMP = 5 + 1 TS_TOTAL_MSGS = 6 + 1 T_THREADID = 0 T_UNREAD = 1 T_STAR = 2 T_DATE_HTML = 3 T_AUTHORS_HTML = 4 T_FLAGS = 5 T_SUBJECT_HTML = 6 T_SNIPPET_HTML = 7 T_CATEGORIES = 8 T_ATTACH_HTML = 9 T_MATCHING_MSGID = 10 T_EXTRA_SNIPPET = 11 CS_THREADID = 0 CS_SUBJECT = 1 CS_TITLE_HTML = 2 CS_SUMMARY_HTML = 3 CS_CATEGORIES = 4 CS_PREVNEXTTHREADIDS = 5 CS_THREAD_UPDATED = 6 CS_NUM_MSGS = 7 CS_ADKEY = 8 CS_MATCHING_MSGID = 9 MI_FLAGS = 0 MI_NUM = 1 MI_MSGID = 2 MI_STAR = 3 MI_REFMSG = 4 MI_AUTHORNAME = 5 MI_AUTHORFIRSTNAME = 6 # ? -- Name supplied by rj MI_AUTHOREMAIL = 6 + 1 MI_MINIHDRHTML = 7 + 1 MI_DATEHTML = 8 + 1 MI_TO = 9 + 1 MI_CC = 10 + 1 MI_BCC = 11 + 1 MI_REPLYTO = 12 + 1 MI_DATE = 13 + 1 MI_SUBJECT = 14 + 1 MI_SNIPPETHTML = 15 + 1 MI_ATTACHINFO = 16 + 1 MI_KNOWNAUTHOR = 17 + 1 MI_PHISHWARNING = 18 + 1 A_ID = 0 A_FILENAME = 1 A_MIMETYPE = 2 A_FILESIZE = 3 CT_NAME = 0 CT_COUNT = 1 AR_SUCCESS = 0 AR_MSG = 1 SM_COMPOSEID = 0 SM_SUCCESS = 1 SM_MSG = 2 SM_NEWTHREADID = 3 CMD_SEARCH = "SEARCH" ACTION_TOKEN_COOKIE = "GMAIL_AT" U_VIEW = "view" U_PAGE_VIEW = "page" U_THREADLIST_VIEW = "tl" U_CONVERSATION_VIEW = "cv" U_COMPOSE_VIEW = "cm" U_PRINT_VIEW = "pt" U_PREFERENCES_VIEW = "pr" U_JSREPORT_VIEW = "jr" U_UPDATE_VIEW = "up" U_SENDMAIL_VIEW = "sm" U_AD_VIEW = "ad" U_REPORT_BAD_RELATED_INFO_VIEW = "rbri" U_ADDRESS_VIEW = "address" U_ADDRESS_IMPORT_VIEW = "ai" U_SPELLCHECK_VIEW = "sc" U_INVITE_VIEW = "invite" U_ORIGINAL_MESSAGE_VIEW = "om" U_ATTACHMENT_VIEW = "att" U_DEBUG_ADS_RESPONSE_VIEW = "da" U_SEARCH = "search" U_INBOX_SEARCH = "inbox" U_STARRED_SEARCH = "starred" U_ALL_SEARCH = "all" U_DRAFTS_SEARCH = "drafts" U_SENT_SEARCH = "sent" U_SPAM_SEARCH = "spam" U_TRASH_SEARCH = "trash" U_QUERY_SEARCH = "query" U_ADVANCED_SEARCH = "adv" U_CREATEFILTER_SEARCH = "cf" U_CATEGORY_SEARCH = "cat" U_AS_FROM = "as_from" U_AS_TO = "as_to" U_AS_SUBJECT = "as_subj" U_AS_SUBSET = "as_subset" U_AS_HAS = "as_has" U_AS_HASNOT = "as_hasnot" U_AS_ATTACH = "as_attach" U_AS_WITHIN = "as_within" U_AS_DATE = "as_date" U_AS_SUBSET_ALL = "all" U_AS_SUBSET_INBOX = "inbox" U_AS_SUBSET_STARRED = "starred" U_AS_SUBSET_SENT = "sent" U_AS_SUBSET_DRAFTS = "drafts" U_AS_SUBSET_SPAM = "spam" U_AS_SUBSET_TRASH = "trash" U_AS_SUBSET_ALLSPAMTRASH = "ast" U_AS_SUBSET_READ = "read" U_AS_SUBSET_UNREAD = "unread" U_AS_SUBSET_CATEGORY_PREFIX = "cat_" U_THREAD = "th" U_PREV_THREAD = "prev" U_NEXT_THREAD = "next" U_DRAFT_MSG = "draft" U_START = "start" U_ACTION = "act" U_ACTION_TOKEN = "at" U_INBOX_ACTION = "ib" U_MARKREAD_ACTION = "rd" U_MARKUNREAD_ACTION = "ur" U_MARKSPAM_ACTION = "sp" U_UNMARKSPAM_ACTION = "us" U_MARKTRASH_ACTION = "tr" U_ADDCATEGORY_ACTION = "ac_" U_REMOVECATEGORY_ACTION = "rc_" U_ADDSTAR_ACTION = "st" U_REMOVESTAR_ACTION = "xst" U_ADDSENDERTOCONTACTS_ACTION = "astc" U_DELETEMESSAGE_ACTION = "dm" U_DELETE_ACTION = "dl" U_EMPTYSPAM_ACTION = "es_" U_EMPTYTRASH_ACTION = "et_" U_SAVEPREFS_ACTION = "prefs" U_ADDRESS_ACTION = "a" U_CREATECATEGORY_ACTION = "cc_" U_DELETECATEGORY_ACTION = "dc_" U_RENAMECATEGORY_ACTION = "nc_" U_CREATEFILTER_ACTION = "cf" U_REPLACEFILTER_ACTION = "rf" U_DELETEFILTER_ACTION = "df_" U_ACTION_THREAD = "t" U_ACTION_MESSAGE = "m" U_ACTION_PREF_PREFIX = "p_" U_REFERENCED_MSG = "rm" U_COMPOSEID = "cmid" U_COMPOSE_MODE = "cmode" U_COMPOSE_SUBJECT = "su" U_COMPOSE_TO = "to" U_COMPOSE_CC = "cc" U_COMPOSE_BCC = "bcc" U_COMPOSE_BODY = "body" U_PRINT_THREAD = "pth" CONV_VIEW = "conv" TLIST_VIEW = "tlist" PREFS_VIEW = "prefs" HIST_VIEW = "hist" COMPOSE_VIEW = "comp" HIDDEN_ACTION = 0 USER_ACTION = 1 BACKSPACE_ACTION = 2 |