pax_global_header00006660000000000000000000000064112627755260014527gustar00rootroot0000000000000052 comment=4ebb6c49b9f10f93cf3e5e374893cf932223ceec takuo-IMAProwl-4ebb6c4/000077500000000000000000000000001126277552600147755ustar00rootroot00000000000000takuo-IMAProwl-4ebb6c4/.gitignore000066400000000000000000000000051126277552600167600ustar00rootroot00000000000000logs takuo-IMAProwl-4ebb6c4/AUTHORS000066400000000000000000000000651126277552600160460ustar00rootroot00000000000000IMAProwl authors: Takuo Kitame . takuo-IMAProwl-4ebb6c4/ChangeLog000066400000000000000000000133471126277552600165570ustar00rootroot000000000000002009-10-07 Takuo Kitame * imaprowl.rb (login): MailBox name should be UTF-7 * tagged as 1.2.1 2009-10-06 Takuo Kitame * imaprowl.rb (check_unseen): try body.encode() with src encoding as 'ISO-2022-JP' if body.encoding is US-ASCII. (don't warry ISO-2022-JP is compatible with US-ASCII) 2009-10-05 Takuo Kitame * imaprowl.rb: bump version 1.2.1 more verbose logging for DEBUG (warn): new logger function for Logger::WARN (check_unseen): falling back to default format if @format not usable. (idler): handle some IMAP responses. 2009-09-29 Takuo Kitame * config: added Format. Interval is now renamed to Timeout print/log warning 'Interval is deprecated.' * imaprowl.rb (check_unseen): format string can be used for prowl event text. simplified string count method. (initialize): default value of SubjectLength is 20 * tagged as 1.2 2009-09-25 Takuo Kitame * imaprowl.rb (check_unseen): always convert body to UTF-8 * tagged as 1.1.2 2009-09-18 Takuo Kitame * imaprowl.rb: String#encode use option :undef=>:replace and replacement charactor should be default. * merged 1.1, tagged as 1.1.1 2009-09-17 Takuo Kitame * imaprowl.rb: don't use Iconv or NKF. use String#encode instead. (iconv_mime_decode): renamed to mime_decode() (check_unseen): fetch BODY should be BODY.PEEK (post_escape): used for escaping string while HTTP/POST (prowl): use post_escape() instead of URI#escape (check_unseen): remove empty line and white-space of line-head before POST. (check_unseen): triming should be done before count length. 2009-09-16 Takuo Kitame * New branch: 1.1 * imaprowl.rb (get_text_part): try to get TEXT part of a mail. (check_unseen): try to get first text part as body if possible. 2009-09-16 Takuo Kitame * imaprowl.rb (check_unseen): should retry to prowl if fail to prowl. * debian/*: Depends on ruby1.9.1 * tagged as 1.0.1 2009-09-15 Takuo Kitame * imaprowl.rb: use Iconv if it's available. added Signal.trap(:TERM). (iconv_mime_decode): MIME decode and convert to UTF-8. (check_unseen): use iconv instead of NKF. Don't prowl body if it's contains invalid UTF-8 charactor. Subject will be shorten length with value of SubjectLength clear @notified cache if no UNSEEN mail. rescue all exception while processing text and will prowl with error message. nil check before checking variable content. (initialize): default SubjectLength is 30 * LICENSE: fixed typo. * tagged as 1.0.0 2009-09-10 Takuo Kitame * Added debian/manpage.xml * debian/rules (build): added rule for building manpage. replace #!/usr/bin/ruby to ruby1.9 * debian/control (Description): update (Build-Depends): added docbook-xsl, xsltproc, docbook-xml * README: update * config.yml: update * Tagged as 0.9.2 2009-09-09 Takuo Kitame * AUTHORS: Added. * LINCESE: Ditto. * GPL: Ditto. * imapidle.rb: Added copyright notice. * Tagged as 0.9.1 2009-09-08 takuo * 0.9 * imaprowl.rb: STDOUT/STDERR always sync=true support daemonize with Process.daemon. config file load path order. Added some command line options. -c (config file), -q (daemon), -d (debug) 2009-09-07 takuo * 0.8.2: fix again. * imaprowl.rb (check_unseen): fix error caused by undefined method 'encoding' 2009-09-07 takuo * Bug fix release : 0.8.1 * imaprowl.rb (check_unseen): fix error caused by undefined method 'encoding' Catch the exception while parsing a Mail. 2009-09-04 takuo * merge non-idle-support branch * imaprowl.rb (checker): NOOP interval uses @noop value as seconds disabling account if Enable == false * config.yml: update example. * README: up-to-date * IMAProwl 0.8 -- is now works with not IDLE capable IMAP server. 2009-09-04 takuo * imaprowl.rb (@idle_thread): renamed to @loop_thread. (@no_idle): boolean flag for non-IDLE supported account. (checker): added. noop loop to check new unseen mail. 2009-09-04 takuo * imaprowl.rb(check_unseen): should use FETCH BODY.PEEK instead of FETCH BODY. * tagged 0.7.1 2009-09-04 takuo * imaprowl.rb: Refectoring and Refactoring. Hopefully fixed the blocking issue. (status): added to check thread availability. * up-to-date 0.7 2009-09-01 takuo * imaprowl.rb (class): @@logger will be initialize in IMAProwl#new. @@conf added to store the global configuration. (prowl): refactoring. (check_unseen): fetch should call only onece with message set array. refactoring. change some exception handling. refactoring... 2009-08-31 takuo * imaprowl.rb (class): prowl_conf and logger are now class variable. (debug),(error),(info): Print all log into STDOUT/STDERR if LogDir is undefined. (idler): Fix issue that IMAProwl won't reconnect when error occurred at check_unseen(). Some clean-ups. 2009-08-29 takuo * imaprowl.rb: fix does not send priority parameter. 2009-08-28 takuo * README: default interval is 20. update, rubygems is no longer required. up-to-date 0.6. * config.yml: added Priority item in Account * imaprowl.rb: no longer use rubygems. support HTTP Proxy for prowling. configurable Prowl Priority by Account. don't output any log when LogDir is undefined. 2009-08-25 takuo * .gitignore, README, config.yml, imapidle.rb, imaprowl.rb: 0.5 with cleanup Repo takuo-IMAProwl-4ebb6c4/GPL000066400000000000000000000431031126277552600153430ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser 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. Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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. , 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 Lesser General Public License instead of this License. takuo-IMAProwl-4ebb6c4/LICENSE000066400000000000000000000051611126277552600160050ustar00rootroot00000000000000This program can be (re)distributed under Ruby's License. Copyright(c) 2009 Takuo Kitame . IMAProwl is copyrighted free software by Takuo Kitame . You can redistribute it and/or modify it under either the terms of the GPL (see the file GPL), or the conditions below: 1. You may make and give away verbatim copies of the source form of the software without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may modify your copy of the software in any way, provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or by allowing the author to include your modifications in the software. b) use the modified software only within your corporation or organization. c) give non-standard binaries non-standard names, with instructions on where to get the original software distribution. d) make other distribution arrangements with the author. 3. You may distribute the software in object code or binary form, provided that you do at least ONE of the following: a) distribute the binaries and library files of the software, together with instructions (in the manual page or equivalent) on where to get the original distribution. b) accompany the distribution with the machine-readable source of the software. c) give non-standard binaries non-standard names, with instructions on where to get the original software distribution. d) make other distribution arrangements with the author. 4. You may modify and include the part of the software into any other software (possibly commercial). But some files in the distribution are not written by the author, so that they are not under these terms. For the list of those files and their copying conditions, see the file LEGAL. 5. The scripts and library files supplied as input to or produced as output from the software do not automatically fall under the copyright of the software, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this software. 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. GNU General Public Lincese: Referer the GPL file in this archive.takuo-IMAProwl-4ebb6c4/README000066400000000000000000000051631126277552600156620ustar00rootroot00000000000000IMAProwl Version 1.2 * Requirements - Ruby 1.9.0 or later with OpenSSL module. - Prowl service account. (free to get your account, http://prowl.weks.net/) - Prowl iPhone application from AppStore, not free. - IMAP server should support IMAPs(IMAP over SSL) or TLS. * Instruction - edit example configuration file and copy it to ~/.imaprowl.conf - execute imaprowl.rb with ruby1.9 * Command line option - -c, --config FILENAME Specify configuration file. - -q, --daemon Enable daemon mode. - -d, --debug Enable debug mode. * Configuration file - load path order. (it'll be overridden with -c option) 1. -c option 2. $HOME/.imaprowl.conf 3. `pwd`/imaprowl.conf 4. `pwd`/config.yml (deprecated) 5. dirname($0)/imaprowl.conf - config description LogDir: log directory, ex: "/home/foo/logs/". If it's not defined, output all logs into STDOUT/ERR and turn on debug mode forcefully. Debug: [optional] to enable debug output, default: false Daemon: [optional] to enable daemon mode, default: false Prowl: APIKey: The prowl apikey of your account ProxyHost: ProxyPort: ProxyUser: ProxyPass: [optional] HTTP Proxy settings if it's available. Accounts: - Appication: application name for prowl. (Identity of account) User: username for IMAP server. Pass: password for IMAP server. Host: hostname or IP address of IMAP server, SSL/TLS support is required. Port: [optional] TCP port number of IMAP server, default: 993 Priority: [optional] Notification Priority: -2(low) to 2(high), default: 0 MailBox: [optional] mailbox to check UNSEEN, default: INBOX BodyLength: [optional] body length for prowl notification, default: 100, Max: 1000 SubjectLength: [optional] subject length for prowl notification, default: 20 Format: [optional] prowl text format, you can use "%{subject}", "%{from}", "%{name}" and "%{addr}" keyword in the format string. default: "%{subject} (%{from})" Timeout: (in minutes) [optional] Timeout for No-Response, default: 20 NOOPInterval: (in seconds) [optional] NOOP interval for no-IDLE mode, it should be really short about 30 or so. default: 30 NoIDLE: [optional] force no-IDLE mode, default: false. Enable: [optional] false to disable this account, default: true -- Takuo Kitame. http://github.com/takuo/ takuo-IMAProwl-4ebb6c4/config.yml000066400000000000000000000017601126277552600167710ustar00rootroot00000000000000## -*- encoding: utf-8 -*- ## ## example configuration (version >= 1.2) ## ## if undefine LogDir, Debug mode is forcefully enabled. LogDir: /home/you/logs/ Debug: false Daemon: true ## API Key can be defined up to 5-keys with comma separated values. Prowl: APIKey: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ## IMAP Accounts. Accounts: - Application: GMail User: yourname Pass: password Host: imap.gmail.com BodyLength: 100 SubjectLength: 20 Priority: 0 Format: "%{subject} (%{name} <%{addr}>)" Timeout: 7 # Timeout for NoResponse during IDLE. Recommend you set 6-7 for GMail. (in minutes) - Application: SoftBank User: yourname Pass: password Host: imap.softbank.jp BodyLength: 256 SubjectLength: 20 Priority: 0 Format: "Subject:%{subject} From:%{from}" NOOPInterval: 20 # NOOP(check) interval with no-IDLE mode. (in seconds) NoIDLE: true # unnecessary, because it should be auto-detected. Enable: false # diable this account. Set true to enable this account. takuo-IMAProwl-4ebb6c4/debian/000077500000000000000000000000001126277552600162175ustar00rootroot00000000000000takuo-IMAProwl-4ebb6c4/debian/changelog000066400000000000000000000022661126277552600200770ustar00rootroot00000000000000imaprowl (1.2.1-1) unstable; urgency=low * New upstream release. -- Takuo KITAME Wed, 07 Oct 2009 11:19:00 +0900 imaprowl (1.2.0-1) unstable; urgency=low * New upstream release. -- Takuo KITAME Tue, 29 Sep 2009 19:39:15 +0900 imaprowl (1.1.2-1) unstable; urgency=low * New upstream release. -- Takuo KITAME Sat, 26 Sep 2009 00:31:18 +0900 imaprowl (1.1.1-1) unstable; urgency=low * New upstream release. -- Takuo KITAME Fri, 18 Sep 2009 18:29:58 +0900 imaprowl (1.0.1-1) unstable; urgency=low * New upstream release. * Depends on ruby1.9.1 instead of ruby1.9 -- Takuo KITAME Wed, 16 Sep 2009 17:34:14 +0900 imaprowl (1.0.0-1) unstable; urgency=low * New upstream release. -- Takuo KITAME Wed, 16 Sep 2009 08:23:00 +0900 imaprowl (0.9.2-2) unstable; urgency=low * debian/copyright: mentions copyright of imapidle.rb. -- Takuo KITAME Mon, 14 Sep 2009 19:12:20 +0900 imaprowl (0.9.2-1) unstable; urgency=low * Initial release (Closes: #545822) -- Takuo KITAME Wed, 09 Sep 2009 20:40:07 +0900 takuo-IMAProwl-4ebb6c4/debian/compat000066400000000000000000000000021126277552600174150ustar00rootroot000000000000007 takuo-IMAProwl-4ebb6c4/debian/control000066400000000000000000000015271126277552600176270ustar00rootroot00000000000000Source: imaprowl Section: mail Priority: optional Maintainer: Takuo KITAME Build-Depends: debhelper (>= 7.0.50~), docbook-xsl, xsltproc, docbook-xml Standards-Version: 3.8.3 Homepage: http://github.com/takuo/IMAProwl Package: imaprowl Architecture: all Depends: ${misc:Depends}, ruby1.9.1, libopenssl-ruby1.9.1 Description: IMAP new mail notification utility for iPhone using Prowl Public API Prowl is a service and an App for iPhone's Push Notification service.(APNs) see http://prowl.weks.net/ for more about Prowl. . IMAProwl is an utility script to notify new mail of IMAP server with Prowl service. It's very useful to push notification of GMail or any other IMAP mail service to your iPhone. . This program uses IMAP/IDLE(RFC2177) or IMAP/NOOP to check the new mail on IMAP server and uses Prowl Public API via HTTPS. takuo-IMAProwl-4ebb6c4/debian/copyright000066400000000000000000000062331126277552600201560ustar00rootroot00000000000000This work was packaged for Debian by: Takuo KITAME on Wed, 09 Sep 2009 20:40:07 +0900 It was downloaded from Upstream Author: Takuo KITAME imapidle.rb has been copy'n pasted from Net::IMAP of ruby-1.9.2 Shugo Maeda Copyright: Copyright (C) 2009 Takuo Kitame. Copyright (C) 2000 Shugo Maeda License: Same as Ruby's License. The Debian packaging is: Copyright (C) 2009 Takuo KITAME IMAProwl is copyrighted free software by Takuo Kitame . You can redistribute it and/or modify it under either the terms of the GPL (see the file GPL), or the conditions below: 1. You may make and give away verbatim copies of the source form of the software without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may modify your copy of the software in any way, provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or by allowing the author to include your modifications in the software. b) use the modified software only within your corporation or organization. c) give non-standard binaries non-standard names, with instructions on where to get the original software distribution. d) make other distribution arrangements with the author. 3. You may distribute the software in object code or binary form, provided that you do at least ONE of the following: a) distribute the binaries and library files of the software, together with instructions (in the manual page or equivalent) on where to get the original distribution. b) accompany the distribution with the machine-readable source of the software. c) give non-standard binaries non-standard names, with instructions on where to get the original software distribution. d) make other distribution arrangements with the author. 4. You may modify and include the part of the software into any other software (possibly commercial). But some files in the distribution are not written by the author, so that they are not under these terms. For the list of those files and their copying conditions, see the file LEGAL. 5. The scripts and library files supplied as input to or produced as output from the software do not automatically fall under the copyright of the software, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this software. 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. GNU General Public License: On Debian systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/GPL'. takuo-IMAProwl-4ebb6c4/debian/dirs000066400000000000000000000000331126277552600170770ustar00rootroot00000000000000usr/bin usr/lib/ruby/1.9.1 takuo-IMAProwl-4ebb6c4/debian/docs000066400000000000000000000000171126277552600170700ustar00rootroot00000000000000README AUTHORS takuo-IMAProwl-4ebb6c4/debian/examples000066400000000000000000000000131126277552600177520ustar00rootroot00000000000000config.yml takuo-IMAProwl-4ebb6c4/debian/manpage.xml000066400000000000000000000217671126277552600203660ustar00rootroot00000000000000 .
will be generated. You may view the manual page with: nroff -man .
| less'. A typical entry in a Makefile or Makefile.am is: DB2MAN = /usr/share/sgml/docbook/stylesheet/xsl/nwalsh/manpages/docbook.xsl XP = xsltproc -''-nonet -''-param man.charmap.use.subset "0" manpage.1: manpage.xml $(XP) $(DB2MAN) $< The xsltproc binary is found in the xsltproc package. The XSL files are in docbook-xsl. A description of the parameters you can use can be found in the docbook-xsl-doc-* packages. Please remember that if you create the nroff version in one of the debian/rules file targets (such as build), you will need to include xsltproc and docbook-xsl in your Build-Depends control field. Alternatively use the xmlto command/package. That will also automatically pull in xsltproc and docbook-xsl. Notes for using docbook2x: docbook2x-man does not automatically create the AUTHOR(S) and COPYRIGHT sections. In this case, please add them manually as ... . To disable the automatic creation of the AUTHOR(S) and COPYRIGHT sections read /usr/share/doc/docbook-xsl/doc/manpages/authors.html. This file can be found in the docbook-xsl-doc-html package. Validation can be done using: `xmllint -''-noout -''-valid manpage.xml` General documentation about man-pages and man-page-formatting: man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/ --> ]> &dhtitle; &dhpackage; &dhfirstname; &dhsurname; Wrote this manpage for the Debian system.
&dhemail;
2009 &dhusername; This manual page was written for the Debian system (and may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or (at your option) any later version published by the Free Software Foundation. On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL.
&dhucpackage; &dhsection; &dhpackage; IMAP new mail notification utility for iPhone using Prowl Public API &dhpackage; &dhpackage; DESCRIPTION This manual page documents briefly the &dhpackage; command. This manual page was written for the Debian distribution because the original program does not have a manual page. &dhpackage; is an IMAP new mail notification utility for iPhone using Prowl Public API Prowl is a service and an App for iPhone's Push Notification service.(APNs) See for more about Prowl. IMAProwl is an utility script to notify new mail of IMAP server with Prowl service. It's very useful to push notification of GMail or any other IMAP mail service to your iPhone. This program uses IMAP/IDLE(RFC2177) or IMAP/NOOP to check the new mail on IMAP server and uses Prowl Public API via HTTPS. REQUIREMENTS Ruby script language version >= 1.9.0 OpenSSL extenstion library for Ruby IMAP server must support SSL/TLS connection. The Prowl service account. It's free, you can register at Your iPhone deveice and the Prowl.app from AppStore. OPTIONS The program follows the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options is included below. Configuration file to load. Enable daemon mode. &dhpackage; will launch as background process. Enable debug output. Show summary of options. Show version of program. FILES ${HOME}/.imaprowl.conf The per-user configuration file to control the behaviour of &dhpackage;. See /usr/share/doc/&dhpackage;/examples/config.yml for further details. ISSUES The program is currently limited to only work with the ruby1.9. The upstreams Issue tracker can be found at .
takuo-IMAProwl-4ebb6c4/debian/manpages000066400000000000000000000000131126277552600177270ustar00rootroot00000000000000imaprowl.1 takuo-IMAProwl-4ebb6c4/debian/rules000077500000000000000000000016571126277552600173100ustar00rootroot00000000000000#!/usr/bin/make -f # Sample debian/rules that uses debhelper. # This file is public domain software, originally written by Joey Hess. # # This version is for packages that are architecture independent. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 PACKAGE=imaprowl %: dh $@ override_dh_auto_clean: dh_auto_clean -rm -f imaprowl.1 -rm -f imaprowl override_dh_install: install -m 0644 imapidle.rb `pwd`/debian/$(PACKAGE)/usr/lib/ruby/1.9.1/ install -m 0755 imaprowl `pwd`/debian/$(PACKAGE)/usr/bin/ override_dh_auto_build: dh_auto_build sed -e 's%^#!/usr/bin/ruby$$%#!/usr/bin/ruby1.9.1%g' \ imaprowl.rb > imaprowl xsltproc --nonet \ --param make.year.ranges 1 \ --param make.single.year.ranges 1 \ --param man.charmap.use.subset 0 \ -o ./ \ /usr/share/xml/docbook/stylesheet/nwalsh/manpages/docbook.xsl \ debian/manpage.xml takuo-IMAProwl-4ebb6c4/imapidle.rb000066400000000000000000000017551126277552600171160ustar00rootroot00000000000000# # # This code has been copied from Ruby-1.9.2's Net::IMAP. # # Copyright (C) 2000 Shugo Maeda # # This library is distributed under the terms of the Ruby license. # You can freely distribute/modify this library. # # class Net::IMAP def idle(&response_handler) raise LocalJumpError, "no block given" unless response_handler response = nil synchronize do tag = Thread.current[:net_imap_tag] = generate_tag put_string "#{tag} IDLE#{CRLF}" begin add_response_handler response_handler @idle_done_cond = new_cond @idle_done_cond.wait @idle_done_cond = nil ensure remove_response_handler response_handler put_string "DONE#{CRLF}" response = get_tagged_response( tag, "IDLE") end end response end def idle_done synchronize do if @idle_done_cond.nil? raise Net::IMAP::Error, 'not during IDLE' end @idle_done_cond.signal end end end takuo-IMAProwl-4ebb6c4/imaprowl.rb000077500000000000000000000372211126277552600171640ustar00rootroot00000000000000#!/usr/bin/ruby # # IMAProwl - Prowl notification for IMAP new mail # Version: 1.2 # # Copyright (c) 2009 Takuo Kitame. # # You can redistribute it and/or modify it under the same term as Ruby. # STDOUT.sync = STDERR.sync = true $:.insert(0, File.dirname(__FILE__)) IMAPROWL_VERSION = "1.2.1" if RUBY_VERSION < "1.9.0" STDERR.puts "IMAProwl #{IMAPROWL_VERSION} requires Ruby >= 1.9.0" exit end $0 = "IMAProwl/#{IMAPROWL_VERSION}" require 'optparse' require 'uri' require 'net/https' require 'net/imap' require 'yaml' require 'logger' require 'imapidle' unless Net::IMAP.respond_to?("idle") class IMAProwl PROWL_API_ADD = "https://prowl.weks.net/publicapi/add" @@conf = Hash.new @@logger = nil @@prowl_conf = nil attr_reader :enable attr_reader :loop_thread def initialize( global, conf ) @@conf = global _prowl_conf_validate( global['Prowl'] ) @application = conf['Application'] ? conf['Application'] : "IMAProwl" @user = conf['User'] @pass = conf['Pass'] @host = conf['Host'] @port = conf['Port'] ? conf['Port'] : 993 @mailbox = conf['MailBox'] ? conf['MailBox'] : "INBOX" # backward compat @timeout = conf['Timeout'] ? conf['Timeout'] : ( conf['Interval'] ? conf['Interval'] : 20 ) if conf['Interval'] warn = "Warning: 'Interval' is deprecated. You should use 'Timeout' instead." STDERR.print "#{warn}\n" warn warn end @noop = conf['NOOPInterval'] ? conf['NOOPInterval'] : 30 @subject_length = conf['SubjectLength'] ? conf['SubjectLength'] - 1 : 19 @body_length = conf['BodyLength'] ? conf['BodyLength'] - 1 : 99 @body_length = 1 if @body_length < 0 @subject_length = 1 if @subject_length < 0 @priority = conf['Priority'] ? conf['Priority'] : 0 @notified = [] @enable = conf.has_key?('Enable') ? conf['Enable'] : true @no_idle = conf.has_key?('NoIDLE') ? conf['NoIDLE'] : false @format = conf.has_key?('Format') ? conf['Format'] : "%{subject} (%{from})" end # start() should run only once def start info "Starting." connect() unless @imap.capability.include?( 'IDLE' ) error "Error: #{@host} does not support IDLE." error "Falling back to no IDLE support mode." @no_idle = true end login() check_unseen( false ) if @no_idle checker() else idler() end end def restart info "Restarting..." connect() login() if @no_idle checker() else check_unseen( true ) idler() end debug "Restarted" end def stop unless @no_idle @idle_time = nil @imap.idle_done debug "DONE IDLE." end end def status return if @no_idle retried = false debug "Check process status..." begin if @imap.disconnected? @loop_thread.exit if @loop_thread.alive? error "socket is disconnected. trying to reconnect..." restart elsif ! @loop_thread.alive? error "IDLE thread is dead." restart end if @timeout > 0 && @idle_time && Time.now - @idle_time > 60 * @timeout info "Timeout exceed. " stop end rescue @loop_thread.exit if @loop_thread.alive? error $!.to_s unless retried retried = true retry end end end private def post_escape( string ) string.gsub(/([^ a-zA-Z0-9_.-]+)/) do '%' + $1.unpack('H2' * $1.bytesize).join('%').upcase end.tr(' ', '+') end def mime_decode( input, out_charset = 'utf-8' ) while input.sub!(/(=\?[A-Za-z0-9-]+\?[BQbq]\?[^\?]+\?=)(?:(?:\r\n)?[\s\t])+(=\?[A-Za-z0-9-]+\?[BQbq]\?[^\?]+\?=)/, '\1\2') end begin ret = input.sub!( /=\?([A-Za-z0-9-]+)\?([BQbq])\?([^\?]+)\?=/ ) { charset = $1 enc = $2.upcase word = $3 debug "Decode MIME hedaer: Charset: #{charset}, Encode: #{enc}, Word: #{word}" word = word.unpack( { "B"=>"m*", "Q"=>"M*" }[enc] ).first # Iconv.conv( out_charset + "//IGNORE", charset, word ) word.encode( out_charset, charset, :undef=>:replace, :invalid=>:replace ) } return ret ? mime_decode( input ) : input rescue # "Error while convert MIME string." error "Error while converting MIME header: #{input}" debug "E: #{$!}" return input end end def _prowl_conf_validate( val ) return if @@prowl_conf @@prowl_conf = val unless @@prowl_conf.kind_of?( Hash ) STDERR.print "Configuration Error: Prowl section must be Hash.\n" exit 1 end unless @@prowl_conf.has_key?( 'APIKey' ) STDERR.print "Configuration Error: APIKey must be given.\n" exit 1 end _init_logger() end def _init_logger if @@conf['LogDir'] logdir = @@conf['LogDir'] Dir.mkdir( logdir ) unless File.exist?( logdir ) filename = File.join( logdir, "imaprowl.log" ) STDOUT.puts "All logs will be written into #{filename}." @@logger = Logger.new( filename, 'daily' ) @@logger.level = @@conf['Debug'] ? Logger::DEBUG : Logger::INFO @@logger.datetime_format = "%Y-%m-%dT%H:%M:%S" else @@logger = nil end end def _log( severity, str ) if @@logger @@logger.add( severity, str, @application ) else format = "[%Y-%m-%dT%H:%M:%S##{Process.pid}] #{@application} - #{str}\n" if severity == Logger::ERROR STDERR.print Time.now.strftime( format ) else print Time.now.strftime( format ) end end end def debug( str ) _log( Logger::DEBUG, "#{Thread.current}:#{str}" ) end def error( str ) _log( Logger::ERROR, "#{Thread.current}:#{str}" ) end def warn( str ) _log( Logger::WARN, str) end def info( str ) _log( Logger::INFO, str ) end def login return true if @logged_in ret = @imap.login( @user, @pass ) if ret.name != "OK" error "Failed to login: user: #{@user}@#{@host}." return false end @imap.select( Net::IMAP.encode_utf7( @mailbox ) ) @logged_in = true return true end def connect @logged_in = false begin @imap = Net::IMAP.new( @host, @port, true, nil, false ) # don't verify cert rescue error "Error on connect()" end end def disconnected? return @imap.disconnected? end def prowl( params = {} ) uri = URI::parse( PROWL_API_ADD ) if @@prowl_conf['ProxyHost'] http = Net::HTTP::Proxy( @@prowl_conf['ProxyHost'], @@prowl_conf['ProxyPort'], @@prowl_conf['ProxyUser'], @@prowl_conf['ProxyPass']).new( uri.host, uri.port ) else http = Net::HTTP.new( uri.host, uri.port ) end http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Post.new( uri.request_uri ) request.content_type = "application/x-www-form-urlencoded" query = params.map do |key, val| "#{key}=#{post_escape( val.to_s )}" end return http.request(request, query.join('&')) end def get_text_part( struct, pos ) if struct.kind_of?( Net::IMAP::BodyTypeMultipart ) struct.parts.each_index do |i| pos.push( i+1 ) part, pos = get_text_part( struct.parts[i], pos ) return part, pos if part && part.media_type == "TEXT" pos.pop end end if struct.media_type == "TEXT" return struct, pos end return nil, pos end def check_unseen( will_prowl = false ) debug "Checking UNSEEN mail." unseen = @imap.search( ['UNSEEN'] ) if unseen.size == 0 @notified = [] return end unseen_set = Array.new data_set = @imap.fetch( unseen, "(ENVELOPE BODYSTRUCTURE UID)" ) data_set.each do |data| begin attr = data.attr if @notified.include?( attr["UID"] ) debug "SKIP Already notified: UID=#{attr["UID"]}" unseen_set.push attr["UID"] next end # header process envelope = attr["ENVELOPE"] addr = "#{envelope.from.first.mailbox}@#{envelope.from.first.host}" name = envelope.from.first.name begin name = name ? mime_decode( name ) : "" from = name != "" ? name : addr rescue error "Error: Invalid From." debug $!.to_s from = "[Invalid From]" end begin subject = envelope.subject ? mime_decode( envelope.subject ) : "Untitled" if subject.size > @subject_length subject = subject[0..@subject_length] + "..." end rescue error "Error: Invalid Subject." debug $!.to_s subject = "[Invalid Subject]" end begin event = @format % { :subject => subject, :from => from, :name=>name, :addr=>addr } rescue KeyError error "Invalid format string: #{@format}" @format = "%{subject} from: %{from}" warn "Failing back to default format: #{@format}" retry rescue ArgumentError warn "This ruby does not support format string with Hash argument. falling back to default format." event = "#{subject} (#{from})" end # body process begin part, pos = get_text_part( attr['BODYSTRUCTURE'], [] ) if part section = pos.size > 0 ? pos.join('.') : "1" debug "Detected text part: [#{section}]" tmp = @imap.uid_fetch( attr['UID'], "BODY.PEEK[#{section}]" ).first body = tmp.attr["BODY[#{section}]"] else body = "[Body does not contain TEXT part]" part = attr['BODYSTRUCTURE'] debug "No text part found." end if part.media_type != "TEXT" # do nothing elsif part.respond_to?('encoding') && part.encoding == "QUOTED-PRINTABLE" body = body.unpack("M*").first elsif part.respond_to?('encoding') && part.encoding == "BASE64" body = body.unpack("m*").first end charset = nil if part.param && part.param['CHARSET'] charset = part.param['CHARSET'] end body.force_encoding( "ISO-2022-JP" ) if body.encoding == Encoding::US_ASCII debug "Convert body charset from #{charset ? charset : body.encoding.to_s}" begin body.encode!( "UTF-8", charset, :undef=>:replace, :invalid=>:replace ) rescue error "Error while converting body from #{charset}" debug $!.to_s body = "[Body contains invalid charactor]" end body = body.gsub(/^[\s\t]*/, '').gsub(/^$/, '') if body.size > @body_length body = body[0..@body_length] + "..." end rescue error "Error: Could not parse body text" debug $!.to_s body = "[Could not parse body]" end # prowling if will_prowl info "Prowling... UID=#{attr["UID"]}" debug "Prowling: " + event + " " + body begin presp = prowl( :apikey=> @@prowl_conf['APIKey'], :application => @application, :event => event, :description => body, :priority => @priority ) unseen_set.push attr["UID"] if presp && presp.code == "200" debug "Response: #{presp.code}" rescue error "Error while HTTP/POST process." debug $! end else unseen_set.push attr["UID"] debug "Caching: " + event + " " + body debug "Not Prowled (Caching): UID=#{attr["UID"]}" end rescue error "Error while parsing mail: UID=#{attr["UID"]}. Skipped." unseen_set.push attr["UID"] debug $! end end # caching @notified = unseen_set end def checker debug "Won't use IDLE to check unseen mail." @loop_thread = Thread.start do loop do begin event = false @imap.synchronize do @imap.noop event = true if @imap.responses["EXISTS"][-1] @imap.responses.delete("EXISTS") end info "Received EXISTS." if event check_unseen( true ) if event sleep( @noop ) rescue error "Error in checker(): #{$!}" debug "Exiting thread" Thread.current.exit end end # loop end # Thread end def idler @loop_thread = Thread.start do loop do begin event = false debug "Entering IDLE." @idle_time = Time.now @imap.idle do |resp| if resp.kind_of?( Net::IMAP::UntaggedResponse ) case resp.name when "EXISTS" event = true info "Received EXISTS." @idle_time = nil @imap.idle_done debug "DONE IDLE." when "OK" info "Received OK" + resp.data.respond_to('text') ? resp.data.text : "" else debug "FIXME: Unhandled response: #{resp.name}: #{resp}" end elsif resp.kind_of?( Net::IMAP::ContinuationRequest ) debug "Received idling" else debug "FIXME: Unhandled response: #{resp.name}, #{resp}" end end check_unseen( true ) if event rescue error "Error in idler(): #{$!}" debug "Exiting thread" Thread.current.exit end debug "idler(): Still in loop" end # loop end # Thread end end # class ## __MAIN__ ## command line options ProgramConfig = Hash.new opts = OptionParser.new opts.on( "-c", "--config FILENAME", String, "Specify the config file." ) { |v| ProgramConfig[:config] = v } opts.on( "-q", "--daemon",nil, "Enable daemon mode.") { |v| ProgramConfig[:daemon] = true } opts.on( "-d", "--debug", nil, "Enable debug output." ) { |v| ProgramConfig[:debug] = true } opts.version = IMAPROWL_VERSION opts.program_name = "imaprowl" opts.parse!( ARGV ) ## config file config_order = [ File.join( ENV['HOME'], '.imaprowl.conf' ), File.join( Dir.pwd, 'imaprowl.conf' ), File.join( Dir.pwd, 'config.yml' ), File.join( File.dirname( __FILE__ ), 'imaprowl.conf' ) ] filename = nil if ProgramConfig[:config] if File.exist?( ProgramConfig[:config] ) filename = ProgramConfig[:config] else STDERR.print "Configuration file does not exist: #{ProgramConfig[:config]}\n" exit 1 end else config_order.each do |conf| next unless File.exist?( conf ) filename = conf break end end if filename.nil? STDERR.print "No configuration file exist.\n" STDERR.print "File candidates are:\n" STDERR.print config_order.join("\n") STDERR.print "\n" exit 1 end STDOUT.print "LoadConf: #{filename}\n" config = YAML.load_file( filename ) config["Debug"] = true if ProgramConfig[:debug] ## Daemon mode if ProgramConfig[:daemon] || config['Daemon'] begin Process.daemon( true, true ) rescue STDERR.print $! exit 1 end STDOUT.print "Daemonized. PID=#{Process.pid}\n" end ## Create Account Thread application = Array.new config['Accounts'].each do |account| app = IMAProwl.new( config, account ) next unless app.enable app.start() application.push( app ) end ## Signal trap Signal.trap(:INT) { application.each do |app| app.loop_thread.exit if app.loop_thread.alive? app.stop end sleep 1 exit } Signal.trap(:TERM) { application.each do |app| app.loop_thread.exit if app.loop_thread.alive? app.stop end sleep 1 exit } ## main loop loop do sleep 60 application.each do |app| app.status end end ## __END__