From 576b42b9942be0c354d62a81da096a8088fc4d44 Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy <watcherhd@gmail.com> Date: Sat, 27 Jul 2013 10:41:43 +0000 Subject: - WebView Protocol 0.1.3.10 added (not adopted) git-svn-id: http://svn.miranda-ng.org/main/trunk@5499 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/!NotAdopted/WebView/Docs/changelog.txt | 6 + plugins/!NotAdopted/WebView/Docs/todo.txt | 3 + .../!NotAdopted/WebView/Docs/webview-license.txt | 340 ++++ .../!NotAdopted/WebView/Docs/webview-readme.txt | 1000 +++++++++++ plugins/!NotAdopted/WebView/forkthread.c | 77 + plugins/!NotAdopted/WebView/main.c | 566 +++++++ plugins/!NotAdopted/WebView/res/Icon_14.ico | Bin 0 -> 2550 bytes plugins/!NotAdopted/WebView/res/Thumbs.db | Bin 0 -> 16384 bytes plugins/!NotAdopted/WebView/res/alert.ico | Bin 0 -> 2550 bytes plugins/!NotAdopted/WebView/res/find.ico | Bin 0 -> 2550 bytes plugins/!NotAdopted/WebView/res/folder.ico | Bin 0 -> 2550 bytes plugins/!NotAdopted/WebView/res/markallread.ico | Bin 0 -> 2550 bytes plugins/!NotAdopted/WebView/res/options.ico | Bin 0 -> 2550 bytes plugins/!NotAdopted/WebView/res/ping.ico | Bin 0 -> 894 bytes plugins/!NotAdopted/WebView/res/popup.ico | Bin 0 -> 2550 bytes plugins/!NotAdopted/WebView/res/show_hide.ico | Bin 0 -> 2550 bytes plugins/!NotAdopted/WebView/res/stick.ico | Bin 0 -> 2550 bytes plugins/!NotAdopted/WebView/res/stop.ico | Bin 0 -> 2550 bytes plugins/!NotAdopted/WebView/res/unstick.ico | Bin 0 -> 2550 bytes plugins/!NotAdopted/WebView/res/update.ico | Bin 0 -> 2550 bytes plugins/!NotAdopted/WebView/res/updateall.ico | Bin 0 -> 2550 bytes plugins/!NotAdopted/WebView/res/url.ico | Bin 0 -> 2550 bytes plugins/!NotAdopted/WebView/res/web.ico | Bin 0 -> 894 bytes plugins/!NotAdopted/WebView/resource.h | 138 ++ plugins/!NotAdopted/WebView/webview.c | 1116 +++++++++++++ plugins/!NotAdopted/WebView/webview.dev | 179 ++ plugins/!NotAdopted/WebView/webview.h | 431 +++++ plugins/!NotAdopted/WebView/webview.rc | 378 +++++ plugins/!NotAdopted/WebView/webview_alerts.c | 1304 +++++++++++++++ plugins/!NotAdopted/WebView/webview_cleanup.c | 631 +++++++ plugins/!NotAdopted/WebView/webview_common.h | 248 +++ plugins/!NotAdopted/WebView/webview_datawnd.c | 997 +++++++++++ plugins/!NotAdopted/WebView/webview_getdata.c | 955 +++++++++++ plugins/!NotAdopted/WebView/webview_opts.c | 1740 ++++++++++++++++++++ plugins/!NotAdopted/WebView/webview_private.h | 23 + plugins/!NotAdopted/WebView/webview_services.c | 770 +++++++++ 36 files changed, 10902 insertions(+) create mode 100644 plugins/!NotAdopted/WebView/Docs/changelog.txt create mode 100644 plugins/!NotAdopted/WebView/Docs/todo.txt create mode 100644 plugins/!NotAdopted/WebView/Docs/webview-license.txt create mode 100644 plugins/!NotAdopted/WebView/Docs/webview-readme.txt create mode 100644 plugins/!NotAdopted/WebView/forkthread.c create mode 100644 plugins/!NotAdopted/WebView/main.c create mode 100644 plugins/!NotAdopted/WebView/res/Icon_14.ico create mode 100644 plugins/!NotAdopted/WebView/res/Thumbs.db create mode 100644 plugins/!NotAdopted/WebView/res/alert.ico create mode 100644 plugins/!NotAdopted/WebView/res/find.ico create mode 100644 plugins/!NotAdopted/WebView/res/folder.ico create mode 100644 plugins/!NotAdopted/WebView/res/markallread.ico create mode 100644 plugins/!NotAdopted/WebView/res/options.ico create mode 100644 plugins/!NotAdopted/WebView/res/ping.ico create mode 100644 plugins/!NotAdopted/WebView/res/popup.ico create mode 100644 plugins/!NotAdopted/WebView/res/show_hide.ico create mode 100644 plugins/!NotAdopted/WebView/res/stick.ico create mode 100644 plugins/!NotAdopted/WebView/res/stop.ico create mode 100644 plugins/!NotAdopted/WebView/res/unstick.ico create mode 100644 plugins/!NotAdopted/WebView/res/update.ico create mode 100644 plugins/!NotAdopted/WebView/res/updateall.ico create mode 100644 plugins/!NotAdopted/WebView/res/url.ico create mode 100644 plugins/!NotAdopted/WebView/res/web.ico create mode 100644 plugins/!NotAdopted/WebView/resource.h create mode 100644 plugins/!NotAdopted/WebView/webview.c create mode 100644 plugins/!NotAdopted/WebView/webview.dev create mode 100644 plugins/!NotAdopted/WebView/webview.h create mode 100644 plugins/!NotAdopted/WebView/webview.rc create mode 100644 plugins/!NotAdopted/WebView/webview_alerts.c create mode 100644 plugins/!NotAdopted/WebView/webview_cleanup.c create mode 100644 plugins/!NotAdopted/WebView/webview_common.h create mode 100644 plugins/!NotAdopted/WebView/webview_datawnd.c create mode 100644 plugins/!NotAdopted/WebView/webview_getdata.c create mode 100644 plugins/!NotAdopted/WebView/webview_opts.c create mode 100644 plugins/!NotAdopted/WebView/webview_private.h create mode 100644 plugins/!NotAdopted/WebView/webview_services.c (limited to 'plugins/!NotAdopted') diff --git a/plugins/!NotAdopted/WebView/Docs/changelog.txt b/plugins/!NotAdopted/WebView/Docs/changelog.txt new file mode 100644 index 0000000000..7394a55a5a --- /dev/null +++ b/plugins/!NotAdopted/WebView/Docs/changelog.txt @@ -0,0 +1,6 @@ +-0.1.3.10 +-Made separate Unicode and ANSI versions of plugin. +-Removed some old unneeded code. + + + \ No newline at end of file diff --git a/plugins/!NotAdopted/WebView/Docs/todo.txt b/plugins/!NotAdopted/WebView/Docs/todo.txt new file mode 100644 index 0000000000..58bece465a --- /dev/null +++ b/plugins/!NotAdopted/WebView/Docs/todo.txt @@ -0,0 +1,3 @@ + + + diff --git a/plugins/!NotAdopted/WebView/Docs/webview-license.txt b/plugins/!NotAdopted/WebView/Docs/webview-license.txt new file mode 100644 index 0000000000..7f1161073d --- /dev/null +++ b/plugins/!NotAdopted/WebView/Docs/webview-license.txt @@ -0,0 +1,340 @@ + 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) 19yy <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) 19yy 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. diff --git a/plugins/!NotAdopted/WebView/Docs/webview-readme.txt b/plugins/!NotAdopted/WebView/Docs/webview-readme.txt new file mode 100644 index 0000000000..8c441c1feb --- /dev/null +++ b/plugins/!NotAdopted/WebView/Docs/webview-readme.txt @@ -0,0 +1,1000 @@ +*************************************** +* Webview Protocol Plugin by Bumper1 * +*************************************** + + + +About +----- + +A plugin for Miranda IM which adds web pages as contacts to your contact list and can +display text and/or changes within those pages in a window, as well as issue different types of +alerts when changes occur. + +You need special status icons for this protocol, these icons are available here: +http://www.miranda-im.org/download/details.php?action=viewfile&id=1274 +------- +WARNING +---------- + +On a large site (approx ~50kbytes) with "clean up display" option enabled the processor +may approach 100% until the tags are removed and text formatting is complete. +To minimise this only select a section of the web page to be displayed (the larger +the selection the longer it will take to remove the tags and format the text). + + +Installation: + +Copy the dll file to your plugins folder like any other plugin, but if you want the ping fuction to work, copy psite.bat to the same folder as miranda32.exe + +Features +-------- +Creates contacts on your Contact list representing web pages. A dialog displaying +the text on that web page can be accessed through the contact menu of the contact +that represents that web page. + +You can add more sites to the contact list using the Webview -> Add Contact +item on the Main menu. +You can update your Webview contacts all at once using the Webview -> Update All Webview +Sites item on the Main menu. +You can enable/disable timed updates of your contacts using the Webview -> Auto Update +Enabled item on the Main menu. + +If you have the main menu items disabled and you have the TopToolbar plugin loaded Webview +will load three buttons on the toolbar for Adding contacts, updating all Webview site and +for enabling auto update. + + +There are various options which you can set from each individual site/Webview contact on your +contact list; you can set the name of the contact, the site URL, start string, end string, logging +options, clean up of the display (removal of excess whitespace, tags and conversion of HTML +character codes to displayable characters), and the action to take when double clicking on a +contact (either open that site in a browser window or display site in the Webview data display +window). You can adjust all these settings from the Contact Options item on each contact menu. +The amount of white space removed can be set by the user for each contact. + +There is also an option to "Display whole web page"; if you use this option then it will +display the whole web page in the data display window. +If you use the option "Display between Start and End strings then you need to use +unique strings on the web page to set the part of the page you want to display. + +The clean up display option stops tags being displayed in the data window. +It also removes extra white space to help tidy up the display. The amount +of white space removed can be set from options. + +You can also set various alerts on a contact by contact basis. You can set an alert to be +issued if a certain string is present, if anything on the whole web page (or in the displayed +portion of the web page) changes or you can have an alert issued only of a specific +part of the web page changes. + +You can also set the method by which you want to be alerted on a contact by contact basis. +You can set the alert to issue a popup using the PopUp plugin, open the data display +window, display the alert using the OSD plugin or log to file. + + + +You can set the update interval, suppression of error messages, disabling of the main menu item +(hiding main menu item requires a reboot for changes to be seen), whether to update data on +Miranda startup, hiding/showing of the protocol icon on the status bar, updating data for a specfic +site when its data display window is opened and text/background color all from the main +Miranda Webview options. You can also set the text attributes. +You can set an option to save the position of individual data display windows. + +You can set the error messages to be displayed using the PopUp +plugin (or the OSD plugin if the Popup service isn't available). +If you don't select errors to be displayed with the Popup plugin (or the OSD plugin), or neither +the Popup or OSD plugins are loaded then the error is displayed using a balloon tip (if the OS +supports it). + +When plugin is first installed the window updates once an hour. +The timer can be set in options, setting timer to 0 disables updates +( plugin will still do one update on start up even if timer=0). + +The "Update Data" button on the data window will re-download date from the specific website +that data window uses. +The "Stick to the front" button on the data window will allow or stop the display window +staying on top of other windows. +The "Find" button on the data window will allow you to find a word or phrase in the data +window. + +You can copy, cut and delete text from the data display window as well +as copy all, select all and clear all text by a drop down menu +when you click with your right mouse key on the edit area of the data +display window. + +The web page being available, down or lagging, server error returned or alert issued will all +change the status icon on the contact list for the specific contact that even happened to. +Online, offline, error and alert all have their own icon which can be set in Miranda's Icon +options. + +N/A status icon means the site is offline or lagging. +Away status icon means the server returned an error. +Online status icon means site is working normally. +Offline status icon means the protocol has been manually put offline. +Occupied status icon means an alert has been issued for that site. +DND status icon means plugin is downloading or processing data for that site. + +You can set the sound to be used when there is an alert in the Sounds section of Miranda +Options. + +In PopUp options you can set the popup time out, various options for selecting the color of the +popup and select left and right click options. + +You can view the complete source code for a web page if you set the Contact Options +to display the whole web page, untick Clean Up Display then update (download) +the data for that Webview contact. + + +***** +Here follow the essential settings you need to have +right to get a result. +***** + +There is an option in the contact options to put in the URL of the +website you wish to display contents of. +Note: Netlib doesn't support redirection, make sure you dont use +plugin to monitor a site that does this because it will not work. + +There are two search string options which are used to find data on the +web page. The first is the Start string, this is a string or sequences of tags and words in the source +code of the web page where you wish to begin displaying data on your data window. +The second is the End string, this is a string or sequences of tags and words in the source code of +the web page where you wish to stop displaying data on your data window. +Note: To find these display strings you should know how to look at the source code of +the web page you are looking at. If you don't wish to use a browser to go find out what the +source code looks the you can use the search strings like this: +Start:<html +End:</html> + +or +Start:<HTML +End:</HTML> + +If you do not want to have to use start and end strings you can select the option +to display the whole site then the plugin will display the contents of the entire +web page. + +There is a button to the Contact Options dialog to copy the display +Start and End strings to the alert Start and End strings and set +the event type to "Alert When A Specific Part of Web Page Changes". +***** + + +Requirements +------------ + - Miranda IM 0.7++ +(Popup plugin recommended + but not essential) + +Popup plugin is used for displaying error messages, but OSD plugin can also be used. + + +To Do +-------- +-Unicode support!!! +-need to review the plugin documentation and see what needs to be added or removed from it. +-window option to load cache into window and have it processed? +-create webview group on contactlist and automatically add sites to it? +-menu item to close all webview windows? + + + +Changelog +---------- +0.0.1.0 +-Use SETI@Home 1.3.0.0 sources as + base code for Webview +-Change icons +-rename and remove various options + and DBKeys +-Lets set some HTML headers to keep + some sites happy +-Successfully displayed selected data from + a site using search strings +0.0.2.0 +-Removed some old data window functions +-Prevent users using an end string, thats present + in the data BEFORE the search string. +-Created a dialog for displaying data, + discontinue using MessageBox() +-Don't open another dialog if one is + already open +-Update dialog automatically after download +-Clear data in dialog only if new data exists +-Display complete page if no search strings + set or if not present +-Added back "stick to front" and "hide/show" features + to code. +-Treat a destroyed window the same as a hidden + one in options and menus +-Added back right-click menu and automove + to code(automove a little buggy) +-Add hyperlink to dialog +-Use dllname in titlebar +-Add resize code +-Added Multiwindow code(buggy) +0.0.3.0 +-Back out displaying complete page if no search strings + set or if not present (results unpredictable) +-Update hyperlink when changed in options +-Back out code to allow automove to be used if + dragged with titlebar.Caused plugin to consume + all system resources when first minimized then attempted + to restore/maximise/close. +-Make sure correct url value present before + opening it using the hyperlink +-Removed option and key for disabling automove, + user can just drag with the titlebar +-Removed all options and keys related to + saving to file, not really needed, + data can be copied and pasted from + data window. +-Removed option for clearing old data. + Code now does this automatically if + needed +-Removed common dialog library +-#include <richedit.h> +0.0.4.0 +-Got rid of the old data structures +-Positioned the close button a little better +-Check to see that Miranda version is at least + 0.3.2.0 before loading plugin +-Added richedit control to dialog +-Hotkeys working again +-Backout Multiwindow code, much too buggy +-Intermittant crash on startup.Cause seems + to be that popup service isn't threadsafe. + Don't call from thread, use a timer to call + an error function that will check for presence + of errors +-Unregister then reset hotkeys after dialog is + created +-Got rid of some old unused variables +-rebase to 0x2d900000 +-Use modeless dialog instead of + MessageBox() +-Make sure there isn't more than one error + dialog with same message created (assuming + user closes all the error messages) +0.0.5.0 +-If the update interval is set to zero + don't activate the error reporting timer on + startup +-Only do update on startup if interval is not + zero +-If the update interval is changed to a value + other than zero then restart the error reporting + timer +-Added advanced options to control displaying text + before or after the search strings +-Got change background color option working +-Error check is now run one minute after update +-Added a button in advanced options to check + for errors +-Make data dialog read only +-Error timer not restarting with correct interval +-Moved Load() to main.c +-Added support for PluginUninstaller +-Renamed license and readme to make + easier to uninstall +-Got "use windows colors" option + working +0.0.6.0 +-Replaced the right click menu with a button + on the data display window +-Use main plugin icon for button +-Improved code for setting background + color +-Got text color working +-Change memory usage depending + on data download size +-Write downloaded data to the + database(maybe just a temporary + measure) +-Clear display before write new data + to dialog +-Don't allocate/free memory or use + download arrays if download unsuccessful +-URL not showing on dialog after reboot +-Initialise dialog with web data stored in + database +-Cleaned up an icon +-Removed writing data to database +-Only free memory when new data available + and in Unload() so all functions can + access data +0.0.7.0 +-Wrote basic data save to file function +-Readded common dialog library and restored + the saving functions to similar level to + that in SETI@Home plugin +-Changed the advanced search options a little + to avoid confusion. +-got basic tag erasing code in place +-Fixed crash in tag erasing code +-Got tag with attributes erasing working +-Support filtering both upper and lower + case tags +-Remove excess whitespace +-Improvments to background color code +-small changes to text coloring code +-Got rid of "Use windows colors" option +-Put in an option to enable filtering + of tags and whitespace +-Fixed crash while removing whitespace + if search strings were not found/set +-Choice to enable using popup plugin or not + even if popup service exists +-Fixed some error dialog bugs +-Fixed automove, now works better + with titlebar, removed the easy move + feature for now +-Don't save win size, position etc. when + window max'ed or min'ed, also don't + automove() +-Save width of window +-Fixed bug where the saved window size/position + wasn't being used +-Save new window size/position after resizing +-Holding down ctrl key while moving + data dialog disables automove +-Load old NETLIBHTTPREQUEST struct + if Miranda version less than 0.3.3 +-Remove some old unneeded variables +0.0.8.0 +-Warning on startup if Miranda version less than + 0.3.2 +-Disable "Use Popup Plugin" option if popup + service isn't loaded +-Other small changes to Advanced Options +-Resistered the webview protocol and + added basic services +-Allow return to be allowed in the richedit + control with out closing the dialog +-Add maximise and minimise buttons to data + dialog +-Got rid of horizontal scroll bar on data + dialog, the richedit control automatically + wordwraps +-Added contact to clist, make it name itself to + the same as the dllname +-Don't add contact to list if a contact already + exists +-Changed the minutes setting to spin control +0.0.9.0 +-Change main menu items dynamically +-Changed options dialog to make visually + better.Removed some options, changed others +-Use balloon tip for error messages +-Removed "use popup plugin option". + Plugin now uses the following 3 methods for + displaying errors(in decreasing priority) + *Balloon tip(if OS supports) + *popup plugin(if service loaded) + *Error dialog(if the neither balloon tip + or popup can be used) +-If server is down but previously gave back + a server error then make sure the server error + is cleared before reporting that the server is down. +-Control contact status by global status and protocol + status +-Don't download data if current protocol status + is offline +-Change contact status depending on download + *Download success = online + *server offline = n/a + *server error = away +-Added item to contact menu to show/hide + data dialog +-Treat <a> same as other tags for now +-first public alpha release +0.0.10.0 +-Remove support for 0.3.2 NetLib +-Don't load plugin if Miranda version + less than 0.3.3 +-Remove hbrush, not used anymore +-Fixed intermittant crash when contact + already exists +-minor changes to options +-added items to contact for update,stick to + front and open web page. +-New icons for show/hide window om menu menu. +-Dynamically change contact menu item text + and icons +-Some changes to drop down menu +-URLs now open webpage when clicked +-Added new Unstick icon +-Removed advanced search options.Search + strings are now always included in displayed + data (prior to tag filtering) +-Added Webview Group to clist to hold + contacts generated by multiple instances + of the plugin +0.0.11.0 +-make spin control work in the correct direction +-Moved options to Network group +-Dynamtically change text on data dialog + menu items +-Remove stick to front and update data Main menu + items +-Stop sending Content-Length header to sites +-Moved save to file options from advanced + options dialog to options dialog +-Removed check for errors option +-Made logging to file an advanced option +-Added multiple monitor support +-Destroy data window when ME_SYSTEM_PRESHUTDOWN + event occurs +-reduce disk I/O by storing colors, + window height and window position + in global variables.Variables only + read/written to DB on start/exit. +-added copy/copy all/select all menu to right click +0.0.12.0 +-Added size grip to data dialog +-Added separate stick/unstick button to data dialog +-Removed stick/unstick item from drop down menu +-Made buttons into flat buttons +-Make WM_CLOSE hide the data window instead of + destroying it. +-Removed Update and Stick/Unstick contact menu + items +-Moved main menu item position to the same place + as other protocols +-Removed advanced option dialog for now +-Updates to README +0.0.13.0 +-Double clicking on contact opens web page in browser +-Added some comments to menu items. Some menu items + will be removed in a future release, and other new + items will be added(new items are disabled for now) +-New icons for Add user and Contact options menu items + and new icon for drop down menu button on data window +-Added some more tags to the filter +-Change (Latin, Numeric and some punctuation) HTML + character codes into characters. +-Change data window caption to the URL. +-Change contact name to the URL. +0.0.14.0 +-Added icon to data window titlebar +-Filter out some more tags +-Added update button to data window +-Removed drop down menu button (no + need for anymore, all of the functions + of it can be accessed from the data window) +-Added Clear All, Paste, Cut and Delete + to right click menu +-Fixed a bug where double clicking on any + contact from any protocol opened up + a page in a browser.. opps +0.0.15.0 +-Added tooltips to buttons +-added more tags to filter +-Added contact options dialog (disabled + for now) +-Crash when tag filter sometimes tries to write + outside of the array (hopefully fixed). +-Crash with some sites crash if free + szInfo after tags are filtered + out(hopefully fixed) +-Crash (possibly related to the crashes above), + no idea what causes it really but fixed by + a delay midway in the tag filtering function +0.0.16.0 +-Added some more tags to filter +-Opps..was dependant on other plugins + to load richedit into memory +-Removed options in Miranda options + for hiding and sticking window to the + front(no longer needed because soon + will be moving to contact based options) +0.0.17.0 +-Enabled the contact optons dialog +-Removed Url, start string and start string + options from plugin options to the contact + options dialog +-Store url, start string and start string + in the contact settings not in the plugin + module in the database. +-reduced some crash risks +-Added option to enable updating data on + Miranda startup +0.0.18.0 +-possible crash when freeing memory in unload, + free in pre-shutdown instead (possibly isn't + the solution) +-Enable the add contact menu item. +-Some other changes to usage of malloc + and free +-Small delay added before downloading data + on startup, also reduced a delay else + where in the code +-Added code to check multiple sites +-Some more code to try and avoid crashes +-Change individual contact status to indicate + site status +-Remove hotkeys (possibly temporarily) +-Move save to file options to contact options +0.0.19.0 +-More stability improvements +-Stick to front option working again +-Disable file save options in add contact dialog +-Code cleanup +0.0.20.0 +-URL sometimes corrupted +-Got background and text color change options + working +-Removed feature where timer set to zero stopped you + downloading data manually +-Clear all data windows when changing text/background + color (possibly a temporary measure) +-More code cleanup +0.0.21.0 +-User can choose either to open web page + in a browser or opening the data window + as the action taken when double clicking + on a webview contact +-Option to update data when data window + opened +-Removed old show/hide contact menu item + and replaced with a new open/close menu item + with a new icon +-New add contact icon and show more icons + on dialogs +-Better handling of protocol/global status +-Other minor fixes +-Added a new contact option to add + contact/site name. +-When adding a new site,if you leave the site name + blank then the site name will automatically be + the same as the sites URL +0.0.22.0 +-Make an option to hide icon on status bar +-show the icon again if there is a crash +-Make the titlebar text of the contacts + data window the same as the name of the + contact +-only look for end string further down + the page from the start string +-Remove garbage from end of displayed + text +0.0.23.0 +-Got the options on the data display window + working properly again +-Fixed a bug where double clicking on a webview + contact sometimes opened a message window. +-Cleaned up code +0.0.24.0 +-Allow user to set separate double click action + for each webview contact from the contact options. +-Updated icons. +-Faster (and more stable) method for copying web data + into memory used. +-Use Save As dialog instead of Open + to select log file. +-Added a search button to Webview data window. + Search is pretty basic as yet but it shows you + the approximate area of the window where the search + keyword was found. +-Use monospaced font in data window because its easier + to read text in window. Also made font bigger for the same + reason. +-Status messages displayed on status bar of data window. +-Code to remove more unsupported symbol codes and other + unwanted data from the data window when the clean + up display option is selected. +-Updates to the README. +0.0.25.0 +-The Find button now can find and highlight the + exact position of the requested word in the + data window. +-The Find button's text search is no longer case + sensitive. +-Status bar on data display window now tells you + the time the last update of data occured from + that window. +-You can now set the exact amount of whitespace + to filter out of the data window display through + a trackerbar control in Miranda options. +-Font face and size as well as attributes bold, italic + and underline can now be set from Miranda options. +-Some stability fixes and slightly better support for + large sites. +-Added more panes to the status bar. +-Status bar on data display window now tells you + the number of bytes of data displayed in that + window and the number of bytes downloaded. +-Fixed a bug which caused some of the text not to + be formatted correctly with larger sites. +-Some other minor changes. +0.0.26.0 +-Removed some spaces left in the formatted text by the + character code to symbol function. +-Compiled code with some optimisations. +-Added options to Miranda options to select + the method of tag filtering; accurate, fast + or dynamic filtering. +-Moved Display Clean-up options to the contact + options dialog so you can set different options + for each site. +-Moved options back to Plugins group. +-Some bug fixes for the Add Contact/Contact + options window. +-Fixed bug where part of the code regarded + a error reply from the server as a download + success. +-Status messages for "Server down or lagging", + "Server replied with an error code" and "Download + successful now about to process data" added to + status bar messages on the data display window. +-Some more tags added to tag filter +-More changes to the README. +0.0.27.0 +-Make sure the first letter of the plugin name + in options is always uppercase. +-Error messages now show for each individual site + using either balloon message on the system tray + icon or using popup plugin if available. The + popup messages are better and that option is + recommended. +-New Contact Options button added to the data + display window which replaces the Options menu item + on the contact menu. +-Some changes to code that removes the parts of the webpage + that are supposed to remain hidden. +-There is only one method of filtering now; the fast + filter. All options for choosing filter method removed. +-Added Alert button to data display window. +-There are two alert methods used for now; popup + plugin and sound file. There is one alert event + for now; string present in downloaded data. +-Small problem with plugin's response to global + status changes fixed. +0.0.28.0 +-Added some more translatable strings. +-Fixed some bugs in and added some improvements + to the Alert Options dialog. +-Log to file was removed from Contact Options + and is now an Alert option. +0.0.29.0 +-Made the plugin information in the plugin listing + more descriptive. +-Fixed bug with hyperlink on data display window by + making control a button. +-Added cancel and Apply buttons to Add Webview Site, + Contact Options and Alert Options windows. +-If the user does not supply a name when creating + a new webview contact then the plugin no longer just + uses the URL of the site as a name but requests + that the user supply a name. Using a URL as a + name just looked too messy. +-When an alert is issued the date and time of the alert + is appended to the contact name. +-The contact name in Contact Options is the contact name without + any alert time and date appended to it. +-Fixed bug which where the presence of an ampersand in the + url caused letters to be underlined or missing in the + text of the url button on the data display window. +-Removed the sound alert. Now you can instead set + a sound be played when an alert occurs from the + same Sounds group in options that other plugins + use. +-Disabled the apply button on the add contact window. +-Added more translatable strings including error + messages, menu items and status bar messages. +-Fixed bug where the description of the amount + of white space removal was not showing in the + Add Webview Site window. +-Other minor changes. +0.0.30.0 +-Set the titlebar text of the display data window + to contact name without any alert time and date + appended to it. +-Added event-type "Alert When The Web Page Change". + This produces a user-defined alert when the the + contents of a page change from what was on the page + when it was last checked. This option creates + a file on the users harddrive for every contact + this option is set for. +-Update URL displayed on the data display window + if that URL is changed in Contact Options. +-Fixed bug which caused buttons on data display + window not to work if URL was changed. +-Use PUShowMessage to generate any popup error + messages. +-Contact Options now requests that the user supply a name + for a contact if one is not already supplied. +-Contact Options and Add Webview Site windows now check + to see if there are any invalid symbols in the contact name + (this is needed to make sure the file name is valid for the + cache file). +-Change the titlebar text of the data display window when + the contact name is changed and the changes are applied ( + used to work only if user pressed "Ok"). +-Made some more of the text on different windows titlebar's + translatable.Also made some changes to the code to allow + the translation of some of the dynamic strings which occur + on the data display windows status bar and in alert popups. +-Added an alert type to open the data display window when + a user defined event occurs. +-Fixed bug which caused the icon of the (Disable) Stick to the + Front button always to show the Disable icon when the + window was first opened by double clicking on a contact. +0.0.31.0 +-Make sure the time and date is not appended to the contact + name on contact list UNLESS an alert has been issued. +-Miranda Translator tool was not translating some strings + correctly even though they were translatable. Made changes + to the code to help the Translator extract the correct strings. +-Make the appending of the time of the last alert to the contact + list name a contact option. +-Added a Popup option dialog to the PopUps group in Miranda + options so users can set the color of the Alert popups separately + from the color of the data display window. The user can also set + the popup delay from this option dialog. +-Added an option to Alert Options to allow the user to define whether + the date is added to the contact name as a suffix or a prefix. +-increased thread safety for popups. +-Added webview to the "KnownModules" list. +-User can now control whether the time added to the contact name + is in 24 hour or 12 hour format. +0.0.32.0 +-Made an install script for Miranda Installer. +-Added an item to the Main menu to allow the user to update + all Webview sites at once. +-Cleaned up indents in source code. +-Fixed bug in the the code which removes unsupported character + code from the display. +-Fixed bug in code which caused the plugin not to clean up the display + if one or more of the Start or End strings was not present on + the web page even if plugin didn't need to check for these strings. +-Separated the sources out into smaller files. +-There was no way of adding a new webview site if the user had disabled + the main menu items. Added options to take place of the main menu items + in the main Miranda options dialog and made sure these options are not + enabled unless the main menu is disabled. +-Right clicking on a popup now opens the web site in a browser window. +-Added "Only Update Window on Alert" to main Miranda options to prevent + contents of the data display window being overwritten if there + is not an alert. +-Changed the automove function so it no longer moves the data display + window back on screen (if the user moves it off of it) but just + makes sure the position will be on screen the next time it is created. +-If Miranda crashed on exit then the window colors were not being + saved; save colors when the color options are changed to prevent this + happening. +-Added a main menu item to enable or disable automatic updates of webview + sites. +-Increased time interval range from 0-99 minutes to 0-999 minutes. +-Fixed some bugs in the the Popup options. +-Added option to use the same colors in the alert popup as is + used in the data display window. +-User can now set the left and right click popup actions from + popup options. User can set the actions to open data display window, + open web page or dismiss popup. +0.1.0.0 +-First Beta release +-Make sure the first letter of the Webview menu title on + the Main menu is uppercase. +-Use the Miranda Find/Add Contacts dialog to add webview + sites to the contact list. +-Use the URL to create a name for the contact. +-Make sure the update button on the data display window + always can update the text in the window even if the + "Only Update Window on Alert" option ticked. +-Fixed bug which caused an invalid window position to be written + to the database if data display window was minimised when + Miranda exited. +-Make sure the site name in Contact options and on the data + display window's titlebar is the same as the contact name + on the contact list unless it has a date added to it. +-If Miranda crashed on exit then the window position was not being + saved; save position when the window is closed to prevent this + happening. +-On slower systems data display window was seen in a different + area of the screen when opened then it was seen to move to + the correct position on the screen. Put fixes in place to correct this. +-Added an event type to test if a specific area of a webpage has changed +-Fixed some bugs in the Alert Options dialog. +-Fixed bug which caused update button to become disabled if the + user clicked the button when that site was already being downloaded. +-Check for alerts BEFORE filtering cleaning up the text. +-Added the option to display alerts using the OSD plugin. +-Fixed a bug that caused the plugin to falsely report that + the monitored website had changed. +-Make sure the Apply buttons on the Contact Options and the + Alert Options windows is disabled unless there is a change + made to the options. +-If either the display or alert start/end strings aren't present on + on a site issue an alert. +-Start/End string not present and invalid search parameter errors + now set the contact to Away status (just like server error codes). +-Added a button to the Contact Options dialog to copy the display + Start and End strings to the alert Start and End strings and set + the event type to "Alert When A Specific Part of Web Page Changes". +-If a server replies with an error code display the exact error code + returned. +-Find/Add dialog was truncating URL's. +-Added more compact Contact Options and Alert Options dialogs +-Made the comboboxes in the Alert Options dialog translatable. +-Some improvements to the code that fixes the underlined text + bug on the url button. +-Disable both the Contact Options and the Alert Options button + when then either then Contact Options or the Alert Options + button is opened (need to do this to avoid a bug). +-Allow user to have more than one contact with the same URL + if those contacts have different names. If more than one + contact has the same name and URL then issue a warning + when using buttons on those contacts data display window. +-Allow user to add contacts with the same URL and an existing + Webview contact. +-Append a random number to the contact name when it is created + to avoid creation of Webview contacts with the same name if + they are using the same URL. +-Added a status bar message to tell the user that a site is currently + downloading if they try to update another site manually. +-Error now display using either PopUp plugin or the OSD plugin + if the "display errors using PopUp plugin" option is selected. + The plugin tries to use the PopUp plugin first but if that service + is not available then it uses the OSD plugin (if plugin is loaded). +-Removed some unneeded preshutdown code. +-Removed support for Plugin Uninstaller (that plugin will not work in + Miranda 0.4 anyway). +-Removed main Webview option control which was used to add new Webview + contacts (the user can easily do this through the main menu item or + by the Find/Add dialog if the main menu item is disabled). +-Updates to the README. +0.1.1.0 +-Some improvement to the code that converts HTML character entities to + symbols. +-Remember contact previous status on startup. +-Stop the User Details dialog from constantly displaying "...Updating...". +--Button in the Contact Options dialog to copy the Start and End strings + was not setting the event type to "Alert When A Specific Part of Web Page Changes". +-If "Update window only on Alert" option was ticked statusbar was always displaying + "processing data, please wait" if all the sites were updated at the same time. Corrected + and added another status message. +-Make sure all existing Webview contacts are set to online status the first time this + version of Webview is loaded. +-Added a control to the main options to allow the user to set a delay of up to 120 + seconds before Webview updates on start-up. +-Make sure the timed updates cannot occur until the update on start up is finished. +-Don't log to file twice if both types of start/end strings are not present and there is an + alert to indicate this. +-Automatically delete the cache file (if one exists) when deleting a Webview contact + or when alerts are disabled for that contact. +-Webview now knows when a contact is renamed on the contact list. +-Rename the cache file (if one exists) when a contact is renamed. +-Added the option to save the position of individual data display windows. +-Added some delays to make the plugin slightly less CPU usage intensive + during data download and processing. +-Added an advanced option to disable the download protection code if + the user wishes to do this. This has the advantage of being able to + download more than one site at the same time but it also potentially + could cause corruption of data. +-Fixed a bug in the main Webview options. +-Display time/date in the logs and on the status bar in the + users own language. +-Bug causing last letter in display to be sometimes repeated. + This isn't a complete fix but it should stop the worst cases. +-Added option to Contact Options so user can choose to log + data to file in its raw state or with all the tags removed. +-Added a new status (DND) to indicate the plugin is downloading or processing + data for a particular site. +-Filter out (most) CSS attributes. +-When part of the web page has changed, change the color of the text + and background (and select the text) in the part of the page you are + monitoring so that the user can find this portion of the page easier + within the larger body of the displayed text. +-Made some more space for translation strings in options. +-Fixed some bugs in the EraseBlock function which causes + the plugin to hang while processing data. +-Data window too small when it opened the first time. Made + window bigger. +-Use SkinAddNewSoundEx instead of SkinAddNewSound. +-Prevent Miranda versions less than 0.4.0.0 from loading plugin. +-Cleaned up code. +-Added TopToolBar buttons for adding Webview sites,updating + all Webview sites and disabling/enabling auto update. +-Only load TopToolBar buttons if Main Menu items are disabled. +-0.1.3.1 +-added "prettier" icon resources. +-Removed" Add Webview Site from main menu. +-Added code to get ride of <style> </style>. +-removed TopToolbar support +-Added Contact Options and Contact Alert Options to the contact menu. +-Moved from PLUGININFO to PLUGININFOEX structure +-Moved Webview's options from "Plugins" to "Network" in Miranda's options page. +-Improved language pack support. +-Added menu item to open cache folder. +-New icon for Update All main menu item and Open Web Page contact menu item. +-Added main menu item to mark all sites read +-Added contact menu item to update site data. +-Added Contact Menu item to ping the web site to test if there is any issue with connectivity. +-0.1.3.2 +-Fixed an old bug where a DB value was getting written to any contact which was double clicked + regardless of its protocol. +-The URL of a Webview contact is now also the contact's "Web Page" in user details. +-Stop displaying unneeded status icons on the status bar. +-Removed BBCode from popups to make compatible with YAPP. +-The progress of data processing is shown on the data window. +-Added contact menu item to stop the data processing on a site. +-0.1.3.3 +-Stopped translating some clist items that should not be translated except by the core. +-Add random number to contacts name when contact is created, if its the same as the + name of another webview contact on the list. +-When updating all sites, don't wait for one site to finish updating before updating + the next. +-The contact's StatusMsg now reports the site updating, offline, online, alert issued and site errors. +-Removed an old part of the data window that is no longer needed. +-Added a button to the data window to allow the user to stop data processing. +-Text in data window updates during data processing. +-0.1.3.4 +-Backed out a change in the code which was causing false alerts. Contacts have to + wait for other sites to stop updating before updating themselves. +-Smaller cache size. +-0.1.3.5 +-Destroy services on exit. +-Popup message when all sites have been updated. +-If Miranda crashes, the status icon no longer reappears on the statusbar bar, if + the user had originally chosen to hide it. +-0.1.3.6 +-Smaller dll size. +-Swapped the stick and unstick icons. +-Added option to Main Options to display site data in a Popup when there is an alert. +-Show error message if psite.bat doesn't exist and user is attempting to ping a site. +-Show error message if cache folder doesn't exist and user is attempting to open it. +-0.1.3.7 +-Fixed a potential crash when updating contacts. +-If user renames a contact to a name containing a forbidden character, + there is an error popup to inform them and the character is converted to a "_" + and a random number appended to the end of the name. + -0.1.3.8 + -The "Update on Window Open" option has been changed to "Load Page on Window Open". +This change means when the option is selected, the window will first of all attempt to +load information into the window from the cache, and only if the cache file doesn't exist +will it attempt to download the web page and display it. +-Mark site as read when window is opened and window is set to load data on open. +-0.1.3.9 +-Prevent a crash when "Add Contact" is used instead of "Find/Add Contact", and also when + "Find/Add Contact" is used incorrectly. +- Opening a site in a browser window using double click, contact menu, the url button + on the data window or clicking on popups, all set the contacts status to online/read. +-Added a counter to the Webview main menu, which shows how many minutes to the next update. +-Changed the "Permanent" and "From Popup Plugin" options in popup options, from radio + buttons to buttons. +-0.1.3.10 +-Made separate Unicode and ANSI versions of plugin. +-Removed some old unneeded code. + + + + + + + + + + + +********************* +Copyright +--------- +Copyright (C) 2011 Vincent Joyce + +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. + + + diff --git a/plugins/!NotAdopted/WebView/forkthread.c b/plugins/!NotAdopted/WebView/forkthread.c new file mode 100644 index 0000000000..a1e8a2613a --- /dev/null +++ b/plugins/!NotAdopted/WebView/forkthread.c @@ -0,0 +1,77 @@ +/* +A plugin for Miranda IM which displays web page text in a window. +Copyright (C) 2005 Vincent Joyce. + +Miranda IM: the free icq client for MS Windows +Copyright (C) 2000-2 Richard Hughes, Roland Rabien & Tristan Van de Vreede + +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. +*/ + + +#include "webview_common.h" + + +//from Yahoo to make it work on Dev C++ + +#if 0 + #include <crtdbg.h> +#else +#define __try +#define __except(x) if (0) /* don't execute handler */ +#define __finally + +#define _try __try +#define _except __except +#define _finally __finally +#endif + + + + +void __cdecl forkthread_r(void *param) +{ + struct FORK_ARG *fa=(struct FORK_ARG*)param; + void (*callercode)(void*)=fa->threadcode; + void *arg=fa->arg; + CallService(MS_SYSTEM_THREAD_PUSH,0,0); + SetEvent(fa->hEvent); + __try { + callercode(arg); + } __finally { + CallService(MS_SYSTEM_THREAD_POP,0,0); + } + return; +} + + + + +//////////////// + +unsigned long forkthread ( void (__cdecl *threadcode)(void*),unsigned long stacksize,void *arg) +{ + unsigned long rc; + struct FORK_ARG fa; + fa.hEvent=CreateEvent(NULL,FALSE,FALSE,NULL); + fa.threadcode=threadcode; + fa.arg=arg; + rc=_beginthread(forkthread_r,stacksize,&fa); + if ((unsigned long)-1L != rc) { + WaitForSingleObject(fa.hEvent,INFINITE); + } //if + CloseHandle(fa.hEvent); + return rc; +} diff --git a/plugins/!NotAdopted/WebView/main.c b/plugins/!NotAdopted/WebView/main.c new file mode 100644 index 0000000000..5b389a146d --- /dev/null +++ b/plugins/!NotAdopted/WebView/main.c @@ -0,0 +1,566 @@ +/* + * A plugin for Miranda IM which displays web page text in a window. + * Copyright (C) 2005 Vincent Joyce. + * + * Miranda IM: the free icq client for MS Windows + * Copyright (C) 2000-2 Richard Hughes, Roland Rabien & Tristan Van de Vreede + * + * 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. + */ + +#include "webview_common.h" +#include "webview_services.c" +//#ifdef UNICODE_VERISON +//#include "utf8.c" +//#endif + +static HANDLE hService[20]; + +static HANDLE hButtonInit = NULL; +static HANDLE hUpdateButton = NULL; +static HANDLE hAddSite = NULL; +static HANDLE hAutoUpdate = NULL; +static HANDLE hHookModulesLoaded = NULL; +static HANDLE hHookOptsInit = NULL; +static HANDLE hNetlibUser = NULL; +static HANDLE hDoubleclick = NULL; +static HANDLE hWindowList = NULL; +HMODULE hRichEd = NULL; +static HANDLE hEventContactDeleted = NULL; +static HANDLE hDBSettingChanged = NULL; +int hLangpack = 0; + + +PLUGININFOEX pluginInfo = +{ + sizeof(PLUGININFOEX), + #if defined( _UNICODE ) + "Webview Protocol (Unicode)", + #else + "Webview Protocol", + #endif + PLUGIN_MAKE_VERSION(0, 1, 3, 10), + "Adds web pages as contacts to your contact list and can display text and/or issue change alerts from those pages in a window", + "Vincent Joyce", + "ungoliante666@hotmail.com", + "� 2011 Vincent Joyce", + "http://miranda-im.org", + UNICODE_AWARE, + 0, + #if defined( _UNICODE ) + {0xcd5427fb, 0x5320, 0x4f65, { 0xb4, 0xbf, 0x86, 0xb7, 0xcf, 0x7b, 0x50, 0x87}} + // {CD5427FB-5320-4f65-B4BF-86B7CF7B5087} + #else + {0x28108e4b, 0x8680, 0x4961, { 0xbd, 0x31, 0x74, 0x54, 0xc1, 0x3f, 0xc5, 0xdf}} + // {28108E4B-8680-4961-BD31-7454C13FC5DF} + #endif +}; + + + + +/********************************/ + +int WebsiteContactCommand(WPARAM wParam, LPARAM lParam) +{ + WebsiteMenuCommand((WPARAM) wParam, (LPARAM) lParam); + return 0; +} + +/*******************************/ + +/*******************************/ + +void InitServices() +{ + char SvcFunc[100]; + + strcpy(SvcFunc, DLLNAME); + strcat(SvcFunc, PS_GETCAPS); + hService[0] = CreateServiceFunction(SvcFunc, GetCaps); + + strcpy(SvcFunc, DLLNAME); + strcat(SvcFunc, PS_GETNAME); + hService[1] =CreateServiceFunction(SvcFunc, GetName); + + strcpy(SvcFunc, DLLNAME); + strcat(SvcFunc, PS_LOADICON); + hService[2] =CreateServiceFunction(SvcFunc, BPLoadIcon); + + strcpy(SvcFunc, DLLNAME); + strcat(SvcFunc, PS_SETSTATUS); + hService[3] = CreateServiceFunction(SvcFunc, SetStatus); + + strcpy(SvcFunc, DLLNAME); + strcat(SvcFunc, PS_GETSTATUS); + hService[4] =CreateServiceFunction(SvcFunc, GetStatus); + // + strcpy(SvcFunc, DLLNAME); + strcat(SvcFunc, PS_BASICSEARCH); + hService[5] = CreateServiceFunction(SvcFunc, BasicSearch); + + strcpy(SvcFunc, DLLNAME); + strcat(SvcFunc, PS_ADDTOLIST); + hService[6] =CreateServiceFunction(SvcFunc, AddToList); + + strcpy(SvcFunc, DLLNAME); + strcat(SvcFunc, PSS_GETINFO); + hService[7] =CreateServiceFunction(SvcFunc, GetInfo); + +} + +/*******************************/ +void ChangeContactStatus(int con_stat) +{ + HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + char *szProto; + WORD status_code = 0; + + if (con_stat == 0) + status_code = ID_STATUS_OFFLINE; + + if (con_stat == 1) + status_code = ID_STATUS_ONLINE; + + if (con_stat == 2) + status_code = ID_STATUS_AWAY; + + if (con_stat == 3) + status_code = ID_STATUS_NA; + + while (hContact != NULL) + { + szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + if (szProto != NULL && !lstrcmp(DLLNAME, szProto)) + { + DBWriteContactSettingWord(hContact, DLLNAME, "Status", status_code); + } + hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0); + } + +} +/***************************/ + +/***********************/ +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + hInst = hinstDLL; + return TRUE; +} +/************************/ + +/*******************/ +__declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + + if (mirandaVersion < PLUGIN_MAKE_VERSION(0, 7, 0, 0)) + MessageBox(NULL, "Please upgrade your Miranda IM, version you are using is too old.\nThe current stable release is 0.9.25.", "Webview plugin error", MB_OK); + + if (mirandaVersion < PLUGIN_MAKE_VERSION(0, 7, 0, 0)) + return NULL; + + return &pluginInfo; +} +/******************/ + +/******************/ +static const MUUID interfaces[] = {MIID_PROTOCOL, MIID_LAST}; +__declspec(dllexport) const MUUID * MirandaPluginInterfaces(void) +{ + return interfaces; +} +/******************/ + + + + +/************************/ +int __declspec(dllexport) Unload(void) +{ + + ChangeContactStatus(0); + + KillTimer(NULL, timerId); + KillTimer(NULL, Countdown); + + DBWriteContactSettingByte(NULL, DLLNAME, HAS_CRASHED_KEY, 0); + SavewinSettings(); + if (hRichEd) + FreeLibrary(hRichEd); + + if (hHookOptsInit) + UnhookEvent(hHookOptsInit); + + if (hHookModulesLoaded) + UnhookEvent(hHookModulesLoaded); + if (hNetlibUser) + Netlib_CloseHandle(hNetlibUser); + if (hDoubleclick) + UnhookEvent(hDoubleclick); + if (hHookDisplayDataAlert) + UnhookEvent(hHookDisplayDataAlert); + if (hHookAlertPopup) + UnhookEvent(hHookAlertPopup); + if (hHookAlertWPopup) + UnhookEvent(hHookAlertWPopup); + if (hEventContactDeleted) + UnhookEvent(hEventContactDeleted); + if (hDBSettingChanged) + UnhookEvent(hDBSettingChanged); + if (hUpdateButton) + UnhookEvent(hUpdateButton); + + hNetlibUser = NULL; + if (h_font != NULL) + DeleteObject(h_font); + if (hMenu) + DestroyMenu(hMenu); + if (hButtonInit) + UnhookEvent(hButtonInit); + if (hAddSite) + UnhookEvent(hAddSite); + if (hWindowList ) + UnhookEvent(hWindowList); + + DestroyServiceFunction(0); + + return 0; +} +/***********************/ + +/***************************************/ +int __declspec(dllexport) Load(PLUGINLINK * link) +{ + PROTOCOLDESCRIPTOR pd; + char path[MAX_PATH]; + char *dllname; + char *fend; + char countername[100]; + DBVARIANT dbv; + HGENMENU hRoot; + + //hRoot = MO_GetProtoRootMenu(DLLNAME); + //hRoot= ( HGENMENU )CallService( MO_GETPROTOROOTMENU, ( WPARAM )DLLNAME, 0 ); + + + + + + + GetModuleFileName(hInst, path, sizeof(path)); + dllname = strrchr(path, '\\'); + dllname++; + fend = strrchr(path, '.'); + *fend = '\0'; + DLLNAME = strdup(dllname); + + strncpy(optionsname, DLLNAME, sizeof(optionsname)); + optionsname[0] = toupper(optionsname[0]); + + pluginLink = link; + hDoubleclick = HookEvent(ME_CLIST_DOUBLECLICKED, Doubleclick); + hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXT)); + hRichEd = LoadLibrary("Riched20.dll"); + + /*TIMERS*/ + // + if ((DBGetContactSettingDword(NULL, DLLNAME, REFRESH_KEY, 0) != 0)) + { + timerId = SetTimer(NULL, 0, ((DBGetContactSettingDword(NULL, DLLNAME, REFRESH_KEY, 0)) * MINUTE), (TIMERPROC) timerfunc); + DBWriteContactSettingDword(NULL, DLLNAME, COUNTDOWN_KEY, 0); + Countdown = SetTimer(NULL, 0, MINUTE, (TIMERPROC) Countdownfunc); + } + // + + CheckDbKeys(); + InitialiseGlobals(); + + // register webview protocol + ZeroMemory(&pd, sizeof(pd)); + pd.cbSize = sizeof(pd); + pd.szName = DLLNAME; + pd.type = PROTOTYPE_PROTOCOL; + CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM) & pd); + +//protocol services + InitServices(); + +//add sound event to options + SkinAddNewSoundEx("webviewalert", optionsname, Translate("Alert Event")); + +//add module to known list + DBWriteContactSettingString(NULL, "KnownModules", "Webview Protocol", DLLNAME); + +/* + if (DBGetContactSettingByte(NULL, DLLNAME, HAS_CRASHED_KEY, 0)) + { + DBWriteContactSettingByte(NULL, DLLNAME, HIDE_STATUS_ICON_KEY, 0); + DBFreeVariant(&dbv); + } +*/ + +//value is 1 if menu is disabled + DBWriteContactSettingByte(NULL, DLLNAME, MENU_IS_DISABLED_KEY, 1); + + if (!(DBGetContactSettingByte(NULL, DLLNAME, MENU_OFF, 0))) + { +//value is 0 if menu is enabled + DBWriteContactSettingByte(NULL, DLLNAME, MENU_IS_DISABLED_KEY, 0); + + // + + + + + /*DISABLE WEBVIEW*/ + + hService[8] =CreateServiceFunction("DisableWebview", AutoUpdateMCmd); + ZeroMemory(&mi, sizeof(mi)); + mi.cbSize = sizeof(mi); + mi.position = 20200001; + mi.pszPopupName = optionsname; + mi.flags = 0; + mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_SITE)); + if (DBGetContactSettingByte(NULL, DLLNAME, DISABLE_AUTOUPDATE_KEY, 0)) + mi.pszName = "Auto Update Disabled"; + + if (!(DBGetContactSettingByte(NULL, DLLNAME, DISABLE_AUTOUPDATE_KEY, 0))) + mi.pszName = "Auto Update Enabled"; + + mi.pszService = "DisableWebview"; + hMenuItem1 = (HANDLE) CallService(MS_CLIST_ADDMAINMENUITEM, 0, (LPARAM) & mi); + //hMenuItem1 = (HANDLE) CallService(MS_CLIST_ADDPROTOMENUITEM, 0, (LPARAM) & mi); + + + + + + + + // + /* + * Update all webview contacts + */ + + hService[9] =CreateServiceFunction("UpdateAll", UpdateAllMenuCommand); + + ZeroMemory(&mi, sizeof(mi)); + mi.cbSize = sizeof(mi); + mi.position = 500090002; + mi.pszPopupName = optionsname; + mi.flags = 0; + mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_UPDATEALL)); + mi.pszContactOwner = NULL; + mi.pszName = "Update All Webview Sites"; + mi.pszService = "UpdateAll"; + CallService(MS_CLIST_ADDMAINMENUITEM, 0, (LPARAM) & mi); + + + + /* + // strcpy(tDest,"/Mind"); + mi.hParentMenu = NULL; + mi.pszName = "Update All Webview Sites"; + // mi.icolibItem = (HANDLE)IDI_UPDATEALL; + mi.icolibItem =LoadSkinnedIconHandle(IDI_UPDATEALL); + + (HGENMENU)( CallService( MS_CLIST_ADDPROTOMENUITEM, 0, (LPARAM) & mi)); +*/ + +// + + + /* + * Mark All Webview Sites Read + */ + hService[10] =CreateServiceFunction("MarkAllSitesRead", MarkAllReadMenuCommand); + ZeroMemory(&mi, sizeof(mi)); + mi.cbSize = sizeof(mi); + mi.position = 500090099; + mi.pszPopupName = optionsname; + mi.flags = 0; + mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_MARKALLREAD)); + mi.pszContactOwner = NULL; + mi.pszName = "Mark All Webview Sites Read"; + mi.pszService = "MarkAllSitesRead"; + CallService(MS_CLIST_ADDMAINMENUITEM, 0, (LPARAM) & mi); + //CallService( MS_CLIST_ADDPROTOMENUITEM, 0, (LPARAM) & mi); + + + // + /* + * open cache directory + */ + hService[11] =CreateServiceFunction("OpenCacheFolder", OpenCacheDir); + ZeroMemory(&mi, sizeof(mi)); + mi.cbSize = sizeof(mi); + mi.position = 500090099; + mi.pszPopupName = optionsname; + mi.flags = 0; + mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_FOLDER)); + mi.pszContactOwner = NULL; + mi.pszName = "Open Cache Folder"; + mi.pszService = "OpenCacheFolder"; + CallService(MS_CLIST_ADDMAINMENUITEM, 0, (LPARAM) & mi); + //CallService( MS_CLIST_ADDPROTOMENUITEM, 0, (LPARAM) & mi); + + + // + /* + * Countdown test + */ + + hService[12] =CreateServiceFunction("Countdown", CountdownMenuCommand); + + ZeroMemory(&mi, sizeof(mi)); + mi.cbSize = sizeof(mi); + mi.position = 600090099;; + mi.pszPopupName = optionsname; + mi.flags = 0; + mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_UPDATEALL)); + mi.pszContactOwner = NULL; + // +sprintf(countername, "%d Minutes to Update", (DBGetContactSettingDword(NULL, DLLNAME, COUNTDOWN_KEY, (DWORD)&dbv)) ); + DBFreeVariant(&dbv); + mi.pszName = countername; + // + + mi.pszService = "Countdown"; + //CallService(MS_CLIST_ADDMAINMENUITEM, 0, (LPARAM) & mi); + hMenuItemCountdown = (HANDLE) CallService(MS_CLIST_ADDMAINMENUITEM, 0, (LPARAM) & mi); + + + + + } + /* + * contact menu + */ + hService[13] =CreateServiceFunction("Open web page", WebsiteMenuCommand); + ZeroMemory(&mi, sizeof(mi)); + mi.cbSize = sizeof(mi); + mi.position = 100; + mi.flags = 0; + mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_URL)); + mi.pszContactOwner = DLLNAME; + mi.pszService = "Open web page"; + mi.pszName = "Open web page"; + CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM) & mi); + + hService[14] =CreateServiceFunction("OpenClose Window", DataWndMenuCommand); + ZeroMemory(&mi, sizeof(mi)); + mi.cbSize = sizeof(mi); + mi.position = 100; + mi.flags = 0; + mi.pszContactOwner = DLLNAME; + mi.pszService = "OpenClose Window"; + mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_SHOW_HIDE)); + mi.pszName = "Open/Close window"; + CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM) & mi); + + + + hService[15] =CreateServiceFunction("UpdateData", ContactMenuItemUpdateData); + ZeroMemory(&mi, sizeof(mi)); + mi.cbSize = sizeof(mi); + mi.position = 2222220; + mi.flags = 0; + mi.pszContactOwner = DLLNAME; + mi.pszService = "UpdateData"; + mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_UPDATE)); + mi.pszName = "Update Data"; + CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM) & mi); + + + hService[16] =CreateServiceFunction("ContactOptions", CntOptionsMenuCommand); + ZeroMemory(&mi, sizeof(mi)); + mi.cbSize = sizeof(mi); + mi.position = 2222220; + mi.flags = 0; + mi.pszContactOwner = DLLNAME; + mi.pszService = "ContactOptions"; + mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_OPTIONS)); + mi.pszName = "Contact Options"; + CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM) & mi); + + + + + hService[17] =CreateServiceFunction("ContactAlertOpts", CntAlertMenuCommand); + ZeroMemory(&mi, sizeof(mi)); + mi.cbSize = sizeof(mi); + mi.position = 2222220; + mi.flags = 0; + mi.pszContactOwner = DLLNAME; + mi.pszService = "ContactAlertOpts"; + mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ALERT)); + mi.pszName = "Contact Alert Options"; + CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM) & mi); + + + + hService[18] =CreateServiceFunction("PingWebsite", PingWebsiteMenuCommand); + ZeroMemory(&mi, sizeof(mi)); + mi.cbSize = sizeof(mi); + mi.position = 2222220; + mi.flags = 0; + mi.pszContactOwner = DLLNAME; + mi.pszService = "PingWebsite"; + mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_PING)); + mi.pszName = "Ping Web Site"; + CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM) & mi); + + hService[19] =CreateServiceFunction("StopDataProcessing", StpPrcssMenuCommand); + ZeroMemory(&mi, sizeof(mi)); + mi.cbSize = sizeof(mi); + mi.position = 2222220; + mi.flags = 0; + mi.pszContactOwner = DLLNAME; + mi.pszService = "StopDataProcessing"; + mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_STOP)); + mi.pszName = "Stop Data Processing"; + CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM) & mi); + + + + + hWindowList = (HANDLE) CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0); + + hHookModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded); + hDBSettingChanged = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, DBSettingChanged); + hEventContactDeleted = HookEvent(ME_DB_CONTACT_DELETED, SiteDeleted); + + + mir_getLP(&pluginInfo); + + DBWriteContactSettingByte(NULL, DLLNAME, HAS_CRASHED_KEY, 1); + return 0; + DBWriteContactSettingByte(NULL, DLLNAME, HAS_CRASHED_KEY, 0); +} + +/***************************************/ + + +void DestroyServices(void) +{ + unsigned i; + + for (i = sizeof(hService)/sizeof(HANDLE); i--; ) + { + if (hService[i] != NULL) + DestroyServiceFunction(hService[i]); + } +} +/********************************************/ diff --git a/plugins/!NotAdopted/WebView/res/Icon_14.ico b/plugins/!NotAdopted/WebView/res/Icon_14.ico new file mode 100644 index 0000000000..e7577d004b Binary files /dev/null and b/plugins/!NotAdopted/WebView/res/Icon_14.ico differ diff --git a/plugins/!NotAdopted/WebView/res/Thumbs.db b/plugins/!NotAdopted/WebView/res/Thumbs.db new file mode 100644 index 0000000000..a90efcbdb1 Binary files /dev/null and b/plugins/!NotAdopted/WebView/res/Thumbs.db differ diff --git a/plugins/!NotAdopted/WebView/res/alert.ico b/plugins/!NotAdopted/WebView/res/alert.ico new file mode 100644 index 0000000000..86d8a9819a Binary files /dev/null and b/plugins/!NotAdopted/WebView/res/alert.ico differ diff --git a/plugins/!NotAdopted/WebView/res/find.ico b/plugins/!NotAdopted/WebView/res/find.ico new file mode 100644 index 0000000000..49ce7340b6 Binary files /dev/null and b/plugins/!NotAdopted/WebView/res/find.ico differ diff --git a/plugins/!NotAdopted/WebView/res/folder.ico b/plugins/!NotAdopted/WebView/res/folder.ico new file mode 100644 index 0000000000..e9777a4596 Binary files /dev/null and b/plugins/!NotAdopted/WebView/res/folder.ico differ diff --git a/plugins/!NotAdopted/WebView/res/markallread.ico b/plugins/!NotAdopted/WebView/res/markallread.ico new file mode 100644 index 0000000000..1fd4064a75 Binary files /dev/null and b/plugins/!NotAdopted/WebView/res/markallread.ico differ diff --git a/plugins/!NotAdopted/WebView/res/options.ico b/plugins/!NotAdopted/WebView/res/options.ico new file mode 100644 index 0000000000..ddb72fb8ca Binary files /dev/null and b/plugins/!NotAdopted/WebView/res/options.ico differ diff --git a/plugins/!NotAdopted/WebView/res/ping.ico b/plugins/!NotAdopted/WebView/res/ping.ico new file mode 100644 index 0000000000..2f9b702beb Binary files /dev/null and b/plugins/!NotAdopted/WebView/res/ping.ico differ diff --git a/plugins/!NotAdopted/WebView/res/popup.ico b/plugins/!NotAdopted/WebView/res/popup.ico new file mode 100644 index 0000000000..f83a62a64c Binary files /dev/null and b/plugins/!NotAdopted/WebView/res/popup.ico differ diff --git a/plugins/!NotAdopted/WebView/res/show_hide.ico b/plugins/!NotAdopted/WebView/res/show_hide.ico new file mode 100644 index 0000000000..afae803b69 Binary files /dev/null and b/plugins/!NotAdopted/WebView/res/show_hide.ico differ diff --git a/plugins/!NotAdopted/WebView/res/stick.ico b/plugins/!NotAdopted/WebView/res/stick.ico new file mode 100644 index 0000000000..a11221d6c6 Binary files /dev/null and b/plugins/!NotAdopted/WebView/res/stick.ico differ diff --git a/plugins/!NotAdopted/WebView/res/stop.ico b/plugins/!NotAdopted/WebView/res/stop.ico new file mode 100644 index 0000000000..b62ed82acf Binary files /dev/null and b/plugins/!NotAdopted/WebView/res/stop.ico differ diff --git a/plugins/!NotAdopted/WebView/res/unstick.ico b/plugins/!NotAdopted/WebView/res/unstick.ico new file mode 100644 index 0000000000..edb7c1f4e7 Binary files /dev/null and b/plugins/!NotAdopted/WebView/res/unstick.ico differ diff --git a/plugins/!NotAdopted/WebView/res/update.ico b/plugins/!NotAdopted/WebView/res/update.ico new file mode 100644 index 0000000000..c6e4c359a7 Binary files /dev/null and b/plugins/!NotAdopted/WebView/res/update.ico differ diff --git a/plugins/!NotAdopted/WebView/res/updateall.ico b/plugins/!NotAdopted/WebView/res/updateall.ico new file mode 100644 index 0000000000..482bbf2826 Binary files /dev/null and b/plugins/!NotAdopted/WebView/res/updateall.ico differ diff --git a/plugins/!NotAdopted/WebView/res/url.ico b/plugins/!NotAdopted/WebView/res/url.ico new file mode 100644 index 0000000000..6baf15c3c5 Binary files /dev/null and b/plugins/!NotAdopted/WebView/res/url.ico differ diff --git a/plugins/!NotAdopted/WebView/res/web.ico b/plugins/!NotAdopted/WebView/res/web.ico new file mode 100644 index 0000000000..2b5a44dbf9 Binary files /dev/null and b/plugins/!NotAdopted/WebView/res/web.ico differ diff --git a/plugins/!NotAdopted/WebView/resource.h b/plugins/!NotAdopted/WebView/resource.h new file mode 100644 index 0000000000..d9185c6182 --- /dev/null +++ b/plugins/!NotAdopted/WebView/resource.h @@ -0,0 +1,138 @@ +#define UNI 1 + +#define IDI_SITE 101 +#define IDI_STICK 102 +#define IDI_UNSTICK 103 +#define IDI_URL 104 +#define IDI_OPTIONS 105 +#define IDI_UPDATE 106 +#define IDI_SHOW_HIDE 107 +#define IDI_FIND 108 +#define IDI_ALERT 110 +#define IDI_FOLDER 111 +#define IDI_UPDATEALL 112 +#define IDI_MARKALLREAD 113 +#define IDI_PING 114 +#define IDI_STOP 115 + + +#define IDC_UPDATE_ONSTART 300 +#define IDC_DBLE_WEB 301 +#define IDC_DBLE_WIN 302 +#define IDC_UPDATE_ON_OPEN 303 +#define IDC_UPDATE_ONALERT 304 + +#define IDD_OPT 443 +#define IDC_STATIC 444 +#define IDC_DISABLEMENU 446 +#define IDC_OPEN_WEBPAGE 447 +#define IDC_TIME 450 + +#define IDC_BGCOLOR 451 +#define IDC_TXTCOLOR 452 +#define IDC_RESTART 453 +#define IDC_CLEAN 457 +#define IDC_SUPPRESS 458 +#define IDC_SPIN1 461 +#define IDC_HIDE_STATUS_ICON 464 +#define IDC_RWSPACE 465 +#define IDC_RWSPC_TEXT 466 +#define IDC_TYPEFACE 467 +#define IDC_FONT_BOLD 468 +#define IDC_FONT_ITALIC 469 +#define IDC_FONT_UNDERLINE 470 +#define IDC_FONTSIZE 471 +#define IDC_U_SE_STRINGS 475 +#define IDC_U_ALLSITE 476 +#define IDC_ERROR_POPUP 477 +#define IDC_START_DELAY 480 +#define IDC_SPIN2 481 +#define IDC_STARTDELAYTXT 482 +#define IDC_STDELAYSECTXT 483 +#define IDC_SAVE_INDIVID_POS 484 +#define IDC_ADV_GRP 485 +#define IDC_NO_PROTECT 486 +#define IDC_NOT_RECOMND_TXT 487 +#define IDC_SCRIPT 488 +#define IDC_DATAPOPUP 489 + +#define IDR_CONTEXT 500 +#define IDM_CUT 501 +#define IDM_PASTE 502 +#define IDM_DELETE 503 +#define IDM_CLEAR_ALL 504 +#define IDM_COPY 505 +#define IDM_COPYALL 506 +#define IDM_SELECTALL 507 + +#define IDC_SITE_NAME 551 +#define IDC_ERR_CHK 552 +#define IDC_APPEND 554 +#define IDC_FILENAME 555 +#define IDC_BROWSE 556 +#define IDC_SAVE_AS_RAW 557 +//#define IDC_AGENT 557//temp + +#define IDD_DISPLAY_DATA 600 +#define IDC_OPEN_URL 601 +#define IDC_DATA 602 +#define IDC_UPDATE_BUTTON 603 +#define IDC_STICK_BUTTON 604 +#define IDC_FIND_BUTTON 605 +#define IDC_STATUSBAR 606 +#define IDC_OPTIONS_BUTTON 607 +#define IDC_ALERT_BUTTON 608 +//#define IDC_HIDDEN_URL 609 +#define IDC_STOP 609 + +#define IDC_ERRORMSG 620 + +#define IDD_CONTACT_OPT 700 +#define IDC_END 701 +#define IDC_START 702 +#define IDC_URL 703 +#define IDC_OPT_CANCEL 704 +#define IDC_OPT_APPLY 705 +#define IDC_CPY_STRINGS 706 + + +#define IDD_FIND 750 +#define IDC_FINDWHAT 751 +#define IDC_OK 752 +#define IDC_CANCEL 753 +#define IDC_SEARCH_COMPLETE 754 + +#define IDD_ALRT_OPT 801 +#define IDC_ENABLE_ALERTS 802 +#define IDC_OK2 803 +#define IDC_ALERT_STRING 804 +#define IDC_ALERT_TYPE 807 +#define IDC_EVENT_TYPE 808 +#define IDC_ALERT_CANCEL 809 +#define IDC_ALERT_APPLY 810 +#define IDC_START2 811 +#define IDC_END2 812 +#define IDC_ADD_DATE_NAME 813 +#define IDC_DELAY 814 +#define IDC_PREFIX 815 +#define IDC_SUFFIX 816 +#define IDC_24_HOUR 817 +#define IDC_ALWAYS_LOG 818 + +#define IDD_POPUP 850 +#define IDC_POP_BGCOLOUR 851 +#define IDC_POP_TEXTCOLOUR 852 +#define IDC_PD1 853 +#define IDC_PD2 854 +//#define IDC_PD3 855 +#define IDC_PREVIEW 856 +#define IDC_POP_USEWINCOLORS 857 +#define IDC_POP_USESAMECOLORS 858 +#define IDC_POP_USECUSTCOLORS 859 +#define IDC_LCLK_WINDOW 860 +#define IDC_LCLK_WEB_PGE 861 +#define IDC_LCLK_DISMISS 862 +#define IDC_RCLK_WINDOW 863 +#define IDC_RCLK_WEB_PGE 864 +#define IDC_RCLK_DISMISS 865 +//#define IDC_PUALERT 866 diff --git a/plugins/!NotAdopted/WebView/webview.c b/plugins/!NotAdopted/WebView/webview.c new file mode 100644 index 0000000000..8976b3f043 --- /dev/null +++ b/plugins/!NotAdopted/WebView/webview.c @@ -0,0 +1,1116 @@ +/* + * A plugin for Miranda IM which displays web page text in a window Copyright + * (C) 2005 Vincent Joyce. + * + * Miranda IM: the free icq client for MS Windows Copyright (C) 2000-2 + * Richard Hughes, Roland Rabien & Tristan Van de Vreede + * + * 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. + */ +#include "webview.h" +#include "webview_alerts.c" +#include "webview_getdata.c" +#include "webview_opts.c" +#include "webview_cleanup.c" +#include "webview_datawnd.c" + + + +static HANDLE hHookOptsInit = NULL; +static HANDLE hAddSite = NULL; +static HANDLE hAutoUpdate = NULL; +PLUGINLINK *pluginLink; +char *WndClass = "WEBWnd"; +WNDCLASSEX wincl; +MSG messages; +DWORD winheight; +int StartUpDelay = 0; + +/*************************/ +void ChangeMenuItem1() +{ + /* + * Enable or Disable auto updates + */ + ZeroMemory(&mi, sizeof(mi)); + mi.cbSize = sizeof(mi); + mi.flags = CMIM_NAME | CMIM_ICON; + mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_SITE)); + + if (!(DBGetContactSettingByte(NULL, DLLNAME, DISABLE_AUTOUPDATE_KEY, 0))) + mi.pszName = Translate("Auto Update Enabled"); + + if ((DBGetContactSettingByte(NULL, DLLNAME, DISABLE_AUTOUPDATE_KEY, 0))) + mi.pszName = Translate("Auto Update Disabled"); + + CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) hMenuItem1, (LPARAM) & mi); +} + +/**********************/ + + +/*************************/ +void ChangeMenuItemCountdown() +{ + /* + * countdown + */ +char countername[100]; +DBVARIANT dbv; + + ZeroMemory(&mi, sizeof(mi)); + mi.cbSize = sizeof(mi); + mi.flags = CMIM_NAME | CMIM_ICON; + mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_UPDATEALL)); + + sprintf(countername, "%d Minutes to Update", (DBGetContactSettingDword(NULL, DLLNAME, COUNTDOWN_KEY, (DWORD)&dbv)) ); + DBFreeVariant(&dbv); + mi.pszName = countername; + + CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) hMenuItemCountdown, (LPARAM) & mi); +} + +/**********************/ + + + +/*********************/ +static int CALLBACK EnumFontsProc(ENUMLOGFONTEX * lpelfe, NEWTEXTMETRICEX * lpntme, int FontType, LPARAM lParam) +{ + if (!IsWindow((HWND) lParam)) + return FALSE; + if (SendMessage((HWND) lParam, CB_FINDSTRINGEXACT, -1, (LPARAM) lpelfe->elfLogFont.lfFaceName) == CB_ERR) + SendMessage((HWND) lParam, CB_ADDSTRING, 0, (LPARAM) lpelfe->elfLogFont.lfFaceName); + return TRUE; +} +/*******************/ + +/**********************/ +void FillFontListThread(HWND hwndDlg) +{ + LOGFONT lf = {0}; + HDC hdc = GetDC(hwndDlg); + + lf.lfCharSet = DEFAULT_CHARSET; + lf.lfFaceName[0] = 0; + lf.lfPitchAndFamily = 0; + EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC) EnumFontsProc, (LPARAM) GetDlgItem(hwndDlg, IDC_TYPEFACE), 0); + ReleaseDC(hwndDlg, hdc); + return; +} +/*********************/ + +/*******************************/ + +void TxtclrLoop() +{ + HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + char *szProto; + + while (hContact != NULL) + { + szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + // + if (szProto != NULL && !lstrcmp(DLLNAME, szProto)) + { + + HWND hwndDlg = (WindowList_Find(hWindowList, hContact)); + + SetDlgItemText(hwndDlg, IDC_DATA, ""); + InvalidateRect(hwndDlg, NULL, 1); + } + // + hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0); + } + +} +/***************************/ +/*******************************/ + +void BGclrLoop() +{ + HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + char *szProto; + + while (hContact != NULL) + { + szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + // + if (szProto != NULL && !lstrcmp(DLLNAME, szProto)) + { + + HWND hwndDlg = (WindowList_Find(hWindowList, hContact)); + + SetDlgItemText(hwndDlg, IDC_DATA, ""); + SendMessage(GetDlgItem(hwndDlg, IDC_DATA), EM_SETBKGNDCOLOR, 0, BackgoundClr); + InvalidateRect(hwndDlg, NULL, 1); + } + // + hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0); + } + +} +/***************************/ + +void StartUpdate(void *dummy) +{ + HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + char *szProto; + + StartUpDelay = 1; + + Sleep(((DBGetContactSettingDword(NULL, DLLNAME, START_DELAY_KEY, 0)) * SECOND)); + + while (hContact != NULL) + { + szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + // + if (szProto != NULL && !lstrcmp(DLLNAME, szProto)) + GetData(hContact); + // + hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0); + } + StartUpDelay = 0; +} +/*******************************/ + +void ContactLoop(void *dummy) +{ + HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + char *szProto; + char galert[300]; + + if (StartUpDelay == 0) + { + + while (hContact != NULL) + { + szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + // + if (szProto != NULL && !lstrcmp(DLLNAME, szProto)) + + GetData(hContact); + //forkthread(GetData, 0, hContact); + Sleep(10); // avoid 100% CPU + // + + hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0); + } + } + sprintf(galert, "%s", (Translate("All Webview sites have been updated."))); + WAlertPopup((WPARAM) NULL, galert); +} + +/***************************/ + + +/****************************/ + /**********************/ +int MarkAllReadMenuCommand(WPARAM wParam, LPARAM lParam) +{ + ChangeContactStatus(1); + return 0; +} +/*************************/ + +/****************************/ + + + + +/**********************/ +void InitialiseGlobals(void) +{ + + Xposition = DBGetContactSettingDword(NULL, DLLNAME, Xpos_WIN_KEY, 0); + + Yposition = DBGetContactSettingDword(NULL, DLLNAME, Ypos_WIN_KEY, 0); + + if (Yposition == -32000) + Yposition = 100; + + if (Xposition == -32000) + Xposition = 100; + + BackgoundClr = DBGetContactSettingDword(NULL, DLLNAME, BG_COLOR_KEY, 0); + + TextClr = DBGetContactSettingDword(NULL, DLLNAME, TXT_COLOR_KEY, 0); + + WindowHeight = DBGetContactSettingDword(NULL, DLLNAME, WIN_HEIGHT_KEY, 0); + + WindowWidth = DBGetContactSettingDword(NULL, DLLNAME, WIN_WIDTH_KEY, 0); + +} +/********************************/ + +/***************************/ +int Doubleclick(WPARAM wParam, LPARAM lParam) +{ + DBVARIANT dbv; + char *szProto = NULL; + char url[300]; + + url[0] = '\0'; + + szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + +// write default values first time contact is double clicked + if (DBGetContactSetting((HANDLE) wParam, DLLNAME, DBLE_WIN_KEY, &dbv)) + { + if (!(lstrcmp(DLLNAME, szProto))) + DBWriteContactSettingByte((HANDLE) wParam, DLLNAME, DBLE_WIN_KEY, 1); + } + + //szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + + if (szProto != NULL) + { + if (!(lstrcmp(DLLNAME, szProto))) + { + // + if (!(DBGetContactSettingByte((HANDLE) wParam, DLLNAME, DBLE_WIN_KEY, 0))) + { + DBGetContactSetting((HANDLE) wParam, DLLNAME, "URL", &dbv); + wsprintf(url, "%s", dbv.pszVal); + CallService(MS_UTILS_OPENURL, 1, (WPARAM) url); + DBFreeVariant(&dbv); + DBWriteContactSettingWord((HANDLE) wParam, DLLNAME, "Status", ID_STATUS_ONLINE); + } + // + + if ((DBGetContactSettingByte((HANDLE) wParam, DLLNAME, DBLE_WIN_KEY, 0))) + { + HWND hwndDlg; + + if ((hwndDlg = (WindowList_Find(hWindowList, (HANDLE) wParam)))) + { + SetForegroundWindow(hwndDlg); + SetFocus(hwndDlg); + } else + { + hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DISPLAY_DATA), NULL, DlgProcDisplayData, (LPARAM) (HANDLE) wParam); + + if (DBGetContactSettingByte((HANDLE) wParam, DLLNAME, ON_TOP_KEY, 0)) + { + SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0))); + + if ((DBGetContactSettingByte(NULL, DLLNAME, SAVE_INDIVID_POS_KEY, 0))) + { + SetWindowPos( + hwndDlg, + HWND_TOPMOST, + DBGetContactSettingDword((HANDLE) wParam, DLLNAME, "WVx", 100), // Xposition, + DBGetContactSettingDword((HANDLE) wParam, DLLNAME, "WVy", 100), // Yposition, + DBGetContactSettingDword((HANDLE) wParam, DLLNAME, "WVwidth", 412), // WindowWidth, + DBGetContactSettingDword((HANDLE) wParam, DLLNAME, "WVheight", 350), // WindowHeight, + 0); + } else + { + SetWindowPos( + hwndDlg, + HWND_TOPMOST, + Xposition, + Yposition, + WindowWidth, + WindowHeight, + 0); + } + + } + if (!(DBGetContactSettingByte((HANDLE) wParam, DLLNAME, ON_TOP_KEY, 0))) + {// + SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_UNSTICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0))); + + if ((DBGetContactSettingByte(NULL, DLLNAME, SAVE_INDIVID_POS_KEY, 0))) + { + SetWindowPos( + hwndDlg, + HWND_NOTOPMOST, + DBGetContactSettingDword((HANDLE) wParam, DLLNAME, "WVx", 100), // Xposition, + DBGetContactSettingDword((HANDLE) wParam, DLLNAME, "WVy", 100), // Yposition, + DBGetContactSettingDword((HANDLE) wParam, DLLNAME, "WVwidth", 412), // WindowWidth, + DBGetContactSettingDword((HANDLE) wParam, DLLNAME, "WVheight", 350), // WindowHeight, + 0); + } else + { + SetWindowPos( + hwndDlg, + HWND_NOTOPMOST, + Xposition, + Yposition, + WindowWidth, + WindowHeight, + 0); + } + + } + } + // + ShowWindow(hwndDlg, SW_SHOW); + SetActiveWindow(hwndDlg); + // + + if ((DBGetContactSettingByte(NULL, DLLNAME, UPDATE_ON_OPEN_KEY, 0))) + { + if ((DBGetContactSettingByte((HANDLE) wParam, DLLNAME, ENABLE_ALERTS_KEY, 0))) + forkthread(ReadFromFile, 0, (HANDLE) wParam); + else + forkthread(GetData, 0, (HANDLE) wParam); + DBWriteContactSettingWord((HANDLE) wParam, DLLNAME, "Status", ID_STATUS_ONLINE); + } + } + // + return 1; + } + } + return 0; +} +/**************************/ + +/***************************/ +//int SendToRichEdit(HWND hWindow, char *truncated, COLORREF rgbText, COLORREF rgbBack) +int SendToRichEdit(HWND hWindow, TCHAR *truncated, COLORREF rgbText, COLORREF rgbBack) +{ + + CHARFORMAT2 cfFM; + DBVARIANT dbv; + DWORD bold = 0; + DWORD italic = 0; + DWORD underline = 0; + + // + + // ////// + int len; + + //MessageBox(NULL, "Test", "0", MB_OK); + + + len = GetWindowTextLength(GetDlgItem(hWindow, IDC_DATA)); + + // + SetDlgItemText(hWindow, IDC_DATA, ""); + + //MessageBox(NULL, "Test", "1", MB_OK); + + // + ZeroMemory(&cfFM, sizeof(cfFM)); + // + + cfFM.cbSize = sizeof(CHARFORMAT2); + cfFM.dwMask = CFM_COLOR | CFM_CHARSET | CFM_FACE | ENM_LINK | ENM_MOUSEEVENTS | CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_SIZE; + + if ((DBGetContactSettingByte(NULL, DLLNAME, FONT_BOLD_KEY, 0))) + bold = CFE_BOLD; + + if ((DBGetContactSettingByte(NULL, DLLNAME, FONT_ITALIC_KEY, 0))) + italic = CFE_ITALIC; + + if ((DBGetContactSettingByte(NULL, DLLNAME, FONT_UNDERLINE_KEY, 0))) + underline = CFE_UNDERLINE; + + cfFM.dwEffects = bold | italic | underline; + + // ///////// + + //MessageBox(NULL, "Test", "2", MB_OK); + + /**/ + if (!DBGetContactSetting(NULL, DLLNAME, FONT_FACE_KEY, &dbv)) + { +/* +#ifdef UNICODE_VERISON + MultiByteToWideChar(CP_ACP, 0, (TCHAR *) cfFM.szFaceName, -1, (wchar_t *) dbv.pszVal, 200); +#endif +*/ +//#ifndef UNICODE_VERISON + lstrcpy(cfFM.szFaceName, dbv.pszVal); +//#endif + DBFreeVariant(&dbv); + } + /**/ + + //MessageBox(NULL, "Test", "3", MB_OK); +// + + HDC hDC; + hDC = GetDC(hWindow); + cfFM.yHeight = (BYTE) MulDiv(abs(lf.lfHeight), 120, GetDeviceCaps(GetDC(hWindow), LOGPIXELSY)) * (DBGetContactSettingByte(NULL, DLLNAME, FONT_SIZE_KEY, 0)); + ReleaseDC(hWindow, hDC); +// + cfFM.bCharSet = DBGetContactSettingByte(NULL, DLLNAME, FONT_SCRIPT_KEY, 1); + + cfFM.bPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; + + cfFM.crTextColor = rgbText; + + cfFM.crBackColor = rgbBack; + + SendMessage(GetDlgItem(hWindow, IDC_DATA), EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) & cfFM); + + //MessageBox(NULL, "Test", "4", MB_OK); + +// ////////////////////////// + + SendDlgItemMessage(hWindow, IDC_DATA, EM_SETSEL, 0, -1); + + // MessageBox(NULL, "Test", "5", MB_OK); +//// +#ifdef UNICODE_VERISON + + wchar_t tmp4[strlen(truncated)]; + + + int c = lstrlenA(truncated); + +MultiByteToWideChar(CP_UTF8, 0, (CHAR *)truncated, -1, tmp4, strlen(truncated)); + + + +//SetDlgItemTextW(hwndDlg, IDC_DATA, (wchar_t *)&tmp2); +//MessageBoxW(NULL, tmp2, L"OOOO", MB_OK); +SendDlgItemMessageW(hWindow, IDC_DATA, EM_REPLACESEL, FALSE, (LPARAM) tmp4); + #endif + +#ifndef UNICODE_VERISON + SendDlgItemMessage(hWindow, IDC_DATA, EM_REPLACESEL, FALSE, (LPARAM) truncated); + #endif +//// + // MessageBox(NULL, "Test", "6", MB_OK); + + SendMessage(GetDlgItem(hWindow, IDC_DATA), EM_SETCHARFORMAT, SCF_ALL, (LPARAM) & cfFM); + // MessageBox(NULL, "Test", "7", MB_OK); + + return 1; +} + +/*************************/ + +/*******************************/ +void timerfunc(void) +{ + DBWriteContactSettingByte(NULL, DLLNAME, HAS_CRASHED_KEY, 0); + + if (!(DBGetContactSettingByte(NULL, DLLNAME, OFFLINE_STATUS, 0))) + { + if (!(DBGetContactSettingByte(NULL, DLLNAME, DISABLE_AUTOUPDATE_KEY, 0))) + forkthread(ContactLoop, 0, NULL); + } + + DBWriteContactSettingDword(NULL, DLLNAME, COUNTDOWN_KEY, 0); +} +/*******************************/ + + +/*******************************/ +void Countdownfunc(void) +{ +DWORD timetemp=100; +//char tempcnterchar[100]; +DBVARIANT dbv; + +timetemp=(DBGetContactSettingDword(NULL, DLLNAME, COUNTDOWN_KEY, (DWORD)&dbv)); + DBFreeVariant(&dbv); + +// sprintf(tempcnterchar, "%d", timetemp); +//MessageBox(NULL, tempcnterchar, "1", MB_OK); + + if((timetemp < 0) || (timetemp ==0)) + { + timetemp=(DBGetContactSettingDword(NULL, DLLNAME, REFRESH_KEY, (DWORD)&dbv)); + DBWriteContactSettingDword(NULL, DLLNAME, COUNTDOWN_KEY, timetemp); + DBFreeVariant(&dbv); + } + +//sprintf(tempcnterchar, "%d", timetemp); +//MessageBox(NULL, tempcnterchar, "2", MB_OK); + +timetemp = timetemp - 1; + + + +DBWriteContactSettingDword(NULL, DLLNAME, COUNTDOWN_KEY, timetemp); + +//sprintf(tempcnterchar, "%d", timetemp); +//MessageBox(NULL, tempcnterchar, "3", MB_OK); + + ChangeMenuItemCountdown(); + +} +/*******************************/ + +/****************/ +static int OptInitialise(WPARAM wParam, LPARAM lParam) +{ + OPTIONSDIALOGPAGE odp = {0}; + + ZeroMemory(&odp, sizeof(odp)); + odp.cbSize = sizeof(odp); + odp.position = 0; + odp.hInstance = hInst; + odp.pszTemplate = MAKEINTRESOURCE(IDD_OPT); + odp.pszGroup = Translate("Network"); + odp.pszTitle = optionsname; + odp.pfnDlgProc = DlgProcOpt; + odp.flags = ODPF_BOLDGROUPS; + odp.expertOnlyControls = expertOnlyControls; + odp.nExpertOnlyControls = sizeof(expertOnlyControls) / sizeof(expertOnlyControls[0]); + CallService(MS_OPT_ADDPAGE, wParam, (LPARAM) & odp); + + // if popup service exists + if ((ServiceExists(MS_POPUP_ADDPOPUP))) + { + ZeroMemory(&odp, sizeof(odp)); + odp.cbSize = sizeof(odp); + odp.position = 100000000; + odp.hInstance = hInst; + odp.pszTemplate = MAKEINTRESOURCE(IDD_POPUP); + odp.pszTitle = optionsname; + odp.pszGroup = Translate("PopUps"); + odp.groupPosition = 910000000; + odp.flags = ODPF_BOLDGROUPS; + odp.pfnDlgProc = DlgPopUpOpts; + CallService(MS_OPT_ADDPAGE, wParam, (LPARAM) & odp); + } + return 0; +} +/***************/ + +/**********/ + +void FontSettings(void) +{ + char fontfacename[20]; + + ZeroMemory(&fontfacename, sizeof(fontfacename)); + + lf.lfHeight = 16; + lf.lfWidth = 0; + lf.lfEscapement = 0; + lf.lfOrientation = 0; + lf.lfWeight = FW_NORMAL; + lf.lfItalic = FALSE; + lf.lfUnderline = FALSE; + lf.lfStrikeOut = 0; + lf.lfCharSet = ANSI_CHARSET; + lf.lfOutPrecision = OUT_DEFAULT_PRECIS; + lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; + lf.lfQuality = DEFAULT_QUALITY; + lf.lfPitchAndFamily = FIXED_PITCH | FF_MODERN; + lstrcpy(lf.lfFaceName, "Courier"); + +} + +/**********/ + +/************/ +int ModulesLoaded(WPARAM wParam, LPARAM lParam) +{ + NETLIBUSER nlu = {0}; + char tempNdesc[50]; + + tempNdesc[0] = '\0'; + + sprintf(tempNdesc, "%s connection settings", DLLNAME); + + nlu.cbSize = sizeof(nlu); + nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS; + nlu.szSettingsModule = DLLNAME; + nlu.szDescriptiveName = tempNdesc; + + hHookOptsInit = HookEvent(ME_OPT_INITIALISE, OptInitialise); + hNetlibUser = (HANDLE) CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM) & nlu); + +// + hHookDisplayDataAlert = CreateHookableEvent(ME_DISPLAYDATA_ALERT); + HookEvent(ME_DISPLAYDATA_ALERT, (void *) DataWndAlertCommand); +// + hHookAlertPopup = CreateHookableEvent(ME_POPUP_ALERT); + HookEvent(ME_POPUP_ALERT, (void *) PopupAlert); +// + hHookAlertWPopup = CreateHookableEvent(ME_WPOPUP_ALERT); + HookEvent(ME_WPOPUP_ALERT, (void *) WPopupAlert); +// +// + hHookErrorPopup = CreateHookableEvent(ME_POPUP_ERROR); + HookEvent(ME_POPUP_ERROR, (void *) ErrorMsgs); +// + hHookAlertOSD = CreateHookableEvent(ME_OSD_ALERT); + HookEvent(ME_OSD_ALERT, (void *) OSDAlert); +// + + FontSettings(); + + h_font = CreateFontIndirect(&lf); + +// get data on startup + if ((DBGetContactSettingByte(NULL, DLLNAME, UPDATE_ONSTART_KEY, 0))) + forkthread(StartUpdate, 0, NULL); + +/****END ALWAYS****/ + + return 0; +} +/*********/ + +/***********************/ +int DataWndMenuCommand(WPARAM wParam, LPARAM lParam) +{ + HWND hwndDlg; + + if ((hwndDlg = (WindowList_Find(hWindowList, (HANDLE) wParam)))) + { + DestroyWindow(hwndDlg); + return 0; + } else + { + + hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DISPLAY_DATA), NULL, DlgProcDisplayData, (LPARAM) (HANDLE) wParam); + + if (DBGetContactSettingByte((HANDLE) wParam, DLLNAME, ON_TOP_KEY, 0)) + { + SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0))); + if ((DBGetContactSettingByte(NULL, DLLNAME, SAVE_INDIVID_POS_KEY, 0))) + { + SetWindowPos( + hwndDlg, + HWND_TOPMOST, + DBGetContactSettingDword((HANDLE) wParam, DLLNAME, "WVx", 100), // Xposition, + DBGetContactSettingDword((HANDLE) wParam, DLLNAME, "WVy", 100), // Yposition, + DBGetContactSettingDword((HANDLE) wParam, DLLNAME, "WVwidth", 100), // WindowWidth, + DBGetContactSettingDword((HANDLE) wParam, DLLNAME, "WVheight", 100), // WindowHeight, + 0); + } else + { + SetWindowPos( + hwndDlg, + HWND_TOPMOST, + Xposition, + Yposition, + WindowWidth, + WindowHeight, + 0); + + } + } + if (!(DBGetContactSettingByte((HANDLE) wParam, DLLNAME, ON_TOP_KEY, 0))) + {// + SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_UNSTICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0))); + + if ((DBGetContactSettingByte(NULL, DLLNAME, SAVE_INDIVID_POS_KEY, 0))) + { + SetWindowPos( + hwndDlg, + HWND_NOTOPMOST, + DBGetContactSettingDword((HANDLE) wParam, DLLNAME, "WVx", 100), // Xposition, + DBGetContactSettingDword((HANDLE) wParam, DLLNAME, "WVy", 100), // Yposition, + DBGetContactSettingDword((HANDLE) wParam, DLLNAME, "WVwidth", 100), // WindowWidth, + DBGetContactSettingDword((HANDLE) wParam, DLLNAME, "WVheight", 100), // WindowHeight, + 0); + } else + { + SetWindowPos( + hwndDlg, + HWND_NOTOPMOST, + Xposition, + Yposition, + WindowWidth, + WindowHeight, + 0); + } + + } + } + + // + ShowWindow(hwndDlg, SW_SHOW); + SetActiveWindow(hwndDlg); + // + if ((DBGetContactSettingByte(NULL, DLLNAME, UPDATE_ON_OPEN_KEY, 0))) + { + if ((DBGetContactSettingByte((HANDLE) wParam, DLLNAME, ENABLE_ALERTS_KEY, 0))) + forkthread(ReadFromFile, 0, (HANDLE) wParam); + else + forkthread(GetData, 0, (HANDLE) wParam); + DBWriteContactSettingWord((HANDLE) wParam, DLLNAME, "Status", ID_STATUS_ONLINE); + } + + return 0; +} + +/***********************/ + +/**********************/ +int UpdateAllMenuCommand(WPARAM wParam, LPARAM lParam) +{ + forkthread(ContactLoop, 0, NULL); + return 0; +} +/*************************/ + +/************************/ +int AutoUpdateMCmd(WPARAM wParam, LPARAM lParam) +{ + if (DBGetContactSettingByte(NULL, DLLNAME, DISABLE_AUTOUPDATE_KEY, 0)) + DBWriteContactSettingByte(NULL, DLLNAME, DISABLE_AUTOUPDATE_KEY, 0); + else if (!(DBGetContactSettingByte(NULL, DLLNAME, DISABLE_AUTOUPDATE_KEY, 0))) + DBWriteContactSettingByte(NULL, DLLNAME, DISABLE_AUTOUPDATE_KEY, 1); + + ChangeMenuItem1(); + return 0; +} +/**********************/ + +/***************************/ +int AddContactMenuCommand(WPARAM wParam, LPARAM lParam) +{ + DBWriteContactSettingString(NULL, "FindAdd", "LastSearched", DLLNAME); + CallService(MS_FINDADD_FINDADD, 0, 0); + return 0; +} +/***************************/ + +/***********************/ +int OnTopMenuCommand(WPARAM wParam, LPARAM lParam, HANDLE singlecontact) +{ + int ontop = 0; + int done = 0; + + if (((DBGetContactSettingByte(singlecontact, DLLNAME, ON_TOP_KEY, 0))) && done == 0) + { + DBWriteContactSettingByte(singlecontact, DLLNAME, ON_TOP_KEY, 0); + ontop = 0; + done = 1; + } + if ((!(DBGetContactSettingByte(singlecontact, DLLNAME, ON_TOP_KEY, 0))) && done == 0) + { + DBWriteContactSettingByte(singlecontact, DLLNAME, ON_TOP_KEY, 1); + ontop = 1; + done = 1; + } + return 0; +} +/*********************/ + +/********************/ +int WebsiteMenuCommand(WPARAM wParam, LPARAM lParam) +{ + DBVARIANT dbv; + char url[300]; + + url[0] = '\0'; +// + DBGetContactSetting((HANDLE) wParam, DLLNAME, "URL", &dbv); + wsprintf(url, "%s", dbv.pszVal); + CallService(MS_UTILS_OPENURL, 1, (WPARAM) url); + DBFreeVariant(&dbv); + DBWriteContactSettingWord((HANDLE) wParam, DLLNAME, "Status", ID_STATUS_ONLINE); +// / + + return 0; +} +/*******************/ + + + +/****************/ +int UpdateMenuCommand(WPARAM wParam, LPARAM lParam, HANDLE singlecontact) +{ + + forkthread(GetData, 0, singlecontact); + + return 0; +} + +/***************/ + + +/*******************/ +int ContactMenuItemUpdateData (WPARAM wParam, LPARAM lParam) +{ +UpdateMenuCommand(wParam, lParam, (HANDLE) wParam); +return 0; +} +/*******************/ + + + +/********************/ +int CntOptionsMenuCommand(WPARAM wParam, LPARAM lParam) +{ + +HWND hwndDlg; + + if ((hwndDlg = (WindowList_Find(hWindowList, (HANDLE) wParam)))) + { + DestroyWindow(hwndDlg); + return 0; + } else + { + hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CONTACT_OPT ), NULL, DlgProcContactOpt, (LPARAM) (HANDLE) wParam); + ShowWindow(hwndDlg, SW_SHOW); + SetActiveWindow(hwndDlg); + } + return 0; +} +/*******************/ + +/********************/ +int CntAlertMenuCommand(WPARAM wParam, LPARAM lParam) +{ + +HWND hwndDlg; + + if ((hwndDlg = (WindowList_Find(hWindowList, (HANDLE) wParam)))) + { + DestroyWindow(hwndDlg); + return 0; + } else + { + hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ALRT_OPT), NULL, DlgProcAlertOpt, (LPARAM) (HANDLE) wParam); + ShowWindow(hwndDlg, SW_SHOW); + SetActiveWindow(hwndDlg); + } + return 0; +} +/*******************/ + +int CountdownMenuCommand(WPARAM wParam, LPARAM lParam) +{ + + return 0; +} + +/**************/ + +void CheckDbKeys(void) +{ + DBVARIANT dbv; + + if (DBGetContactSetting(NULL, DLLNAME, HAS_CRASHED_KEY, &dbv)) + { + DBWriteContactSettingByte(NULL, DLLNAME, HAS_CRASHED_KEY, 0); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, UPDATE_ONSTART_KEY, &dbv)) + { + DBWriteContactSettingByte(NULL, DLLNAME, UPDATE_ONSTART_KEY, 0); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, MENU_OFF, &dbv)) + { + DBWriteContactSettingByte(NULL, DLLNAME, MENU_OFF, 0); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, Ypos_WIN_KEY, &dbv)) + { + DBWriteContactSettingDword(NULL, DLLNAME, Ypos_WIN_KEY, 0); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, Xpos_WIN_KEY, &dbv)) + { + DBWriteContactSettingDword(NULL, DLLNAME, Xpos_WIN_KEY, 0); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, REFRESH_KEY, &dbv)) + { + DBWriteContactSettingDword(NULL, DLLNAME, REFRESH_KEY, TIME); + DBFreeVariant(&dbv); + } + + if (DBGetContactSetting(NULL, DLLNAME, COUNTDOWN_KEY, &dbv)) + { + DBWriteContactSettingDword(NULL, DLLNAME, COUNTDOWN_KEY, 0); + DBFreeVariant(&dbv); + } + + if (DBGetContactSetting(NULL, DLLNAME, BG_COLOR_KEY, &dbv)) + { + DBWriteContactSettingDword(NULL, DLLNAME, BG_COLOR_KEY, Def_color_bg); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, TXT_COLOR_KEY, &dbv)) + { + DBWriteContactSettingDword(NULL, DLLNAME, TXT_COLOR_KEY, Def_color_txt); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, WIN_HEIGHT_KEY, &dbv)) + { + DBWriteContactSettingDword(NULL, DLLNAME, WIN_HEIGHT_KEY, 152); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, SUPPRESS_ERR_KEY, &dbv)) + { + DBWriteContactSettingByte(NULL, DLLNAME, SUPPRESS_ERR_KEY, 0); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, WIN_WIDTH_KEY, &dbv)) + { + DBWriteContactSettingDword(NULL, DLLNAME, WIN_WIDTH_KEY, 250); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, OFFLINE_STATUS, &dbv)) + { + DBWriteContactSettingByte(NULL, DLLNAME, OFFLINE_STATUS, 1); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, UPDATE_ON_OPEN_KEY, &dbv)) + { + DBWriteContactSettingByte(NULL, DLLNAME, UPDATE_ON_OPEN_KEY, 0); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, FONT_FACE_KEY, &dbv)) + { + DBWriteContactSettingString(NULL, DLLNAME, FONT_FACE_KEY, "Courier"); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, FONT_BOLD_KEY, &dbv)) + { + DBWriteContactSettingByte(NULL, DLLNAME, FONT_BOLD_KEY, 0); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, FONT_ITALIC_KEY, &dbv)) + { + DBWriteContactSettingByte(NULL, DLLNAME, FONT_ITALIC_KEY, 0); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, FONT_UNDERLINE_KEY, &dbv)) + { + DBWriteContactSettingByte(NULL, DLLNAME, FONT_UNDERLINE_KEY, 0); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, FONT_SIZE_KEY, &dbv)) + { + DBWriteContactSettingByte(NULL, DLLNAME, FONT_SIZE_KEY, 14); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, ERROR_POPUP_KEY, &dbv)) + { + DBWriteContactSettingByte(NULL, DLLNAME, ERROR_POPUP_KEY, 0); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, POP_DELAY_KEY, &dbv)) + { + DBWriteContactSettingDword(NULL, DLLNAME, POP_DELAY_KEY, 0); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, POP_BG_CLR_KEY, &dbv)) + { + DBWriteContactSettingDword(NULL, DLLNAME, POP_BG_CLR_KEY, Def_color_bg); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, POP_TXT_CLR_KEY, &dbv)) + { + DBWriteContactSettingDword(NULL, DLLNAME, POP_TXT_CLR_KEY, Def_color_txt); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, POP_USEWINCLRS_KEY, &dbv)) + { + DBWriteContactSettingByte(NULL, DLLNAME, POP_USEWINCLRS_KEY, 0); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, MENU_IS_DISABLED_KEY, &dbv)) + { + DBWriteContactSettingByte(NULL, DLLNAME, MENU_IS_DISABLED_KEY, 0); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, UPDATE_ONALERT_KEY, &dbv)) + { + DBWriteContactSettingByte(NULL, DLLNAME, UPDATE_ONALERT_KEY, 0); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, DISABLE_AUTOUPDATE_KEY, &dbv)) + { + DBWriteContactSettingByte(NULL, DLLNAME, DISABLE_AUTOUPDATE_KEY, 0); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, POP_USESAMECLRS_KEY, &dbv)) + { + DBWriteContactSettingByte(NULL, DLLNAME, POP_USESAMECLRS_KEY, 1); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, POP_USECUSTCLRS_KEY, &dbv)) + { + DBWriteContactSettingByte(NULL, DLLNAME, POP_USECUSTCLRS_KEY, 0); + DBFreeVariant(&dbv); + } + // + if (DBGetContactSetting(NULL, DLLNAME, LCLK_WINDOW_KEY, &dbv)) + { + DBWriteContactSettingByte(NULL, DLLNAME, LCLK_WINDOW_KEY, 0); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, LCLK_WEB_PGE_KEY, &dbv)) + { + DBWriteContactSettingByte(NULL, DLLNAME, LCLK_WEB_PGE_KEY, 0); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, LCLK_DISMISS_KEY, &dbv)) + { + DBWriteContactSettingByte(NULL, DLLNAME, LCLK_DISMISS_KEY, 1); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, RCLK_WINDOW_KEY, &dbv)) + { + DBWriteContactSettingByte(NULL, DLLNAME, RCLK_WINDOW_KEY, 0); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, RCLK_WEB_PGE_KEY, &dbv)) + { + DBWriteContactSettingByte(NULL, DLLNAME, RCLK_WEB_PGE_KEY, 1); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, RCLK_DISMISS_KEY, &dbv)) + { + DBWriteContactSettingByte(NULL, DLLNAME, RCLK_DISMISS_KEY, 0); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, START_DELAY_KEY, &dbv)) + { + DBWriteContactSettingDword(NULL, DLLNAME, START_DELAY_KEY, 0); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, SAVE_INDIVID_POS_KEY, &dbv)) + { + DBWriteContactSettingByte(NULL, DLLNAME, SAVE_INDIVID_POS_KEY, 0); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, NO_PROTECT_KEY, &dbv)) + { + DBWriteContactSettingByte(NULL, DLLNAME, NO_PROTECT_KEY, 0); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(NULL, DLLNAME, FONT_SCRIPT_KEY, &dbv)) + { + DBWriteContactSettingByte(NULL, DLLNAME, FONT_SCRIPT_KEY, 0); + DBFreeVariant(&dbv); + } + + if (DBGetContactSetting(NULL, DLLNAME, DATA_POPUP_KEY, &dbv)) + { + DBWriteContactSettingByte(NULL, DLLNAME, DATA_POPUP_KEY, 0); + DBFreeVariant(&dbv); + } + +// if (DBGetContactSetting(NULL, DLLNAME, INBUILTPOP_KEY, &dbv)) +// { +// DBWriteContactSettingByte(NULL, DLLNAME, INBUILTPOP_KEY, 0); +// DBFreeVariant(&dbv); +// } + + +} + +/***************/ diff --git a/plugins/!NotAdopted/WebView/webview.dev b/plugins/!NotAdopted/WebView/webview.dev new file mode 100644 index 0000000000..4eabde27b8 --- /dev/null +++ b/plugins/!NotAdopted/WebView/webview.dev @@ -0,0 +1,179 @@ +[Project] +FileName=webview.dev +Name=webview +UnitCount=13 +Type=3 +Ver=1 +ObjFiles= +Includes= +Libs= +PrivateResource=webview_private.rc +ResourceIncludes= +MakeIncludes= +Compiler=-DBUILDING_DLL=1_@@_-Os_@@__@@__@@__@@__@@__@@__@@__@@__@@__@@__@@__@@__@@__@@__@@_ +CppCompiler= +Linker=../../../../../../../Dev-Cpp/lib/libgdi32.a_@@_../../../../../../../Dev-Cpp/lib/libcomdlg32.a_@@__@@_ +IsCpp=0 +Icon= +ExeOutput= +ObjectOutput= +OverrideOutput=1 +OverrideOutputName=webview.dll +HostApplication= +Folders= +CommandLine= +IncludeVersionInfo=1 +SupportXPThemes=0 +CompilerSet=0 +CompilerSettings=0000000000000000000100 +UseCustomMakefile=0 +CustomMakefile= + +[VersionInfo] +Major=0 +Minor=1 +Release=3 +Build=10 +LanguageID=1033 +CharsetID=1252 +CompanyName= +FileVersion=0.1.3.10 +FileDescription=Webview protocol plugin for Miranda IM +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion= +AutoIncBuildNr=0 + +[Unit2] +FileName=main.c +Folder= +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= +CompileCpp=0 + +[Unit3] +FileName=webview_common.h +CompileCpp=0 +Folder= +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit5] +FileName=webview.h +CompileCpp=0 +Folder=forkthread.c +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit1] +FileName=resource.h +Folder= +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= +CompileCpp=0 + +[Unit4] +FileName=forkthread.c +CompileCpp=0 +Folder= +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit6] +FileName=webview.c +CompileCpp=0 +Folder= +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit7] +FileName=webview.rc +CompileCpp=0 +Folder=Resources +Compile=1 +Link=0 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit8] +FileName=webview_services.c +CompileCpp=0 +Folder= +Compile=1 +Link=0 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd=$(CC) -c services.c -o services.o $(CFLAGS) + +[Unit9] +FileName=webview_getdata.c +CompileCpp=0 +Folder= +Compile=1 +Link=0 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd=$(CC) -c webview_getdata.c -o webview_getdata.o $(CFLAGS) + +[Unit10] +FileName=webview_opts.c +CompileCpp=0 +Folder= +Compile=1 +Link=0 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd=$(CC) -c webview_dlgprocs.c -o webview_dlgprocs.o $(CFLAGS) + +[Unit11] +FileName=webview_cleanup.c +CompileCpp=0 +Folder= +Compile=1 +Link=0 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd=$(CC) -c webview_cleanup.c -o webview_cleanup.o $(CFLAGS) + +[Unit12] +FileName=webview_datawnd.c +CompileCpp=0 +Folder= +Compile=1 +Link=0 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd=$(CC) -c webview_datawnd.c -o webview_datawnd.o $(CFLAGS) + +[Unit13] +FileName=webview_alerts.c +CompileCpp=0 +Folder=webview +Compile=1 +Link=0 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd=$(CC) -c webview_alerts.c -o webview_alerts.o $(CFLAGS) + diff --git a/plugins/!NotAdopted/WebView/webview.h b/plugins/!NotAdopted/WebView/webview.h new file mode 100644 index 0000000000..dc8f3b1720 --- /dev/null +++ b/plugins/!NotAdopted/WebView/webview.h @@ -0,0 +1,431 @@ +/* + * A plugin for Miranda IM which displays web page text in a window Copyright + * (C) 2005 Vincent Joyce. + * + * Miranda IM: the free icq client for MS Windows Copyright (C) 2000-2 + * Richard Hughes, Roland Rabien & Tristan Van de Vreede + * + * 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. + */ +#include "webview_common.h" +#include <shlwapi.h> +#include <stdio.h> +#include <richedit.h> +#include "../include/m_options.h" +#include "../include/m_clui.h" +#include "../include/m_popup.h" + + +#define Xpos_WIN_KEY "win_Xpos" +#define Ypos_WIN_KEY "win_Ypos" +#define BG_COLOR_KEY "BgColor" +#define TXT_COLOR_KEY "TxtColor" +#define WIN_HEIGHT_KEY "Height" +#define SUPPRESS_ERR_KEY "Suppress error messages" +#define WIN_WIDTH_KEY "Width" +#define FILE_KEY "Filename" +#define APPEND_KEY "Append" +#define UPDATE_ONSTART_KEY "update_onboot" +#define UPDATE_ON_OPEN_KEY "update_on_Window_open" +#define FONT_FACE_KEY "FontFace" +#define FONT_BOLD_KEY "FontBold" +#define FONT_ITALIC_KEY "FontItalic" +#define FONT_UNDERLINE_KEY "FontUnderline" +#define FONT_SIZE_KEY "FontSize" +#define ERROR_POPUP_KEY "UsePopupPlugin" +#define ENABLE_ALERTS_KEY "EnableAlerts" +#define ALERT_STRING_KEY "ALERTSTRING" +#define ALERT_TYPE_KEY "Alert_Type" +#define APND_DATE_NAME_KEY "AppendDateContact" +#define POP_DELAY_KEY "PopUpDelay" +#define POP_BG_CLR_KEY "PopBGClr" +#define POP_TXT_CLR_KEY "PopTxtClr" +#define POP_USEWINCLRS_KEY "PopUseWinClrs" +#define CONTACT_PREFIX_KEY "PrefixDateContact" +#define USE_24_HOUR_KEY "Use24hourformat" +#define POP_USESAMECLRS_KEY "PopUseSameClrs" +#define POP_USECUSTCLRS_KEY "PopUseCustomClrs" +#define LCLK_WINDOW_KEY "LeftClkWindow" +#define LCLK_WEB_PGE_KEY "LeftClkWebPage" +#define LCLK_DISMISS_KEY "LeftClkDismiss" +#define RCLK_WINDOW_KEY "RightClkWindow" +#define RCLK_WEB_PGE_KEY "RightClkWebPage" +#define RCLK_DISMISS_KEY "RightClkDismiss" +//#define INBUILTPOP_KEY "UseInbuiltPopupAlert" + +#define TIME 60 +#define Def_color_bg 0x00ffffff +#define Def_color_txt 0x00000000 +#define HK_SHOWHIDE 3001 + +#define MAXSIZE1 250000 +#define MAXSIZE2 500000 +#define MAXSIZE3 1000000 + +static UINT expertOnlyControls[] = +{IDC_ADV_GRP, + IDC_NO_PROTECT, +IDC_NOT_RECOMND_TXT}; + +//lets get rid of some warnings +void ErrorMsgs(char *contactname, char *displaytext); +void CodetoSymbol(char *truncated); +static void GetData(void *hContact); +BOOL CALLBACK DlgProcDisplayData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); +void FillFontListThread(HWND hwndDlg); +static BOOL CALLBACK DlgProcAlertOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); +int DataWndAlertCommand(void *AContact); + + + // /////////////////////// +// characters and symbols// +// /////////////////////// + +#define AMOUNT3 164 + +char *CharacterCodes[AMOUNT3] = +{ + + """, + "&", + "<", + ">", + " ", + "¡", + "¢", + "£", + "¤", + "¥", + "¦", + "§", + "¨", + "©", + "ª", + "«", + "¬", + "­", + "®", + "¯", + "°", + "±", + "²", + "³", + "´", + "µ", + "¶", + "·", + "¸", + "¹", + "º", + "»", + "¼", + "½", + "¾", + "¿", + "À", + "Á", + "Â", + "Ã", + "Ä", + "Å", + "Æ", + "Ç", + "È", + "É", + "Ê", + "Ë", + "Ì", + "Í", + "Î", + "Ï", + "Ð", + "Ñ", + "Ò", + "Ó", + "Ô", + "Õ", + "Ö", + "×", + "Ø", + "Ù", + "Ú", + "Û", + "Ü", + "Ý", + "Þ", + "ß", + "à", + "á", + "â", + "ã", + "ä", + "å", + "æ", + "ç", + "è", + "é", + "ê", + "ë", + "ì", + "í", + "î", + "ï", + "ð", + "ñ", + "ò", + "ó", + "ô", + "õ", + "ö", + "÷", + "ø", + "ù", + "ú", + "û", + "ü", + "ý", + "þ", + "&yumil;", + "Œ", // greater that 255, extra latin characters + "œ", + "Š", + "š", + "Ÿ", + "ƒ", + "ˆ", + "˜", + "Œ", + "œ", + "Š", + "š", + "Ÿ", + "ƒ", + "ˆ", + "˜", + "–", // Misc other characters + "—", + "‘", + "’", + "‚", + "“", + "”", + "„", + "†", + "‡", + "•", + "…", + "‰", + "‹", + "›", + "€", + "ℑ", + "ℜ", + "™", + "–", + "—", + "‘", + "’", + "‚", + "“", + "”", + "„", + "†", + "‡", + "•", + "…", + "‰", + "‹", + "›", + "€", + "ℑ", + "ℜ", + "™", + " ", + " ", + " ", + " ", + " ", + " ", + "õ", // symbols without numeric code + "¿", + "¦", +"¯"}; + +char Characters[AMOUNT3] = +{ + '\"', + '&', + '<', + '>', + ' ', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', // greater than 255 extra latin characters + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', // misc other characters + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + 'I', + 'R', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + '�', + 'I', + 'R', + '�', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + '�', + '�', + '�', +'�'}; diff --git a/plugins/!NotAdopted/WebView/webview.rc b/plugins/!NotAdopted/WebView/webview.rc new file mode 100644 index 0000000000..b3b4bb33c2 --- /dev/null +++ b/plugins/!NotAdopted/WebView/webview.rc @@ -0,0 +1,378 @@ +////////////////// +#include <windows.h> +#include "resource.h" +/////////////////// + + + + +///////////////////////////// +////Icons +///////////////////////////// + +IDI_SITE ICON DISCARDABLE "res\\web.ico" +IDI_STICK ICON DISCARDABLE "res\\stick.ico" +IDI_UNSTICK ICON DISCARDABLE "res\\unstick.ico" +IDI_URL ICON DISCARDABLE "res\\url.ico" +IDI_OPTIONS ICON DISCARDABLE "res\\options.ico" +IDI_UPDATE ICON DISCARDABLE "res\\update.ico" +IDI_SHOW_HIDE ICON DISCARDABLE "res\\show_hide.ico" +IDI_FIND ICON DISCARDABLE "res\\find.ico" +IDI_ALERT ICON DISCARDABLE "res\\alert.ico" +IDI_FOLDER ICON DISCARDABLE "res\\folder.ico" +IDI_UPDATEALL ICON DISCARDABLE "res\\updateall.ico" +IDI_MARKALLREAD ICON DISCARDABLE "res\\markallread.ico" +IDI_PING ICON DISCARDABLE "res\\ping.ico" +IDI_STOP ICON DISCARDABLE "res\\stop.ico" + +///////////////////////////////////////////////////////////////////////////// + + + +////////////////////////// +//// Main Options +/////////////////////////// +IDD_OPT DIALOGEX 0,0,280,231 +STYLE WS_CHILD | WS_VISIBLE +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + // + + GROUPBOX "Webview",IDC_STATIC,1,11,278,63,WS_GROUP + // + LTEXT "Update data every",IDC_STATIC,6,26,100,8 + EDITTEXT IDC_TIME,84,26,28,12,ES_AUTOHSCROLL | ES_NUMBER + CONTROL "Spin1",IDC_SPIN1,"msctls_updown32",UDS_SETBUDDYINT | + UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | + UDS_NOTHOUSANDS,125,11,7,11 + LTEXT "minutes",IDC_STATIC,113,26,25,8 + // + LTEXT "Delay update on start",IDC_STARTDELAYTXT,6,49,100,8 + EDITTEXT IDC_START_DELAY,84,49,28,12,ES_AUTOHSCROLL | ES_NUMBER + CONTROL "Spin2",IDC_SPIN2,"msctls_updown32",UDS_SETBUDDYINT | + UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | + UDS_NOTHOUSANDS,125,34,7,11 + LTEXT "seconds",IDC_STDELAYSECTXT,113,49,36,8 + // + CONTROL "Hide icon on status bar",IDC_HIDE_STATUS_ICON,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,150,20,128,8 + CONTROL "Disable main menu items",IDC_DISABLEMENU,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,150,30,128,8 + CONTROL "Load Page on Window Open",IDC_UPDATE_ON_OPEN,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,150,40,128,8 + CONTROL "Update data on start-up",IDC_UPDATE_ONSTART,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,150,50,128,8 + CONTROL "Only Update Window on Alert",IDC_UPDATE_ONALERT,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,150,60,128,8 + +/////////// + + GROUPBOX "Window Appearance",IDC_STATIC,1,75,278,62 + LTEXT "Background Color:",IDC_STATIC,16,85,69,8 + CONTROL "",IDC_BGCOLOR,"ColourPicker",WS_TABSTOP,85,85,20,8 + LTEXT "Text Color:",IDC_STATIC,16,95,69,8 + CONTROL "",IDC_TXTCOLOR,"ColourPicker",WS_TABSTOP,85,95,20,8 + + COMBOBOX IDC_TYPEFACE,16,105,136,182,CBS_DROPDOWN | CBS_SORT | + WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SCRIPT,58,120,72,68,CBS_DROPDOWNLIST | WS_VSCROLL | + WS_TABSTOP + + COMBOBOX IDC_FONTSIZE,16,120,40,69,CBS_DROPDOWN | WS_VSCROLL | + WS_TABSTOP + CONTROL "Bold",IDC_FONT_BOLD,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,160,90,48,8 + CONTROL "Italic",IDC_FONT_ITALIC,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,160,100,48,8 + CONTROL "Underline",IDC_FONT_UNDERLINE,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,160,110,58,8 + CONTROL "Save Individual Window Positions",IDC_SAVE_INDIVID_POS,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,132,122,146,8 + +/////////// + GROUPBOX "Error Messages",IDC_STATIC,1,137,278,25 + CONTROL "Suppress error messages",IDC_SUPPRESS,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,16,149,105,8 + CONTROL "Display using PopUp or OSD plugin",IDC_ERROR_POPUP,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,140,149,130,8 +////////// + GROUPBOX "Expert Options",IDC_ADV_GRP,142,163,137,35,WS_GROUP + CONTROL "Disable Download Protection",IDC_NO_PROTECT,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,148,175,130,8 + LTEXT "(Not Recommended)",IDC_NOT_RECOMND_TXT,148,185,122,8 +////////// + GROUPBOX "Display Data in Popup on Alert",IDC_STATIC, 1, 164, 139, 34 + CONTROL "Display Data in Popup", IDC_DATAPOPUP , "Button", + BS_AUTOCHECKBOX | WS_TABSTOP, 16, 177, 120, 8 +///// + LTEXT "You may need to restart Miranda IM for this change to take effect.",IDC_RESTART, + 30,220,230,8,NOT WS_VISIBLE + + +END + +/////////////////////////////////////////////////////////////////////////////////// +//data window +//////////////// +IDD_DISPLAY_DATA DIALOGEX 0, 0, 212, 150 +STYLE DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | + NOT WS_VISIBLE | WS_SYSMENU | WS_CAPTION | WS_THICKFRAME |WS_MAXIMIZEBOX | + WS_MINIMIZEBOX +EXSTYLE WS_EX_CONTROLPARENT +CAPTION "" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 + +BEGIN + +CONTROL "",IDC_UPDATE_BUTTON,"MButtonClass",WS_TABSTOP,5,1,16,14 +CONTROL "",IDC_STICK_BUTTON,"MButtonClass",WS_TABSTOP,25,1,16,14 +CONTROL "",IDC_FIND_BUTTON,"MButtonClass",WS_TABSTOP,45,1,16,14 +CONTROL "",IDC_OPTIONS_BUTTON,"MButtonClass",WS_TABSTOP,65,1,16,14 +CONTROL "",IDC_ALERT_BUTTON ,"MButtonClass",WS_TABSTOP,85,1,16,14 +CONTROL "",IDC_STOP ,"MButtonClass",WS_TABSTOP,105,1,16,14 +//LTEXT "",IDC_HIDDEN_URL,1,17,381,1,SS_NOPREFIX | NOT WS_VISIBLE +CONTROL "",IDC_OPEN_URL ,"MButtonClass",WS_TABSTOP,1,19,212,8 +#ifdef UNI +CONTROL "",IDC_DATA,"RichEdit20W", ES_LEFT | ES_MULTILINE | ES_WANTRETURN | WS_CHILD | WS_VISIBLE | WS_VSCROLL, 1, 28, 209, 110 +//CONTROL "",IDC_DATA,"RichEdit20W", ES_LEFT | ES_MULTILINE | ES_WANTRETURN | WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_OEMCONVERT, 100, 128, 120, 11 +#endif +#ifndef UNI +CONTROL "",IDC_DATA,"RichEdit20A", ES_LEFT | ES_MULTILINE | ES_WANTRETURN | WS_CHILD | WS_VISIBLE | WS_VSCROLL, 1, 28, 209, 110 +#endif +CONTROL "", IDC_STATUSBAR, "msctls_statusbar32", SBARS_SIZEGRIP | WS_CHILD | WS_VISIBLE, 128, 4, 60, 12 + + + + +END + + +/////////////////////////////////////////////////////////////////////// +///contact options +////////// +IDD_CONTACT_OPT DIALOGEX 0, 0, 367, 115 +STYLE DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | + WS_VISIBLE | WS_SYSMENU | WS_CAPTION +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN +// + GROUPBOX "Webview",IDC_STATIC, 4, 1, 239, 44 ,WS_GROUP + RTEXT "Contact name:",IDC_STATIC,7, 14, 72, 8 + EDITTEXT IDC_SITE_NAME, 80, 12, 158, 12 ,ES_AUTOHSCROLL + RTEXT "URL:",IDC_STATIC,7, 28, 72, 8 + EDITTEXT IDC_URL, 80, 26, 158, 12,ES_AUTOHSCROLL + // + GROUPBOX "Display", IDC_STATIC, 245, 1, 120, 92,WS_GROUP + CONTROL "Between Start and End strings",IDC_U_SE_STRINGS,"Button", + BS_AUTORADIOBUTTON, 249, 25, 113, 8 + CONTROL "Whole web page",IDC_U_ALLSITE,"Button", + BS_AUTORADIOBUTTON, 249, 12, 113, 8 + RTEXT "Start:",IDC_STATIC, 249, 39, 30, 8 + EDITTEXT IDC_START, 280, 37, 70, 12 ,ES_AUTOHSCROLL + RTEXT "End:",IDC_STATIC,249, 53, 30, 8 + EDITTEXT IDC_END, 280, 51, 70, 12 ,ES_AUTOHSCROLL + DEFPUSHBUTTON "Copy Strings to Alerts",IDC_CPY_STRINGS, 249, 66, 101, 12 + //LTEXT "(pastes strings)",IDC_CPY_STR_TXT, 270, 81, 92, 8 + // + GROUPBOX "Double click action",IDC_STATIC, 4, 47, 111, 47 ,WS_GROUP + CONTROL "Opens Web page",IDC_DBLE_WEB,"Button", + BS_AUTORADIOBUTTON, 6, 68, 105, 8 + CONTROL "Opens Data Window",IDC_DBLE_WIN,"Button", + BS_AUTORADIOBUTTON,6, 81, 105, 8 + // + GROUPBOX "Display Clean-up",IDC_STATIC, 117, 47, 126, 47 ,WS_GROUP + CONTROL "Remove HTML",IDC_CLEAN,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP, 120, 59, 100, 8 + CONTROL "Slider1",IDC_RWSPACE,"msctls_trackbar32",TBS_BOTH | + TBS_NOTICKS | WS_TABSTOP,120, 70, 100, 8 + LTEXT "",IDC_RWSPC_TEXT, 120, 81, 120, 8 ,WS_VISIBLE + // + DEFPUSHBUTTON "OK",IDOK, 207, 98, 50, 14 + PUSHBUTTON "Cancel",IDC_OPT_CANCEL, 261, 98, 50, 14 + PUSHBUTTON "Apply",IDC_OPT_APPLY, 315, 98, 50, 14 + + +END + +///////////////////////////////////////////////////////////////////////////////////// +//find window +////// +IDD_FIND DIALOGEX 0, 0, 230, 46 +STYLE DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_CONTROLPARENT +CAPTION "Find" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + EDITTEXT IDC_FINDWHAT,48,11,115,12,ES_AUTOHSCROLL + DEFPUSHBUTTON "&Find Next",IDC_OK,173,7,50,14 + PUSHBUTTON "Cancel",IDC_CANCEL,173,24,50,14 + LTEXT "Find What:",IDC_STATIC,7,13,39,9 + GROUPBOX "",IDC_STATIC,48,24,115,18 + LTEXT "Search was completed.",IDC_SEARCH_COMPLETE, + 52,30,90,8,NOT WS_VISIBLE +END + + + +/////////////////////////////////// +//Alert Options +//////// +IDD_ALRT_OPT DIALOGEX 0, 0, 337, 185 +STYLE DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_SYSMENU | WS_CAPTION +EXSTYLE WS_EX_CONTROLPARENT +CAPTION "Alert Options" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 + +BEGIN + + GROUPBOX "Events And Alerts",IDC_STATIC,3, 4, 331, 71,WS_GROUP + CONTROL "Enable Alerts",IDC_ENABLE_ALERTS,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP, 9, 13, 82, 13 + CONTROL "Always Log To File",IDC_ALWAYS_LOG,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP, 9, 25, 82, 13 + // + GROUPBOX "",IDC_STATIC,7, 36, 324, 35 ,WS_GROUP + CONTROL "Add Time And Date Of Alert To Contact Name",IDC_ADD_DATE_NAME,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP, 9, 42, 235, 13 + CONTROL "Use 24 hour time format instead of 12 hour",IDC_24_HOUR,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,9, 57, 235, 13 + CONTROL "Add As Prefix",IDC_PREFIX,"Button", + BS_AUTORADIOBUTTON, 248, 46, 82, 8 + CONTROL "Add As Suffix",IDC_SUFFIX,"Button", + BS_AUTORADIOBUTTON, 248, 58, 82, 8 + // + RTEXT "Alert When:",IDC_STATIC, 120, 13, 63, 9 + COMBOBOX IDC_EVENT_TYPE,184, 11, 147, 63 ,CBS_DROPDOWN | + WS_VSCROLL | WS_TABSTOP + RTEXT "Alert Type:",IDC_STATIC, 120, 27, 63, 9 + COMBOBOX IDC_ALERT_TYPE, 184, 26, 147, 67 ,CBS_DROPDOWN | + WS_VSCROLL | WS_TABSTOP + // + ////////// + GROUPBOX "Test Conditions",IDC_STATIC, 3, 77, 331, 58 ,WS_GROUP + // + GROUPBOX "Alert When String Is Present On Web Page",IDC_STATIC, 7, 85, 144, 44 ,WS_GROUP + RTEXT "String:",IDC_STATIC, 10, 99, 34, 8 + EDITTEXT IDC_ALERT_STRING, 45, 97, 103, 12 ,ES_AUTOHSCROLL + // + GROUPBOX "Alert When Specific Area Of Web Page Changes",IDC_STATIC,155, 85, 176, 44 ,WS_GROUP + RTEXT "Start:",IDC_STATIC, 163, 97, 36, 8 + EDITTEXT IDC_START2,200, 95, 126, 12,ES_AUTOHSCROLL + RTEXT "End:",IDC_STATIC, 163, 112, 36, 8 + EDITTEXT IDC_END2,200, 110, 125, 12,ES_AUTOHSCROLL + // + ///////// + // + GROUPBOX "Log To file",IDC_STATIC, 3, 137, 246, 37,WS_GROUP + RTEXT "Log File:",IDC_STATIC, 8, 148, 39, 9 + EDITTEXT IDC_FILENAME, 48, 147, 174, 12,ES_AUTOHSCROLL + PUSHBUTTON "...",IDC_BROWSE, 228, 148, 15, 11 + CONTROL "Append data to file",IDC_APPEND,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,8, 161, 132, 8 + CONTROL "Save as raw data",IDC_SAVE_AS_RAW,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,141, 161, 106, 8 + + // + + DEFPUSHBUTTON "OK",IDC_OK2, 276, 137, 50, 14 + PUSHBUTTON "Cancel",IDC_ALERT_CANCEL, 276, 153, 50, 14 + PUSHBUTTON "Apply",IDC_ALERT_APPLY, 276, 169, 50, 14 + // + + + + +END +////////////// +//popup options +/////// +IDD_POPUP DIALOGEX 0, 0, 306, 183 +STYLE DS_MODALFRAME | DS_FIXEDSYS | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + //// + GROUPBOX "Popup Delay",IDC_STATIC,8,5,150,54,WS_GROUP + //CONTROL "Delay",IDC_PD3,"Button",BS_AUTORADIOBUTTON,18,15,47,8 + LTEXT "Delay",IDC_STATIC,18,15,47,8 + EDITTEXT IDC_DELAY,65,15,31,9,ES_RIGHT | ES_AUTOHSCROLL | + ES_NUMBER | NOT WS_BORDER,WS_EX_STATICEDGE + LTEXT "seconds",IDC_STATIC,106,15,34,10 + //CONTROL "From PopUp Plugin",IDC_PD1,"Button",BS_AUTORADIOBUTTON, + // 18,30,110,8 + CONTROL "From PopUp Plugin",IDC_PD1,"MButtonClass",WS_TABSTOP, + 18,30,110,8 + //CONTROL "Permanent",IDC_PD2,"Button",BS_AUTORADIOBUTTON,18,45, + // 110,8 + CONTROL "Permanent",IDC_PD2,"MButtonClass",WS_TABSTOP,18,45, + 110,8 + + //// + CONTROL "Preview",IDC_PREVIEW,"MButtonClass",WS_TABSTOP,223,30, + 45,11,0x18000000L + //// + GROUPBOX "Colors",IDC_STATIC,8,60,270,60,WS_GROUP + CONTROL "Use Custom Colors",IDC_POP_USECUSTCOLORS,"Button", + BS_AUTORADIOBUTTON,18,70,111,13 + LTEXT "Background",IDC_STATIC,223,65,50,8,SS_CENTERIMAGE + LTEXT "Text",IDC_STATIC,147,65,50,8,SS_CENTERIMAGE + CONTROL "",IDC_POP_BGCOLOUR,"ColourPicker",WS_TABSTOP,223,75,35,11 + CONTROL "",IDC_POP_TEXTCOLOUR,"ColourPicker",WS_TABSTOP,147,75,35,11 + CONTROL "Use Windows Colors",IDC_POP_USEWINCOLORS,"Button", + BS_AUTORADIOBUTTON,18,85,121,13 + CONTROL "Use Same Colors As Data Window", IDC_POP_USESAMECOLORS,"Button", + BS_AUTORADIOBUTTON,18,100,161,13 + //// + + GROUPBOX "Left Click Action",IDC_STATIC,8,125,120,54,WS_GROUP + CONTROL "Open Data Display Window",IDC_LCLK_WINDOW,"Button", + BS_AUTORADIOBUTTON,18,135,100,8 + CONTROL "Open Web Page",IDC_LCLK_WEB_PGE,"Button", + BS_AUTORADIOBUTTON,18,150,100,8 + CONTROL "Dismiss PopUp",IDC_LCLK_DISMISS,"Button", + BS_AUTORADIOBUTTON,18,165,100,8 + + + GROUPBOX "Right Click Action",IDC_STATIC,160,125,120,54,WS_GROUP + CONTROL "Open Data Display Window",IDC_RCLK_WINDOW,"Button", + BS_AUTORADIOBUTTON,170,135,100,8 + CONTROL "Open Web Page",IDC_RCLK_WEB_PGE,"Button", + BS_AUTORADIOBUTTON,170,150,100,8 + CONTROL "Dismiss PopUp",IDC_RCLK_DISMISS,"Button", + BS_AUTORADIOBUTTON,170,165,100,8 + + //CONTROL "Use Popup Plugins Notify Popups",IDC_PUALERT,"Button", + // BS_AUTOCHECKBOX | WS_TABSTOP,16,185,130,8 + +END + + + + + +///////////////////////////// + +/////////////// +//Menus +/////////////// + +IDR_CONTEXT MENU DISCARDABLE +BEGIN + POPUP "Log" + BEGIN + MENUITEM "&Copy", IDM_COPY + MENUITEM "C&ut", IDM_CUT + MENUITEM "&Delete", IDM_DELETE + MENUITEM "&Paste", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Co&py All", IDM_COPYALL + MENUITEM "&Select All", IDM_SELECTALL + MENUITEM "C&lear All", IDM_CLEAR_ALL + + END +END + + + diff --git a/plugins/!NotAdopted/WebView/webview_alerts.c b/plugins/!NotAdopted/WebView/webview_alerts.c new file mode 100644 index 0000000000..93f0070a7d --- /dev/null +++ b/plugins/!NotAdopted/WebView/webview_alerts.c @@ -0,0 +1,1304 @@ +/* + * A plugin for Miranda IM which displays web page text in a window Copyright + * (C) 2005 Vincent Joyce. + * + * Miranda IM: the free icq client for MS Windows Copyright (C) 2000-2 + * Richard Hughes, Roland Rabien & Tristan Van de Vreede + * + * 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. + */ + +static HANDLE hWindowList = NULL; + +/**********************************/ +int CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + HANDLE hContact; + char popupurl[300]; + DBVARIANT dbv; + + hContact = PUGetContact(hWnd); + + ZeroMemory(&popupurl, sizeof(popupurl)); + DBGetContactSetting(hContact, DLLNAME, URL_KEY, &dbv); + _snprintf(popupurl, sizeof(popupurl), "%s", dbv.pszVal); + DBFreeVariant(&dbv); + + switch (message) + { + case WM_COMMAND: + case WM_CONTEXTMENU: + { + if (message == WM_COMMAND) // left click + { + if(hContact != NULL) + { + // open data window + + if ((DBGetContactSettingByte(NULL, DLLNAME, LCLK_WINDOW_KEY, 0))) + { + NotifyEventHooks(hHookDisplayDataAlert, (int) hContact, 0); + forkthread(GetData, 0, hContact); + PUDeletePopUp(hWnd); + } + // open url + if ((DBGetContactSettingByte(NULL, DLLNAME, LCLK_WEB_PGE_KEY, 0))) + { + CallService(MS_UTILS_OPENURL, (WPARAM) 1, (LPARAM) popupurl); + PUDeletePopUp(hWnd); + DBWriteContactSettingWord((HANDLE) wParam, DLLNAME, "Status", ID_STATUS_ONLINE); + } + // dismiss + if ((DBGetContactSettingByte(NULL, DLLNAME, LCLK_DISMISS_KEY, 0))) + { + PUDeletePopUp(hWnd); + } + + + } + + else if(hContact == NULL) + PUDeletePopUp(hWnd); + + } + + + + else if (message == WM_CONTEXTMENU) // right click + + { + if(hContact != NULL) + { + + // open datA window + + if ((DBGetContactSettingByte(NULL, DLLNAME, RCLK_WINDOW_KEY, 0))) + { + NotifyEventHooks(hHookDisplayDataAlert, (int) hContact, 0); + forkthread(GetData, 0, hContact); + PUDeletePopUp(hWnd); + } + // open url + if ((DBGetContactSettingByte(NULL, DLLNAME, RCLK_WEB_PGE_KEY, 0))) + { + CallService(MS_UTILS_OPENURL, (WPARAM) 1, (LPARAM) popupurl); + PUDeletePopUp(hWnd); + DBWriteContactSettingWord((HANDLE) wParam, DLLNAME, "Status", ID_STATUS_ONLINE); + } + // dismiss + if ((DBGetContactSettingByte(NULL, DLLNAME, RCLK_DISMISS_KEY, 0))) + { + PUDeletePopUp(hWnd); + } + } + else if(hContact == NULL) + PUDeletePopUp(hWnd); + } + + + + } + break; + } + + return DefWindowProc(hWnd, message, wParam, lParam); +} +/*********************************/ + +/*******************/ +int WDisplayDataAlert(void *AContact) +{ + NotifyEventHooks(hHookDisplayDataAlert, (int) AContact, 0); + return 0; +} +/**************/ + +/*******************/ +int WAlertPopup(WPARAM hContact, char *displaytext) +{ + NotifyEventHooks(hHookAlertPopup, (WPARAM) hContact, (LPARAM) displaytext); + return 0; +} +/**************/ + +/*******************/ +//int WAlertPopup(WPARAM hContact, char *displaytext) +int WAlertWPopup(WPARAM hContact, WCHAR *displaytext) +{ + NotifyEventHooks(hHookAlertWPopup, (WPARAM) hContact, (LPARAM) displaytext); + return 0; +} +/**************/ + + +/*******************/ +int WErrorPopup(char *namecontact, char *textdisplay) +{ + NotifyEventHooks(hHookErrorPopup, (WPARAM) namecontact, (LPARAM) textdisplay); + return 0; +} +/**************/ +/*******************/ +int WAlertOSD(WPARAM hContact, char *displaytext) +{ + NotifyEventHooks(hHookAlertOSD, (WPARAM) hContact, (LPARAM) displaytext); + return 0; +} +/**************/ + +/********************/ + +int WPopupAlert(WPARAM wParam, WCHAR *displaytext) +{ + POPUPDATAW ppd; + DWORD delay = 0; + DWORD colorBack, colorText; + char contactname[255]; + DBVARIANT dbv; + char delaystr[4]; + + // setup the popup + ZeroMemory(&ppd, sizeof(POPUPDATAW)); + ZeroMemory(&contactname, sizeof(contactname)); + +if( ((HANDLE)wParam) != NULL) +{ + DBGetContactSetting((HANDLE) wParam, DLLNAME, PRESERVE_NAME_KEY, &dbv); + _snprintf(contactname, sizeof(contactname), "%s", dbv.pszVal); + DBFreeVariant(&dbv); +} +else +_snprintf(contactname, sizeof(contactname), "%s", DLLNAME); + + + ppd.lchContact = (HANDLE) wParam; + // + MultiByteToWideChar(CP_UTF8, 0, contactname, -1, ppd.lptzContactName, strlen(contactname)); + // + ppd.lchIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_SITE)); + // + if ((wcslen(displaytext) == MAX_SECONDLINE) || (wcslen(displaytext) > MAX_SECONDLINE)) + _snwprintf(ppd.lptzText,MAX_SECONDLINE -1, displaytext); + else if (wcslen(displaytext) < MAX_SECONDLINE) + swprintf(ppd.lptzText, displaytext); + + // + if ((DBGetContactSettingByte(NULL, DLLNAME, POP_USECUSTCLRS_KEY, 0))) + { + colorBack = DBGetContactSettingDword(NULL, DLLNAME, POP_BG_CLR_KEY, 0); + colorText = DBGetContactSettingDword(NULL, DLLNAME, POP_TXT_CLR_KEY, 0); + } + if ((DBGetContactSettingByte(NULL, DLLNAME, POP_USEWINCLRS_KEY, 0))) + { + colorBack = GetSysColor(COLOR_BTNFACE); + colorText = GetSysColor(COLOR_WINDOWTEXT); + } + if ((DBGetContactSettingByte(NULL, DLLNAME, POP_USESAMECLRS_KEY, 0))) + { + colorBack = BackgoundClr; + colorText = TextClr; + } + ppd.colorBack = colorBack; + ppd.colorText = colorText; + // + ppd.PluginWindowProc = NULL; + // + //ppd.iSeconds = (atol("5")); + delay = DBGetContactSettingDword(NULL, DLLNAME, POP_DELAY_KEY, 0); + ppd.iSeconds = delay; + // + + if (ServiceExists(MS_POPUP_ADDPOPUPW)) + CallService(MS_POPUP_ADDPOPUPW, (WPARAM) &ppd, 0); + + + + + + ////////////////////////////////////////////////////////////////////// + +// if ((DBGetContactSettingByte(NULL, DLLNAME, INBUILTPOP_KEY, 0))) +// PUShowMessage(displaytext, SM_NOTIFY); +// else +// { +// } + + return 0; + +} +/********************/ +/********************/ + +int PopupAlert(WPARAM wParam, char *displaytext) +{ + POPUPDATAEX ppd; + DWORD delay = 0; + DWORD colorBack, colorText; + char contactname[255]; + DBVARIANT dbv; + char delaystr[4]; + + // setup the popup + ZeroMemory(&ppd, sizeof(POPUPDATA)); + ZeroMemory(&contactname, sizeof(contactname)); + +if( ((HANDLE)wParam) != NULL) +{ + DBGetContactSetting((HANDLE) wParam, DLLNAME, PRESERVE_NAME_KEY, &dbv); + _snprintf(contactname, sizeof(contactname), "%s", dbv.pszVal); + DBFreeVariant(&dbv); +} +else +_snprintf(contactname, sizeof(contactname), "%s", DLLNAME); + + + + ppd.lchContact = (HANDLE) wParam; + strcpy(ppd.lpzContactName, contactname); + ppd.lchIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_SITE)); + // + //sprintf(ppd.lpzText, Translate("This is a preview popup.")); + if ((strlen(displaytext) == MAX_SECONDLINE) || (strlen(displaytext) > MAX_SECONDLINE)) + _snprintf(ppd.lpzText,MAX_SECONDLINE -1, "%s", displaytext); + else if (strlen(displaytext) < MAX_SECONDLINE) + sprintf(ppd.lpzText, Translate(displaytext)); + // + if ((DBGetContactSettingByte(NULL, DLLNAME, POP_USECUSTCLRS_KEY, 0))) + { + colorBack = DBGetContactSettingDword(NULL, DLLNAME, POP_BG_CLR_KEY, 0); + colorText = DBGetContactSettingDword(NULL, DLLNAME, POP_TXT_CLR_KEY, 0); + } + if ((DBGetContactSettingByte(NULL, DLLNAME, POP_USEWINCLRS_KEY, 0))) + { + colorBack = GetSysColor(COLOR_BTNFACE); + colorText = GetSysColor(COLOR_WINDOWTEXT); + } + if ((DBGetContactSettingByte(NULL, DLLNAME, POP_USESAMECLRS_KEY, 0))) + { + colorBack = BackgoundClr; + colorText = TextClr; + } + ppd.colorBack = colorBack; + ppd.colorText = colorText; + // + ppd.PluginWindowProc = NULL; + // + //ppd.iSeconds = (atol("5")); + delay = DBGetContactSettingDword(NULL, DLLNAME, POP_DELAY_KEY, 0); + ppd.iSeconds = delay; + // + + if (ServiceExists(MS_POPUP_ADDPOPUPEX)) + CallService(MS_POPUP_ADDPOPUPEX, (WPARAM) &ppd, 0); + + + + + ////////////////////////////////////////////////////////////////////// + +// if ((DBGetContactSettingByte(NULL, DLLNAME, INBUILTPOP_KEY, 0))) +// PUShowMessage(displaytext, SM_NOTIFY); +// else +// { +// } + + return 0; + +} +/********************/ + +/********************/ + +int OSDAlert(WPARAM wParam, char *displaytext) +{ + char contactname[255]; + DBVARIANT dbv; + char newdisplaytext[2000]; + + ZeroMemory(&contactname, sizeof(contactname)); + ZeroMemory(&newdisplaytext, sizeof(newdisplaytext)); + + +if(((HANDLE)wParam) != NULL) +{ + DBGetContactSetting((HANDLE) wParam, DLLNAME, PRESERVE_NAME_KEY, &dbv); + _snprintf(contactname, sizeof(contactname), "%s", dbv.pszVal); + DBFreeVariant(&dbv); +} +else +_snprintf(contactname, sizeof(contactname), "%s", DLLNAME); + + + _snprintf(newdisplaytext, sizeof(newdisplaytext), "%s: %s", contactname, Translate(displaytext)); + + if (ServiceExists("OSD/Announce")) + CallService("OSD/Announce", (WPARAM) newdisplaytext, 0); + + return 0; +} +/********************/ + +/*****************/ +void ErrorMsgs(char *contactname, char *displaytext) +{ + char newdisplaytext[2000]; + + if (!(DBGetContactSettingByte(NULL, DLLNAME, SUPPRESS_ERR_KEY, 0))) + { + if ((ServiceExists(MS_POPUP_ADDPOPUP) != 0) && ((DBGetContactSettingByte(NULL, DLLNAME, ERROR_POPUP_KEY, 0)))) + { + _snprintf(newdisplaytext, sizeof(newdisplaytext), "%s\n%s", contactname, displaytext); + PUShowMessage(newdisplaytext, SM_WARNING); + } else if ((ServiceExists("OSD/Announce") != 0) && ((DBGetContactSettingByte(NULL, DLLNAME, ERROR_POPUP_KEY, 0)))) + { + _snprintf(newdisplaytext, sizeof(newdisplaytext), "%s: %s", contactname, Translate(displaytext)); + CallService("OSD/Announce", (WPARAM) newdisplaytext, 0); + } else if (ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) + { + MIRANDASYSTRAYNOTIFY webview_tip = {0}; + + webview_tip.cbSize = sizeof(MIRANDASYSTRAYNOTIFY); + webview_tip.szProto = NULL; + webview_tip.szInfoTitle = contactname; + webview_tip.szInfo = Translate(displaytext); + webview_tip.dwInfoFlags = NIIF_ERROR; + webview_tip.uTimeout = 15000; + CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM) &webview_tip); + } // //////////// + + } +} +/********************/ + +/***************************/ +void SaveToFile(char *AContact, char *truncated) +{ + FILE *pfile; + char *mode; + DBVARIANT dbv; + char url[300]; + char contactname[100]; + + ZeroMemory(&contactname, sizeof(contactname)); + DBGetContactSetting(AContact, "CList", "MyHandle", &dbv); + _snprintf(contactname, sizeof(contactname), "%s", dbv.pszVal); + DBFreeVariant(&dbv); + + if (!(DBGetContactSettingByte(AContact, DLLNAME, APPEND_KEY, 0))) + mode = "w"; + else + mode = "a"; + + url[0] = '\0'; + + DBGetContactSetting(AContact, DLLNAME, URL_KEY, &dbv); + _snprintf(url, sizeof(url), "%s", dbv.pszVal); + + DBFreeVariant(&dbv); + + DBGetContactSetting(AContact, DLLNAME, FILE_KEY, &dbv); + if ((pfile = fopen(dbv.pszVal, mode)) == NULL) + { + WErrorPopup(contactname, Translate("Cannot write to file")); + } else + { +// + + char tstr[128]; + char timestring[128]; + char timeprefix[32]; + char temptime1[32]; + char temptime2[32]; + char temptime[128]; + time_t ftime; + struct tm *nTime; + + ZeroMemory(&tstr, sizeof(tstr)); + ZeroMemory(&temptime, sizeof(temptime)); + ZeroMemory(&timeprefix, sizeof(timeprefix)); + ZeroMemory(&temptime1, sizeof(temptime1)); + ZeroMemory(&temptime2, sizeof(temptime2)); + ZeroMemory(×tring, sizeof(timestring)); + + setlocale(LC_ALL, ""); + + ftime = time(NULL); + nTime = localtime(&ftime); + + _snprintf(timeprefix, sizeof(timeprefix), " %s ", (Translate("Last updated on"))); + strftime(temptime1, 32, " %a, %b %d, %Y ", nTime); + strftime(temptime2, 32, " %I:%M %p.", nTime); + _snprintf(timestring, sizeof(timestring), "(%s)%s\n%s,%s\n", DLLNAME, url, temptime1, temptime2); + + fputs(timestring, pfile); +// + + fwrite(truncated, strlen(truncated), 1, pfile); + + fputs("\n\n", pfile); + + fclose(pfile); + } + + DBFreeVariant(&dbv); +} + +/***************************/ + +/**************************/ +int ProcessAlerts(HANDLE AContact, char *truncated, char *tstr, char *contactname, int notpresent) +{ + + char alertstring[255]; + char displaystring[300]; + FILE *pcachefile; + char cachepath[MAX_PATH]; + char cachedirectorypath[MAX_PATH]; + char newcachepath[MAX_PATH + 50]; + char *cacheend; + DBVARIANT tdbv; + int wasAlert = 0; + + // + int statalertpos = 0, disalertpos = 0, statalertposend = 0; + char *alertpos; + char Alerttempstring[300], Alerttempstring2[300]; + static char cachecompare[MAXSIZE1]; + static char raw[MAXSIZE1]; + + // + char tempraw[MAXSIZE1]; + char statustext[200]; + int alertIndex = 0; + int eventIndex = 0; + +//MessageBox(NULL, contactname, "pro-contname2", MB_OK); + + ZeroMemory(&tempraw, sizeof(tempraw)); + ZeroMemory(&raw, sizeof(raw)); + + strncpy(tempraw, truncated, sizeof(tempraw)); + + ZeroMemory(&alertstring, sizeof(alertstring)); + ZeroMemory(&cachepath, sizeof(cachepath)); + ZeroMemory(&cachedirectorypath, sizeof(cachedirectorypath)); + ZeroMemory(&newcachepath, sizeof(newcachepath)); + ZeroMemory(&Alerttempstring, sizeof(Alerttempstring)); + ZeroMemory(&Alerttempstring2, sizeof(Alerttempstring2)); + ZeroMemory(&cachecompare, sizeof(cachecompare)); + + // + + // alerts + if ((DBGetContactSettingByte(AContact, DLLNAME, ENABLE_ALERTS_KEY, 0))) // ALERTS + // + // ARE + // ENABLED + + { + + if (!DBGetContactSetting(AContact, DLLNAME, ALRT_INDEX_KEY, &tdbv)) // TYPES + // + // OF + // ALERTS + + { + alertIndex = DBGetContactSettingByte(AContact, DLLNAME, ALRT_INDEX_KEY, 0); + DBFreeVariant(&tdbv); + + if (!DBGetContactSetting(AContact, DLLNAME, EVNT_INDEX_KEY, &tdbv)) + { + + eventIndex = DBGetContactSettingByte(AContact, DLLNAME, EVNT_INDEX_KEY, 0); + DBFreeVariant(&tdbv); + } + if ((notpresent)) + { + if (alertIndex == 0) // Popup + + { + Sleep(1000); + sprintf(displaystring, "%s", (Translate("Start/end strings not found or strings not set."))); + WAlertPopup((WPARAM) AContact, displaystring); + // contactlist name// + if ((DBGetContactSettingByte(AContact, DLLNAME, APND_DATE_NAME_KEY, 0))) + DBWriteContactSettingString(AContact, "CList", "MyHandle", tstr); + } // + + else if (alertIndex == 1) // log to file + + { + if (!DBGetContactSetting(AContact, DLLNAME, FILE_KEY, &tdbv)) + { + int AmountWspcRem = 0; + + if (!(DBGetContactSettingByte(AContact, DLLNAME, SAVE_AS_RAW_KEY, 0))) + { + // + CodetoSymbol(tempraw); + Sleep(100); // avoid 100% CPU + + EraseBlock(tempraw); + Sleep(100); // avoid 100% CPU + + FastTagFilter(tempraw); + Sleep(100); // avoid 100% CPU + + NumSymbols(tempraw); + Sleep(100); // avoid 100% CPU + + EraseSymbols(tempraw); + Sleep(100); // avoid 100% CPU + + AmountWspcRem = DBGetContactSettingByte(AContact, DLLNAME, RWSPACE_KEY, 0); + RemoveInvis(tempraw, AmountWspcRem); + Sleep(100); // avoid 100% CPU + + Removewhitespace(tempraw); + } + // + SaveToFile(AContact, tempraw); + DBFreeVariant(&tdbv); + // contactlist name// + if ((DBGetContactSettingByte(AContact, DLLNAME, APND_DATE_NAME_KEY, 0))) + DBWriteContactSettingString(AContact, "CList", "MyHandle", tstr); + } + } // + + else if (alertIndex == 3) // osd + + { + WAlertOSD((WPARAM) AContact, Translate("Alert start/end strings not found or strings not set.")); + // contactlist name// + if ((DBGetContactSettingByte(AContact, DLLNAME, APND_DATE_NAME_KEY, 0))) + DBWriteContactSettingString(AContact, "CList", "MyHandle", tstr); + } else if (eventIndex == 2) // window + + { + WDisplayDataAlert(AContact); + // contactlist name// + if ((DBGetContactSettingByte(AContact, DLLNAME, APND_DATE_NAME_KEY, 0))) + DBWriteContactSettingString(AContact, "CList", "MyHandle", tstr); + + HWND hwndDlg = (WindowList_Find(hWindowList, AContact)); + + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), " %s", Translate("Start/end strings not found or strings not set.")); + SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext); + } // + + else + MessageBox(NULL, Translate("Start/end strings not found or strings not set."), DLLNAME, MB_OK); + } + if (eventIndex == 0) // string present + + { + + if (!DBGetContactSetting(AContact, DLLNAME, ALERT_STRING_KEY, &tdbv)) + { + strncpy(alertstring, tdbv.pszVal, sizeof(alertstring)); + DBFreeVariant(&tdbv); + + if ((strstr(tempraw, alertstring)) != 0) + { // // ENDALERT EVENT:CHECK FOR STRING + + // there was an alert + wasAlert = 1; + + // play sound? + SkinPlaySound("webviewalert"); + // + if ((!notpresent)) + { + + if (alertIndex == 0) // popup + + { + sprintf(displaystring, "%s \"%s\" %s.", (Translate("The string")), alertstring, (Translate("has been found on the web page"))); + WAlertPopup((WPARAM) AContact, displaystring); + + // contactlist name// + if ((DBGetContactSettingByte(AContact, DLLNAME, APND_DATE_NAME_KEY, 0))) + DBWriteContactSettingString(AContact, "CList", "MyHandle", tstr); + } // + + else if (alertIndex == 1) // LOG + + { + if (!DBGetContactSetting(AContact, DLLNAME, FILE_KEY, &tdbv)) + { + + int AmountWspcRem = 0; + + if (!(DBGetContactSettingByte(AContact, DLLNAME, SAVE_AS_RAW_KEY, 0))) + { + // + CodetoSymbol(tempraw); + Sleep(100); // avoid 100% CPU + + EraseBlock(tempraw); + Sleep(100); // avoid 100% CPU + + FastTagFilter(tempraw); + Sleep(100); // avoid 100% CPU + + NumSymbols(tempraw); + Sleep(100); // avoid 100% CPU + + EraseSymbols(tempraw); + Sleep(100); // avoid 100% CPU + + AmountWspcRem = DBGetContactSettingByte(AContact, DLLNAME, RWSPACE_KEY, 0); + RemoveInvis(tempraw, AmountWspcRem); + Sleep(100); // avoid 100% CPU + + Removewhitespace(tempraw); + // + } + SaveToFile(AContact, tempraw); + DBFreeVariant(&tdbv); + // contactlist name// + if ((DBGetContactSettingByte(AContact, DLLNAME, APND_DATE_NAME_KEY, 0))) + DBWriteContactSettingString(AContact, "CList", "MyHandle", tstr); + } + } // + + else if (alertIndex == 3) // osd + + { + sprintf(displaystring, "%s \"%s\" %s.", (Translate("The string")), alertstring, (Translate("has been found on the web page"))); + WAlertOSD((WPARAM) AContact, displaystring); + + // contactlist name// + if ((DBGetContactSettingByte(AContact, DLLNAME, APND_DATE_NAME_KEY, 0))) + DBWriteContactSettingString(AContact, "CList", "MyHandle", tstr); + } else if (alertIndex == 2) // window + + { + WDisplayDataAlert(AContact); + // contactlist name// + if ((DBGetContactSettingByte(AContact, DLLNAME, APND_DATE_NAME_KEY, 0))) + DBWriteContactSettingString(AContact, "CList", "MyHandle", tstr); + + HWND hwndDlg = (WindowList_Find(hWindowList, AContact)); + + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), " %s", Translate("Download successful; about to process data...")); + SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext); + } // + + else + MessageBox(NULL, Translate("Unknown Alert Type."), DLLNAME, MB_OK); + } + // + } // // END ALERT EVENT:CHECK FOR STRING + + } // alert string + + } else if (eventIndex == 1) // webpage changed + + { + + // TEST GET NAME FOR CACHE + GetModuleFileName(hInst, cachepath, sizeof(cachepath)); + cacheend = strrchr(cachepath, '\\'); + cacheend++; + *cacheend = '\0'; + + _snprintf(cachedirectorypath, sizeof(cachedirectorypath), "%s%s%s", cachepath, DLLNAME, "cache\\"); + CreateDirectory(cachedirectorypath, NULL); + _snprintf(newcachepath, sizeof(newcachepath), "%s%s%s%s%s", cachepath, DLLNAME, "cache\\", contactname, ".txt"); + // file exists? + if ((_access(newcachepath, 0)) != -1) + { + if ((pcachefile = fopen(newcachepath, "r")) == NULL) + { + WErrorPopup(contactname, Translate("Cannot read from file")); + } else + { + ZeroMemory(&cachecompare, sizeof(cachecompare)); + fread(cachecompare, sizeof(cachecompare), 1, pcachefile); + fclose(pcachefile); + } + } + // write to cache + if ((pcachefile = fopen(newcachepath, "w")) == NULL) + { + WErrorPopup(contactname, Translate("Cannot write to file 1")); + MessageBox(NULL, newcachepath, "1", MB_OK); + } else + { + + fwrite(tempraw, strlen(tempraw), 1, pcachefile); //smaller cache + fclose(pcachefile); + DBWriteContactSettingString(AContact, DLLNAME, CACHE_FILE_KEY, newcachepath); + } + // end write to cache + + if (strncmp(tempraw, cachecompare, (strlen(tempraw))) != 0) //lets try this instead + { + + // play sound? + SkinPlaySound("webviewalert"); + // there was an alert + wasAlert = 1; + + if ((!notpresent)) + { + + if (alertIndex == 0) // popup + + { + WAlertPopup((WPARAM) AContact, Translate("The Web Page Has Changed.")); + // contactlist name// + if ((DBGetContactSettingByte(AContact, DLLNAME, APND_DATE_NAME_KEY, 0))) + DBWriteContactSettingString(AContact, "CList", "MyHandle", tstr); + } // + + else if (alertIndex == 3) // osd + + { + WAlertOSD((WPARAM) AContact, Translate("The Web Page Has Changed.")); + // contactlist name// + if ((DBGetContactSettingByte(AContact, DLLNAME, APND_DATE_NAME_KEY, 0))) + DBWriteContactSettingString(AContact, "CList", "MyHandle", tstr); + } else if (alertIndex == 1) // log + + { + if (!DBGetContactSetting(AContact, DLLNAME, FILE_KEY, &tdbv)) + { + int AmountWspcRem = 0; + + if (!(DBGetContactSettingByte(AContact, DLLNAME, SAVE_AS_RAW_KEY, 0))) + { + // + CodetoSymbol(tempraw); + Sleep(100); // avoid 100% CPU + + EraseBlock(tempraw); + Sleep(100); // avoid 100% CPU + + FastTagFilter(tempraw); + Sleep(100); // avoid 100% CPU + + NumSymbols(tempraw); + Sleep(100); // avoid 100% CPU + + EraseSymbols(tempraw); + Sleep(100); // avoid 100% CPU + + AmountWspcRem = DBGetContactSettingByte(AContact, DLLNAME, RWSPACE_KEY, 0); + RemoveInvis(tempraw, AmountWspcRem); + Sleep(100); // avoid 100% CPU + + Removewhitespace(tempraw); + } + // + SaveToFile(AContact, tempraw); + DBFreeVariant(&tdbv); + // contactlist name// + if ((DBGetContactSettingByte(AContact, DLLNAME, APND_DATE_NAME_KEY, 0))) + DBWriteContactSettingString(AContact, "CList", "MyHandle", tstr); + } + } // + + else if (alertIndex == 2) // window + + { + WDisplayDataAlert(AContact); + // contactlist name// + if ((DBGetContactSettingByte(AContact, DLLNAME, APND_DATE_NAME_KEY, 0))) + DBWriteContactSettingString(AContact, "CList", "MyHandle", tstr); + } // + + else + MessageBox(NULL, Translate("Unknown Alert Type."), DLLNAME, MB_OK); + } + } + } +// + + if (eventIndex == 2) // part of webpage changed + + { + + // ////////// + // + DBGetContactSetting(AContact, DLLNAME, ALRT_S_STRING_KEY, &tdbv); + _snprintf(Alerttempstring, sizeof(Alerttempstring), "%s", tdbv.pszVal); + DBFreeVariant(&tdbv); + // + DBGetContactSetting(AContact, DLLNAME, ALRT_E_STRING_KEY, &tdbv); + _snprintf(Alerttempstring2, sizeof(Alerttempstring2), "%s", tdbv.pszVal); + DBFreeVariant(&tdbv); + // + + // putting data into string + if (((strstr(tempraw, Alerttempstring)) != 0) && ((strstr(tempraw, Alerttempstring2)) != 0)) + { + +//start string + alertpos = strstr(tempraw, Alerttempstring); + statalertpos = alertpos - tempraw; +// + ZeroMemory(&alertpos, sizeof(alertpos)); +//end string + alertpos = strstr(tempraw, Alerttempstring2); + statalertposend = alertpos - tempraw + strlen(Alerttempstring2); +// + if (statalertpos > statalertposend) + { + memset(&tempraw, ' ', statalertpos); + ZeroMemory(&alertpos, sizeof(alertpos)); + alertpos = strstr(tempraw, Alerttempstring2); + statalertposend = alertpos - tempraw + strlen(Alerttempstring2); + } + if (statalertpos < statalertposend) + { + ZeroMemory(&raw, sizeof(raw)); + +//start string + alertpos = strstr(tempraw, Alerttempstring); + statalertpos = alertpos - tempraw; +// + +//end string + alertpos = strstr(tempraw, Alerttempstring2); + statalertposend = alertpos - tempraw + strlen(Alerttempstring2); +// + + if (statalertpos > statalertposend) + { + memset(&tempraw, ' ', statalertpos); + ZeroMemory(&alertpos, sizeof(alertpos)); + alertpos = strstr(tempraw, Alerttempstring2); + statalertposend = alertpos - tempraw + strlen(Alerttempstring2); + } + disalertpos = 0; + +//write selected data to string + strncpy(raw, &tempraw[statalertpos], (statalertposend - statalertpos)); + raw[(statalertposend - statalertpos)] = '\0'; + + } + } // end putting data into string + + else // start and/or end string not present + + { + + if (alertIndex == 0) // popup + + { + Sleep(1000); + sprintf(displaystring, "%s", (Translate("Alert start/end strings not found or strings not set."))); + WAlertPopup((WPARAM) AContact, displaystring); + // contactlist name// + if ((DBGetContactSettingByte(AContact, DLLNAME, APND_DATE_NAME_KEY, 0))) + DBWriteContactSettingString(AContact, "CList", "MyHandle", tstr); + } // + + else if (alertIndex == 1) // LOG + + { + if (!(notpresent)) // dont log to file twice if both types + // of start/end strings not present + + { + if (!DBGetContactSetting(AContact, DLLNAME, FILE_KEY, &tdbv)) + { + int AmountWspcRem = 0; + + if (!(DBGetContactSettingByte(AContact, DLLNAME, SAVE_AS_RAW_KEY, 0))) + { + // + CodetoSymbol(tempraw); + Sleep(100); // avoid 100% CPU + + EraseBlock(tempraw); + Sleep(100); // avoid 100% CPU + + FastTagFilter(tempraw); + Sleep(100); // avoid 100% CPU + + NumSymbols(tempraw); + Sleep(100); // avoid 100% CPU + + EraseSymbols(tempraw); + Sleep(100); // avoid 100% CPU + + AmountWspcRem = DBGetContactSettingByte(AContact, DLLNAME, RWSPACE_KEY, 0); + RemoveInvis(tempraw, AmountWspcRem); + Sleep(100); // avoid 100% CPU + + Removewhitespace(tempraw); + } + // + SaveToFile(AContact, tempraw); + DBFreeVariant(&tdbv); + // contactlist name// + if ((DBGetContactSettingByte(AContact, DLLNAME, APND_DATE_NAME_KEY, 0))) + DBWriteContactSettingString(AContact, "CList", "MyHandle", tstr); + } + } + } // + + else if (alertIndex == 3) // osd + + { + WAlertOSD((WPARAM) AContact, Translate("Alert start/end strings not found or strings not set.")); + // contactlist name// + if ((DBGetContactSettingByte(AContact, DLLNAME, APND_DATE_NAME_KEY, 0))) + DBWriteContactSettingString(AContact, "CList", "MyHandle", tstr); + } else if (alertIndex == 2) // window + + { + WDisplayDataAlert(AContact); + // contactlist name// + if ((DBGetContactSettingByte(AContact, DLLNAME, APND_DATE_NAME_KEY, 0))) + DBWriteContactSettingString(AContact, "CList", "MyHandle", tstr); + + HWND hwndDlg = (WindowList_Find(hWindowList, AContact)); + + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), " %s", Translate("Alert start/end strings not found or strings not set.")); + SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext); + } // + + else + MessageBox(NULL, Translate("Alert start/end strings not found or strings not set."), DLLNAME, MB_OK); + DBWriteContactSettingWord(AContact, DLLNAME, "Status", ID_STATUS_AWAY); + } + +/////////////// + + if (((strstr(tempraw, Alerttempstring)) != 0) && ((strstr(tempraw, Alerttempstring2)) != 0)) + { + + // TEST GET NAME FOR CACHE + GetModuleFileName(hInst, cachepath, sizeof(cachepath)); + cacheend = strrchr(cachepath, '\\'); + cacheend++; + *cacheend = '\0'; + + _snprintf(cachedirectorypath, sizeof(cachedirectorypath), "%s%s%s", cachepath, DLLNAME, "cache\\"); + CreateDirectory(cachedirectorypath, NULL); + _snprintf(newcachepath, sizeof(newcachepath), "%s%s%s%s%s", cachepath, DLLNAME, "cache\\", contactname, ".txt"); + // file exists? + if ((_access(newcachepath, 0)) != -1) + { + if ((pcachefile = fopen(newcachepath, "r")) == NULL) + { + WErrorPopup(contactname, Translate("Cannot read from file")); + } else + { + ZeroMemory(&cachecompare, sizeof(cachecompare)); + fread(cachecompare, sizeof(cachecompare), 1, pcachefile); + fclose(pcachefile); + } + } + // write to cache + if ((pcachefile = fopen(newcachepath, "w")) == NULL) + { + WErrorPopup(contactname, Translate("Cannot write to file 2")); + } else + { + fwrite(raw, strlen(raw), 1, pcachefile); //smaller cache + DBWriteContactSettingString(AContact, DLLNAME, CACHE_FILE_KEY, newcachepath); + fclose(pcachefile); + } + // end write to cache + if (strncmp(raw, cachecompare, (strlen(raw))) != 0) //lets try this instead + { + + // play sound? + SkinPlaySound("webviewalert"); + // there was an alert + wasAlert = 1; + + if ((!notpresent)) + { + + if (alertIndex == 0) // popup + + { + WAlertPopup((WPARAM) AContact, Translate("Specific Part Of The Web Page Has Changed.")); + // contactlist name// + if ((DBGetContactSettingByte(AContact, DLLNAME, APND_DATE_NAME_KEY, 0))) + DBWriteContactSettingString(AContact, "CList", "MyHandle", tstr); + } // + + else if (alertIndex == 3) // osd + + { + WAlertOSD((WPARAM) AContact, Translate("Specific Part Of The Web Page Has Changed.")); + // contactlist name// + if ((DBGetContactSettingByte(AContact, DLLNAME, APND_DATE_NAME_KEY, 0))) + DBWriteContactSettingString(AContact, "CList", "MyHandle", tstr); + } else if (alertIndex == 1) // log to file + + { + if (!DBGetContactSetting(AContact, DLLNAME, FILE_KEY, &tdbv)) + { + int AmountWspcRem = 0; + + if (!(DBGetContactSettingByte(AContact, DLLNAME, SAVE_AS_RAW_KEY, 0))) + { + // + CodetoSymbol(tempraw); + Sleep(100); // avoid 100% CPU + + EraseBlock(tempraw); + Sleep(100); // avoid 100% CPU + + FastTagFilter(tempraw); + Sleep(100); // avoid 100% CPU + + NumSymbols(tempraw); + Sleep(100); // avoid 100% CPU + + EraseSymbols(tempraw); + Sleep(100); // avoid 100% CPU + + AmountWspcRem = DBGetContactSettingByte(AContact, DLLNAME, RWSPACE_KEY, 0); + RemoveInvis(tempraw, AmountWspcRem); + Sleep(100); // avoid 100% CPU + + Removewhitespace(tempraw); + } + // + SaveToFile(AContact, tempraw); + DBFreeVariant(&tdbv); + // contactlist name// + if ((DBGetContactSettingByte(AContact, DLLNAME, APND_DATE_NAME_KEY, 0))) + DBWriteContactSettingString(AContact, "CList", "MyHandle", tstr); + } + } // + + else if (alertIndex == 2) // window + + { + WDisplayDataAlert(AContact); + // contactlist name// + if ((DBGetContactSettingByte(AContact, DLLNAME, APND_DATE_NAME_KEY, 0))) + DBWriteContactSettingString(AContact, "CList", "MyHandle", tstr); + } // + + else + MessageBox(NULL, Translate("Unknown Alert Type."), DLLNAME, MB_OK); + } + } + } + } +// + } // alert type + + } + // end alerts + +//if always log to file option is enabled do this + if (wasAlert) + { + if (alertIndex != 1) // dont do for log to file alert + + { + if ((DBGetContactSettingByte(AContact, DLLNAME, ALWAYS_LOG_KEY, 0))) + { + if (!DBGetContactSetting(AContact, DLLNAME, FILE_KEY, &tdbv)) + { + int AmountWspcRem = 0; + + if (!(DBGetContactSettingByte(AContact, DLLNAME, SAVE_AS_RAW_KEY, 0))) + { + // + CodetoSymbol(tempraw); + Sleep(100); // avoid 100% CPU + + EraseBlock(tempraw); + Sleep(100); // avoid 100% CPU + + FastTagFilter(tempraw); + Sleep(100); // avoid 100% CPU + + NumSymbols(tempraw); + Sleep(100); // avoid 100% CPU + + EraseSymbols(tempraw); + Sleep(100); // avoid 100% CPU + + AmountWspcRem = DBGetContactSettingByte(AContact, DLLNAME, RWSPACE_KEY, 0); + RemoveInvis(tempraw, AmountWspcRem); + Sleep(100); // avoid 100% CPU + + Removewhitespace(tempraw); + } + // + SaveToFile(AContact, tempraw); + DBFreeVariant(&tdbv); + } + } + } + } + strncpy(truncated, tempraw, strlen(truncated)); + + return wasAlert; +} +/**************************/ + +/***********************/ +int DataWndAlertCommand(void *AContact) +{ + HWND hwndDlg; + + if ((hwndDlg = (WindowList_Find(hWindowList, (HANDLE) AContact)))) + { + return 0; + } + hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DISPLAY_DATA), NULL, DlgProcDisplayData, (LPARAM) (HANDLE) AContact); + + if (DBGetContactSettingByte(AContact, DLLNAME, ON_TOP_KEY, 0)) + { + SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0))); + if ((DBGetContactSettingByte(NULL, DLLNAME, SAVE_INDIVID_POS_KEY, 0))) + { + SetWindowPos( + hwndDlg, + HWND_TOPMOST, + DBGetContactSettingDword(AContact, DLLNAME, "WVx", 100), // Xposition, + DBGetContactSettingDword(AContact, DLLNAME, "WVy", 100), // Yposition, + DBGetContactSettingDword(AContact, DLLNAME, "WVwidth", 100), // WindowWidth, + DBGetContactSettingDword(AContact, DLLNAME, "WVheight", 100), // WindowHeight, + 0); + } else + { + SetWindowPos( + hwndDlg, + HWND_TOPMOST, + Xposition, + Yposition, + WindowWidth, + WindowHeight, + 0); + } + + } + if (!(DBGetContactSettingByte(AContact, DLLNAME, ON_TOP_KEY, 0))) + {// + SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_UNSTICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0))); + + if ((DBGetContactSettingByte(NULL, DLLNAME, SAVE_INDIVID_POS_KEY, 0))) + { + SetWindowPos( + hwndDlg, + HWND_NOTOPMOST, + DBGetContactSettingDword(AContact, DLLNAME, "WVx", 100), // Xposition, + DBGetContactSettingDword(AContact, DLLNAME, "WVy", 100), // Yposition, + DBGetContactSettingDword(AContact, DLLNAME, "WVwidth", 100), // WindowWidth, + DBGetContactSettingDword(AContact, DLLNAME, "WVheight", 100), // WindowHeight, + 0); + } else + { + SetWindowPos( + hwndDlg, + HWND_NOTOPMOST, + Xposition, + Yposition, + WindowWidth, + WindowHeight, + 0); + } + } + ShowWindow(hwndDlg, SW_SHOW); + SetActiveWindow(hwndDlg); + + return 0; +} + +/***********************/ +/***************************/ +static void ReadFromFile(void *AContact) +{ + FILE *pfile; + DBVARIANT dbv; + char contactname[100]; + char truncated[MAXSIZE1]; + int AmountWspcRem = 0; + int fileexists = 0; + + + HWND hwndDlg = (WindowList_Find(hWindowList, AContact)); + + ZeroMemory(&contactname, sizeof(contactname)); + DBGetContactSetting(AContact, "CList", "MyHandle", &dbv); + _snprintf(contactname, sizeof(contactname), "%s", dbv.pszVal); + DBFreeVariant(&dbv); + + + +//// + DBGetContactSetting(AContact, DLLNAME, CACHE_FILE_KEY, &dbv); +//// + if ((pfile = fopen(dbv.pszVal, "r")) == NULL) + { + //WErrorPopup(contactname, Translate("Cannot read from cache file")); + SendToRichEdit(hwndDlg, + Translate("Cannot read from cache file"), + TextClr, + BackgoundClr); + fileexists =0; + } + else + { + fread(truncated, sizeof(truncated), 1, pfile); + fclose(pfile); + fileexists =1; + } + + DBFreeVariant(&dbv); + + if(fileexists) {/// + + CodetoSymbol(truncated); + Sleep(100); // avoid 100% CPU + + EraseBlock(truncated); + Sleep(100); // avoid 100% CPU + + FastTagFilter(truncated); + Sleep(100); // avoid 100% CPU + + NumSymbols(truncated); + Sleep(100); // avoid 100% CPU + + EraseSymbols(truncated); + Sleep(100); // avoid 100% CPU + + AmountWspcRem = DBGetContactSettingByte(AContact, DLLNAME, RWSPACE_KEY, 0); + RemoveInvis(truncated, AmountWspcRem); + Sleep(100); // avoid 100% CPU + + Removewhitespace(truncated); + + SendToRichEdit(hwndDlg, + truncated, + TextClr, + BackgoundClr); + + SetDlgItemText(hwndDlg, IDC_STATUSBAR, Translate("Loaded From Cache")); + + } /// +} + +/***************************/ diff --git a/plugins/!NotAdopted/WebView/webview_cleanup.c b/plugins/!NotAdopted/WebView/webview_cleanup.c new file mode 100644 index 0000000000..af5a8f476e --- /dev/null +++ b/plugins/!NotAdopted/WebView/webview_cleanup.c @@ -0,0 +1,631 @@ +/* + * A plugin for Miranda IM which displays web page text in a window Copyright + * (C) 2005 Vincent Joyce. + * + * Miranda IM: the free icq client for MS Windows Copyright (C) 2000-2 + * Richard Hughes, Roland Rabien & Tristan Van de Vreede + * + * 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. + */ + +/************************/ +void CodetoSymbol(char *truncated) +{ + int counter = 0; + int position = 0, recpos = 0, n; + static char *stringfrompos; + + for (n = 0; n < AMOUNT3; n++) + { + + while (1) // loop forever + + { + Sleep(1); // avoid 100% CPU + + if (((strstr(truncated, CharacterCodes[n])) != 0)) +// does character code exist? + { + + if (strstr(truncated, CharacterCodes[n]) != 0) + { + stringfrompos = strstr(truncated, CharacterCodes[n]); + } + position = stringfrompos - truncated; + counter = 0; + while (counter != (strlen(CharacterCodes[n]))) + { + truncated[position + counter] = ' '; + counter++; + } + + truncated[(position + counter) - 1] = Characters[n]; + +// + strncpy(&truncated[position], &truncated[position + strlen(CharacterCodes[n])] - 1, strlen(&truncated[position]) - 1); +// + + } // end does character code exist? + + if (recpos == position) + break; // break out of loop if doesn't find new character code + + recpos = position; + } // end loop forever + + } // for + +} + +/**********************/ + +/************************/ +void EraseBlock(char *truncated) +{ + int counter = 0; + int positionStart = 0, positionEnd = 0; + char *stringfrompos; + char *tempraw; + int BlockLength = 0; + +// ////// + + tempraw = malloc(MAXSIZE1); + + if (truncated) + strncpy(tempraw, truncated, MAXSIZE1); + +// /////////////////////////// + +// 1// + + while (1) + { + Sleep(1); // avoid 100% CPU + // /get start and end of block + + if (strstr(tempraw, "<!--") != 0) // does tag exist? + + { + stringfrompos = strstr(tempraw, "<!--"); + positionStart = stringfrompos - tempraw; + } + if (strstr(tempraw, "-->") != 0) // does tag exist? + + { + stringfrompos = strstr(tempraw, "-->"); + positionEnd = stringfrompos - tempraw; + } + BlockLength = (positionEnd - positionStart) + 3; + + if ((strstr(tempraw, "<!--") == 0) || (strstr(tempraw, "-->") == 0)) + break; + +///////////////////////////////////////// + + // ///////// + if (strstr(tempraw, "<!--") != 0) + { + for (counter = 0; counter < BlockLength; counter++) + { + tempraw[positionStart + counter] = ' '; + } + } + // ////////// + + if ((positionStart == 0) && (positionEnd == 0)) + break; + if (positionStart > positionEnd) + break; + + positionStart = 0; + positionEnd = 0; + } + +// /////////////////////////// + positionStart = 0; + positionEnd = 0; + +// 2// + while (1) + { + Sleep(1); // avoid 100% CPU + // /get start and end of block + + if (((strstr(tempraw, "<script")) != 0) || (strstr(tempraw, "<SCRIPT") != 0)) // does + // + // tag + // exist? + + { + if (strstr(tempraw, "<script") != 0) + stringfrompos = strstr(tempraw, "<script"); + else + stringfrompos = strstr(tempraw, "<SCRIPT"); + + positionStart = stringfrompos - tempraw; + } + if (((strstr(tempraw, "</script")) != 0) || (strstr(tempraw, "</SCRIPT") != 0)) // does + // + // tag + // exist? + + { + if (strstr(tempraw, "<script") != 0) + stringfrompos = strstr(tempraw, "</script"); + else + stringfrompos = strstr(tempraw, "</SCRIPT"); + + positionEnd = stringfrompos - tempraw; + } + BlockLength = (positionEnd - positionStart) + 9; + + if ((strstr(tempraw, "<script") != 0) && (strstr(tempraw, "</script") == 0)) + break; + + if ((strstr(tempraw, "<SCRIPT") != 0) && (strstr(tempraw, "</SCRIPT") == 0)) + break; + +/////////////////////////////////////// + + // ///////// + + if (((strstr(tempraw, "<script")) != 0) || ((strstr(tempraw, "<SCRIPT")) != 0)) + { + for (counter = 0; counter < BlockLength; counter++) + { + tempraw[positionStart + counter] = ' '; + } + } + // ////////// + + if ((positionStart == 0) && (positionEnd == 0)) + break; + if (positionStart > positionEnd) + break; + + positionStart = 0; + positionEnd = 0; + } + +// //// +// 3// + while (1) + { + Sleep(1); // avoid 100% CPU + // /get start and end of block + + if (((strstr(tempraw, "<style")) != 0) || (strstr(tempraw, "<STYLE") != 0)) // does + // + // tag + // exist? + + { + if (strstr(tempraw, "<style") != 0) + stringfrompos = strstr(tempraw, "<style"); + else + stringfrompos = strstr(tempraw, "<STYLE"); + + positionStart = stringfrompos - tempraw; + } + if (((strstr(tempraw, "</style")) != 0) || (strstr(tempraw, "</STYLE") != 0)) // does + // + // tag + // exist? + + { + if (strstr(tempraw, "<style") != 0) + stringfrompos = strstr(tempraw, "</style"); + else + stringfrompos = strstr(tempraw, "</STYLE"); + + positionEnd = stringfrompos - tempraw; + } + BlockLength = (positionEnd - positionStart) + 8; + + if ((strstr(tempraw, "<style") != 0) && (strstr(tempraw, "</style") == 0)) + break; + + if ((strstr(tempraw, "<STYLE") != 0) && (strstr(tempraw, "</STYLE") == 0)) + break; + +/////////////////////////////////////// + + // ///////// + + if (((strstr(tempraw, "<style")) != 0) || ((strstr(tempraw, "<STYLE")) != 0)) + { + for (counter = 0; counter < BlockLength; counter++) + { + tempraw[positionStart + counter] = ' '; + } + } + // ////////// + + if ((positionStart == 0) && (positionEnd == 0)) + break; + if (positionStart > positionEnd) + break; + + positionStart = 0; + positionEnd = 0; + } + +// //// + + + + + // 4// + /**/ + + while (1) + { + Sleep(1); // avoid 100% CPU + // /get start and end of block + + if (strstr(tempraw, "{") != 0) // does tag exist? + + { + stringfrompos = strstr(tempraw, "{"); + positionStart = stringfrompos - tempraw; + } + if (strstr(tempraw, "}") != 0) // does tag exist? + + { + stringfrompos = strstr(tempraw, "}"); + positionEnd = stringfrompos - tempraw; + } + BlockLength = (positionEnd - positionStart) + 1; + + if ((strstr(tempraw, "}") == 0) || (strstr(tempraw, "{") == 0)) + break; + +///////////////////////////////////////// + + // ///////// + if (strstr(tempraw, "{") != 0) + { + for (counter = 0; counter < BlockLength; counter++) + { + tempraw[positionStart + counter] = ' '; + } + } + // ////////// + + if ((positionStart == 0) && (positionEnd == 0)) + break; + if (positionStart > positionEnd) + break; + + positionStart = 0; + positionEnd = 0; + } + +// /////////////////////////// + positionStart = 0; + positionEnd = 0; + + /**/ + strncpy(truncated, tempraw, strlen(truncated)); + + free(tempraw); +} + +/************************/ + +/************************/ +void EraseSymbols(char *truncated) +{ + int counter = 0; + int position = 0, recpos = 0; + char *stringfrompos; + char *tempraw; + + tempraw = malloc(MAXSIZE1); + + if (truncated) + strncpy(tempraw, truncated, MAXSIZE1); + +// ////// + + while (1) + { + Sleep(1); // avoid 100% CPU + + /**/ + counter = 0; + if ((strstr(tempraw, "&#")) != 0) + { + stringfrompos = strstr(tempraw, "&#"); + position = stringfrompos - tempraw; + // + while (1) + { + tempraw[position + counter] = ' '; + counter++; + if (counter > 20) + break; + if (tempraw[position + counter] == ' ') + break; + } + if (tempraw[position + counter] == ';') + { + tempraw[position + counter] = ' '; + } + // + } + if (recpos == position) + break; + recpos = position; + /**/ + } + +// //// + + strncpy(truncated, tempraw, strlen(truncated)); + + free(tempraw); +} + +/************************/ + +/************************/ +void NumSymbols(char *truncated) +{ + int counter = 0; + int position = 0, recpos = 0; + char *stringfrompos; + char symbol[20]; + int character; + char *tempraw; + + tempraw = malloc(MAXSIZE1); + + if (truncated) + strncpy(tempraw, truncated, MAXSIZE1); + + while (1) + { + Sleep(1); // avoid 100% CPU + + /**/ + counter = 0; + + if ((strstr(tempraw, "&#")) != 0) + { + stringfrompos = strstr(tempraw, "&#"); + position = stringfrompos - tempraw; + + // + while (1) + { + if (counter > 1) + symbol[counter - 2] = tempraw[position + counter]; + + tempraw[position + counter] = ' '; + counter++; + if (counter > 20) + break; + if ((tempraw[position + counter] == ';')) + { + symbol[counter - 2] = '\0'; + character = atoi(symbol); + + if (character > 0 && character < 256) + { + memset(&tempraw[position], character, 1); + } + break; + } + } + + if (tempraw[position + counter] == ';') + { + tempraw[position + counter] = ' '; + + } + // + } + if (recpos == position) + break; + recpos = position; + /**/ + } + +// //// + + strncpy(truncated, tempraw, strlen(truncated)); + free(tempraw); +} + +/************************/ + +/************************/ +void FastTagFilter(char *truncated) +{ + int counter = 0; + char *tempraw; + +// ////// + tempraw = malloc(MAXSIZE1); + + if (truncated) + strncpy(tempraw, truncated, MAXSIZE1); + + for (counter = 0; counter < lstrlen(tempraw); counter++) + { + if (tempraw[counter] == '<') + { + while (tempraw[counter] != '>') + { + if (counter >= lstrlen(tempraw)) + break; + tempraw[counter] = ' '; + counter++; + } + if (tempraw[counter] == '>') + tempraw[counter] = ' '; + } + } + + strncpy(truncated, tempraw, strlen(truncated)); + free(tempraw); +} +/*************************/ + +/********************/ +void RemoveInvis(char *truncated, int AmountWspcRem) +{ + int counter = 0; + int erase = 0; + int RemovalLevel = 0; + char *tempraw; + + tempraw = malloc(MAXSIZE1); + + if (truncated) + strncpy(tempraw, truncated, MAXSIZE1); + + switch (AmountWspcRem) + { + + case 1: + RemovalLevel = 80; // small + + break; + case 2: + RemovalLevel = 30; // medium + + break; + case 3: + RemovalLevel = 10; // large + + break; + default: + break; + + } + +// ////// + for (counter = 0; counter < lstrlen(tempraw); counter++) + { + + // + if (AmountWspcRem != 0 && AmountWspcRem != 4) + { + if ((tempraw[counter] == '\n') || (tempraw[counter] == ' ') || (tempraw[counter] == '\r')) + erase = erase + 1; + else + erase = 0; + + if (erase > RemovalLevel) + tempraw[counter] = ' '; + } + // + if (AmountWspcRem == 4) + { + if ((tempraw[counter] == '\n') || (tempraw[counter] == ' ') || (tempraw[counter] == '\r')) + tempraw[counter] = ' '; + } + // + + } // end for + // ////// + + strncpy(truncated, tempraw, strlen(truncated)); + free(tempraw); +} + +/******************/ + +/******************/ +void RemoveTabs(char *truncated) +{ + int counter = 0; + char *tempraw; + + tempraw = malloc(MAXSIZE1); + + if (truncated) + strncpy(tempraw, truncated, MAXSIZE1); + + for (counter = 0; counter < lstrlen(tempraw); counter++) + { + + if (tempraw[counter] == '\t') + tempraw[counter] = ' '; + + } // end for + + strncpy(truncated, tempraw, strlen(truncated)); + + free(tempraw); +} + +/******************/ + +/********************/ +void Removewhitespace(char *truncated) +{ + int counter = 0; + int counter2 = 0; + int pos1 = 0, pos2 = 0; + + for (counter = 0; counter < lstrlen(truncated); counter++) + { + if (truncated[counter] == ' ' && truncated[counter + 1] == ' ') + { + pos1 = counter + 1; + counter2 = counter; + + while (truncated[counter2] == ' ') + { + counter2++; + } + + pos2 = counter2; + strncpy(&truncated[pos1], &truncated[pos2], strlen(&truncated[pos1]) - 1); + + } // end if + + } // end for + +} + +/******************/ + +/********************/ +void Filter(char *truncated) +{ + int counter = 0; + char tempraw[MAXSIZE1]; + + strncpy(tempraw, truncated, sizeof(tempraw)); + + for (counter = 0; counter < lstrlen(tempraw); counter++) + { + + if ((tempraw[counter] == '\n') || (tempraw[counter] == '\r') || (tempraw[counter] == '\t')) + { + strncpy(&tempraw[counter], &tempraw[counter + 1], strlen(&tempraw[counter]) - 1); + } + } // end for + + strncpy(truncated, tempraw, strlen(truncated)); + +} + +/******************/ diff --git a/plugins/!NotAdopted/WebView/webview_common.h b/plugins/!NotAdopted/WebView/webview_common.h new file mode 100644 index 0000000000..82e10eab79 --- /dev/null +++ b/plugins/!NotAdopted/WebView/webview_common.h @@ -0,0 +1,248 @@ +/* __try/__finally taken from abiword patch found on the web */ +#if 0 + #include <crtdbg.h> +#else +#define __try +#define __except(x) if (0) /* don't execute handler */ +#define __finally + +#define _try __try +#define _except __except +#define _finally __finally +#endif + + + +#include <windows.h> +#include <process.h> +#include <string.h> +#include <ctype.h> +#include <io.h> +#include <time.h> +#include <locale.h> +#include <wchar.h> +#include <tchar.h> +#include <Richedit.h> +#include <Commctrl.h> +#include <dirent.h> +#include "../include/newpluginapi.h" +#include "../include/m_system.h" +//#include "../include/m_netlib.h" +#include "../include/m_clist.h" +#include "../include/m_clui.h" +#include "../include/m_database.h" +#include "../include/m_protomod.h" +#include "../include/m_protocols.h" +#include "../include/m_protosvc.h" +#include "../include/m_button.h" +#include "../include/m_utils.h" +#include "../include/m_skin.h" +#include "../include/m_genmenu.h" +#include "../include/m_icolib.h" + + + +#define MIRANDA_CUSTOM_LP + + + + + +#include "../include/m_netlib.h" +#include "../include/m_langpack.h" +#include "../include/m_findadd.h" + +// leave here as reference +/* +#define UNICODE_VERISON +#define UNICODE +#define _UNICODE +*/ +#include "resource.h" + + +//extern unsigned lpcp; + + + +#define CFM_BACKCOLOR 0x04000000 + +#define MENU_OFF "DisableMenu" +#define REFRESH_KEY "Refresh interval" +#define ON_TOP_KEY "Always on top" +#define OFFLINE_STATUS "OfflineOnBoot" +#define URL_KEY "URL" +#define START_STRING_KEY "Start_string" +#define END_STRING_KEY "End_String" +#define DBLE_WIN_KEY "Doub_click_win" +#define HIDE_STATUS_ICON_KEY "Hide_Status_Icon" +#define HAS_CRASHED_KEY "Has_Crashed" +#define U_ALLSITE_KEY "UseAllTheWebsite" +#define MENU_IS_DISABLED_KEY "MainMenuReallyDisabled" +#define UPDATE_ONALERT_KEY "WND_UPDATE_OALERY_ONLY" +#define DISABLE_AUTOUPDATE_KEY "Disable_Auto_Update" +#define RWSPACE_KEY "level_of_wspace_removal" +#define PRESERVE_NAME_KEY "PreserveName" +#define CLEAR_DISPLAY_KEY "Remove_tags_whitespace" +#define ALRT_S_STRING_KEY "ALRT_S_STRING" +#define ALRT_E_STRING_KEY "ALRT_E_STRING" +#define ALRT_INDEX_KEY "AlertIndex" +#define EVNT_INDEX_KEY "EventIndex" +#define START_DELAY_KEY "StartUpDelay" +#define ALWAYS_LOG_KEY "AlwaysLogToFile" +#define SAVE_INDIVID_POS_KEY "SaveIndividWinPos" +#define NO_PROTECT_KEY "NoDownloadProtection" +#define SAVE_AS_RAW_KEY "SaveAsRaw" +#define FONT_SCRIPT_KEY "FontScript" +#define STOP_KEY "StopProcessing" +#define DATA_POPUP_KEY "DisplayDataPopup" +#define COUNTDOWN_KEY "Countdown" + +#define MINUTE 60000 +#define SECOND 1000 +#define MONITOR_DEFAULTTONEAREST 2 + +#define MS_UPDATE_ALL "Webview/UpdateAll" +#define MS_ADD_SITE "Webview/AddSite" +#define MS_AUTO_UPDATE "Webview/AutoUpdate" + +#define CACHE_FILE_KEY "Filename" + + +/* + * some globals for window settings + */ +DWORD Xposition; +DWORD Yposition; +DWORD BackgoundClr; +DWORD TextClr; +DWORD WindowHeight; +DWORD WindowWidth; + +UINT_PTR timerId; +UINT_PTR Countdown; +LOGFONT lf; +HFONT h_font; +HWND ContactHwnd; +HINSTANCE hInst; +HMENU hMenu; +char *DLLNAME; +int bpStatus; +CLISTMENUITEM mi; +HANDLE hMenuItem1; +HANDLE hMenuItemCountdown; +char optionsname[80]; + +struct FORK_ARG +{ + HANDLE hEvent; + void (__cdecl * threadcode) (void *); + unsigned (__stdcall * threadcodeex) (void *); + void *arg; +}; + +//lets get rid of some warnings +void timerfunc(void); +void Countdownfunc(void); +void SavewinSettings(void); +void ValidatePosition(HWND hwndDlg); +void CheckDbKeys(void); +void __cdecl forkthread_r(void *param); +unsigned long forkthread(void (__cdecl * threadcode) (void *), unsigned long stacksize, void *arg); +int WebsiteMenuCommand(WPARAM wParam, LPARAM lParam); +int UpdateMenuCommand(WPARAM wParam, LPARAM lParam, HANDLE singlecontact); +int OnTopMenuCommand(WPARAM wParam, LPARAM lParam, HANDLE singlecontact); +int AddContactMenuCommand(WPARAM wParam, LPARAM lParam); +int ContactOptionsMenuCommand(WPARAM wParam, LPARAM lParam); +int CntOptionsMenuCommand(WPARAM wParam, LPARAM lParam); +int CntAlertMenuCommand(WPARAM wParam, LPARAM lParam); +int ModulesLoaded(WPARAM wParam, LPARAM lParam); +void ChangeMenuItem3(); +int ContactMenuItemUpdateData (WPARAM wParam, LPARAM lParam); +int MarkAllReadMenuCommand(WPARAM wParam, LPARAM lParam); + + +// +int ShowHideContactCommand(WPARAM wParam, LPARAM lParam); + +// +int Doubleclick(WPARAM wParam, LPARAM lParam); +int DataWndMenuCommand(WPARAM wParam, LPARAM lParam); +//int SendToRichEdit(HWND hWindow, char *truncated, COLORREF rgbText, COLORREF rgbBack); +int SendToRichEdit(HWND hWindow, TCHAR *truncated, COLORREF rgbText, COLORREF rgbBack); +int UpdateAllMenuCommand(WPARAM wParam, LPARAM lParam); +int CountdownMenuCommand(WPARAM wParam, LPARAM lParam); + +//Services +int GetCaps(WPARAM wParam, LPARAM lParam); +int GetName(WPARAM wParam, LPARAM lParam); +int BPLoadIcon(WPARAM wParam, LPARAM lParam); // BPLoadIcon + + // because LoadIcon + // wont work.. + +int SetStatus(WPARAM wParam, LPARAM lParam); +int GetStatus(WPARAM wParam, LPARAM lParam); + +// +void ChangeContactStatus(int con_stat); +void InitialiseGlobals(void); +void FontSettings(void); + +/// + +void Removewhitespace(char *truncated); +void RemoveInvis(char *truncated, int AmountWspcRem); +void RemoveTabs(char *truncated); +void FastTagFilter(char *truncated); +void EraseBlock(char *truncated); +void EraseSymbols(char *truncated); +int ProcessAlerts(HANDLE AContact, char *truncated, char *tstr, char *contactname, int notpresent); + +BOOL CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam); +BOOL CALLBACK DlgProcFind(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); +int DataDialogResize(HWND hwndDlg, LPARAM lParam, UTILRESIZECONTROL * urc); + +void Filter(char *truncated); +void TxtclrLoop(); +void BGclrLoop(); +void ContactLoop(void *dummy); +void NumSymbols(char *truncated); + +int AutoUpdateMCmd(WPARAM wParam, LPARAM lParam); +BOOL CALLBACK DlgProcContactOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); +void AckFunc(void *dummy); +int SiteDeleted(WPARAM wParam, LPARAM lParam); + + + +int WErrorPopup(char *namecontact, char *textdisplay); +void DestroyServices(void); + + + +////////////////////// +// wrappers +HANDLE hHookDisplayDataAlert; + +#define ME_DISPLAYDATA_ALERT "Miranda/ALERT/DISPLAYDATA" + +HANDLE hHookAlertPopup; + +#define ME_POPUP_ALERT "Miranda/ALERT/POPUP" + +HANDLE hHookAlertWPopup; + +#define ME_WPOPUP_ALERT "Miranda/ALERT/WPOPUP" + +HANDLE hHookErrorPopup; + +#define ME_POPUP_ERROR "Miranda/ERROR/POPUP" + +HANDLE hHookAlertOSD; + +#define ME_OSD_ALERT "Miranda/ALERT/OSD" +//////////// + +//test +//int utf8_encode(const char *from, char **to); diff --git a/plugins/!NotAdopted/WebView/webview_datawnd.c b/plugins/!NotAdopted/WebView/webview_datawnd.c new file mode 100644 index 0000000000..3f607e3014 --- /dev/null +++ b/plugins/!NotAdopted/WebView/webview_datawnd.c @@ -0,0 +1,997 @@ +/* + * A plugin for Miranda IM which displays web page text in a window Copyright + * (C) 2005 Vincent Joyce. + * + * Miranda IM: the free icq client for MS Windows Copyright (C) 2000-2 + * Richard Hughes, Roland Rabien & Tristan Van de Vreede + * + * 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. + */ + +/*************/ +BOOL CALLBACK DlgProcFind(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + HWND ParentHwnd; + static char Searchstr[128]; + static int loc; + static int oldloc; + static int startposition; + static int OLDstartposition; + + ParentHwnd = GetParent(hwndDlg); + + switch (msg) + { + case WM_INITDIALOG: + { + TranslateDialogDefault(hwndDlg); + SetWindowLong(hwndDlg, GWL_USERDATA, lParam); + + SetWindowText(hwndDlg, Translate("Find")); + + SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon(hInst, MAKEINTRESOURCE(IDI_FIND))); + + return TRUE; + } + break; + + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDC_OK: // find Next + + { + char NewSearchstr[128]; + char *tempbuffer; + int len; + int location = 0; + int startsel = 0, endsel = 0; + char buff[MAXSIZE1]; + + ZeroMemory(&NewSearchstr, sizeof(NewSearchstr)); + + len = GetWindowTextLength(GetDlgItem(ParentHwnd, IDC_DATA)); + + tempbuffer = malloc(len + 2); + + GetWindowText(GetDlgItem(ParentHwnd, IDC_DATA), tempbuffer, len); + strncpy(buff, tempbuffer, sizeof(buff)); + free(tempbuffer); + + Filter(buff); + CharUpperBuff(buff, lstrlen(buff)); + + GetDlgItemText(hwndDlg, IDC_FINDWHAT, NewSearchstr, sizeof(NewSearchstr)); + CharUpperBuff(NewSearchstr, lstrlen(NewSearchstr)); + + OLDstartposition = startposition; + + if ((strstr(Searchstr, NewSearchstr)) != 0) + { + startposition = loc + strlen(Searchstr); + } else + { + oldloc = 0; + startposition = 0; + } + + strcpy(Searchstr, NewSearchstr); + // + + /**/ + if (!(startposition > strlen(buff))) + location = (strstr(buff + startposition, NewSearchstr)) - buff; + /**/ + + oldloc = loc; + loc = location; + + if (loc == 0) + { + ShowWindow(GetDlgItem(hwndDlg, IDC_SEARCH_COMPLETE), SW_SHOW); + loc = (strstr(buff, NewSearchstr)) - buff; + startsel = loc; + endsel = loc + strlen(NewSearchstr); + oldloc = 0; + startposition = 0; + } else + { + ShowWindow(GetDlgItem(hwndDlg, IDC_SEARCH_COMPLETE), SW_HIDE); + startsel = loc; + endsel = loc + strlen(NewSearchstr); + } + + CHARRANGE sel2 = {startsel, endsel}; + + // + SendMessage(GetDlgItem(ParentHwnd, IDC_DATA), EM_EXSETSEL, 0, (LPARAM) & sel2); + SetFocus(GetDlgItem(ParentHwnd, IDC_DATA)); + // + + return TRUE; + } + case WM_DESTROY: + case IDC_CANCEL: + { + EnableWindow(GetDlgItem(ParentHwnd, IDC_FIND_BUTTON), 1); + EnableWindow(ParentHwnd, 1); + DestroyWindow(hwndDlg); + } + break; + + } + break; + } + return FALSE; +} + +/**************/ + +/*******************************/ +BOOL CALLBACK DlgProcDisplayData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + DBVARIANT dbv; + DBVARIANT dbv2; + DBVARIANT dbv3; + RECT rc; + char url[300]; + + switch (msg) + { + case WM_INITDIALOG: + { + TranslateDialogDefault(hwndDlg); + + // + + HANDLE hContact2 = (HANDLE) lParam; + + SetWindowLong(hwndDlg, GWL_USERDATA, (LONG) hContact2); + WindowList_Add(hWindowList, hwndDlg, hContact2); + // // + url[0] = '\0'; + DBGetContactSetting(hContact2, DLLNAME, URL_KEY, &dbv); + _snprintf(url, sizeof(url), "%s", dbv.pszVal); + DBFreeVariant(&dbv); + // // + char buttontext[256]; + char stringbefore[256]; + char *stringafter; + char newbuttontext[256]; + int pos = 0; + int posafter = 0; + int posbefore = 0; + + ZeroMemory(&buttontext, sizeof(buttontext)); + ZeroMemory(&newbuttontext, sizeof(newbuttontext)); + _snprintf(buttontext, sizeof(buttontext), "%s", url); + _snprintf(newbuttontext, sizeof(newbuttontext), "%s", url); + + if ((strstr(newbuttontext, "&")) != 0) + { + while (1) + { + + ZeroMemory(&stringbefore, sizeof(stringbefore)); + + if ((strstr(newbuttontext, "&")) == 0) + break; + + _snprintf(buttontext, sizeof(buttontext), "%s", newbuttontext); + stringafter = strstr(buttontext, "&"); + pos = (stringafter - buttontext); + posbefore = (stringafter - buttontext) - 1; + posafter = (stringafter - buttontext) + 1; + strncpy(&stringafter[0], &stringafter[1], strlen(stringafter)); + _snprintf(stringbefore, pos, "%s", buttontext); + _snprintf(newbuttontext, sizeof(buttontext), "%s%s%s", stringbefore, "!!", stringafter); + + posafter = 0; + posbefore = 0; + } + + while (1) + { + if ((strstr(newbuttontext, "!")) != 0) + { + stringafter = strstr(newbuttontext, "!"); + pos = (stringafter - newbuttontext); + newbuttontext[pos] = '&'; + } + if ((strstr(newbuttontext, "!")) == 0) + break; + + } + } + SetDlgItemText(hwndDlg, IDC_OPEN_URL, newbuttontext); + //SetDlgItemText(hwndDlg, IDC_HIDDEN_URL, url); + // // + // + char preservename[100]; + + ZeroMemory(&preservename, sizeof(preservename)); + + DBGetContactSetting(hContact2, DLLNAME, PRESERVE_NAME_KEY, &dbv); + _snprintf(preservename, sizeof(preservename), "%s", dbv.pszVal); + DBFreeVariant(&dbv); + + SetWindowText(hwndDlg, preservename); + // + SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon(hInst, MAKEINTRESOURCE(IDI_SITE))); + + // ////// + COLORREF colour; + COLORREF txtcolor; + + colour = BackgoundClr; + SendDlgItemMessage(hwndDlg, IDC_DATA, EM_SETBKGNDCOLOR, 0, colour); + // ///// + + // // + SendDlgItemMessage(hwndDlg, IDC_UPDATE_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_UPDATE), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0))); + SendMessage(GetDlgItem(hwndDlg, IDC_UPDATE_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Update Data"), 0); + + SendDlgItemMessage(hwndDlg, IDC_FIND_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_FIND), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0))); + SendMessage(GetDlgItem(hwndDlg, IDC_FIND_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Find"), 0); + + SendDlgItemMessage(hwndDlg, IDC_OPTIONS_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_OPTIONS), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0))); + SendMessage(GetDlgItem(hwndDlg, IDC_OPTIONS_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Contact Options"), 0); + + SendDlgItemMessage(hwndDlg, IDC_ALERT_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_ALERT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0))); + SendMessage(GetDlgItem(hwndDlg, IDC_ALERT_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Alert Options"), 0); + + SendDlgItemMessage(hwndDlg, IDC_STOP, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_STOP), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0))); + SendMessage(GetDlgItem(hwndDlg, IDC_STOP), BUTTONADDTOOLTIP, (WPARAM) Translate("Stop Processing"), 0); + // /// + SendMessage(GetDlgItem(hwndDlg, IDC_OPEN_URL), BUTTONADDTOOLTIP, (WPARAM) Translate("Click here to open this URL in a browser window."), 0); + // /// + + if (!(DBGetContactSettingByte(hContact2, DLLNAME, ON_TOP_KEY, 0))) + {// + SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_UNSTICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0))); + SendMessage(GetDlgItem(hwndDlg, IDC_STICK_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Stick to the front"), 0); + } + if (DBGetContactSettingByte(hContact2, DLLNAME, ON_TOP_KEY, 0)) + { + SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0))); + SendMessage(GetDlgItem(hwndDlg, IDC_STICK_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Disable Stick to the Front"), 0); + } + // // + + SendMessage(GetDlgItem(hwndDlg, IDC_DATA), WM_SETFONT, (WPARAM) h_font, 1); + + txtcolor = TextClr; + + SetDlgItemText(hwndDlg, IDC_DATA, ""); + + InvalidateRect(hwndDlg, NULL, 1); + + // + + // / + SendMessage(GetDlgItem(hwndDlg, IDC_DATA), EM_AUTOURLDETECT, 1, 0); + int mask = (int) SendMessage(GetDlgItem(hwndDlg, IDC_DATA), EM_GETEVENTMASK, 0, 0); + + SendMessage(GetDlgItem(hwndDlg, IDC_DATA), EM_SETEVENTMASK, 0, mask | ENM_LINK | ENM_MOUSEEVENTS); + + // / + SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BUTTONSETASFLATBTN, 0, 0); + SendDlgItemMessage(hwndDlg, IDC_UPDATE_BUTTON, BUTTONSETASFLATBTN, 0, 0); + SendDlgItemMessage(hwndDlg, IDC_FIND_BUTTON, BUTTONSETASFLATBTN, 0, 0); + SendDlgItemMessage(hwndDlg, IDC_OPTIONS_BUTTON, BUTTONSETASFLATBTN, 0, 0); + SendDlgItemMessage(hwndDlg, IDC_ALERT_BUTTON, BUTTONSETASFLATBTN, 0, 0); + SendDlgItemMessage(hwndDlg, IDC_STOP, BUTTONSETASFLATBTN, 0, 0); + // + SendDlgItemMessage(hwndDlg, IDC_OPEN_URL, BUTTONSETASFLATBTN, 0, 0); + // + + { + int partWidth[2]; + SIZE textSize; + HDC hdc; + + hdc = GetDC(GetDlgItem(hwndDlg, IDC_STATUSBAR)); + SelectObject(hdc, (HFONT) SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, WM_GETFONT, 0, 0)); + GetTextExtentPoint32(hdc, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", lstrlen("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"), &textSize); + partWidth[0] = textSize.cx; + ReleaseDC(GetDlgItem(hwndDlg, IDC_STATUSBAR), hdc); + partWidth[1] = -1; + SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, SB_SETPARTS, sizeof(partWidth) / sizeof(partWidth[0]), (LPARAM) partWidth); + SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, SB_SETTEXT, 1 | SBT_OWNERDRAW, 0); + + } + // + + if ((DBGetContactSettingByte(NULL, DLLNAME, SAVE_INDIVID_POS_KEY, 0))) + Utils_RestoreWindowPosition(hwndDlg, hContact2, DLLNAME, "WV"); + } + break; + + // ////////// + + case WM_NOTIFY: + switch (((NMHDR *) lParam)->code) + { + + // + case EN_MSGFILTER: + switch (((MSGFILTER *) lParam)->msg) + { + case WM_RBUTTONUP: + { + HMENU hSubMenu; + POINT pt; + CHARRANGE sel, all = {0, -1}; + + hSubMenu = GetSubMenu(hMenu, 0); + CallService(MS_LANGPACK_TRANSLATEMENU, (WPARAM) hSubMenu, 0); + SendMessage(((NMHDR *) lParam)->hwndFrom, EM_EXGETSEL, 0, (LPARAM) & sel); + + EnableMenuItem(hSubMenu, IDM_COPY, MF_ENABLED); + EnableMenuItem(hSubMenu, IDM_CUT, MF_ENABLED); + EnableMenuItem(hSubMenu, IDM_DELETE, MF_ENABLED); + + if (sel.cpMin == sel.cpMax) + { + EnableMenuItem(hSubMenu, IDM_COPY, MF_BYCOMMAND | MF_GRAYED); + EnableMenuItem(hSubMenu, IDM_CUT, MF_BYCOMMAND | MF_GRAYED); + EnableMenuItem(hSubMenu, IDM_DELETE, MF_BYCOMMAND | MF_GRAYED); + } + pt.x = (short) LOWORD(((ENLINK *) lParam)->lParam); + pt.y = (short) HIWORD(((ENLINK *) lParam)->lParam); + ClientToScreen(((NMHDR *) lParam)->hwndFrom, &pt); + switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL)) + { + case IDM_COPY: + { + SendMessage(((NMHDR *) lParam)->hwndFrom, WM_COPY, 0, 0); + } + break; + case IDM_COPYALL: + { + SendMessage(((NMHDR *) lParam)->hwndFrom, EM_EXSETSEL, 0, (LPARAM) & all); + SendMessage(((NMHDR *) lParam)->hwndFrom, WM_COPY, 0, 0); + SendMessage(((NMHDR *) lParam)->hwndFrom, EM_EXSETSEL, 0, (LPARAM) & sel); + } + break; + case IDM_SELECTALL: + { + SendMessage(((NMHDR *) lParam)->hwndFrom, EM_EXSETSEL, 0, (LPARAM) & all); + } + break; + case IDM_CUT: + { + SendMessage(((NMHDR *) lParam)->hwndFrom, WM_CUT, 0, 0); + } + break; + + case IDM_PASTE: + { + SendMessage(((NMHDR *) lParam)->hwndFrom, WM_PASTE, 0, 0); + } + break; + case IDM_DELETE: + { + SendMessage(((NMHDR *) lParam)->hwndFrom, WM_CLEAR, 0, 0); + } + break; + case IDM_CLEAR_ALL: + { + SetDlgItemText(hwndDlg, IDC_DATA, ""); + SetFocus(GetDlgItem(hwndDlg, IDC_DATA)); + } + break; + } + } + } + break; + + // + case EN_LINK: + + switch (((ENLINK *) lParam)->msg) + { + case WM_RBUTTONDOWN: + case WM_LBUTTONUP: + { + TEXTRANGE tr; + CHARRANGE sel; + + SendDlgItemMessage(hwndDlg, IDC_DATA, EM_EXGETSEL, 0, (LPARAM) & sel); + if (sel.cpMin != sel.cpMax) + break; + tr.chrg = ((ENLINK *) lParam)->chrg; + + tr.lpstrText = malloc(tr.chrg.cpMax - tr.chrg.cpMin + 8); + + SendDlgItemMessage(hwndDlg, IDC_DATA, EM_GETTEXTRANGE, 0, (LPARAM) & tr); + +/* +#ifdef UNICODE_VERISON + if (wcschr(tr.lpstrText, '@') != NULL && wcschr(tr.lpstrText, ':') == NULL && wcschr(tr.lpstrText, '/') == NULL) + { + MoveMemory(tr.lpstrText + 7, tr.lpstrText, tr.chrg.cpMax - tr.chrg.cpMin + 1); + CopyMemory(tr.lpstrText, "mailto:", 7); + } +#endif +*/ + +//#ifndef UNICODE_VERISON + if (strchr(tr.lpstrText, '@') != NULL && strchr(tr.lpstrText, ':') == NULL && strchr(tr.lpstrText, '/') == NULL) + { + MoveMemory(tr.lpstrText + 7, tr.lpstrText, tr.chrg.cpMax - tr.chrg.cpMin + 1); + CopyMemory(tr.lpstrText, "mailto:", 7); + } +//#endif + + CallService(MS_UTILS_OPENURL, 1, (LPARAM) tr.lpstrText); + SetFocus(GetDlgItem(hwndDlg, IDC_DATA)); + + free(tr.lpstrText); + break; + } + } + break; + + } + break; // notify + + // /////////// + + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDC_OPEN_URL: + { + + + ZeroMemory(&url, sizeof(url)); + GetDlgItemText(hwndDlg, IDC_OPEN_URL, url, sizeof(url)); + CallService(MS_UTILS_OPENURL, 1, (LPARAM) url); + DBWriteContactSettingWord((HANDLE) wParam, DLLNAME, "Status", ID_STATUS_ONLINE); + + } + break; + + case IDC_UPDATE_BUTTON: + { + HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + char *szProto; + char urltext[300]; + char titlebartxt[300]; + int contactcount = 0; + + ZeroMemory(&urltext, sizeof(urltext)); + ZeroMemory(&titlebartxt, sizeof(titlebartxt)); + + //GetDlgItemText(hwndDlg, IDC_HIDDEN_URL, urltext, sizeof(urltext)); + GetDlgItemText(hwndDlg, IDC_OPEN_URL, urltext, sizeof(urltext)); + GetWindowText(hwndDlg, titlebartxt, sizeof(titlebartxt)); + + while (hContact != NULL) + { + szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + if (szProto != NULL && !lstrcmp(DLLNAME, szProto)) + { + DBGetContactSetting(hContact, DLLNAME, URL_KEY, &dbv); + DBGetContactSetting(hContact, DLLNAME, PRESERVE_NAME_KEY, &dbv2); + + if ((!lstrcmp(urltext, dbv.pszVal)) && (!lstrcmp(titlebartxt, dbv2.pszVal))) + { + contactcount++; + if (contactcount > 1) + { + MessageBox(NULL, Translate("ERROR: You have two or more Webview contacts with the same URL and contact name."), DLLNAME, MB_OK); + break; + } + EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE_BUTTON), 0); + UpdateMenuCommand(wParam, lParam, hContact); + } + DBFreeVariant(&dbv); + DBFreeVariant(&dbv2); + } + hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0); + } + } + break; + + + + case IDC_STOP: + { + HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + char *szProto; + char urltext[300]; + char titlebartxt[300]; + int contactcount = 0; + + ZeroMemory(&urltext, sizeof(urltext)); + ZeroMemory(&titlebartxt, sizeof(titlebartxt)); + + //GetDlgItemText(hwndDlg, IDC_HIDDEN_URL, urltext, sizeof(urltext)); + GetDlgItemText(hwndDlg, IDC_OPEN_URL, urltext, sizeof(urltext)); + GetWindowText(hwndDlg, titlebartxt, sizeof(titlebartxt)); + + while (hContact != NULL) + { + szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + if (szProto != NULL && !lstrcmp(DLLNAME, szProto)) + { + DBGetContactSetting(hContact, DLLNAME, URL_KEY, &dbv); + DBGetContactSetting(hContact, DLLNAME, PRESERVE_NAME_KEY, &dbv2); + + if ((!lstrcmp(urltext, dbv.pszVal)) && (!lstrcmp(titlebartxt, dbv2.pszVal))) + { + contactcount++; + if (contactcount > 1) + { + MessageBox(NULL, Translate("ERROR: You have two or more Webview contacts with the same URL and contact name."), DLLNAME, MB_OK); + break; + } + DBWriteContactSettingByte(hContact, DLLNAME, STOP_KEY, 1); + } + DBFreeVariant(&dbv); + DBFreeVariant(&dbv2); + } + hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0); + } + } + break; + + + + case IDC_STICK_BUTTON: + { + +// ///////// + + HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + char *szProto; + char urltext2[300]; + char titlebartxt[300]; + int contactcount = 0; + + ZeroMemory(&urltext2, sizeof(urltext2)); + ZeroMemory(&titlebartxt, sizeof(titlebartxt)); + + //GetDlgItemText(hwndDlg, IDC_HIDDEN_URL, urltext2, sizeof(urltext2)); + GetDlgItemText(hwndDlg, IDC_OPEN_URL, urltext2, sizeof(urltext2)); + GetWindowText(hwndDlg, titlebartxt, sizeof(titlebartxt)); + + while (hContact != NULL) + { + szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + if (szProto != NULL && !lstrcmp(DLLNAME, szProto)) + { + DBGetContactSetting(hContact, DLLNAME, URL_KEY, &dbv); + DBGetContactSetting(hContact, DLLNAME, PRESERVE_NAME_KEY, &dbv2); + + if ((!lstrcmp(urltext2, dbv.pszVal)) && (!lstrcmp(titlebartxt, dbv2.pszVal))) + { + contactcount++; + if (contactcount > 1) + { + MessageBox(NULL, Translate("ERROR: You have two or more Webview contacts with the same URL and contact name."), DLLNAME, MB_OK); + break; + } + OnTopMenuCommand(wParam, lParam, hContact); + DBFreeVariant(&dbv); + break; + } + DBFreeVariant(&dbv); + DBFreeVariant(&dbv2); + } + hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0); + } + // + +// //////// + + if (!(DBGetContactSettingByte(hContact, DLLNAME, ON_TOP_KEY, 0))) + {// + SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_UNSTICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0))); + SendMessage(GetDlgItem(hwndDlg, IDC_STICK_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Stick to the front"), 0); + if ((DBGetContactSettingByte(NULL, DLLNAME, SAVE_INDIVID_POS_KEY, 0))) + { + + SetWindowPos( + hwndDlg, + HWND_NOTOPMOST, + 0, // Xposition, + 0, // Yposition, + 0, // WindowWidth, + 0, // WindowHeight, + SWP_NOSIZE | SWP_NOMOVE); + } else + { + + SetWindowPos( + hwndDlg, + HWND_NOTOPMOST, + 0, + 0, + 0, + 0, + SWP_NOSIZE | SWP_NOMOVE); + } + + } + if (DBGetContactSettingByte(hContact, DLLNAME, ON_TOP_KEY, 0)) + { + SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0))); + SendMessage(GetDlgItem(hwndDlg, IDC_STICK_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Disable Stick to the front"), 0); + + if ((DBGetContactSettingByte(NULL, DLLNAME, SAVE_INDIVID_POS_KEY, 0))) + { + SetWindowPos( + hwndDlg, + HWND_TOPMOST, + 0, // Xposition, + 0, // Yposition, + 0, // WindowWidth, + 0, // WindowHeight, + SWP_NOSIZE | SWP_NOMOVE); + } else + { + SetWindowPos( + hwndDlg, + HWND_TOPMOST, + 0, + 0, + 0, + 0, + SWP_NOSIZE | SWP_NOMOVE); + + } + + } + DBFreeVariant(&dbv); + } + break; + + // // + case IDC_FIND_BUTTON: + { + HWND hwndFind; + + hwndFind = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FIND), hwndDlg, DlgProcFind, (LPARAM) (HANDLE) wParam); + ShowWindow(hwndFind, SW_SHOW); + EnableWindow(GetDlgItem(hwndDlg, IDC_FIND_BUTTON), 0); + } + break; + + case IDC_OPTIONS_BUTTON: + { + HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + char *szProto; + char urltext[300]; + char titlebartxt[300]; + int contactcount = 0; + + // + ZeroMemory(&urltext, sizeof(urltext)); + ZeroMemory(&titlebartxt, sizeof(titlebartxt)); + + //GetDlgItemText(hwndDlg, IDC_HIDDEN_URL, urltext, sizeof(urltext)); + GetDlgItemText(hwndDlg, IDC_OPEN_URL, urltext, sizeof(urltext)); + GetWindowText(hwndDlg, titlebartxt, sizeof(titlebartxt)); + + while (hContact != NULL) + { + szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + if (szProto != NULL && !lstrcmp(DLLNAME, szProto)) + { + DBGetContactSetting(hContact, DLLNAME, URL_KEY, &dbv); + DBGetContactSetting(hContact, DLLNAME, PRESERVE_NAME_KEY, &dbv2); + + if ((!lstrcmp(urltext, dbv.pszVal)) && (!lstrcmp(titlebartxt, dbv2.pszVal))) + { + contactcount++; + if (contactcount > 1) + { + MessageBox(NULL, Translate("ERROR: You have two or more Webview contacts with the same URL and contact name."), DLLNAME, MB_OK); + break; + } + ContactHwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CONTACT_OPT), hwndDlg, DlgProcContactOpt, (LPARAM) (HANDLE) hContact); + ShowWindow(ContactHwnd, SW_SHOW); + SetActiveWindow(ContactHwnd); + EnableWindow(GetDlgItem(hwndDlg, IDC_OPTIONS_BUTTON), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_BUTTON), 0); + + } + DBFreeVariant(&dbv); + DBFreeVariant(&dbv2); + + } + hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0); + } + + // + } + break; + + // /// + case IDC_ALERT_BUTTON: + { + HWND hwndAlertOpt; + HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + char *szProto; + char urltext[300]; + char titlebartxt[300]; + int contactcount = 0; + + // + ZeroMemory(&urltext, sizeof(urltext)); + ZeroMemory(&titlebartxt, sizeof(titlebartxt)); + + //GetDlgItemText(hwndDlg, IDC_HIDDEN_URL, urltext, sizeof(urltext)); + GetDlgItemText(hwndDlg, IDC_OPEN_URL, urltext, sizeof(urltext)); + GetWindowText(hwndDlg, titlebartxt, sizeof(titlebartxt)); + + while (hContact != NULL) + { + szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + if (szProto != NULL && !lstrcmp(DLLNAME, szProto)) + { + DBGetContactSetting(hContact, DLLNAME, URL_KEY, &dbv); + DBGetContactSetting(hContact, DLLNAME, PRESERVE_NAME_KEY, &dbv2); + + if ((!lstrcmp(urltext, dbv.pszVal)) && (!lstrcmp(titlebartxt, dbv2.pszVal))) + { + contactcount++; + if (contactcount > 1) + { + MessageBox(NULL, Translate("ERROR: You have two or more Webview contacts with the same URL and contact name."), DLLNAME, MB_OK); + break; + } + hwndAlertOpt = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ALRT_OPT), hwndDlg, DlgProcAlertOpt, (LPARAM) (HANDLE) hContact); + ShowWindow(hwndAlertOpt, SW_SHOW); + SetActiveWindow(hwndAlertOpt); + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_BUTTON), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_OPTIONS_BUTTON), 0); + + } + DBFreeVariant(&dbv); + DBFreeVariant(&dbv2); + } + hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0); + } + + } + break; + + case IDOK: + case IDCANCEL: + if (hwndDlg != NULL) + DestroyWindow(hwndDlg); + return TRUE; + } + break; + + break; + + case WM_CLOSE: + { + // + HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + char *szProto; + char urltext[300]; + char titlebartxt[300]; + int contactcount = 0; + + if (Yposition == -32000) + Yposition = 100; + + if (Xposition == -32000) + Xposition = 100; + + SavewinSettings(); + + /**/ + // + ZeroMemory(&urltext, sizeof(urltext)); + ZeroMemory(&titlebartxt, sizeof(titlebartxt)); + + //GetDlgItemText(hwndDlg, IDC_HIDDEN_URL, urltext, sizeof(urltext)); + GetDlgItemText(hwndDlg, IDC_OPEN_URL, urltext, sizeof(urltext)); + GetWindowText(hwndDlg, titlebartxt, sizeof(titlebartxt)); + + while (hContact != NULL) + { + szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + if (szProto != NULL && !lstrcmp(DLLNAME, szProto)) + { + DBGetContactSetting(hContact, DLLNAME, URL_KEY, &dbv); + DBGetContactSetting(hContact, DLLNAME, PRESERVE_NAME_KEY, &dbv2); + + if ((!lstrcmp(urltext, dbv.pszVal)) && (!lstrcmp(titlebartxt, dbv2.pszVal))) + { + contactcount++; + if (contactcount > 1) + break; + + // + Utils_SaveWindowPosition(hwndDlg, hContact, DLLNAME, "WV"); + + // + + } + DBFreeVariant(&dbv); + DBFreeVariant(&dbv2); + + } + hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0); + } + + /**/ + + if (hwndDlg != NULL) + DestroyWindow(hwndDlg); + return 0; + break; + } + + case WM_DESTROY: + { + WindowList_Remove(hWindowList, hwndDlg); + return 0; + break; + } + + case WM_SIZE: + { + UTILRESIZEDIALOG urd = {0}; + + urd.cbSize = sizeof(urd); + urd.hInstance = hInst; + urd.hwndDlg = hwndDlg; + urd.lParam = 0; + urd.lpTemplate = MAKEINTRESOURCE(IDD_DISPLAY_DATA); + urd.pfnResizer = DataDialogResize; + CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM) & urd); + InvalidateRect(hwndDlg, NULL, TRUE); + + GetWindowRect(hwndDlg, &rc); + + // global + Xposition = rc.left; + Yposition = rc.top; + WindowHeight = rc.bottom - rc.top; + WindowWidth = rc.right - rc.left; + + break; + } + + case WM_MOVE: + if ((!IsIconic(hwndDlg)) && (!IsZoomed(hwndDlg))) + { + + GetWindowRect(hwndDlg, &rc); + // global + Xposition = rc.left; + Yposition = rc.top; + WindowHeight = rc.bottom - rc.top; + WindowWidth = rc.right - rc.left; + + if ((GetAsyncKeyState(VK_CONTROL) & 0x8000)) + { + break; + return 0; + } + ValidatePosition(hwndDlg); + + } + } + return FALSE; +} +/***********************/ + +/*****************************/ + +int DataDialogResize(HWND hwndDlg, LPARAM lParam, UTILRESIZECONTROL * urc) +{ + switch (urc->wId) + { + + case IDC_OPEN_URL: + return RD_ANCHORX_WIDTH | RD_ANCHORY_TOP; + case IDC_DATA: + return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT; + case IDC_STATUSBAR: + return RD_ANCHORX_WIDTH | RD_ANCHORX_RIGHT; + + } + return RD_ANCHORX_LEFT | RD_ANCHORY_TOP; +} + +/****************************/ + +/************/ +void SavewinSettings(void) +{ + + if (Yposition == -32000) + Yposition = 100; + + if (Xposition == -32000) + Xposition = 100; + + DBWriteContactSettingDword(NULL, DLLNAME, Xpos_WIN_KEY, Xposition); + DBWriteContactSettingDword(NULL, DLLNAME, Ypos_WIN_KEY, Yposition); + + DBWriteContactSettingDword(NULL, DLLNAME, BG_COLOR_KEY, BackgoundClr); + DBWriteContactSettingDword(NULL, DLLNAME, TXT_COLOR_KEY, TextClr); + DBWriteContactSettingDword(NULL, DLLNAME, WIN_HEIGHT_KEY, WindowHeight); + DBWriteContactSettingDword(NULL, DLLNAME, WIN_WIDTH_KEY, WindowWidth); + +} +/************/ + +/************************/ +void ValidatePosition(HWND hwndDlg) +{ + RECT r; + POINT pt; + + typedef HMONITOR WINAPI MyMonitorFromPoint(POINT, DWORD); + typedef BOOL WINAPI MyGetMonitorInfo(HMONITOR, LPMONITORINFO); + + HMODULE hUserInstance = GetModuleHandle("user32"); + + SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0); + + MyMonitorFromPoint *LPMyMonitorFromPoint = (MyMonitorFromPoint *) GetProcAddress(hUserInstance, "MonitorFromPoint"); + + if (LPMyMonitorFromPoint) + { + MONITORINFO monitorInfo; + HMONITOR hMonitor = LPMyMonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST); // always + + // + + // returns + // a + // valid + // value + + monitorInfo.cbSize = sizeof(MONITORINFO); + + if ((MyGetMonitorInfo *) GetProcAddress(hUserInstance, "GetMonitorInfoA") (hMonitor, &monitorInfo)) + { + CopyMemory(&r, &monitorInfo.rcMonitor, sizeof(RECT)); + + } + } +// /window going off right of screen* + if (((Xposition) + WindowWidth) >= r.right) + { + Xposition = r.right - WindowWidth; + + } +// window going off bottom of screen + if (((Yposition) + (WindowHeight)) >= r.bottom) + { + Yposition = (r.bottom - (WindowHeight)); + + } +// window going off left of screen + if (((Xposition)) >= r.right) + { + Xposition = 0; + + } +} + +/***********************/ diff --git a/plugins/!NotAdopted/WebView/webview_getdata.c b/plugins/!NotAdopted/WebView/webview_getdata.c new file mode 100644 index 0000000000..b3a308beab --- /dev/null +++ b/plugins/!NotAdopted/WebView/webview_getdata.c @@ -0,0 +1,955 @@ +/* + * A plugin for Miranda IM which displays web page text in a window Copyright + * (C) 2005 Vincent Joyce. + * + * Miranda IM: the free icq client for MS Windows Copyright (C) 2000-2 + * Richard Hughes, Roland Rabien & Tristan Van de Vreede + * + * 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. + */ + +static HANDLE hNetlibUser = NULL; +int Startingup = 1; +int AlreadyDownloading = 0; + +/*******************/ +static void GetData(void *AContact) +{ + int statpos = 0, dispos = 0, statposend = 0; + char *pos; + DBVARIANT dbv; + NETLIBHTTPREQUEST nlhr = {0} + , *nlhrReply; + NETLIBHTTPHEADER headers[2]; + char tempstring[300], tempstring2[300]; + int MallocSize = 0; + int DownloadSuccess = 0; + char *raw; + char *szInfo; + char truncated[MAXSIZE1]; + char truncated2[MAXSIZE2]; + int trunccount = 0; + char url[300]; + unsigned long downloadsize = 0; + int AmountWspcRem = 0; + static char contactname[100]; + char statustext[200]; + int TherewasAlert = 0; + int PosButnClick = 0; + char tstr[128]; + static char timestring[128]; + int eventIndex = 0; + int location = 0; + int location2 = 0; + + if (Startingup) + Sleep(2000); + + HWND hwndDlg = (WindowList_Find(hWindowList, AContact)); + + Startingup = 0; + + ZeroMemory(&url, sizeof(url)); + ZeroMemory(&contactname, sizeof(contactname)); + ZeroMemory(&tempstring, sizeof(tempstring)); + ZeroMemory(&tempstring2, sizeof(tempstring2)); + ZeroMemory(&szInfo, sizeof(szInfo)); + ZeroMemory(&dbv, sizeof(dbv)); + ZeroMemory(&tstr, sizeof(tstr)); + ZeroMemory(×tring, sizeof(timestring)); + + + DBWriteContactSettingByte(AContact, DLLNAME, STOP_KEY, 0); + +// + if (DBGetContactSetting(AContact, DLLNAME, PRESERVE_NAME_KEY, &dbv)) + { + DBFreeVariant(&dbv); + DBGetContactSetting(AContact, "CList", "MyHandle", &dbv); + DBWriteContactSettingString(AContact, DLLNAME, PRESERVE_NAME_KEY, dbv.pszVal); + DBFreeVariant(&dbv); + } + DBGetContactSetting(AContact, DLLNAME, PRESERVE_NAME_KEY, &dbv); + _snprintf(contactname, sizeof(contactname), "%s", dbv.pszVal); + DBFreeVariant(&dbv); + //MessageBox(NULL, contactname, "pro-contname0", MB_OK); +// + + url[0] = '\0'; + + if (!Startingup) + DBWriteContactSettingByte(NULL, DLLNAME, HAS_CRASHED_KEY, 1); + + // + DBGetContactSetting(AContact, DLLNAME, START_STRING_KEY, &dbv); + _snprintf(tempstring, sizeof(tempstring), "%s", dbv.pszVal); + DBFreeVariant(&dbv); + // + DBGetContactSetting(AContact, DLLNAME, END_STRING_KEY, &dbv); + _snprintf(tempstring2, sizeof(tempstring2), "%s", dbv.pszVal); + DBFreeVariant(&dbv); + // + DBGetContactSetting(AContact, DLLNAME, URL_KEY, &dbv); + _snprintf(url, sizeof(url), "%s", dbv.pszVal); + DBFreeVariant(&dbv); + + if (strlen(url) < 3) + { + WErrorPopup(contactname, Translate("URL not supplied")); + } + nlhr.cbSize = sizeof(nlhr); + nlhr.requestType = REQUEST_GET; + nlhr.flags = NLHRF_DUMPASTEXT; + nlhr.szUrl = url; + nlhr.headersCount = 2; + + headers[0].szName = "User-Agent"; + headers[0].szValue = "Mozilla/4.0 (compatible; MSIE 6.0; Win32)"; + + headers[1].szName = "Content-Length"; + headers[1].szValue = NULL; + + nlhr.headers = headers; + +// ////// + if ((DBGetContactSettingByte(NULL, DLLNAME, NO_PROTECT_KEY, 0))) // disable + // download + // protection + + AlreadyDownloading = 0; + + // //try site//// + if (!AlreadyDownloading) // not already downloading + + { + + if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_UPDATE_BUTTON))) + PosButnClick = 0; + else + PosButnClick = 1; + EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE_BUTTON), 1); + + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), " %s", Translate("Download in progress, please wait...")); + SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext); + + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), "%s", Translate("Updating...")); + DBWriteContactSettingString(AContact, "CList", "StatusMsg", statustext); +// / + + DBWriteContactSettingWord(AContact, DLLNAME, "Status", ID_STATUS_DND); // download + // and + // processing + // in + // progress + + nlhrReply = (NETLIBHTTPREQUEST *) CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM) hNetlibUser, (LPARAM) & nlhr); + + if (nlhrReply) + { + + if (nlhrReply->resultCode < 200 || nlhrReply->resultCode >= 300) + { + DBWriteContactSettingWord(AContact, DLLNAME, "Status", ID_STATUS_AWAY); + HWND hwndDlg = (WindowList_Find(hWindowList, AContact)); + + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), " %s (%d)", Translate("The server replied with a failure code"), nlhrReply->resultCode); + SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext); + WErrorPopup(contactname, statustext); + + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), " %s (%d)", "HTTP ERROR: ", nlhrReply->resultCode); + DBWriteContactSettingString(AContact, "CList", "StatusMsg", statustext); + } + if (nlhrReply->dataLength) + { + szInfo = malloc(lstrlen(nlhrReply->pData) + 2); + lstrcpyn(szInfo, nlhrReply->pData, lstrlen(nlhrReply->pData)); + downloadsize = lstrlen(nlhrReply->pData); + + trunccount = 0; + lstrcpyn(truncated2, szInfo, MAXSIZE2); + free(szInfo); + +////////////////////////////////////////// + +/* +#ifdef UNICODE_VERISON + +//semi works + + wchar_t tmp2[sizeof(nlhrReply->pData)]; + + + + +MultiByteToWideChar(CP_UTF8, 0, (CHAR *)nlhrReply->pData, -1, tmp2, strlen(nlhrReply->pData)); + +SetDlgItemTextW(hwndDlg, IDC_DATA, (wchar_t *)&tmp2); +//MessageBoxW(NULL, tmp2, L"Umm", MB_OK); + #endif +*/ + + +//////////////////////////////////////////// + sprintf(truncated2, "%s", nlhrReply->pData); + AlreadyDownloading = 1; + } // END DATELENGTH + + } // END REPLY + + if (!(nlhrReply)) + { + DBWriteContactSettingWord(AContact, DLLNAME, "Status", ID_STATUS_NA); + HWND hwndDlg = (WindowList_Find(hWindowList, AContact)); + + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), " %s", Translate("The server is down or lagging.")); + SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext); + WErrorPopup(contactname, statustext); + + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), "%s", Translate("The server is down.")); + DBWriteContactSettingString(AContact, "CList", "StatusMsg", statustext); + + + + } + if (!(nlhrReply)) + DownloadSuccess = 0; + + if ((nlhrReply) && (nlhrReply->resultCode < 200 || nlhrReply->resultCode >= 300)) + { + DownloadSuccess = 0; + } else if (nlhrReply) + DownloadSuccess = 1; + + // + + CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM) nlhrReply); + + if (DownloadSuccess) + { + HWND hwndDlg = (WindowList_Find(hWindowList, AContact)); + + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), " %s", Translate("Download successful; about to process data...")); + SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext); + // MessageBox(NULL, "Crash", "1", MB_OK); + } +///get data in desired range + + // download successful + if (DownloadSuccess) + { + +// all the site + if (DBGetContactSettingByte(AContact, DLLNAME, U_ALLSITE_KEY, 0) == 1) + { + lstrcpyn(truncated, truncated2, MAXSIZE1); + } else // use start and end string + + { + // putting data into string + if (((strstr(truncated2, tempstring)) != 0) && ((strstr(truncated2, tempstring2)) != 0)) + { + +// start string + pos = strstr(truncated2, tempstring); + statpos = pos - truncated2; +// + ZeroMemory(&pos, sizeof(pos)); +// end string + pos = strstr(truncated2, tempstring2); + statposend = pos - truncated2 + strlen(tempstring2); +// + if (statpos > statposend) + { + memset(&truncated2, ' ', statpos); + ZeroMemory(&pos, sizeof(pos)); + pos = strstr(truncated2, tempstring2); + statposend = pos - truncated2 + strlen(tempstring2); + } + if (statpos < statposend) + { + ZeroMemory(&raw, sizeof(raw)); + +// get size for malloc + //MessageBox(NULL, "Crash", "2", MB_OK); + + MallocSize = statposend - statpos; + raw = (char *) malloc(MallocSize + 1); + +// start string + pos = strstr(truncated2, tempstring); + statpos = pos - truncated2; +// + +// end string + pos = strstr(truncated2, tempstring2); + statposend = pos - truncated2 + strlen(tempstring2); +// + //MessageBox(NULL, "Crash", "3", MB_OK); + + if (statpos > statposend) + { + memset(&truncated2, ' ', statpos); + ZeroMemory(&pos, sizeof(pos)); + pos = strstr(truncated2, tempstring2); + statposend = pos - truncated2 + strlen(tempstring2); + } + dispos = 0; + +// write selected data to string + //MessageBox(NULL, "Crash", "4", MB_OK); + + strncpy(raw, &truncated2[statpos], MallocSize); + raw[MallocSize] = '\0'; + + trunccount = 0; + + lstrcpyn(truncated, raw, MAXSIZE1); + + //MessageBox(NULL, "Crash", "5", MB_OK); + /* +#ifdef UNICODE_VERISON + + + wchar_t tmp2[50]; + + MessageBox(NULL, raw, "raw", MB_OK); + + int c = lstrlenA(raw); +MultiByteToWideChar(CP_ACP, 0, raw, c, tmp2, c); + +//MessageBoxW(NULL, tmp2, DLLNAME, MB_OK); + #endif +*/ + free(raw); + + //MessageBox(NULL, "Crash", "6", MB_OK); + + DownloadSuccess = 1; + + } else if (DBGetContactSettingByte(AContact, DLLNAME, U_ALLSITE_KEY, 0) == 0) + { + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), " %s", Translate("Invalid search parameters.")); + WErrorPopup(contactname, statustext); + HWND hwndDlg = (WindowList_Find(hWindowList, AContact)); + + DownloadSuccess = 0; + SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext); + DBWriteContactSettingWord(AContact, DLLNAME, "Status", ID_STATUS_AWAY); + } + } // end putting data into string + + } // end use start and end strings + + } // end download success + + //MessageBox(NULL, "Crash", "7", MB_OK); + + if (DownloadSuccess) // download success + + { + if (statpos == 0 && statposend == 0) + { + if (DBGetContactSettingByte(AContact, DLLNAME, U_ALLSITE_KEY, 0) == 0) + { + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), " %s", Translate("Both search strings not found or strings not set.")); + WErrorPopup(contactname, statustext); + DBWriteContactSettingString(AContact, "CList", "StatusMsg", statustext); + HWND hwndDlg = (WindowList_Find(hWindowList, AContact)); + + DownloadSuccess = 0; + SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext); + TherewasAlert = ProcessAlerts(AContact, statustext, contactname, contactname, 1); + DBWriteContactSettingWord(AContact, DLLNAME, "Status", ID_STATUS_AWAY); + } + } + } // end download success + // ////// + //MessageBox(NULL, "Crash", "8", MB_OK); + + if (DownloadSuccess) // download success + + { + + char timeprefix[32]; + char temptime1[32]; + char timeat[16]; + char temptime2[32]; + char temptime[128]; + time_t ftime; + struct tm *nTime; + + setlocale(LC_ALL, ""); + + if (!DBGetContactSetting(AContact, DLLNAME, PRESERVE_NAME_KEY, &dbv)) + { + ZeroMemory(&temptime, sizeof(temptime)); + ZeroMemory(&tstr, sizeof(tstr)); + ftime = time(NULL); + nTime = localtime(&ftime); + // 12 hour + if (DBGetContactSettingByte(AContact, DLLNAME, USE_24_HOUR_KEY, 0) == 0) + strftime(temptime, 128, "(%b %d,%I:%M %p)", nTime); + // 24 hour + if (DBGetContactSettingByte(AContact, DLLNAME, USE_24_HOUR_KEY, 0) == 1) + strftime(temptime, 128, "(%b %d,%H:%M:%S)", nTime); + + if (DBGetContactSettingByte(AContact, DLLNAME, CONTACT_PREFIX_KEY, 1) == 1) + _snprintf(tstr, sizeof(tstr), "%s %s", temptime, dbv.pszVal); + if (DBGetContactSettingByte(AContact, DLLNAME, CONTACT_PREFIX_KEY, 1) == 0) + _snprintf(tstr, sizeof(tstr), "%s %s", dbv.pszVal, temptime); + DBFreeVariant(&dbv); + } else if (DBGetContactSetting(AContact, DLLNAME, PRESERVE_NAME_KEY, &dbv)) + { + DBFreeVariant(&dbv); + DBGetContactSetting(AContact, "CList", "MyHandle", &dbv); + ZeroMemory(&temptime, sizeof(temptime)); + ZeroMemory(&tstr, sizeof(tstr)); + ftime = time(NULL); + nTime = localtime(&ftime); + // 12 hour + if (DBGetContactSettingByte(AContact, DLLNAME, USE_24_HOUR_KEY, 0) == 0) + strftime(temptime, 128, "(%b %d,%I:%M %p)", nTime); + // 24 hour + if (DBGetContactSettingByte(AContact, DLLNAME, USE_24_HOUR_KEY, 0) == 1) + strftime(temptime, 128, "(%b %d,%H:%M:%S)", nTime); + + DBWriteContactSettingString(AContact, DLLNAME, PRESERVE_NAME_KEY, dbv.pszVal); + if (DBGetContactSettingByte(AContact, DLLNAME, CONTACT_PREFIX_KEY, 1) == 1) + _snprintf(tstr, sizeof(tstr), "%s %s", temptime, dbv.pszVal); + if (DBGetContactSettingByte(AContact, DLLNAME, CONTACT_PREFIX_KEY, 1) == 0) + _snprintf(tstr, sizeof(tstr), "%s %s", dbv.pszVal, temptime); + DBFreeVariant(&dbv); + } + ZeroMemory(&timeprefix, sizeof(timeprefix)); + ZeroMemory(&temptime1, sizeof(temptime1)); + ZeroMemory(&timeat, sizeof(timeat)); + ZeroMemory(&temptime2, sizeof(temptime2)); + ZeroMemory(×tring, sizeof(timestring)); + + ftime = time(NULL); + nTime = localtime(&ftime); + + _snprintf(timeprefix, sizeof(timeprefix), " %s ", (Translate("Last updated on"))); + strftime(temptime1, 32, " %a, %b %d, %Y ", nTime); + _snprintf(timeat, sizeof(timeat), "%s", (Translate("at the time"))); + strftime(temptime2, 32, " %I:%M %p.", nTime); + _snprintf(timestring, sizeof(timestring), "%s%s%s%s", timeprefix, temptime1, timeat, temptime2); + + } // end download success + + //MessageBox(NULL, "Crash", "9", MB_OK); +//////// + + if (DownloadSuccess) + { + // alertfunc + //MessageBox(NULL, contactname, "pro-contname1", MB_OK); + TherewasAlert = ProcessAlerts(AContact, truncated, tstr, contactname, 0); + + // /////// + /**/ + + // get range of text to be highlighted when part of change changes + // + + if (TherewasAlert) + { + // //////////////////////// + static char buff[MAXSIZE1]; + char Alerttempstring[300], Alerttempstring2[300]; + + eventIndex = DBGetContactSettingByte(AContact, DLLNAME, EVNT_INDEX_KEY, 0); + + if (eventIndex == 2) + { + + strncpy(buff, truncated, sizeof(buff)); + + Filter(buff); + // + + // + DBGetContactSetting(AContact, DLLNAME, ALRT_S_STRING_KEY, &dbv); + _snprintf(Alerttempstring, sizeof(Alerttempstring), "%s", dbv.pszVal); + DBFreeVariant(&dbv); + // + DBGetContactSetting(AContact, DLLNAME, ALRT_E_STRING_KEY, &dbv); + _snprintf(Alerttempstring2, sizeof(Alerttempstring2), "%s", dbv.pszVal); + DBFreeVariant(&dbv); + // + + // putting data into string + if (((strstr(buff, Alerttempstring)) != 0) && ((strstr(buff, Alerttempstring2)) != 0)) + { + + // + location = (strstr(buff, Alerttempstring)) - buff; + location2 = (strstr(buff, Alerttempstring2)) - buff; + // + + } + } + // /////////////////////////// + } + // /////// + // MessageBox(NULL, "Crash", "10", MB_OK); + + if ((((strstr(truncated2, tempstring)) != 0) && ((strstr(truncated2, tempstring2)) != 0) && (DBGetContactSettingByte(AContact, DLLNAME, U_ALLSITE_KEY, 0) == 0)) || (DBGetContactSettingByte(AContact, DLLNAME, U_ALLSITE_KEY, 0) == 1)) + { + // MessageBox(NULL, "Crash", "10a", MB_OK); + RemoveTabs(truncated); + //MessageBox(NULL, "Crash", "10b", MB_OK); + + if ((DBGetContactSettingByte(AContact, DLLNAME, CLEAR_DISPLAY_KEY, 0))) + { + HWND hwndDlg = (WindowList_Find(hWindowList, AContact)); + // MessageBox(NULL, "Crash", "10c", MB_OK); + + // + ZeroMemory(&statustext, sizeof(statustext)); + // MessageBox(NULL, "Crash", "10d", MB_OK); + _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data (Stage 1)")); + //MessageBox(NULL, "Crash", "10e", MB_OK); + //SetDlgItemText(hwndDlg, IDC_DATA, truncated); + /**/ + SendToRichEdit(hwndDlg, + truncated, + TextClr, + BackgoundClr + ); + /**/ + //MessageBox(NULL, "Crash", "10f", MB_OK); + SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext); + if (DBGetContactSettingByte(AContact, DLLNAME, STOP_KEY, 1) == 1) + { + + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data stopped by user.")); + SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext); + DBWriteContactSettingByte(AContact, DLLNAME, STOP_KEY, 0); + DBWriteContactSettingWord(AContact, DLLNAME, "Status", ID_STATUS_ONLINE); + DBWriteContactSettingString(AContact, "CList", "StatusMsg", statustext); + AlreadyDownloading = 0; + return; + } + CodetoSymbol(truncated); + Sleep(100); // avoid 100% CPU + + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data (Stage 2)")); + //SetDlgItemText(hwndDlg, IDC_DATA, truncated); + /**/ + SendToRichEdit(hwndDlg, + truncated, + TextClr, + BackgoundClr + ); + /**/ + SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext); + if (DBGetContactSettingByte(AContact, DLLNAME, STOP_KEY, 1) == 1) + { + + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data stopped by user.")); + SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext); + DBWriteContactSettingByte(AContact, DLLNAME, STOP_KEY, 0); + DBWriteContactSettingWord(AContact, DLLNAME, "Status", ID_STATUS_ONLINE); + DBWriteContactSettingString(AContact, "CList", "StatusMsg", statustext); + AlreadyDownloading = 0; + return; + } + + EraseBlock(truncated); + Sleep(100); // avoid 100% CPU + + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data (Stage 3)")); + //SetDlgItemText(hwndDlg, IDC_DATA, truncated); + /**/ SendToRichEdit(hwndDlg, + truncated, + TextClr, + BackgoundClr + ); + /**/ + SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext); + if (DBGetContactSettingByte(AContact, DLLNAME, STOP_KEY, 1) == 1) + { + + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data stopped by user.")); + SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext); + DBWriteContactSettingByte(AContact, DLLNAME, STOP_KEY, 0); + DBWriteContactSettingWord(AContact, DLLNAME, "Status", ID_STATUS_ONLINE); + DBWriteContactSettingString(AContact, "CList", "StatusMsg", statustext); + AlreadyDownloading = 0; + return; + } + FastTagFilter(truncated); + Sleep(100); // avoid 100% CPU + + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data (Stage 4)")); + //SetDlgItemText(hwndDlg, IDC_DATA, truncated); + /**/ SendToRichEdit(hwndDlg, + truncated, + TextClr, + BackgoundClr + );/**/ + SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext); + if (DBGetContactSettingByte(AContact, DLLNAME, STOP_KEY, 1) == 1) + { + + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data stopped by user.")); + SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext); + DBWriteContactSettingByte(AContact, DLLNAME, STOP_KEY, 0); + DBWriteContactSettingWord(AContact, DLLNAME, "Status", ID_STATUS_ONLINE); + DBWriteContactSettingString(AContact, "CList", "StatusMsg", statustext); + AlreadyDownloading = 0; + return; + } + + NumSymbols(truncated); + Sleep(100); // avoid 100% CPU + + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data (Stage 5)")); + //SetDlgItemText(hwndDlg, IDC_DATA, truncated); + /**/SendToRichEdit(hwndDlg, + truncated, + TextClr, + BackgoundClr + );/**/ + SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext); + if (DBGetContactSettingByte(AContact, DLLNAME, STOP_KEY, 1) == 1) + { + + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data stopped by user.")); + SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext); + DBWriteContactSettingByte(AContact, DLLNAME, STOP_KEY, 0); + DBWriteContactSettingWord(AContact, DLLNAME, "Status", ID_STATUS_ONLINE); + DBWriteContactSettingString(AContact, "CList", "StatusMsg", statustext); + AlreadyDownloading = 0; + return; + } + EraseSymbols(truncated); + Sleep(100); // avoid 100% CPU + + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data (Stage 6)")); + //SetDlgItemText(hwndDlg, IDC_DATA, truncated); + /**/SendToRichEdit(hwndDlg, + truncated, + TextClr, + BackgoundClr + );/**/ + SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext); + AmountWspcRem = DBGetContactSettingByte(AContact, DLLNAME, RWSPACE_KEY, 0); + if (DBGetContactSettingByte(AContact, DLLNAME, STOP_KEY, 1) == 1) + { + + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data stopped by user.")); + SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext); + DBWriteContactSettingByte(AContact, DLLNAME, STOP_KEY, 0); + DBWriteContactSettingWord(AContact, DLLNAME, "Status", ID_STATUS_ONLINE); + DBWriteContactSettingString(AContact, "CList", "StatusMsg", statustext); + AlreadyDownloading = 0; + return; + } + RemoveInvis(truncated, AmountWspcRem); + Sleep(100); // avoid 100% CPU + + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data (Stage 7)")); + //SetDlgItemText(hwndDlg, IDC_DATA, truncated); + /**/SendToRichEdit(hwndDlg, + truncated, + TextClr, + BackgoundClr + );/**/ + if (DBGetContactSettingByte(AContact, DLLNAME, STOP_KEY, 1) == 1) + { + + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data stopped by user.")); + SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext); + DBWriteContactSettingByte(AContact, DLLNAME, STOP_KEY, 0); + DBWriteContactSettingWord(AContact, DLLNAME, "Status", ID_STATUS_ONLINE); + DBWriteContactSettingString(AContact, "CList", "StatusMsg", statustext); + AlreadyDownloading = 0; + return; + } + SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext); + Removewhitespace(truncated); + + + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data (Stage 8)")); + //SetDlgItemText(hwndDlg, IDC_DATA, truncated); + SendToRichEdit(hwndDlg, + truncated, + TextClr, + BackgoundClr + ); + // + + #ifdef UNICODE_VERISON + +//semi works + + wchar_t tmp3[strlen(truncated)]; + const char *wobbles; + + int c = lstrlenA(truncated); + //mir_utf8encode(truncated); + //utf8_encode(truncated, tmp3); + //utf8_encode(truncated, wobbles); + + //MessageBox(NULL, utf8encode(truncated),"TEST", MB_OK); + +MultiByteToWideChar(CP_UTF8, 0, truncated, -1, tmp3, strlen(truncated)); +SetDlgItemTextW(hwndDlg, IDC_DATA, (wchar_t *)&tmp3); + #endif + + // + /* SendToRichEdit(hwndDlg, + truncated, + TextClr, + BackgoundClr + );*/ + SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext); + + + //data in popup + #ifdef UNICODE_VERISON + if (TherewasAlert) + { + if ((DBGetContactSettingByte(NULL, DLLNAME, DATA_POPUP_KEY, 0))) + WAlertWPopup((WPARAM)AContact, tmp3); + } + #endif + #ifndef UNICODE_VERISON + if (TherewasAlert) + { + if ((DBGetContactSettingByte(NULL, DLLNAME, DATA_POPUP_KEY, 0))) + WAlertPopup((WPARAM)AContact, truncated); + } + #endif + + + if (DBGetContactSettingByte(AContact, DLLNAME, STOP_KEY, 1) == 1) + { + + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data stopped by user.")); + SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext); + DBWriteContactSettingByte(AContact, DLLNAME, STOP_KEY, 0); + DBWriteContactSettingWord(AContact, DLLNAME, "Status", ID_STATUS_ONLINE); + DBWriteContactSettingString(AContact, "CList", "StatusMsg", statustext); + AlreadyDownloading = 0; + return; + } + // removed any excess characters at the end. + if ((truncated[strlen(truncated) - 1] == truncated[strlen(truncated) - 2]) && (truncated[strlen(truncated) - 2] == truncated[strlen(truncated) - 3])) + { + int counterx = 0; + + while (1) + { + counterx++; + if (truncated[strlen(truncated) - counterx] != truncated[strlen(truncated) - 1]) + { + truncated[(strlen(truncated) - counterx) + 2] = '\0'; + break; + } + } + } + // + + + } + } + if (TherewasAlert) + { + DBWriteContactSettingWord(AContact, DLLNAME, "Status", ID_STATUS_OCCUPIED); + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), "%s", Translate("Alert!")); + DBWriteContactSettingString(AContact, "CList", "StatusMsg", statustext); + } + else + { + DBWriteContactSettingWord(AContact, DLLNAME, "Status", ID_STATUS_ONLINE); + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), "%s", Translate("Online")); + DBWriteContactSettingString(AContact, "CList", "StatusMsg", statustext); + } + } + // ///// + if (DBGetContactSettingByte(AContact, DLLNAME, U_ALLSITE_KEY, 0) == 0) + { + if (statpos > statposend) + DownloadSuccess = 0; + else if (statpos == 0 && statposend == 0) + DownloadSuccess = 0; + else + DownloadSuccess = 1; + } + // ///// + + AlreadyDownloading = 0; + } // end not already downloading + + if (AlreadyDownloading) + { + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), " %s", Translate("A site is already downloading, try again in a moment.")); + SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext); + } + if (DownloadSuccess) // download success + + { + + char BytesString[128]; + //char *BytesString; + HWND hwndDlg = (WindowList_Find(hWindowList, AContact)); + + // update window if the update only on alert option isn't ticked or + // there was an alert or the update button was clicked + if ((!(DBGetContactSettingByte(NULL, DLLNAME, UPDATE_ONALERT_KEY, 0))) || (TherewasAlert == 1) || (PosButnClick == 1)) + { +/* +#ifdef UNICODE_VERISON + wchar_t tmp[500]; + + int a = lstrlenA(raw); + +MultiByteToWideChar(CP_ACP, 0, truncated, (lstrlenA(truncated)), tmp, (lstrlenA(truncated))); + +//MessageBoxW(NULL, tmp, "Yeah I know", MB_OK); + + char tempchar1[200]; + + _snprintf(tempchar1, sizeof(tempchar1), "raw strlen is %d, truncated strlen is %d", (lstrlenA(raw)),(lstrlenA(truncated))); + //MessageBox(NULL, tempchar1, DLLNAME, MB_OK); + + // utf8_encode(truncated, &tmp); + + // MessageBox(NULL, tmp, DLLNAME, MB_OK); + + SetDlgItemTextW(hwndDlg, IDC_DATA, tmp); + + + free(tmp); +#endif +*/ + /**/ +#ifndef UNICODE_VERISON + + SendToRichEdit(hwndDlg, + truncated, + TextClr, + BackgoundClr + ); +#endif + + if (TherewasAlert) + { + // highlight text when part of change changes + if (eventIndex == 2) + { + CHARRANGE sel2 = {location, location2}; + + // + SendMessage(GetDlgItem(hwndDlg, IDC_DATA), EM_EXSETSEL, 0, (LPARAM) & sel2); + SetFocus(GetDlgItem(hwndDlg, IDC_DATA)); + + DWORD HiBackgoundClr; + DWORD HiTextClr; + + HiBackgoundClr = DBGetContactSettingDword(NULL, DLLNAME, BG_COLOR_KEY, 0); + HiTextClr = DBGetContactSettingDword(NULL, DLLNAME, TXT_COLOR_KEY, 0); + + CHARFORMAT2 Format; + + memset(&Format, 0, sizeof(Format)); + Format.cbSize = sizeof(Format); + Format.dwMask = CFM_BOLD | CFM_COLOR | CFM_BACKCOLOR; + Format.dwEffects = CFE_BOLD; + Format.crBackColor = ((~HiBackgoundClr) & 0x00ffffff); + Format.crTextColor = ((~HiTextClr) & 0x00ffffff); + SendMessage(GetDlgItem(hwndDlg, IDC_DATA), EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) & Format); + + } + } + SetDlgItemText(hwndDlg, IDC_STATUSBAR, timestring); + sprintf(BytesString, "%s: %d | %s: %lu", (Translate("Bytes in display")), (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_DATA))), (Translate("Bytes downloaded")), downloadsize); + +/* + #ifdef UNICODE_VERISON + + wchar_t unicodestr[256]; + + char *ansistr = "Hello"; //works 1 + + +//int a = lstrlenA(ansistr);//works 1 + +//MultiByteToWideChar(CP_ACP, 0, ansistr, a, unicodestr, a); //works 1 +// MessageBoxW(NULL, unicodestr, DLLNAME, MB_OK); //works 1 + + + +int b = lstrlenA(BytesString); + +MultiByteToWideChar(CP_ACP, 0, BytesString, b, unicodestr, b); + + SendMessageW(GetDlgItem(hwndDlg, IDC_STATUSBAR), SB_SETTEXT, 1, (LPARAM)unicodestr); + // free(unicodestr); + #endif +*/ + //#ifndef UNICODE_VERISON + SendMessage(GetDlgItem(hwndDlg, IDC_STATUSBAR), SB_SETTEXT, 1, (LPARAM) BytesString); + //#endif + + } else + { + ZeroMemory(&statustext, sizeof(statustext)); + _snprintf(statustext, sizeof(statustext), " %s", Translate("Alert test conditions not met; press the refresh button to view content.")); + SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext); + } + + } + EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE_BUTTON), 1); + + if (!Startingup) + DBWriteContactSettingByte(NULL, DLLNAME, HAS_CRASHED_KEY, 0); + +} + +/*****************/ + + + diff --git a/plugins/!NotAdopted/WebView/webview_opts.c b/plugins/!NotAdopted/WebView/webview_opts.c new file mode 100644 index 0000000000..7db4e5900c --- /dev/null +++ b/plugins/!NotAdopted/WebView/webview_opts.c @@ -0,0 +1,1740 @@ +/* + * A plugin for Miranda IM which displays web page text in a window Copyright + * (C) 2005 Vincent Joyce. + * + * Miranda IM: the free icq client for MS Windows Copyright (C) 2000-2 + * Richard Hughes, Roland Rabien & Tristan Van de Vreede + * + * 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. + */ + +const char *szTrackerBarDescr[] = {"No whitespace removal", "Minimal level of whitespace removal", "Medium level of whitespace removal", "Large level of whitespace removal", "Remove all whitespace",}; +static char *fontSizes[] = {"8", "10", "14", "16", "18", "20", "24", "28"}; +static char *AlertTypes[] = {"Popup Plugin", "Log To File", "Open Data Display Window", "Use OSD Plugin"}; +static char *EventTypes[] = {"A String Is Present", "The Web Page Changes", "A Specific Part of Web Page Changes"}; + +#define M_FILLSCRIPTCOMBO (WM_USER+16) + +/*********************/ +static int CALLBACK EnumFontScriptsProc(ENUMLOGFONTEX * lpelfe, NEWTEXTMETRICEX * lpntme, int FontType, LPARAM lParam) +{ + if (SendMessage((HWND) lParam, CB_FINDSTRINGEXACT, -1, (LPARAM) lpelfe->elfScript) == CB_ERR) + { + int i = SendMessage((HWND) lParam, CB_ADDSTRING, 0, (LPARAM) lpelfe->elfScript); + + SendMessage((HWND) lParam, CB_SETITEMDATA, i, lpelfe->elfLogFont.lfCharSet); + } + return TRUE; +} +/********************/ + +/*********************/ +// copied and modified from NewStatusNotify +BOOL CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + + char str[512]; + DWORD BGColour = 0; + DWORD TextColour = 0; + DWORD delay = 0; + static int test = 0; + + switch (msg) + { + case WM_INITDIALOG: + { + TranslateDialogDefault(hdlg); + +// +//CheckDlgButton(hdlg, IDC_PUALERT, DBGetContactSettingByte(NULL, DLLNAME, INBUILTPOP_KEY, 0)); +// + delay = DBGetContactSettingDword(NULL, DLLNAME, POP_DELAY_KEY, 0); + + // setting popup delay option + itoa(delay, str, 10); + + SetDlgItemText(hdlg, IDC_DELAY, str); +// +/* + if (delay == -1) + CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD2); + else if (delay == 0) + CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD1); + else if (delay != 0 && delay != -1) + CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD3); +*/ +/* + if (delay == -1) + CheckDlgButton(hdlg, IDC_PD2, BST_CHECKED); + else if (delay == 0) + CheckDlgButton(hdlg, IDC_PD1, BST_CHECKED); + else if (delay != 0 && delay != -1) + CheckDlgButton(hdlg, IDC_PD3, BST_CHECKED); +*/ + +// + + BGColour = DBGetContactSettingDword(NULL, DLLNAME, POP_BG_CLR_KEY, 0); + TextColour = DBGetContactSettingDword(NULL, DLLNAME, POP_TXT_CLR_KEY, 0); + + // Colours. First step is configuring the colours. + SendDlgItemMessage(hdlg, IDC_POP_BGCOLOUR, CPM_SETCOLOUR, 0, BGColour); + SendDlgItemMessage(hdlg, IDC_POP_TEXTCOLOUR, CPM_SETCOLOUR, 0, TextColour); + // Second step is disabling them if we want to use default Windows + // ones. + CheckDlgButton(hdlg, IDC_POP_USEWINCOLORS, DBGetContactSettingByte(NULL, DLLNAME, POP_USEWINCLRS_KEY, 0)); + CheckDlgButton(hdlg, IDC_POP_USESAMECOLORS, DBGetContactSettingByte(NULL, DLLNAME, POP_USESAMECLRS_KEY, 0)); + CheckDlgButton(hdlg, IDC_POP_USECUSTCOLORS, DBGetContactSettingByte(NULL, DLLNAME, POP_USECUSTCLRS_KEY, 0)); + // + if ((IsDlgButtonChecked(hdlg, IDC_POP_USEWINCOLORS)) || (IsDlgButtonChecked(hdlg, IDC_POP_USESAMECOLORS))) + { + EnableWindow(GetDlgItem(hdlg, IDC_POP_BGCOLOUR), 0); + EnableWindow(GetDlgItem(hdlg, IDC_POP_TEXTCOLOUR), 0); + } + // + CheckDlgButton(hdlg, IDC_LCLK_WINDOW, DBGetContactSettingByte(NULL, DLLNAME, LCLK_WINDOW_KEY, 0)); + CheckDlgButton(hdlg, IDC_LCLK_WEB_PGE, DBGetContactSettingByte(NULL, DLLNAME, LCLK_WEB_PGE_KEY, 0)); + CheckDlgButton(hdlg, IDC_LCLK_DISMISS, DBGetContactSettingByte(NULL, DLLNAME, LCLK_DISMISS_KEY, 0)); + + CheckDlgButton(hdlg, IDC_RCLK_WINDOW, DBGetContactSettingByte(NULL, DLLNAME, RCLK_WINDOW_KEY, 0)); + CheckDlgButton(hdlg, IDC_RCLK_WEB_PGE, DBGetContactSettingByte(NULL, DLLNAME, RCLK_WEB_PGE_KEY, 0)); + CheckDlgButton(hdlg, IDC_RCLK_DISMISS, DBGetContactSettingByte(NULL, DLLNAME, RCLK_DISMISS_KEY, 0)); + + return TRUE; + } + break; + case WM_COMMAND: + // enable the "apply" button + if (HIWORD(wParam) == BN_CLICKED && GetFocus() == (HWND) lParam) + SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); + // These are simple clicks: we don't save, but we tell the Options Page + // + // to enable the "Apply" button. + switch (LOWORD(wParam)) + { + case IDC_POP_BGCOLOUR: // Fall through + + case IDC_POP_TEXTCOLOUR: + // select new colors + if (HIWORD(wParam) == CPN_COLOURCHANGED) + SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); + break; + case IDC_POP_USESAMECOLORS: + // use same color as data window - enable/disable color selection + // controls + EnableWindow(GetDlgItem(hdlg, IDC_POP_BGCOLOUR), !((BYTE) IsDlgButtonChecked(hdlg, IDC_POP_USESAMECOLORS))); + EnableWindow(GetDlgItem(hdlg, IDC_POP_TEXTCOLOUR), !((BYTE) IsDlgButtonChecked(hdlg, IDC_POP_USESAMECOLORS))); + SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); + break; + case IDC_POP_USEWINCOLORS: + // use window color - enable/disable color selection controls + EnableWindow(GetDlgItem(hdlg, IDC_POP_BGCOLOUR), !((BYTE) IsDlgButtonChecked(hdlg, IDC_POP_USEWINCOLORS))); + EnableWindow(GetDlgItem(hdlg, IDC_POP_TEXTCOLOUR), !((BYTE) IsDlgButtonChecked(hdlg, IDC_POP_USEWINCOLORS))); + SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); + break; + case IDC_POP_USECUSTCOLORS: + EnableWindow(GetDlgItem(hdlg, IDC_POP_BGCOLOUR), ((BYTE) IsDlgButtonChecked(hdlg, IDC_POP_USECUSTCOLORS))); + EnableWindow(GetDlgItem(hdlg, IDC_POP_TEXTCOLOUR), ((BYTE) IsDlgButtonChecked(hdlg, IDC_POP_USECUSTCOLORS))); + break; + + case IDC_PD1: + // Popup delay setting from PopUp plugin + SetDlgItemText(hdlg, IDC_DELAY, "0"); + // CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD1); + break; + case IDC_PD2: + // Popup delay = permanent + SetDlgItemText(hdlg, IDC_DELAY, "-1"); + // CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD2); + break; +// case IDC_PD3: +// CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD3); +// break; + case IDC_DELAY: + { + if (HIWORD(wParam) == EN_CHANGE) + test++; + if (test > 1) + { + //CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD3); + SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); + } + } + break; + + case IDC_PREVIEW: + { + char str3[512]; + POPUPDATAEX ppd; + + ZeroMemory(&ppd, sizeof(POPUPDATA)); + GetDlgItemText(hdlg, IDC_DELAY, str3, sizeof(str3)); + + if (IsDlgButtonChecked(hdlg, IDC_POP_USECUSTCOLORS)) + { + BGColour = (SendDlgItemMessage(hdlg, IDC_POP_BGCOLOUR, CPM_GETCOLOUR, 0, 0)); + TextColour = (SendDlgItemMessage(hdlg, IDC_POP_TEXTCOLOUR, CPM_GETCOLOUR, 0, 0)); + } + if (IsDlgButtonChecked(hdlg, IDC_POP_USEWINCOLORS)) + { + BGColour = GetSysColor(COLOR_BTNFACE); + TextColour = GetSysColor(COLOR_WINDOWTEXT); + } + if (IsDlgButtonChecked(hdlg, IDC_POP_USESAMECOLORS)) + { + BGColour = BackgoundClr; + TextColour = TextClr; + } + ppd.lchContact = NULL; + strcpy(ppd.lpzContactName, DLLNAME); + ppd.lchIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_SITE)); + sprintf(ppd.lpzText, Translate("This is a preview popup.")); + ppd.colorBack = BGColour; + ppd.colorText = TextColour; + ppd.PluginWindowProc = NULL; + ppd.iSeconds = (atol(str3)); + // display popups + if (!ServiceExists(MS_POPUP_ADDPOPUPEX)) // old version + CallService(MS_POPUP_ADDPOPUP, (WPARAM) & ppd, 0); + else + { // new version with delay + ppd.iSeconds = (atol(str3)); + CallService(MS_POPUP_ADDPOPUPEX, (WPARAM) & ppd, 0); + } + } + break; + + } + break; + // End WM_COMMAND + case WM_NOTIFY: // Here we have pressed either the OK or the APPLY + // button. + + switch (((LPNMHDR) lParam)->code) + { + case PSN_APPLY: + { + int popupdelayval = 0; + char str2[512]; + + GetDlgItemText(hdlg, IDC_DELAY, str2, sizeof(str2)); + + popupdelayval = atol(str2); + DBWriteContactSettingDword(NULL, DLLNAME, POP_DELAY_KEY, popupdelayval); + +// +// DBWriteContactSettingByte(NULL, DLLNAME, INBUILTPOP_KEY, (BYTE) IsDlgButtonChecked(hdlg, IDC_PUALERT)); + + DBWriteContactSettingByte(NULL, DLLNAME, LCLK_WINDOW_KEY, (BYTE) IsDlgButtonChecked(hdlg, IDC_LCLK_WINDOW)); + DBWriteContactSettingByte(NULL, DLLNAME, LCLK_WEB_PGE_KEY, (BYTE) IsDlgButtonChecked(hdlg, IDC_LCLK_WEB_PGE)); + DBWriteContactSettingByte(NULL, DLLNAME, LCLK_DISMISS_KEY, (BYTE) IsDlgButtonChecked(hdlg, IDC_LCLK_DISMISS)); + + DBWriteContactSettingByte(NULL, DLLNAME, RCLK_WINDOW_KEY, (BYTE) IsDlgButtonChecked(hdlg, IDC_RCLK_WINDOW)); + DBWriteContactSettingByte(NULL, DLLNAME, RCLK_WEB_PGE_KEY, (BYTE) IsDlgButtonChecked(hdlg, IDC_RCLK_WEB_PGE)); + DBWriteContactSettingByte(NULL, DLLNAME, RCLK_DISMISS_KEY, (BYTE) IsDlgButtonChecked(hdlg, IDC_RCLK_DISMISS)); + +// + DBWriteContactSettingByte(NULL, DLLNAME, POP_USECUSTCLRS_KEY, (BYTE) IsDlgButtonChecked(hdlg, IDC_POP_USECUSTCOLORS)); + DBWriteContactSettingByte(NULL, DLLNAME, POP_USEWINCLRS_KEY, (BYTE) IsDlgButtonChecked(hdlg, IDC_POP_USEWINCOLORS)); + DBWriteContactSettingByte(NULL, DLLNAME, POP_USESAMECLRS_KEY, (BYTE) IsDlgButtonChecked(hdlg, IDC_POP_USESAMECOLORS)); + + BGColour = (SendDlgItemMessage(hdlg, IDC_POP_BGCOLOUR, CPM_GETCOLOUR, 0, 0)); + TextColour = (SendDlgItemMessage(hdlg, IDC_POP_TEXTCOLOUR, CPM_GETCOLOUR, 0, 0)); + + DBWriteContactSettingDword(NULL, DLLNAME, POP_BG_CLR_KEY, BGColour); + DBWriteContactSettingDword(NULL, DLLNAME, POP_TXT_CLR_KEY, TextColour); + + test = 0; + + return TRUE; + } + } + break; + } + return FALSE; +} +/********************/ + +/**************/ +static BOOL CALLBACK DlgProcAlertOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + HWND ParentHwnd; + DBVARIANT dbv; + int i; + int alertIndex = 0; + int eventIndex = 0; + static int test; + + ParentHwnd = GetParent(hwndDlg); + + switch (msg) + { + case WM_INITDIALOG: + { + char transCBstr[50]; + + test = 0; + TranslateDialogDefault(hwndDlg); + HANDLE hContact = (HANDLE) lParam; + + + SetWindowLong(hwndDlg, GWL_USERDATA, (LONG) hContact); + + + /* + if ((WindowList_Find(hWindowList,hContact))==NULL) + WindowList_Add(hWindowList, hwndDlg, hContact); + else + { + WindowList_Remove(hWindowList, hwndDlg); + DestroyWindow(hwndDlg); + } + */ + + + SetWindowText(hwndDlg, Translate("Alert Options")); + + SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon(hInst, MAKEINTRESOURCE(IDI_ALERT))); + + + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 0); + + if (!DBGetContactSetting(hContact, DLLNAME, ALERT_STRING_KEY, &dbv)) + { + SetDlgItemText(hwndDlg, IDC_ALERT_STRING, dbv.pszVal); + DBFreeVariant(&dbv); + } + if (!DBGetContactSetting(hContact, DLLNAME, ALRT_S_STRING_KEY, &dbv)) + { + SetDlgItemText(hwndDlg, IDC_START2, dbv.pszVal); + DBFreeVariant(&dbv); + } + if (!DBGetContactSetting(hContact, DLLNAME, ALRT_E_STRING_KEY, &dbv)) + { + SetDlgItemText(hwndDlg, IDC_END2, dbv.pszVal); + DBFreeVariant(&dbv); + } + CheckDlgButton(hwndDlg, IDC_ENABLE_ALERTS, DBGetContactSettingByte(hContact, DLLNAME, ENABLE_ALERTS_KEY, 0)); + CheckDlgButton(hwndDlg, IDC_ADD_DATE_NAME, DBGetContactSettingByte(hContact, DLLNAME, APND_DATE_NAME_KEY, 0)); + CheckDlgButton(hwndDlg, IDC_24_HOUR, DBGetContactSettingByte(hContact, DLLNAME, USE_24_HOUR_KEY, 0)); + CheckDlgButton(hwndDlg, IDC_ALWAYS_LOG, DBGetContactSettingByte(hContact, DLLNAME, ALWAYS_LOG_KEY, 0)); + + if (!DBGetContactSetting(hContact, DLLNAME, ALRT_INDEX_KEY, &dbv)) + { + int indexAlrtVal = 0; + + indexAlrtVal = DBGetContactSettingByte(hContact, DLLNAME, ALRT_INDEX_KEY, 0); + + ZeroMemory(&transCBstr, sizeof(transCBstr)); + _snprintf(transCBstr, sizeof(transCBstr), "%s", Translate(AlertTypes[indexAlrtVal])); + SetDlgItemText(hwndDlg, IDC_ALERT_TYPE, transCBstr); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(hContact, DLLNAME, ALRT_INDEX_KEY, &dbv)) + { + ZeroMemory(&transCBstr, sizeof(transCBstr)); + _snprintf(transCBstr, sizeof(transCBstr), "%s", Translate(AlertTypes[0])); + SetDlgItemText(hwndDlg, IDC_ALERT_TYPE, transCBstr); + DBWriteContactSettingByte(hContact, DLLNAME, ALRT_INDEX_KEY, 0); + DBFreeVariant(&dbv); + } + if (!DBGetContactSetting(hContact, DLLNAME, EVNT_INDEX_KEY, &dbv)) + { + int indexEvntVal = 0; + + indexEvntVal = DBGetContactSettingByte(hContact, DLLNAME, EVNT_INDEX_KEY, 0); + + ZeroMemory(&transCBstr, sizeof(transCBstr)); + _snprintf(transCBstr, sizeof(transCBstr), "%s", Translate(EventTypes[indexEvntVal])); + SetDlgItemText(hwndDlg, IDC_EVENT_TYPE, transCBstr); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(hContact, DLLNAME, EVNT_INDEX_KEY, &dbv)) + { + ZeroMemory(&transCBstr, sizeof(transCBstr)); + _snprintf(transCBstr, sizeof(transCBstr), "%s", Translate(EventTypes[1])); + SetDlgItemText(hwndDlg, IDC_EVENT_TYPE, transCBstr); + DBWriteContactSettingByte(hContact, DLLNAME, EVNT_INDEX_KEY, 1); + DBFreeVariant(&dbv); + } + for (i = 0; i < sizeof(EventTypes) / sizeof(EventTypes[0]); i++) + { + ZeroMemory(&transCBstr, sizeof(transCBstr)); + _snprintf(transCBstr, sizeof(transCBstr), "%s", Translate(EventTypes[i])); + SendDlgItemMessage(hwndDlg, IDC_EVENT_TYPE, CB_ADDSTRING, 0, (LPARAM) transCBstr); + } + for (i = 0; i < sizeof(AlertTypes) / sizeof(AlertTypes[0]); i++) + { + ZeroMemory(&transCBstr, sizeof(transCBstr)); + _snprintf(transCBstr, sizeof(transCBstr), "%s", Translate(AlertTypes[i])); + SendDlgItemMessage(hwndDlg, IDC_ALERT_TYPE, CB_ADDSTRING, 0, (LPARAM) transCBstr); + } + + if (DBGetContactSetting(hContact, DLLNAME, ENABLE_ALERTS_KEY, &dbv)) + { + CheckDlgButton(hwndDlg, IDC_ENABLE_ALERTS, BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_ADD_DATE_NAME, BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_24_HOUR, BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_PREFIX, BST_UNCHECKED); + } + EnableWindow(GetDlgItem(hwndDlg, IDC_EVENT_TYPE), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_ADD_DATE_NAME), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + + // + if (IsDlgButtonChecked(hwndDlg, IDC_ADD_DATE_NAME)) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_PREFIX), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_SUFFIX), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_24_HOUR), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + } else + { + EnableWindow(GetDlgItem(hwndDlg, IDC_PREFIX), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_SUFFIX), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_24_HOUR), 0); + } + // + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_TYPE), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_START2), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_END2), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_ALWAYS_LOG), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + // + if (!DBGetContactSetting(hContact, DLLNAME, EVNT_INDEX_KEY, &dbv)) + { + eventIndex = DBGetContactSettingByte(hContact, DLLNAME, EVNT_INDEX_KEY, 0); + DBFreeVariant(&dbv); + } + if (!DBGetContactSetting(hContact, DLLNAME, ALRT_INDEX_KEY, &dbv)) + { + alertIndex = DBGetContactSettingByte(hContact, DLLNAME, ALRT_INDEX_KEY, 0); + DBFreeVariant(&dbv); + } + // alerts + if (alertIndex == 0) // Popup + + { + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); + } + } else if (alertIndex == 1) // file + + { + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 1); + } + } else if (alertIndex == 2) // datawindow + + { + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); + } + } else if (alertIndex == 3) // osd + + { + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); + } + } + // events + if (eventIndex == 0) // string is present + + { + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_START2), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_END2), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 1); + } + } else if (eventIndex == 1) // webpage changed + + { + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_START2), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_END2), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 0); + } + } else if (eventIndex == 2) // part of page changed + + { + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_START2), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_END2), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 0); + } + } + // + + // /// + + if (!DBGetContactSetting(hContact, DLLNAME, FILE_KEY, &dbv)) + { + SetDlgItemText(hwndDlg, IDC_FILENAME, dbv.pszVal); + DBFreeVariant(&dbv); + } + CheckDlgButton(hwndDlg, IDC_APPEND, DBGetContactSettingByte(hContact, DLLNAME, APPEND_KEY, 0)); + CheckDlgButton(hwndDlg, IDC_SAVE_AS_RAW, DBGetContactSettingByte(hContact, DLLNAME, SAVE_AS_RAW_KEY, 0)); + + if (DBGetContactSettingByte(hContact, DLLNAME, CONTACT_PREFIX_KEY, 1) == 1) + CheckRadioButton(hwndDlg, IDC_PREFIX, IDC_SUFFIX, IDC_PREFIX); + else + CheckRadioButton(hwndDlg, IDC_PREFIX, IDC_SUFFIX, IDC_SUFFIX); + // /// + + // // + if ((DBGetContactSettingByte(hContact, DLLNAME, ALWAYS_LOG_KEY, 0))) + { + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 1); + } + } + // // + + return TRUE; + } + break; + + case WM_COMMAND: + + switch (LOWORD(wParam)) + { + char stringone[255]; + + case IDC_BROWSE: + { + char szFileName[MAX_PATH]; + OPENFILENAME ofn; + + ZeroMemory(&ofn, sizeof(ofn)); + GetDlgItemText(hwndDlg, IDC_FILENAME, szFileName, sizeof(szFileName)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hwndDlg; + ofn.hInstance = NULL; + ofn.lpstrFilter = "TEXT Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0\0"; + ofn.lpstrFile = szFileName; + ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; + ofn.nMaxFile = sizeof(szFileName); + ofn.nMaxFileTitle = MAX_PATH; + ofn.lpstrDefExt = "txt"; + if (!GetSaveFileName(&ofn)) + break; + SetDlgItemText(hwndDlg, IDC_FILENAME, szFileName); + + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); + } + break; + + case IDC_ADD_DATE_NAME: + { + EnableWindow(GetDlgItem(hwndDlg, IDC_PREFIX), (IsDlgButtonChecked(hwndDlg, IDC_ADD_DATE_NAME))); + EnableWindow(GetDlgItem(hwndDlg, IDC_SUFFIX), (IsDlgButtonChecked(hwndDlg, IDC_ADD_DATE_NAME))); + EnableWindow(GetDlgItem(hwndDlg, IDC_24_HOUR), (IsDlgButtonChecked(hwndDlg, IDC_ADD_DATE_NAME))); + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); + + } + break; + + case IDC_24_HOUR: + case IDC_SUFFIX: + case IDC_PREFIX: + { + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); + } + break; + + case IDC_ALERT_STRING: + { + if (HIWORD(wParam) == EN_CHANGE) + test++; + if (test > 1) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); + } + } + break; + + case IDC_START2: + case IDC_END2: + { + if (HIWORD(wParam) == EN_CHANGE) + test++; + if (test > 3) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); + } + } + break; + + case IDC_APPEND: + { + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); + } + break; + + case IDC_SAVE_AS_RAW: + { + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); + } + break; + + case IDC_ENABLE_ALERTS: + { + HANDLE hContact = (HANDLE) GetWindowLong(hwndDlg, GWL_USERDATA); + + EnableWindow(GetDlgItem(hwndDlg, IDC_ADD_DATE_NAME), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + + if (IsDlgButtonChecked(hwndDlg, IDC_ADD_DATE_NAME)) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_PREFIX), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_SUFFIX), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_24_HOUR), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + } else + { + EnableWindow(GetDlgItem(hwndDlg, IDC_PREFIX), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_SUFFIX), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_24_HOUR), 0); + } + + EnableWindow(GetDlgItem(hwndDlg, IDC_EVENT_TYPE), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_TYPE), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_ALWAYS_LOG), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + + if (!DBGetContactSetting(hContact, DLLNAME, EVNT_INDEX_KEY, &dbv)) + { + eventIndex = DBGetContactSettingByte(hContact, DLLNAME, EVNT_INDEX_KEY, 0); + DBFreeVariant(&dbv); + } + if (!DBGetContactSetting(hContact, DLLNAME, ALRT_INDEX_KEY, &dbv)) + { + alertIndex = DBGetContactSettingByte(hContact, DLLNAME, ALRT_INDEX_KEY, 0); + DBFreeVariant(&dbv); + } + if (eventIndex == 2) // part of webpage changed + + { + EnableWindow(GetDlgItem(hwndDlg, IDC_START2), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_END2), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + } else + { + EnableWindow(GetDlgItem(hwndDlg, IDC_START2), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_END2), 0); + } + + // //////// + if (alertIndex == 0) // popup + + { + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); + + if (eventIndex == 2) // part of webpage changed + + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 0); + + if (eventIndex == 1) // webpage changed + + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 0); + + if (eventIndex == 0) // string present + + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + } + } else if (alertIndex == 1) // log to file + + { + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 1); + + if (eventIndex == 1) // webpage changed + + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 0); + + if (eventIndex == 0) // string present + + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + } else + { + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); + + } + } else if (alertIndex == 2) // display window + + { + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); + + if (eventIndex == 1) // webpage changed + + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 0); + + if (eventIndex == 0) // string present + + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + } + } else if (alertIndex == 3) // osd + + { + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); + + if (eventIndex == 1) // webpage changed + + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 0); + + if (eventIndex == 0) // string present + + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + } + } + if (eventIndex == 0) // string present + + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + + // ///////// + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); + + // /// + + if (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG)) + { + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 1); + } else + { + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); + } + } + // /// + + } + break; + + case IDC_ALWAYS_LOG: + { + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG))); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG))); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG))); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG))); + } + break; + + case IDC_ALERT_TYPE: + { + int alertIndex; + HANDLE hContact = (HANDLE) GetWindowLong(hwndDlg, GWL_USERDATA); + + alertIndex = SendDlgItemMessage(hwndDlg, IDC_ALERT_TYPE, CB_GETCURSEL, 0, 0); + + if (HIWORD(wParam) != CBN_SELCHANGE && HIWORD(wParam) != CBN_EDITCHANGE) + return FALSE; + /**/ + + if (HIWORD(wParam) == CBN_SELCHANGE) + { + + if (alertIndex == 0) + { + // PopUp + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); + DBWriteContactSettingByte(hContact, DLLNAME, ALRT_INDEX_KEY, alertIndex); + } else if (alertIndex == 1) + { + // log to file + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 1); + DBWriteContactSettingByte(hContact, DLLNAME, ALRT_INDEX_KEY, alertIndex); + } else if (alertIndex == 2) + { + // data window + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); + DBWriteContactSettingByte(hContact, DLLNAME, ALRT_INDEX_KEY, alertIndex); + } else if (alertIndex == 3) + { + // OSD + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); + DBWriteContactSettingByte(hContact, DLLNAME, ALRT_INDEX_KEY, alertIndex); + } + if (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG)) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG))); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG))); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG))); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG))); + + } + } + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); + } + break; + case IDC_EVENT_TYPE: + { + int eventIndex; + HANDLE hContact = (HANDLE) GetWindowLong(hwndDlg, GWL_USERDATA); + + eventIndex = SendDlgItemMessage(hwndDlg, IDC_EVENT_TYPE, CB_GETCURSEL, 0, 0); + + if (HIWORD(wParam) != CBN_SELCHANGE && HIWORD(wParam) != CBN_EDITCHANGE) + return FALSE; + + /**/ + + if (HIWORD(wParam) == CBN_SELCHANGE) + { + if (eventIndex == 0) + { + // event when string is present + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_START2), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_END2), 0); + DBWriteContactSettingByte(hContact, DLLNAME, EVNT_INDEX_KEY, eventIndex); + } else if (eventIndex == 1) + { + // event when web page changes + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_START2), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_END2), 0); + DBWriteContactSettingByte(hContact, DLLNAME, EVNT_INDEX_KEY, eventIndex); + } else if (eventIndex == 2) + { + // event when part of web page changes + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_START2), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_END2), 1); + DBWriteContactSettingByte(hContact, DLLNAME, EVNT_INDEX_KEY, eventIndex); + } + } + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); + } + break; + + case IDC_ALERT_APPLY: + case IDC_OK2: + { + HANDLE hContact = (HANDLE) GetWindowLong(hwndDlg, GWL_USERDATA); + char szFileName[MAX_PATH]; + + if (!DBGetContactSetting(hContact, DLLNAME, EVNT_INDEX_KEY, &dbv)) + { + eventIndex = DBGetContactSettingByte(hContact, DLLNAME, EVNT_INDEX_KEY, 0); + DBFreeVariant(&dbv); + } + if (!DBGetContactSetting(hContact, DLLNAME, ALRT_INDEX_KEY, &dbv)) + { + alertIndex = DBGetContactSettingByte(hContact, DLLNAME, ALRT_INDEX_KEY, 0); + DBFreeVariant(&dbv); + } + DBWriteContactSettingByte(hContact, DLLNAME, ENABLE_ALERTS_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)); + DBWriteContactSettingByte(hContact, DLLNAME, APND_DATE_NAME_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_ADD_DATE_NAME)); + DBWriteContactSettingByte(hContact, DLLNAME, USE_24_HOUR_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_24_HOUR)); + DBWriteContactSettingByte(hContact, DLLNAME, ALWAYS_LOG_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG)); + +//if alerts is unticked delete the cache + if (!(IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))) + SiteDeleted((WPARAM) hContact, 0); + + if (eventIndex == 0) // string present + + { + if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_ALERT_STRING)))) + { + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) + { + MessageBox(NULL, Translate("You need to supply a search string."), DLLNAME, MB_OK); + break; + } + } + } + // + if (eventIndex == 2) // part of web page changed + + { + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) + { + if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_START2)))) + { + MessageBox(NULL, Translate("You need to supply a start string."), DLLNAME, MB_OK); + break; + } + if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_END2)))) + { + MessageBox(NULL, Translate("You need to supply an end string."), DLLNAME, MB_OK); + break; + } + } + } + // + if (alertIndex == 1) // log to file + + { + if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_FILENAME)))) + { + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) + { + MessageBox(NULL, Translate("You need to supply a file name and path."), DLLNAME, MB_OK); + break; + } + } + } + // + if (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG)) + { + if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_FILENAME)))) + { + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) + { + MessageBox(NULL, Translate("You need to supply a file name and path."), DLLNAME, MB_OK); + break; + } + } + } + // + + GetDlgItemText(hwndDlg, IDC_FILENAME, szFileName, sizeof(szFileName)); + DBWriteContactSettingString(hContact, DLLNAME, FILE_KEY, szFileName); + + DBWriteContactSettingByte(hContact, DLLNAME, APPEND_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_APPEND)); + DBWriteContactSettingByte(hContact, DLLNAME, SAVE_AS_RAW_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_SAVE_AS_RAW)); + + // + ZeroMemory(&stringone, sizeof(stringone)); + GetDlgItemText(hwndDlg, IDC_ALERT_STRING, stringone, sizeof(stringone)); + DBWriteContactSettingString(hContact, DLLNAME, ALERT_STRING_KEY, stringone); + + ZeroMemory(&stringone, sizeof(stringone)); + GetDlgItemText(hwndDlg, IDC_START2, stringone, sizeof(stringone)); + DBWriteContactSettingString(hContact, DLLNAME, ALRT_S_STRING_KEY, stringone); + + ZeroMemory(&stringone, sizeof(stringone)); + GetDlgItemText(hwndDlg, IDC_END2, stringone, sizeof(stringone)); + DBWriteContactSettingString(hContact, DLLNAME, ALRT_E_STRING_KEY, stringone); + + DBWriteContactSettingByte(hContact, DLLNAME, CONTACT_PREFIX_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_PREFIX)); + + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 0); + + if (LOWORD(wParam) == IDC_OK2) + { + EnableWindow(GetDlgItem(ParentHwnd, IDC_ALERT_BUTTON), 1); + EnableWindow(GetDlgItem(ParentHwnd, IDC_OPTIONS_BUTTON), 1); + WindowList_Remove(hWindowList, hwndDlg); + DestroyWindow(hwndDlg); + } + } + break; + + case IDC_ALERT_CANCEL: + { + EnableWindow(GetDlgItem(ParentHwnd, IDC_ALERT_BUTTON), 1); + EnableWindow(GetDlgItem(ParentHwnd, IDC_OPTIONS_BUTTON), 1); + WindowList_Remove(hWindowList, hwndDlg); + if (hwndDlg) + { + DestroyWindow(hwndDlg); + hwndDlg = NULL; + } + } + break; + + case WM_DESTROY: + case IDC_CANCEL: + { + EnableWindow(GetDlgItem(ParentHwnd, IDC_ALERT_BUTTON), 1); + EnableWindow(GetDlgItem(ParentHwnd, IDC_OPTIONS_BUTTON), 1); + WindowList_Remove(hWindowList, hwndDlg); + DestroyWindow(hwndDlg); + return 0; + } + break; + + } + break; + } + return FALSE; +} + +/**************/ + +/*******************************/ + +BOOL CALLBACK DlgProcContactOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + DBVARIANT dbv; + char url[300]; + HWND ParentHwnd; + static int test; + static int test2; + + + ParentHwnd = GetParent(hwndDlg); + + switch (msg) + { + case WM_INITDIALOG: + { + TranslateDialogDefault(hwndDlg); + + HANDLE hContact = (HANDLE) lParam; + + test = 0; + test2 = 0; + + SetWindowLong(hwndDlg, GWL_USERDATA, (LONG) hContact); + WindowList_Add(hWindowList, hwndDlg, hContact); + + SetWindowText(hwndDlg, Translate("Contact Options")); + + SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon(hInst, MAKEINTRESOURCE(IDI_OPTIONS))); + + EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 0); + + if (!DBGetContactSetting(hContact, DLLNAME, URL_KEY, &dbv)) + { + SetDlgItemText(hwndDlg, IDC_URL, dbv.pszVal); + DBFreeVariant(&dbv); + } + if (!DBGetContactSetting(hContact, DLLNAME, START_STRING_KEY, &dbv)) + { + SetDlgItemText(hwndDlg, IDC_START, dbv.pszVal); + DBFreeVariant(&dbv); + } + if (!DBGetContactSetting(hContact, DLLNAME, END_STRING_KEY, &dbv)) + { + SetDlgItemText(hwndDlg, IDC_END, dbv.pszVal); + DBFreeVariant(&dbv); + } + if (DBGetContactSetting(hContact, DLLNAME, PRESERVE_NAME_KEY, &dbv)) + { + DBFreeVariant(&dbv); + DBGetContactSetting(hContact, "CList", "MyHandle", &dbv); + DBWriteContactSettingString(hContact, DLLNAME, PRESERVE_NAME_KEY, dbv.pszVal); + DBFreeVariant(&dbv); + } + if (!DBGetContactSetting(hContact, DLLNAME, PRESERVE_NAME_KEY, &dbv)) + { + SetDlgItemText(hwndDlg, IDC_SITE_NAME, dbv.pszVal); + DBFreeVariant(&dbv); + } + // + CheckDlgButton(hwndDlg, IDC_CLEAN, DBGetContactSettingByte(hContact, DLLNAME, CLEAR_DISPLAY_KEY, 0)); +// + +// + SendDlgItemMessage(hwndDlg, IDC_RWSPACE, TBM_SETRANGE, FALSE, MAKELONG(0, 4)); + SendDlgItemMessage(hwndDlg, IDC_RWSPACE, TBM_SETPOS, TRUE, DBGetContactSettingByte(hContact, DLLNAME, RWSPACE_KEY, 0)); + SetDlgItemText(hwndDlg, IDC_RWSPC_TEXT, Translate(szTrackerBarDescr[SendDlgItemMessage(hwndDlg, IDC_RWSPACE, TBM_GETPOS, 0, 0)])); +// + +// + EnableWindow(GetDlgItem(hwndDlg, IDC_RWSPACE), (IsDlgButtonChecked(hwndDlg, IDC_CLEAN))); + EnableWindow(GetDlgItem(hwndDlg, IDC_RWSPC_TEXT), (IsDlgButtonChecked(hwndDlg, IDC_CLEAN))); + + if (DBGetContactSettingByte(hContact, DLLNAME, DBLE_WIN_KEY, 1) == 1) + CheckRadioButton(hwndDlg, IDC_DBLE_WEB, IDC_DBLE_WIN, IDC_DBLE_WIN); + else + CheckRadioButton(hwndDlg, IDC_DBLE_WEB, IDC_DBLE_WIN, IDC_DBLE_WEB); + + if (DBGetContactSettingByte(hContact, DLLNAME, U_ALLSITE_KEY, 0) == 1) + { + CheckRadioButton(hwndDlg, IDC_U_SE_STRINGS, IDC_U_ALLSITE, IDC_U_ALLSITE); + EnableWindow(GetDlgItem(hwndDlg, IDC_START), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_END), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_CPY_STRINGS), 0); + + } else + { + CheckRadioButton(hwndDlg, IDC_U_SE_STRINGS, IDC_U_ALLSITE, IDC_U_SE_STRINGS); + EnableWindow(GetDlgItem(hwndDlg, IDC_START), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_END), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_CPY_STRINGS), 1); + //EnableWindow(GetDlgItem(hwndDlg, IDC_CPY_STR_TXT), 1); + } + + } + break; + + case WM_HSCROLL: + SetDlgItemText(hwndDlg, IDC_RWSPC_TEXT, Translate(szTrackerBarDescr[SendDlgItemMessage(hwndDlg, IDC_RWSPACE, TBM_GETPOS, 0, 0)])); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 1); + break; + + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case WM_CLOSE: + case IDCANCEL: + { + if (hwndDlg) + { + DestroyWindow(hwndDlg); + hwndDlg = NULL; + } + return TRUE; + } + break; + + case IDC_SITE_NAME: + case IDC_URL: + { + if (HIWORD(wParam) == EN_CHANGE) + test++; + if (test > 2) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 1); + } + } + break; + + case IDC_DBLE_WEB: + case IDC_DBLE_WIN: + { + EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 1); + } + break; + + case IDC_START: + case IDC_END: + { + if (HIWORD(wParam) == EN_CHANGE) + test2++; + if (test2 > 2) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 1); + } + } + break; + + case IDC_CPY_STRINGS: + { + char string[128]; + HANDLE hContact = (HANDLE) GetWindowLong(hwndDlg, GWL_USERDATA); + + ZeroMemory(&string, sizeof(string)); + GetDlgItemText(hwndDlg, IDC_START, string, sizeof(string)); + DBWriteContactSettingString(hContact, DLLNAME, ALRT_S_STRING_KEY, string); + + ZeroMemory(&string, sizeof(string)); + GetDlgItemText(hwndDlg, IDC_END, string, sizeof(string)); + DBWriteContactSettingString(hContact, DLLNAME, ALRT_E_STRING_KEY, string); + + DBWriteContactSettingWord(hContact, DLLNAME, EVNT_INDEX_KEY, 2); + } + break; + + case IDC_CLEAN: + { + EnableWindow(GetDlgItem(hwndDlg, IDC_RWSPACE), (IsDlgButtonChecked(hwndDlg, IDC_CLEAN))); + EnableWindow(GetDlgItem(hwndDlg, IDC_RWSPC_TEXT), (IsDlgButtonChecked(hwndDlg, IDC_CLEAN))); + EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 1); + break; + } + + case IDC_U_SE_STRINGS: + { + EnableWindow(GetDlgItem(hwndDlg, IDC_START), (IsDlgButtonChecked(hwndDlg, IDC_U_SE_STRINGS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_END), (IsDlgButtonChecked(hwndDlg, IDC_U_SE_STRINGS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_CPY_STRINGS), (IsDlgButtonChecked(hwndDlg, IDC_U_SE_STRINGS))); + //EnableWindow(GetDlgItem(hwndDlg, IDC_CPY_STR_TXT), (IsDlgButtonChecked(hwndDlg, IDC_U_SE_STRINGS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 1); + } + break; + + case IDC_U_ALLSITE: + { + EnableWindow(GetDlgItem(hwndDlg, IDC_START), (IsDlgButtonChecked(hwndDlg, IDC_U_SE_STRINGS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_END), (IsDlgButtonChecked(hwndDlg, IDC_U_SE_STRINGS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_CPY_STRINGS), (IsDlgButtonChecked(hwndDlg, IDC_U_SE_STRINGS))); + + EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 1); + } + break; + + case IDC_OPT_APPLY: + case IDOK: + { + char str[128]; + char contactname[128]; + + // + + if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_URL)))) + { + MessageBox(NULL, Translate("You need to supply a URL."), DLLNAME, MB_OK); + break; + } + if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_START)))) + { + if (IsDlgButtonChecked(hwndDlg, IDC_U_SE_STRINGS)) + { + MessageBox(NULL, Translate("You need to supply a start string."), DLLNAME, MB_OK); + break; + } + } + if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_END)))) + { + if (IsDlgButtonChecked(hwndDlg, IDC_U_SE_STRINGS)) + { + MessageBox(NULL, Translate("You need to supply an end string."), DLLNAME, MB_OK); + break; + } + } + if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_SITE_NAME)))) + { + MessageBox(NULL, Translate("You need to supply a name for the contact."), DLLNAME, MB_OK); + break; + } + ZeroMemory(&contactname, sizeof(contactname)); + GetDlgItemText(hwndDlg, IDC_SITE_NAME, contactname, sizeof(contactname)); + + if (strchr(contactname, '\\') != NULL) + { + MessageBox(NULL, Translate("Invalid symbol present in contact name."), DLLNAME, MB_OK); + break; + } + if (strchr(contactname, '/') != NULL) + { + MessageBox(NULL, Translate("Invalid symbol present in contact name."), DLLNAME, MB_OK); + break; + } + if (strchr(contactname, ':') != NULL) + { + MessageBox(NULL, Translate("Invalid symbol present in contact name."), DLLNAME, MB_OK); + break; + } + if (strchr(contactname, '*') != NULL) + { + MessageBox(NULL, Translate("Invalid symbol present in contact name."), DLLNAME, MB_OK); + break; + } + if (strchr(contactname, '?') != NULL) + { + MessageBox(NULL, Translate("Invalid symbol present in contact name."), DLLNAME, MB_OK); + break; + } + if (strchr(contactname, '\"') != NULL) + { + MessageBox(NULL, Translate("Invalid symbol present in contact name."), DLLNAME, MB_OK); + break; + } + if (strchr(contactname, '<') != NULL) + { + MessageBox(NULL, Translate("Invalid symbol present in contact name."), DLLNAME, MB_OK); + break; + } + if (strchr(contactname, '>') != NULL) + { + MessageBox(NULL, Translate("Invalid symbol present in contact name."), DLLNAME, MB_OK); + break; + } + if (strchr(contactname, '|') != NULL) + { + MessageBox(NULL, Translate("Invalid symbol present in contact name."), DLLNAME, MB_OK); + break; + } + // + + HANDLE hContact = (HANDLE) GetWindowLong(hwndDlg, GWL_USERDATA); + + ZeroMemory(&url, sizeof(url)); + GetDlgItemText(hwndDlg, IDC_URL, url, sizeof(url)); + DBWriteContactSettingString(hContact, DLLNAME, URL_KEY, url); + DBWriteContactSettingString(hContact, DLLNAME, "Homepage", url); + + ZeroMemory(&str, sizeof(str)); + GetDlgItemText(hwndDlg, IDC_START, str, sizeof(str)); + DBWriteContactSettingString(hContact, DLLNAME, START_STRING_KEY, str); + + ZeroMemory(&str, sizeof(str)); + GetDlgItemText(hwndDlg, IDC_END, str, sizeof(str)); + DBWriteContactSettingString(hContact, DLLNAME, END_STRING_KEY, str); + + ZeroMemory(&str, sizeof(str)); + GetDlgItemText(hwndDlg, IDC_SITE_NAME, str, sizeof(str)); + DBWriteContactSettingString(hContact, "CList", "MyHandle", str); + + DBWriteContactSettingByte(hContact, DLLNAME, DBLE_WIN_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_DBLE_WIN)); + DBWriteContactSettingByte(hContact, DLLNAME, U_ALLSITE_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_U_ALLSITE)); + + DBWriteContactSettingByte(hContact, DLLNAME, CLEAR_DISPLAY_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_CLEAN)); + DBWriteContactSettingByte(hContact, DLLNAME, RWSPACE_KEY, (BYTE) (SendDlgItemMessage(hwndDlg, IDC_RWSPACE, TBM_GETPOS, 0, 0))); + + // // + char buttontext[256]; + char stringbefore[256]; + char *stringafter; + char newbuttontext[256]; + int pos = 0; + int posafter = 0; + int posbefore = 0; + + ZeroMemory(&buttontext, sizeof(buttontext)); + ZeroMemory(&newbuttontext, sizeof(newbuttontext)); + + _snprintf(buttontext, sizeof(buttontext), "%s", url); + _snprintf(newbuttontext, sizeof(newbuttontext), "%s", url); + + if ((strstr(newbuttontext, "&")) != 0) + { + + while (1) + { + + ZeroMemory(&stringbefore, sizeof(stringbefore)); + + if ((strstr(newbuttontext, "&")) == 0) + break; + + _snprintf(buttontext, sizeof(buttontext), "%s", newbuttontext); + stringafter = strstr(buttontext, "&"); + pos = (stringafter - buttontext); + posbefore = (stringafter - buttontext) - 1; + posafter = (stringafter - buttontext) + 1; + strncpy(&stringafter[0], &stringafter[1], strlen(stringafter)); + _snprintf(stringbefore, pos, "%s", buttontext); + _snprintf(newbuttontext, sizeof(buttontext), "%s%s%s", stringbefore, "!!", stringafter); + + posafter = 0; + posbefore = 0; + } + + while (1) + { + if ((strstr(newbuttontext, "!")) != 0) + { + stringafter = strstr(newbuttontext, "!"); + pos = (stringafter - newbuttontext); + newbuttontext[pos] = '&'; + } + if ((strstr(newbuttontext, "!")) == 0) + break; + } + } + SetDlgItemText(ParentHwnd, IDC_OPEN_URL, newbuttontext); + //SetDlgItemText(ParentHwnd, IDC_HIDDEN_URL, url); + // // + + // + SetWindowText(ParentHwnd, str); + EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 0); + + if (LOWORD(wParam) == IDOK) + { + EnableWindow(GetDlgItem(ParentHwnd, IDC_OPTIONS_BUTTON), 1); + EnableWindow(GetDlgItem(ParentHwnd, IDC_ALERT_BUTTON), 1); + if (hwndDlg) + { + DestroyWindow(hwndDlg); + hwndDlg = NULL; + } + } + // + } + break; + case IDC_OPT_CANCEL: + { + EnableWindow(GetDlgItem(ParentHwnd, IDC_OPTIONS_BUTTON), 1); + EnableWindow(GetDlgItem(ParentHwnd, IDC_ALERT_BUTTON), 1); + WindowList_Remove(hWindowList, hwndDlg); + if (hwndDlg) + { + DestroyWindow(hwndDlg); + hwndDlg = NULL; + } + } + break; + + } + break; + + case WM_DESTROY: + { + EnableWindow(GetDlgItem(ParentHwnd, IDC_OPTIONS_BUTTON), 1); + EnableWindow(GetDlgItem(ParentHwnd, IDC_ALERT_BUTTON), 1); + WindowList_Remove(hWindowList, hwndDlg); + DestroyWindow(hwndDlg); + return 0; + } + break; + + // + case WM_NOTIFY: + switch (((LPNMHDR) lParam)->code) + { + case PSN_APPLY: + { + } + break; // end apply + + } + break; // end notify + // + + } + return FALSE; +} +/***********************/ + +/***********************/ +static BOOL CALLBACK DlgProcOpt(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + DWORD timerval, delaytime, oldcolor; + DBVARIANT dbv; + static int test = 0; + static int test2 = 0; + + switch (uMsg) + { + case WM_INITDIALOG: + { + int i; + + test = 0; + TranslateDialogDefault(hwndDlg); + + SendDlgItemMessage(hwndDlg, IDC_SPIN1, UDM_SETRANGE, 0, MAKELONG(999, 0)); + SendDlgItemMessage(hwndDlg, IDC_SPIN2, UDM_SETRANGE, 0, MAKELONG(120, 0)); + + SetDlgItemInt(hwndDlg, IDC_TIME, DBGetContactSettingWord(NULL, DLLNAME, REFRESH_KEY, 60), FALSE); + SetDlgItemInt(hwndDlg, IDC_START_DELAY, DBGetContactSettingWord(NULL, DLLNAME, START_DELAY_KEY, 0), FALSE); + + forkthread((void *) FillFontListThread, 0, hwndDlg); + + CheckDlgButton(hwndDlg, IDC_DISABLEMENU, DBGetContactSettingByte(NULL, DLLNAME, MENU_OFF, 0)); + CheckDlgButton(hwndDlg, IDC_SUPPRESS, DBGetContactSettingByte(NULL, DLLNAME, SUPPRESS_ERR_KEY, 0)); + CheckDlgButton(hwndDlg, IDC_UPDATE_ONSTART, DBGetContactSettingByte(NULL, DLLNAME, UPDATE_ONSTART_KEY, 0)); + CheckDlgButton(hwndDlg, IDC_UPDATE_ON_OPEN, DBGetContactSettingByte(NULL, DLLNAME, UPDATE_ON_OPEN_KEY, 0)); + CheckDlgButton(hwndDlg, IDC_HIDE_STATUS_ICON, DBGetContactSettingByte(NULL, DLLNAME, HIDE_STATUS_ICON_KEY, 0)); + CheckDlgButton(hwndDlg, IDC_FONT_BOLD, DBGetContactSettingByte(NULL, DLLNAME, FONT_BOLD_KEY, 0)); + CheckDlgButton(hwndDlg, IDC_FONT_ITALIC, DBGetContactSettingByte(NULL, DLLNAME, FONT_ITALIC_KEY, 0)); + CheckDlgButton(hwndDlg, IDC_FONT_UNDERLINE, DBGetContactSettingByte(NULL, DLLNAME, FONT_UNDERLINE_KEY, 0)); + CheckDlgButton(hwndDlg, IDC_ERROR_POPUP, DBGetContactSettingByte(NULL, DLLNAME, ERROR_POPUP_KEY, 0)); + CheckDlgButton(hwndDlg, IDC_UPDATE_ONALERT, DBGetContactSettingByte(NULL, DLLNAME, UPDATE_ONALERT_KEY, 0)); + CheckDlgButton(hwndDlg, IDC_SAVE_INDIVID_POS, DBGetContactSettingByte(NULL, DLLNAME, SAVE_INDIVID_POS_KEY, 0)); + CheckDlgButton(hwndDlg, IDC_NO_PROTECT, DBGetContactSettingByte(NULL, DLLNAME, NO_PROTECT_KEY, 0)); + CheckDlgButton(hwndDlg, IDC_DATAPOPUP, DBGetContactSettingByte(NULL, DLLNAME, DATA_POPUP_KEY, 0)); + + + + if (!DBGetContactSetting(NULL, DLLNAME, FONT_FACE_KEY, &dbv)) + { + SetDlgItemText(hwndDlg, IDC_TYPEFACE, dbv.pszVal); + DBFreeVariant(&dbv); + } + for (i = 0; i < sizeof(fontSizes) / sizeof(fontSizes[0]); i++) + SendDlgItemMessage(hwndDlg, IDC_FONTSIZE, CB_ADDSTRING, 0, (LPARAM) fontSizes[i]); + + SendMessage(hwndDlg, M_FILLSCRIPTCOMBO, wParam, 0); + + if (!DBGetContactSetting(NULL, DLLNAME, FONT_SIZE_KEY, &dbv)) + { + SetDlgItemInt(hwndDlg, IDC_FONTSIZE, (DBGetContactSettingByte(NULL, DLLNAME, FONT_SIZE_KEY, 0)), FALSE); + DBFreeVariant(&dbv); + } + // + EnableWindow(GetDlgItem(hwndDlg, IDC_FIND_BUTTON), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_BUTTON), 0); +// + SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_SETCOLOUR, 0, (BackgoundClr)); + SendDlgItemMessage(hwndDlg, IDC_TXTCOLOR, CPM_SETCOLOUR, 0, (TextClr)); + +/* + * record bg value for later comparison + */ + oldcolor = BackgoundClr; + + if ((DBGetContactSettingByte(NULL, DLLNAME, SUPPRESS_ERR_KEY, 0))) + { + CheckDlgButton(hwndDlg, IDC_SUPPRESS, BST_CHECKED); + EnableWindow(GetDlgItem(hwndDlg, IDC_ERROR_POPUP), 0); + } else + { + CheckDlgButton(hwndDlg, IDC_SUPPRESS, BST_UNCHECKED); + if ((ServiceExists(MS_POPUP_ADDPOPUP) != 0)) + EnableWindow(GetDlgItem(hwndDlg, IDC_ERROR_POPUP), 1); + } + + if ((ServiceExists(MS_POPUP_ADDPOPUP) == 0)) + EnableWindow(GetDlgItem(hwndDlg, IDC_ERROR_POPUP), 0); + + if ((DBGetContactSettingByte(NULL, DLLNAME, UPDATE_ONSTART_KEY, 0))) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_START_DELAY), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_SPIN2), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_STARTDELAYTXT), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_STDELAYSECTXT), 1); + } else + { + EnableWindow(GetDlgItem(hwndDlg, IDC_START_DELAY), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_SPIN2), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_STARTDELAYTXT), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_STDELAYSECTXT), 0); + } + + } + break; + // + case M_FILLSCRIPTCOMBO: // fill the script combo box and set the + // selection to the value for fontid wParam + + { + LOGFONT lf = {0}; + int i; + HDC hdc = GetDC(hwndDlg); + + lf.lfCharSet = DEFAULT_CHARSET; + GetDlgItemText(hwndDlg, IDC_TYPEFACE, lf.lfFaceName, sizeof(lf.lfFaceName)); + lf.lfPitchAndFamily = 0; + SendDlgItemMessage(hwndDlg, IDC_SCRIPT, CB_RESETCONTENT, 0, 0); + EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC) EnumFontScriptsProc, (LPARAM) GetDlgItem(hwndDlg, IDC_SCRIPT), 0); + ReleaseDC(hwndDlg, hdc); + for (i = SendDlgItemMessage(hwndDlg, IDC_SCRIPT, CB_GETCOUNT, 0, 0) - 1; i >= 0; i--) + { + if (SendDlgItemMessage(hwndDlg, IDC_SCRIPT, CB_GETITEMDATA, i, 0) == (BYTE) ((DBGetContactSettingByte(NULL, DLLNAME, FONT_SCRIPT_KEY, 1)))) + { + SendDlgItemMessage(hwndDlg, IDC_SCRIPT, CB_SETCURSEL, i, 0); + break; + } + } + if (i < 0) + SendDlgItemMessage(hwndDlg, IDC_SCRIPT, CB_SETCURSEL, 0, 0); + break; + } + // + + case WM_COMMAND: + if (HIWORD(wParam) == BN_CLICKED && GetFocus() == (HWND) lParam) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + + switch (LOWORD(wParam)) + { + + case IDC_TXTCOLOR: + { + TextClr = SendDlgItemMessage(hwndDlg, IDC_TXTCOLOR, CPM_GETCOLOUR, 0, 0); + DBWriteContactSettingDword(NULL, DLLNAME, TXT_COLOR_KEY, TextClr); + if (HIWORD(wParam) == CPN_COLOURCHANGED) + { + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + TxtclrLoop(); + } + } + break; + + case IDC_BGCOLOR: + { + BackgoundClr = SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_GETCOLOUR, 0, 0); + DBWriteContactSettingDword(NULL, DLLNAME, BG_COLOR_KEY, BackgoundClr); + if (HIWORD(wParam) == CPN_COLOURCHANGED) + { + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + BGclrLoop(); + } + } + break; + + case IDC_HIDE_STATUS_ICON: + { + ShowWindow(GetDlgItem(hwndDlg, IDC_RESTART), SW_SHOW); + break; + } + + case IDC_SUPPRESS: + { + if ((ServiceExists(MS_POPUP_ADDPOPUP) != 0)) + EnableWindow(GetDlgItem(hwndDlg, IDC_ERROR_POPUP), (!(IsDlgButtonChecked(hwndDlg, IDC_SUPPRESS)))); + } + break; + + case IDC_UPDATE_ONSTART: + { + EnableWindow(GetDlgItem(hwndDlg, IDC_START_DELAY), ((IsDlgButtonChecked(hwndDlg, IDC_UPDATE_ONSTART)))); + EnableWindow(GetDlgItem(hwndDlg, IDC_SPIN2), ((IsDlgButtonChecked(hwndDlg, IDC_UPDATE_ONSTART)))); + EnableWindow(GetDlgItem(hwndDlg, IDC_STARTDELAYTXT), ((IsDlgButtonChecked(hwndDlg, IDC_UPDATE_ONSTART)))); + EnableWindow(GetDlgItem(hwndDlg, IDC_STDELAYSECTXT), ((IsDlgButtonChecked(hwndDlg, IDC_UPDATE_ONSTART)))); + } + break; + + case IDC_DISABLEMENU: + { + ShowWindow(GetDlgItem(hwndDlg, IDC_RESTART), SW_SHOW); + break; + } + + + case IDC_TYPEFACE: + SendMessage(hwndDlg, M_FILLSCRIPTCOMBO, wParam, 0); + case IDC_FONTSIZE: + case IDC_SCRIPT: + { + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + break; + + case IDC_START_DELAY: + { + if (HIWORD(wParam) == EN_CHANGE) + test++; + if (test > 1) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + break; + + case IDC_TIME: + { + if (HIWORD(wParam) == EN_CHANGE) + test2++; + if (test2 > 2) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + break; + + } // end WM_COMMAND + + break; + + case WM_DESTROY: + { + test = 0; + test2 = 0; + } + break; + + case WM_NOTIFY: + switch (((LPNMHDR) lParam)->code) + { + case PSN_APPLY: + { + char str[100]; + + DBWriteContactSettingByte(NULL, DLLNAME, MENU_OFF, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_DISABLEMENU)); + DBWriteContactSettingByte(NULL, DLLNAME, SUPPRESS_ERR_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_SUPPRESS)); + DBWriteContactSettingByte(NULL, DLLNAME, UPDATE_ONSTART_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_UPDATE_ONSTART)); + DBWriteContactSettingByte(NULL, DLLNAME, UPDATE_ON_OPEN_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_UPDATE_ON_OPEN)); + DBWriteContactSettingByte(NULL, DLLNAME, HIDE_STATUS_ICON_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_HIDE_STATUS_ICON)); + DBWriteContactSettingByte(NULL, DLLNAME, FONT_BOLD_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_FONT_BOLD)); + DBWriteContactSettingByte(NULL, DLLNAME, FONT_ITALIC_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_FONT_ITALIC)); + DBWriteContactSettingByte(NULL, DLLNAME, FONT_UNDERLINE_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_FONT_UNDERLINE)); + DBWriteContactSettingByte(NULL, DLLNAME, UPDATE_ONALERT_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_UPDATE_ONALERT)); + DBWriteContactSettingByte(NULL, DLLNAME, SAVE_INDIVID_POS_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_SAVE_INDIVID_POS)); + DBWriteContactSettingByte(NULL, DLLNAME, NO_PROTECT_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_NO_PROTECT)); + DBWriteContactSettingByte(NULL, DLLNAME, DATA_POPUP_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_DATAPOPUP)); + + GetDlgItemText(hwndDlg, IDC_TYPEFACE, str, sizeof(str)); + DBWriteContactSettingString(NULL, DLLNAME, FONT_FACE_KEY, str); + // + DBWriteContactSettingByte(NULL, DLLNAME, FONT_SIZE_KEY, (GetDlgItemInt(hwndDlg, IDC_FONTSIZE, NULL, FALSE))); + DBWriteContactSettingByte(NULL, DLLNAME, FONT_SCRIPT_KEY, ((BYTE) SendDlgItemMessage(hwndDlg, IDC_SCRIPT, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_SCRIPT, CB_GETCURSEL, 0, 0), 0))); + // + DBWriteContactSettingByte(NULL, DLLNAME, ERROR_POPUP_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_ERROR_POPUP)); + + timerval = GetDlgItemInt(hwndDlg, IDC_TIME, NULL, FALSE); + DBWriteContactSettingDword(NULL, DLLNAME, REFRESH_KEY, timerval); + DBWriteContactSettingDword(NULL, DLLNAME, COUNTDOWN_KEY, timerval); + + + delaytime = GetDlgItemInt(hwndDlg, IDC_START_DELAY, NULL, FALSE); + DBWriteContactSettingDword(NULL, DLLNAME, START_DELAY_KEY, delaytime); + + BackgoundClr = (SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_GETCOLOUR, 0, 0)); + TextClr = (SendDlgItemMessage(hwndDlg, IDC_TXTCOLOR, CPM_GETCOLOUR, 0, 0)); + + if ((DBGetContactSettingDword(NULL, DLLNAME, REFRESH_KEY, 0) != 0)) + { + KillTimer(NULL, timerId); + KillTimer(NULL, Countdown); + timerId = SetTimer(NULL, 0, ((DBGetContactSettingDword(NULL, DLLNAME, REFRESH_KEY, 0)) * MINUTE), (TIMERPROC) timerfunc); + Countdown = SetTimer(NULL, 0, MINUTE, (TIMERPROC) Countdownfunc); + } + if ((DBGetContactSettingDword(NULL, DLLNAME, REFRESH_KEY, 0) == 0)) + { + KillTimer(NULL, timerId); + KillTimer(NULL, Countdown); + } + test = 0; + } + break; // end apply + + } + break; // end notify + + default: + break; + } + + return 0; +} +/********************/ diff --git a/plugins/!NotAdopted/WebView/webview_private.h b/plugins/!NotAdopted/WebView/webview_private.h new file mode 100644 index 0000000000..e57fcf9f45 --- /dev/null +++ b/plugins/!NotAdopted/WebView/webview_private.h @@ -0,0 +1,23 @@ +/* THIS FILE WILL BE OVERWRITTEN BY DEV-C++ */ +/* DO NOT EDIT ! */ + +#ifndef WEBVIEW_PRIVATE_H +#define WEBVIEW_PRIVATE_H + +/* VERSION DEFINITIONS */ +#define VER_STRING "0.1.3.10" +#define VER_MAJOR 0 +#define VER_MINOR 1 +#define VER_RELEASE 3 +#define VER_BUILD 10 +#define COMPANY_NAME "" +#define FILE_VERSION "0.1.3.10" +#define FILE_DESCRIPTION "Webview protocol plugin for Miranda IM" +#define INTERNAL_NAME "" +#define LEGAL_COPYRIGHT "" +#define LEGAL_TRADEMARKS "" +#define ORIGINAL_FILENAME "" +#define PRODUCT_NAME "" +#define PRODUCT_VERSION "" + +#endif /*WEBVIEW_PRIVATE_H*/ diff --git a/plugins/!NotAdopted/WebView/webview_services.c b/plugins/!NotAdopted/WebView/webview_services.c new file mode 100644 index 0000000000..8436441ec2 --- /dev/null +++ b/plugins/!NotAdopted/WebView/webview_services.c @@ -0,0 +1,770 @@ +/* + * A plugin for Miranda IM which displays web page text in a window Copyright + * (C) 2005 Vincent Joyce. + * + * Miranda IM: the free icq client for MS Windows Copyright (C) 2000-2 + * Richard Hughes, Roland Rabien & Tristan Van de Vreede + * + * 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. + */ + +static int searchId = -1; +static char sID[32]; + +/************************/ +static int DBSettingChanged(WPARAM wParam, LPARAM lParam) +{ + + DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *) lParam; + char *invalidchar; + + // We can't upload changes to NULL contact + if ((HANDLE) wParam == NULL) + return 0; + + if (!strcmp(cws->szModule, "CList")) + { + HANDLE hContact; + DBVARIANT dbv; + char *szProto; + FILE *pcachefile; + char cachepath[MAX_PATH]; + + char cachedirectorypath[MAX_PATH]; + + char newcachepath[MAX_PATH + 50]; + char renamedcachepath[MAX_PATH + 50]; + char *cacheend; + char OLDcontactname[100]; + char NEWcontactname[100]; + int ranNum; + char ranStr[7]; + int invalidpresent = 0; + + + hContact = (HANDLE) wParam; + szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + if (szProto == NULL || strcmp(szProto, DLLNAME)) + return 0; + + // A contact is renamed + if (!strcmp(cws->szSetting, "MyHandle")) + { + hContact = (HANDLE) wParam; + szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + if (szProto == NULL || strcmp(szProto, DLLNAME)) + return 0; +/////// + if (!DBGetContactSetting(hContact, DLLNAME, PRESERVE_NAME_KEY, &dbv)) + { + char nick[100]; + + ZeroMemory(&OLDcontactname, sizeof(OLDcontactname)); + ZeroMemory(&NEWcontactname, sizeof(NEWcontactname)); + + DBFreeVariant(&dbv); + + ZeroMemory(&nick, sizeof(nick)); + + DBGetContactSetting(hContact, "CList", "MyHandle", &dbv); + _snprintf(nick, sizeof(nick), "%s", dbv.pszVal); + DBFreeVariant(&dbv); + + DBGetContactSetting((HANDLE) wParam, DLLNAME, PRESERVE_NAME_KEY, &dbv); + _snprintf(OLDcontactname, sizeof(OLDcontactname), "%s", dbv.pszVal); + DBFreeVariant(&dbv); + + if (strchr(nick, '\\') != NULL) + { + WErrorPopup("ERROR", Translate("Invalid symbol present in contact name.")); + invalidchar = strchr(nick, '\\'); + *invalidchar = '_'; + invalidpresent =1; + } + + if (strchr(nick, '/') != NULL) + { + WErrorPopup("ERROR", Translate("Invalid symbol present in contact name.")); + invalidchar = strchr(nick, '/'); + *invalidchar = '_'; + invalidpresent =1; + } + + if (strchr(nick, ':') != NULL) + { + WErrorPopup("ERROR", Translate("Invalid symbol present in contact name.")); + invalidchar = strchr(nick, ':'); + *invalidchar = '_'; + invalidpresent =1; + } + + if (strchr(nick, '*') != NULL) + { + WErrorPopup("ERROR", Translate("Invalid symbol present in contact name.")); + invalidchar = strchr(nick, '*'); + *invalidchar = '_'; + invalidpresent =1; + } + + if (strchr(nick, '?') != NULL) + { + WErrorPopup("ERROR", Translate("Invalid symbol present in contact name.")); + invalidchar = strchr(nick, '?'); + *invalidchar = '_'; + invalidpresent =1; + } + + if (strchr(nick, '\"') != NULL) + { + WErrorPopup("ERROR", Translate("Invalid symbol present in contact name.")); + invalidchar = strchr(nick, '\"'); + *invalidchar = '_'; + invalidpresent =1; + } + + if (strchr(nick, '<') != NULL) + { + WErrorPopup("ERROR", Translate("Invalid symbol present in contact name.")); + invalidchar = strchr(nick, '<'); + *invalidchar = '_'; + invalidpresent =1; + } + + if (strchr(nick, '>') != NULL) + { + WErrorPopup("ERROR", Translate("Invalid symbol present in contact name.")); + invalidchar = strchr(nick, '>'); + *invalidchar = '_'; + invalidpresent =1; + } + + if (strchr(nick, '|') != NULL) + { + WErrorPopup("ERROR", Translate("Invalid symbol present in contact name.")); + invalidchar = strchr(nick, '|'); + *invalidchar = '_'; + invalidpresent =1; + } + + if(invalidpresent) + { + srand((unsigned) time(NULL)); + ranNum = (int) 10000 *rand() / (RAND_MAX + 1.0); + _snprintf(ranStr, sizeof(ranStr), "%d", ranNum); + strcat(nick, ranStr); + } + + + + if (((strchr(nick, '(')) == 0)) + { + DBWriteContactSettingString(hContact, DLLNAME, PRESERVE_NAME_KEY, nick); + DBWriteContactSettingString(hContact, DLLNAME, "Nick", nick); + DBWriteContactSettingString(hContact, "CList", "MyHandle", nick); + } + DBGetContactSetting((HANDLE) wParam, DLLNAME, PRESERVE_NAME_KEY, &dbv); + _snprintf(NEWcontactname, sizeof(NEWcontactname), "%s", dbv.pszVal); + DBFreeVariant(&dbv); + +// + + // TEST GET NAME FOR CACHE + GetModuleFileName(hInst, cachepath, sizeof(cachepath)); + cacheend = strrchr(cachepath, '\\'); + cacheend++; + *cacheend = '\0'; + _snprintf(cachedirectorypath, sizeof(cachedirectorypath), "%s%s%s", cachepath, DLLNAME, "cache\\"); + CreateDirectory(cachedirectorypath, NULL); + + + + _snprintf(newcachepath, sizeof(newcachepath), "%s%s%s%s%s", cachepath, DLLNAME, "cache\\", OLDcontactname, ".txt"); + _snprintf(renamedcachepath, sizeof(newcachepath), "%s%s%s%s%s", cachepath, DLLNAME, "cache\\", NEWcontactname, ".txt"); + + + + // file exists? + if ((_access(newcachepath, 0)) != -1) + { + if ((pcachefile = fopen(newcachepath, "r")) != NULL) + { + fclose(pcachefile); + if (lstrcmp(newcachepath, renamedcachepath)) + { + MoveFile(newcachepath, renamedcachepath); + DBWriteContactSettingString(hContact, DLLNAME, CACHE_FILE_KEY, renamedcachepath); + } + + } + } +// + + } +//////// + } + } + return 0; +} +/************************/ + +/************************/ +int SiteDeleted(WPARAM wParam, LPARAM lParam) +{ + FILE *pcachefile; + char cachepath[MAX_PATH]; + char cachedirectorypath[MAX_PATH]; + char newcachepath[MAX_PATH + 50]; + char *cacheend; + char contactname[100]; + DBVARIANT dbv; + + ZeroMemory(&contactname, sizeof(contactname)); + ZeroMemory(&dbv, sizeof(dbv)); + + if (lstrcmp((char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0), DLLNAME)) + return 0; + + DBGetContactSetting((HANDLE) wParam, DLLNAME, PRESERVE_NAME_KEY, &dbv); + _snprintf(contactname, sizeof(contactname), "%s", dbv.pszVal); + DBFreeVariant(&dbv); + + // TEST GET NAME FOR CACHE + GetModuleFileName(hInst, cachepath, sizeof(cachepath)); + cacheend = strrchr(cachepath, '\\'); + cacheend++; + *cacheend = '\0'; + + _snprintf(cachedirectorypath, sizeof(cachedirectorypath), "%s%s%s", cachepath, DLLNAME, "cache\\"); + CreateDirectory(cachedirectorypath, NULL); + _snprintf(newcachepath, sizeof(newcachepath), "%s%s%s%s%s", cachepath, DLLNAME, "cache\\", contactname, ".txt"); + // file exists? + if ((_access(newcachepath, 0)) != -1) + { + if ((pcachefile = fopen(newcachepath, "r")) != NULL) + { + fclose(pcachefile); + DeleteFile(newcachepath); + DBWriteContactSettingString((HANDLE) wParam, DLLNAME, CACHE_FILE_KEY, ""); + } + } + return 0; +} +/************************/ + +/************************/ +static int OpenCacheDir(WPARAM wParam, LPARAM lParam) +{ + char cachepath[MAX_PATH]; + char cachedirectorypath[MAX_PATH]; + char *cacheend; + DIR *pdir = NULL; + + + //GET NAME FOR CACHE + GetModuleFileName(hInst, cachepath, sizeof(cachepath)); + cacheend = strrchr(cachepath, '\\'); + cacheend++; + *cacheend = '\0'; + + _snprintf(cachedirectorypath, sizeof(cachedirectorypath), "%s%s%s%s", cachepath, DLLNAME, "cache\\", cacheend); + + if((pdir = opendir(cachedirectorypath)) == NULL) + { + WErrorPopup("ERROR", Translate("Cache folder does not exist.")); + return 0; + } + + ShellExecute(NULL, "open", cachedirectorypath, NULL, NULL, SW_SHOWNORMAL); + + return 0; +} +/************************/ +/************************/ +static int PingWebsiteMenuCommand(WPARAM wParam, LPARAM lParam) +{ + DBVARIANT dbv; + char url[300]; + static char *Newnick; + static char *Oldnick; + char *Nend; + char Cnick[255]; + FILE *pfile = NULL; + + if ((pfile = fopen("psite.bat", "r")) == NULL) + { + WErrorPopup("ERROR", Translate("Missing \"psite.bat\" file.")); + return 0; + } + + ZeroMemory(&Cnick, sizeof(Cnick)); + ZeroMemory(&url, sizeof(url)); + + DBGetContactSetting((HANDLE) wParam, DLLNAME, "URL", &dbv); + wsprintf(url, "%s", dbv.pszVal); + DBFreeVariant(&dbv); + + strncpy(Cnick, url, sizeof(Cnick)); + Oldnick = strdup(Cnick); + + /**/ + if ((strstr(Cnick, "://")) != 0) + { + Oldnick = strstr(Cnick, "://"); + Oldnick = Oldnick + 3; + } else if ((strstr(Cnick, "://")) == 0) + { + strcpy(Oldnick, Cnick); + } + + Newnick = strdup(Oldnick); + if (strchr(Newnick, '/')) + { + Nend = strchr(Newnick, '/'); + *Nend = '\0'; + } + + //MessageBox(NULL, Newnick, DLLNAME, MB_OK); + + ShellExecute(NULL, "open", "psite.bat", Newnick, NULL, SW_HIDE); + + + return 0; +} +/************************/ + + +/************************/ +static int StpPrcssMenuCommand(WPARAM wParam, LPARAM lParam) +{ + DBVARIANT dbv; + + DBWriteContactSettingByte((HANDLE) wParam, DLLNAME, STOP_KEY, 1); + + return 0; +} +/************************/ + + + +//======================================================= +// GetCaps +// ======================================================= + +int GetCaps(WPARAM wParam, LPARAM lParam) +{ + int ret = 0; + + if (wParam == PFLAGNUM_1) + ret = PF1_BASICSEARCH | PF1_ADDSEARCHRES | PF1_VISLIST; + + if (wParam == PFLAGNUM_2) + { + if (!(DBGetContactSettingByte(NULL, DLLNAME, HIDE_STATUS_ICON_KEY, 0))) + return PF2_ONLINE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND; // add + // the + // possible + // statuses here + + } + if (wParam == PFLAG_UNIQUEIDTEXT) + ret = (int) Translate("Site URL"); + + if (wParam == PFLAGNUM_3) + ret = 0; + + + if (wParam == PFLAGNUM_5) + ret = PF2_INVISIBLE|PF2_SHORTAWAY|PF2_LONGAWAY|PF2_LIGHTDND|PF2_HEAVYDND|PF2_FREECHAT| + PF2_OUTTOLUNCH|PF2_ONTHEPHONE; + + if (wParam == PFLAG_UNIQUEIDSETTING) + ret = (int) "PreserveName"; + + return ret; +} + +//======================================================= +// ======================================================= +// GetName +// ======================================================= +int GetName(WPARAM wParam, LPARAM lParam) +{ + lstrcpyn((char *) lParam, DLLNAME, wParam); + return 0; +} +//======================================================= +// SetStatus +// ======================================================= +int SetStatus(WPARAM wParam, LPARAM lParam) +{ + int oldStatus; + DBVARIANT dbv; + + oldStatus = bpStatus; + char *szProto; + HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + + if (wParam == ID_STATUS_ONLINE) + { + wParam = ID_STATUS_ONLINE; + } else if (wParam == ID_STATUS_OFFLINE) + { + wParam = ID_STATUS_OFFLINE; + } else + { + wParam = ID_STATUS_ONLINE; + } + // broadcast the message + bpStatus = wParam; + + ProtoBroadcastAck(DLLNAME, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE) oldStatus, wParam); + + /**/ + // Make sure no contact has offline status for any reason on first time + // run + if (DBGetContactSetting(NULL, DLLNAME, "FirstTime", &dbv)) + { + while (hContact) + { + szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + if (szProto != NULL && !lstrcmp(DLLNAME, szProto)) + { + DBWriteContactSettingWord(hContact, DLLNAME, "Status", ID_STATUS_ONLINE); + } + hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0); + } + if (DBGetContactSetting(NULL, DLLNAME, "FirstTime", &dbv)) + DBWriteContactSettingByte(NULL, DLLNAME, "FirstTime", 1); + } + DBFreeVariant(&dbv); + /**/ + + if (bpStatus == ID_STATUS_OFFLINE) + DBWriteContactSettingByte(NULL, DLLNAME, OFFLINE_STATUS, 1); + else + DBWriteContactSettingByte(NULL, DLLNAME, OFFLINE_STATUS, 0); + + return 0; +} +//======================================================= +// GetStatus +// ======================================================= + +int GetStatus(WPARAM wParam, LPARAM lParam) +{ + + if (bpStatus == ID_STATUS_ONLINE) + return ID_STATUS_ONLINE; + else if (bpStatus == ID_STATUS_AWAY) + return ID_STATUS_AWAY; + else if (bpStatus == ID_STATUS_NA) + return ID_STATUS_NA; + else if (bpStatus == ID_STATUS_OCCUPIED) + return ID_STATUS_OCCUPIED; + else if (bpStatus == ID_STATUS_DND) + return ID_STATUS_DND; + else + return ID_STATUS_OFFLINE; + +} + +//======================================================= +// BPLoadIcon +// ======================================================= + +int BPLoadIcon(WPARAM wParam, LPARAM lParam) +{ + UINT id; + + switch (wParam & 0xFFFF) + { + case PLI_PROTOCOL: + id = IDI_SITE; + break; + default: + return (int) (HICON) NULL; + } + return (int) LoadImage(hInst, MAKEINTRESOURCE(id), IMAGE_ICON, GetSystemMetrics(wParam & PLIF_SMALL ? SM_CXSMICON : SM_CXICON), GetSystemMetrics(wParam & PLIF_SMALL ? SM_CYSMICON : SM_CYICON), 0); +} + +/*******************/ +static void __cdecl BasicSearchTimerProc(void *pszNick) +{ + PROTOSEARCHRESULT psr; + + ZeroMemory(&psr, sizeof(psr)); + psr.cbSize = sizeof(psr); + psr.nick = (char *) pszNick; + // + + // broadcast the search result + ProtoBroadcastAck(DLLNAME, NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE) 1, (LPARAM) & psr); + ProtoBroadcastAck(DLLNAME, NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE) 1, 0); + + // exit the search + searchId = -1; +} + +/*******************/ + +/*******************/ +int BasicSearch(WPARAM wParam, LPARAM lParam) +{ + static char buf[300]; + + + if (lParam) + lstrcpyn(buf, (const char *) lParam, 256); + // + + if (searchId != -1) + return 0; // only one search at a time + + lstrcpyn(sID, (char *) lParam, sizeof(sID)); + searchId = 1; + // create a thread for the ID search + forkthread(BasicSearchTimerProc, 0, &buf); + + return searchId; +} +/*******************/ + +/*******************/ +int AddToList(WPARAM wParam, LPARAM lParam) +{ + PROTOSEARCHRESULT *psr = (PROTOSEARCHRESULT *) lParam; + DBVARIANT dbv; + static char *Newnick; + static char *Oldnick; + char *Nend; + char Cnick[255]; + int sameurl = 0; + int samename = 0; + + + ZeroMemory(&Cnick, sizeof(Cnick)); + + + // search for existing contact + HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + HANDLE hContact2 = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + char *szProto; + + + + + + while (hContact != NULL) + { + szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + // check if it is a webview contact + if (szProto != NULL && !lstrcmp(DLLNAME, szProto)) + { + // check ID to see if the contact already exist in the database + + if (!DBGetContactSetting(hContact, DLLNAME, "URL", &dbv)) + { + if (!lstrcmpi(psr->nick, dbv.pszVal)) + { + // remove the flag for not on list and hidden, thus make the + // contact visible + // and add them on the list + sameurl++; + if (DBGetContactSettingByte(hContact, "CList", "NotOnList", 1)) + { + DBDeleteContactSetting(hContact, "CList", "NotOnList"); + DBDeleteContactSetting(hContact, "CList", "Hidden"); + } + DBFreeVariant(&dbv); + } + } + DBFreeVariant(&dbv); + + } + hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0); + } + + + + if (psr->nick == NULL) + { + WErrorPopup("ERROR", Translate("Please select site in Find/Add Contacts...")); + return; + } + + // if contact with the same ID was not found, add it + if (psr->cbSize != sizeof(PROTOSEARCHRESULT)) + return (int) (HANDLE) NULL; + hContact = (HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0); + CallService(MS_PROTO_ADDTOCONTACT, (WPARAM) hContact, (LPARAM) DLLNAME); + + +/////////write to db + DBWriteContactSettingByte(hContact, DLLNAME, ON_TOP_KEY, 0); + DBWriteContactSettingByte(hContact, DLLNAME, DBLE_WIN_KEY, 1); + DBWriteContactSettingString(hContact, DLLNAME, END_STRING_KEY, ""); + DBWriteContactSettingByte(hContact, DLLNAME, RWSPACE_KEY, 1); + + + + +//Convert url into a name for contact +/// + if (psr->nick != NULL) + strncpy(Cnick, psr->nick, sizeof(Cnick));// this crashes +/// + + Oldnick = strdup(Cnick); + + + /**/ + if ((strstr(Cnick, "://")) != 0) + { + Oldnick = strstr(Cnick, "://"); + Oldnick = Oldnick + 3; + + } else if ((strstr(Cnick, "://")) == 0) + { + strcpy(Oldnick, Cnick); + + } + if ((strstr(Oldnick, "www.")) != 0) + { + Newnick = strstr(Oldnick, "www."); + Newnick = Newnick + 4; + Nend = strchr(Newnick, '.'); + *Nend = '\0'; + + } else if ((strstr(Oldnick, "WWW.")) != 0) + { + Newnick = strstr(Oldnick, "WWW."); + Newnick = Newnick + 4; + Nend = strchr(Newnick, '.'); + *Nend = '\0'; + + } else + { + + Newnick = strdup(Oldnick); + if (strchr(Newnick, '.')) + { + Nend = strchr(Newnick, '.'); + *Nend = '\0'; + + } + } + + + while (hContact2 != NULL) + { + szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact2, 0); + // check if it is a webview contact + if (szProto != NULL && !lstrcmp(DLLNAME, szProto)) + { + // check ID to see if the contact already exist in the database + + + + if (!DBGetContactSetting(hContact2, DLLNAME, PRESERVE_NAME_KEY, &dbv)) + { + if (!lstrcmpi(Newnick, dbv.pszVal)) + { + // remove the flag for not on list and hidden, thus make the + // contact visible + // and add them on the list + samename++; + if (DBGetContactSettingByte(hContact2, "CList", "NotOnList", 1)) + { + DBDeleteContactSetting(hContact2, "CList", "NotOnList"); + DBDeleteContactSetting(hContact2, "CList", "Hidden"); + } + DBFreeVariant(&dbv); + } + } + DBFreeVariant(&dbv); + + } + hContact2 = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact2, 0); + } + + + + if ((sameurl > 0) || (samename > 0)) // contact has the same url or name as another contact, add rand + // num to name + + { + int ranNum; + char ranStr[7]; + + srand((unsigned) time(NULL)); + + ranNum = (int) 10000 *rand() / (RAND_MAX + 1.0); + + _snprintf(ranStr, sizeof(ranStr), "%d", ranNum); + strcat(Newnick, ranStr); + } +//end convert + + DBWriteContactSettingString(hContact, "CList", "MyHandle", Newnick); + DBWriteContactSettingString(hContact, DLLNAME, PRESERVE_NAME_KEY, Newnick); + DBWriteContactSettingString(hContact, DLLNAME, "Nick", Newnick); + DBWriteContactSettingByte(hContact, DLLNAME, CLEAR_DISPLAY_KEY, 1); + DBWriteContactSettingString(hContact, DLLNAME, START_STRING_KEY, ""); + DBWriteContactSettingString(hContact, DLLNAME, URL_KEY, psr->nick); + DBWriteContactSettingString(hContact, DLLNAME, "Homepage", psr->nick); + DBWriteContactSettingByte(hContact, DLLNAME, U_ALLSITE_KEY, 1); + DBWriteContactSettingWord(hContact, DLLNAME, "Status", ID_STATUS_ONLINE); +//////////////////////// + + + + // ignore status change + DBWriteContactSettingDword(hContact, "Ignore", "Mask", 8); + + Sleep(2); + + DBFreeVariant(&dbv); + + + return (int) hContact; +} +/*******************/ + +/*******************/ +int GetInfo(WPARAM wParam, LPARAM lParam) +{ + forkthread(AckFunc, 0, NULL); + return 1; +} +/*******************/ +/*******************/ +void AckFunc(void *dummy) +{ + HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + char *szProto; + + while (hContact != NULL) + { + szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + // + if (szProto != NULL && !lstrcmp(DLLNAME, szProto)) + ProtoBroadcastAck(DLLNAME, hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE) 1, 0); + // + hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0); + } + +} +/*******************/ + -- cgit v1.2.3