diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2012-07-02 08:36:04 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2012-07-02 08:36:04 +0000 |
commit | 960bb20ccd3c375bcfc8b642fcbe89feaf143b22 (patch) | |
tree | 4fb859975861780dfc932e19513d9efd139924b1 | |
parent | 61930b2a3c3fcbd8f40284ac77902806b2b3b493 (diff) |
only add PasteIt, not adapted
git-svn-id: http://svn.miranda-ng.org/main/trunk@712 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
25 files changed, 4233 insertions, 0 deletions
diff --git a/plugins/PasteIt/Docs/PasteIt_langpack_polish.txt b/plugins/PasteIt/Docs/PasteIt_langpack_polish.txt new file mode 100644 index 0000000000..43342a5dfc --- /dev/null +++ b/plugins/PasteIt/Docs/PasteIt_langpack_polish.txt @@ -0,0 +1,94 @@ +;Paste It
+;==========
+
+;To jest tylko częściowe tłumaczenie
+;Należy go dodać do końca pliku langpack_polish.txt
+
+;Main
+;------
+[Paste It]
+Wklej To
+[Uploads the text to web page and sends the URL to your friends.]
+Umieszcza tekst na stronie www i wysyła link do twoich przyjaciół.
+[Paste It - Select file]
+Wklej To - Wybierz plik
+[Paste It HTTP connections]
+Wklej To połączenia HTTP
+
+;Error messages
+;----------------
+[You've entered invalid codepage. Select codepage from combo box or enter correct number.]
+Wprowadziłeś nieprawidłową stronę kodową. Wybierz ją z combo boxa lub wprowadź poprawną liczbę.
+[Invalid codepage]
+Nieprawidłowa strona kodowa
+[You can only paste 1 file]
+Możesz wkleić tylko 1 plik
+[Cannot get data from clipboard]
+Nie można pobrać danych ze schowka
+[File size is %dKB, do you realy want to paste such large file?]
+Rozmiar pliku wynosi %dKB, napewno chcesz wkleić tak duży plik?
+[Cannot read file '%s']
+Nie można wczytać pliku '%s'
+[File size is larger then 10MB, cannot be send]
+Rozmiar pliku jest większy niż 10MB, nie może zostać wysłany
+[Cannot open file '%s']
+Nie można otworzyć pliku '%s'
+[File '%s' is empty]
+Plik '%s' jest pusty
+[Error during sending text to web page: %s]
+Błąd podczas wysyłania tekstu do strony www: %s
+[Error during sending text to web page]
+Błąd podczas wysyłania tekstu do strony www
+[Error during getting user key from web page: %s]
+Błąd podczas pobierania klucza użytkownika ze strony www: %s
+
+;Options and Menus
+;-------------------
+[Paste from clipboard]
+Wklej ze schowka
+[Paste from file]
+Wklej z pliku
+[Default web page]
+Domyślna strona www
+[Default file encoding]
+Domyślne kodowanie pliku
+[Auto-detect UTF-8]
+Auto-wykrywanie UTF-8
+[Show confirmation dialog box]
+Pokaż okno potwierdzenia
+[Web page settings]
+Ustawienia strony www
+[Web page to configure]
+Strona www do konfiguracji
+[Default formatting]
+Domyślne formatowanie
+[Auto-detect format from file extension]
+Auto-wykrywanie formatu z rozszerzenia pliku
+[Public paste]
+Publiczna wklejka
+[Paste expire date]
+Data ważności wklejki
+[Login as guest]
+Zaloguj się jako gość
+[User key]
+Klucz użytkownika
+[Get user key]
+Pobierz klucz
+[Configure formatting]
+Konfiguruj formatowanie
+[Download more]
+Pobierz więcej
+[Login to pastebin.com]
+Logowanie do pastebin.com
+[Encoding]
+Kodowanie
+[Recode]
+Zmień kodowanie
+[10 minutes]
+10 munut
+[1 hour]
+1 godzina
+[1 day]
+1 dzień
+[1 month]
+1 miesiąc
diff --git a/plugins/PasteIt/Docs/PasteIt_licence.txt b/plugins/PasteIt/Docs/PasteIt_licence.txt new file mode 100644 index 0000000000..7f1161073d --- /dev/null +++ b/plugins/PasteIt/Docs/PasteIt_licence.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/PasteIt/Docs/PasteIt_readme.txt b/plugins/PasteIt/Docs/PasteIt_readme.txt new file mode 100644 index 0000000000..86f9f0c468 --- /dev/null +++ b/plugins/PasteIt/Docs/PasteIt_readme.txt @@ -0,0 +1,49 @@ +********
+Paste It
+********
+
+Description
+===========
+Plugin uploads the text to web page and sends the URL to your friend.
+
+Main features
+=============
+- pastebin.com and wklej.to support
+- paste text from clipboard
+- paste file from clipboard
+- choosing file using file dialog
+- ability to set correct file encoding
+
+!!! Requirements !!!
+====================
+Microsoft Visual C++ 2010 Redistributable Package
+
+Changelog
+=========
+
+--- 1.0.0.3 ---
+* fixed bad decoding characters from clipboard
+
+--- 1.0.0.2 ---
+* increased size of few labels in options
+
+--- 1.0.0.1 ---
+* support chat rooms
+* fixed mispelling
+* fixed bad decoding characters from clipboard
+* increased size of few labels in options
+
+--- 1.0.0.0 ---
++ pastebin.com and wklej.to support
++ paste text from clipboard
++ paste file from clipboard
++ choosing file using file dialog
++ ability to set correct file encoding
+
+Author
+======
+Krzysztof Kral
+
+email: programista@poczta.of.pl
+www: http://programista.free.of.pl/miranda/
+svn: http://svn3.xp-dev.com/svn/PasteIt/
diff --git a/plugins/PasteIt/Docs/PasteIt_translate.txt b/plugins/PasteIt/Docs/PasteIt_translate.txt new file mode 100644 index 0000000000..02470cc6ff --- /dev/null +++ b/plugins/PasteIt/Docs/PasteIt_translate.txt @@ -0,0 +1,94 @@ +;Paste It
+;==========
+
+;Main
+;------
+[Paste It]
+[Uploads the text to web page and sends the URL to your friends.]
+[All Files (*.*)]
+[Paste It - Select file]
+[Paste It HTTP connections]
+
+;Codepages
+;-----------
+[Use default codepage]
+[UTF-8]
+[Thai]
+[Japanese]
+[Simplified Chinese]
+[Korean]
+[Traditional Chinese]
+[Central European]
+[Cyrillic]
+[Cyrillic KOI8-R]
+[Latin I]
+[Greek]
+[Turkish]
+[Hebrew]
+[Arabic]
+[Baltic]
+[Vietnamese]
+[Korean (Johab)]
+[UTF-7]
+[UTF-16]
+[UTF-16BE]
+
+;Error messages
+;----------------
+[Error]
+[You've entered invalid codepage. Select codepage from combo box or enter correct number.]
+[Invalid codepage]
+[You can only paste 1 file]
+[Cannot get data from clipboard]
+[File size is %dKB, do you realy want to paste such large file?]
+[Are You sure?]
+[Cannot read file '%s']
+[File size is larger then 10MB, cannot be send]
+[Cannot open file '%s']
+[File '%s' is empty]
+[Error during sending text to web page: %s]
+[Error during sending text to web page]
+[Error during getting user key from web page: %s]
+
+;Options and Menus
+;-------------------
+[Paste from clipboard]
+[Paste from file]
+[Default web page]
+[Services]
+[Main]
+[Web page]
+[Settings]
+[Default file encoding]
+[Auto-detect UTF-8]
+[Show confirmation dialog box]
+[Autosend download link to contact]
+[Web page settings]
+[Web page to configure]
+[Configure]
+[Default formatting]
+[Auto-detect format from file extension]
+[Public paste]
+[Paste expire date]
+[Login as guest]
+[User key]
+[Get user key]
+[Configure formatting]
+[OK]
+[Cancel]
+[Up]
+[Down]
+[Delete]
+[Restore defaults]
+[Download more]
+[Login to pastebin.com]
+[User name]
+[Password]
+[Format]
+[Encoding]
+[Recode]
+[Never]
+[10 minutes]
+[1 hour]
+[1 day]
+[1 month]
diff --git a/plugins/PasteIt/Options.cpp b/plugins/PasteIt/Options.cpp new file mode 100644 index 0000000000..799bc27e54 --- /dev/null +++ b/plugins/PasteIt/Options.cpp @@ -0,0 +1,979 @@ +/*
+Paste It plugin
+Copyright (C) 2011 Krzysztof Kral
+
+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 version 2
+of the License.
+
+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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "StdAfx.h"
+#include "Options.h"
+#include "resource.h"
+#include "PasteToWeb.h"
+#include "PasteToWeb1.h"
+
+extern HINSTANCE hInst;
+
+#define MODULE "PasteIt"
+
+Options *Options::instance;
+extern PasteToWeb* pasteToWebs[PasteToWeb::pages];
+
+struct TCpTable {
+ UINT cpId;
+ TCHAR *cpName;
+}
+cpTable[] = {
+ { CP_ACP, _T("Use default codepage") },
+ { CP_UTF8, _T("UTF-8") },
+ { 874, _T("Thai") },
+ { 932, _T("Japanese") },
+ { 936, _T("Simplified Chinese") },
+ { 949, _T("Korean") },
+ { 950, _T("Traditional Chinese") },
+ { 1250, _T("Central European") },
+ { 1251, _T("Cyrillic") },
+ { 20866, _T("Cyrillic KOI8-R") },
+ { 1252, _T("Latin I") },
+ { 1253, _T("Greek") },
+ { 1254, _T("Turkish") },
+ { 1255, _T("Hebrew") },
+ { 1256, _T("Arabic") },
+ { 1257, _T("Baltic") },
+ { 1258, _T("Vietnamese") },
+ { 1361, _T("Korean (Johab)") },
+ { CP_UTF7, _T("UTF-7") },
+ { 1200, _T("UTF-16") },
+ { 1201, _T("UTF-16BE") }
+};
+
+Options::Options()
+{
+ defWeb = 0;
+ codepage = CP_ACP;
+ autoUTF = true;
+ confDlg = true;
+ autoSend = false;
+ for(int i = 0 ; i < PasteToWeb::pages; ++i)
+ {
+ webOptions[i] = new WebOptions(i);
+ }
+}
+
+
+Options::~Options()
+{
+ for(int i = 0 ; i < PasteToWeb::pages; ++i)
+ {
+ delete webOptions[i];
+ webOptions[i] = NULL;
+ }
+}
+
+void DefWebPageChanged();
+
+INT_PTR CALLBACK Options::DlgProcOptsMain(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg)
+ {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwndDlg);
+ CheckDlgButton(hwndDlg, IDC_AUTOUTF, instance->autoUTF ? 1 : 0);
+ CheckDlgButton(hwndDlg, IDC_CONFDLG, instance->confDlg ? 1 : 0);
+ CheckDlgButton(hwndDlg, IDC_AUTOSEND, instance->autoSend ? 1 : 0);
+
+ for(int i = 0; i < PasteToWeb::pages; ++i)
+ {
+ ComboBox_AddString(GetDlgItem(hwndDlg, IDC_WEBLIST), pasteToWebs[i]->GetName());
+ }
+
+ ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_WEBLIST), instance->defWeb);
+
+ InitCodepageCB(GetDlgItem(hwndDlg, IDC_CODEPAGE), instance->codepage);
+ return TRUE;
+ }
+ case WM_COMMAND:
+ {
+ if(LOWORD(wParam) == IDC_CODEPAGE)
+ {
+ if(HIWORD(wParam) == CBN_KILLFOCUS)
+ {
+ GetCodepageCB(GetDlgItem(hwndDlg, IDC_CODEPAGE), true, instance->codepage);
+ }
+ }
+
+ if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam)==CBN_SELCHANGE || HIWORD(wParam)==CBN_EDITCHANGE)
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ return TRUE;
+ }
+ case WM_NOTIFY:
+ {
+ if(((LPNMHDR)lParam)->code == PSN_APPLY)
+ {
+ instance->codepage = GetCodepageCB(GetDlgItem(hwndDlg, IDC_CODEPAGE), false, instance->codepage);
+ instance->autoUTF = IsDlgButtonChecked(hwndDlg, IDC_AUTOUTF) ? true : false;
+ instance->confDlg = IsDlgButtonChecked(hwndDlg, IDC_CONFDLG) ? true : false;
+ instance->autoSend = IsDlgButtonChecked(hwndDlg, IDC_AUTOSEND) ? true : false;
+ instance->defWeb = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_WEBLIST));
+
+ DefWebPageChanged();
+
+ Options::instance->Save();
+ }
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+class OptsPagesData
+{
+public:
+ OptsPagesData()
+ : lastPage(0)
+ {
+ init = false;
+ for(int i = 0 ; i < PasteToWeb::pages; ++i)
+ {
+ webOptions[i] = Options::instance->webOptions[i]->Copy();
+ }
+ }
+
+ ~OptsPagesData()
+ {
+ for(int i = 0 ; i < PasteToWeb::pages; ++i)
+ {
+ delete webOptions[i];
+ webOptions[i] = NULL;
+ }
+ }
+
+ WebOptions* webOptions[PasteToWeb::pages];
+ int lastPage;
+ bool init;
+};
+
+struct OptsConfigureData
+{
+ int page;
+ std::list<PasteFormat> tempFormats;
+};
+
+struct OptsLoginData
+{
+ std::wstring user;
+ std::wstring password;
+};
+
+void ReloadFormatsCombo(HWND hWnd, WebOptions* wo)
+{
+ while(ComboBox_DeleteString(hWnd, 0) > 0);
+ int sel = 0;
+ int i = 0;
+ for(std::list<PasteFormat>::iterator it = wo->formats.begin(); it != wo->formats.end(); ++it)
+ {
+ ComboBox_AddString(hWnd, it->name.c_str());
+ if(it->id == wo->defFormatId)
+ sel = i;
+ ++i;
+ }
+ if(!wo->formats.empty())
+ {
+ ComboBox_SetCurSel(hWnd, sel);
+ }
+}
+
+void GetPagesSettings(HWND hwndDlg, OptsPagesData* optsPagesData)
+{
+ int selected = optsPagesData->lastPage;
+ int format = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_DEFFORMAT));
+ if(format >= 0 && format < optsPagesData->webOptions[selected]->formats.size())
+ {
+ for(std::list<PasteFormat>::iterator it = optsPagesData->webOptions[selected]->formats.begin(); it != optsPagesData->webOptions[selected]->formats.end(); ++it)
+ {
+ if(format-- <= 0)
+ {
+ optsPagesData->webOptions[selected]->defFormatId = it->id;
+ break;
+ }
+ }
+ }
+
+ if(optsPagesData->webOptions[selected]->isSendFileName)
+ optsPagesData->webOptions[selected]->sendFileName = IsDlgButtonChecked(hwndDlg, IDC_AUTOFORMAT) ? true : false;
+ if(optsPagesData->webOptions[selected]->isPublicPaste)
+ optsPagesData->webOptions[selected]->publicPaste = IsDlgButtonChecked(hwndDlg, IDC_PUBLICPASTE) ? true : false;
+ if(optsPagesData->webOptions[selected]->isCombo1)
+ {
+ int sel = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_COMBO1));
+ if(sel >= 0 && sel < optsPagesData->webOptions[selected]->combo1Values.size())
+ {
+ for(std::list<PasteFormat>::iterator it = optsPagesData->webOptions[selected]->combo1Values.begin(); it != optsPagesData->webOptions[selected]->combo1Values.end(); ++it)
+ {
+ if(sel-- <= 0)
+ {
+ optsPagesData->webOptions[selected]->combo1 = it->id;
+ break;
+ }
+ }
+ }
+ }
+ if(optsPagesData->webOptions[selected]->isPublicPaste)
+ {
+ if(IsDlgButtonChecked(hwndDlg, IDC_GUEST))
+ {
+ optsPagesData->webOptions[selected]->pastebinUserKey = _T("");
+ }
+ else
+ {
+ TCHAR buf[100];
+ Edit_GetText(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), buf, 100);
+ optsPagesData->webOptions[selected]->pastebinUserKey = buf;
+ }
+ }
+}
+
+INT_PTR CALLBACK Options::DlgProcOptsPages(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg)
+ {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwndDlg);
+ OptsPagesData* optsPagesData = new OptsPagesData();
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)optsPagesData);
+
+ HWND btnhwnd = GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN);
+ int btSize = Button_GetTextLength(btnhwnd);
+ if(btSize > 20)
+ {
+ SetWindowPos(btnhwnd, NULL, 0, 0, 115, 34, SWP_NOZORDER | SWP_NOMOVE | SWP_NOREPOSITION | SWP_NOACTIVATE | SWP_NOREDRAW);
+ }
+
+ for(int i = 0; i < PasteToWeb::pages; ++i)
+ {
+ ComboBox_AddString(GetDlgItem(hwndDlg, IDC_WEBPAGE), pasteToWebs[i]->GetName());
+ }
+
+ ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_WEBPAGE), 0);
+ ReloadFormatsCombo(GetDlgItem(hwndDlg, IDC_DEFFORMAT), optsPagesData->webOptions[0]);
+ if(optsPagesData->webOptions[0]->isSendFileName)
+ CheckDlgButton(hwndDlg, IDC_AUTOFORMAT, optsPagesData->webOptions[0]->sendFileName ? 1 : 0);
+ else
+ ShowWindow(GetDlgItem(hwndDlg,IDC_AUTOFORMAT),SW_HIDE);
+
+ if(Options::instance->webOptions[0]->isPublicPaste)
+ CheckDlgButton(hwndDlg, IDC_PUBLICPASTE, Options::instance->webOptions[0]->publicPaste ? 1 : 0);
+ else
+ ShowWindow(GetDlgItem(hwndDlg,IDC_PUBLICPASTE),SW_HIDE);
+
+ if(Options::instance->webOptions[0]->isCombo1)
+ {
+ int sel = 0;
+ int i = 0;
+ std::wstring &val = Options::instance->webOptions[0]->combo1;
+ HWND cb = GetDlgItem(hwndDlg, IDC_COMBO1);
+ for(std::list<PasteFormat>::iterator it = Options::instance->webOptions[0]->combo1Values.begin(); it != Options::instance->webOptions[0]->combo1Values.end(); ++it)
+ {
+ ComboBox_AddString(cb, it->name.c_str());
+ if(val == it->id)
+ sel = i;
+ ++i;
+ }
+ ComboBox_SetCurSel(cb, sel);
+ Static_SetText(GetDlgItem(hwndDlg,IDC_COMBO1_DESC), Options::instance->webOptions[0]->combo1Desc.c_str());
+ }
+ else
+ {
+ ShowWindow(GetDlgItem(hwndDlg,IDC_COMBO1),SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg,IDC_COMBO1_DESC),SW_HIDE);
+ }
+
+ Edit_LimitText(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), 99);
+ if(Options::instance->webOptions[0]->isPastebin)
+ {
+ std::wstring pastebinUserKey = Options::instance->webOptions[0]->pastebinUserKey;
+ if(pastebinUserKey.empty())
+ {
+ CheckDlgButton(hwndDlg, IDC_GUEST, TRUE);
+ Edit_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), FALSE);
+ Static_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), FALSE);
+ Button_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN), FALSE);
+ }
+ else
+ {
+ Edit_SetText(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), pastebinUserKey.c_str());
+ }
+ }
+ else
+ {
+ ShowWindow(GetDlgItem(hwndDlg, IDC_GUEST), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN), SW_HIDE);
+ }
+
+ optsPagesData->init = true;
+ return TRUE;
+ }
+ case WM_COMMAND:
+ {
+ OptsPagesData* optsPagesData = (OptsPagesData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ if(HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_CONFIGURE)
+ {
+ GetPagesSettings(hwndDlg, optsPagesData);
+ OptsConfigureData d;
+ d.page = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_WEBPAGE));
+ WebOptions* wo = optsPagesData->webOptions[d.page];
+ d.tempFormats = wo->formats;
+ if(DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DLG_CONFIGURE), hwndDlg, DlgProcOptsConfigure, (LPARAM)&d) == IDOK)
+ {
+ wo->formats = d.tempFormats;
+ ReloadFormatsCombo(GetDlgItem(hwndDlg, IDC_DEFFORMAT), wo);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ }
+ else if(HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_PASTEBIN_LOGIN)
+ {
+ OptsLoginData d;
+ if(DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DLG_PASTEBIN_LOGIN), hwndDlg, DlgProcOptsLogin, (LPARAM)&d) == IDOK)
+ {
+ PasteToWeb1 *web = (PasteToWeb1*)pasteToWebs[optsPagesData->lastPage];
+ Edit_SetText(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), web->GetUserKey(d.user, d.password).c_str());
+ }
+ }
+ else if(HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_GUEST)
+ {
+ BOOL enabled = IsDlgButtonChecked(hwndDlg, IDC_GUEST) ? FALSE : TRUE;
+ Edit_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), enabled);
+ Static_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), enabled);
+ Button_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN), enabled);
+ }
+ else if(HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_WEBPAGE)
+ {
+ GetPagesSettings(hwndDlg, optsPagesData);
+ optsPagesData->init = false;
+ optsPagesData->lastPage = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_WEBPAGE));
+ ReloadFormatsCombo(GetDlgItem(hwndDlg, IDC_DEFFORMAT), optsPagesData->webOptions[optsPagesData->lastPage]);
+ if(optsPagesData->webOptions[optsPagesData->lastPage]->isSendFileName)
+ {
+ ShowWindow(GetDlgItem(hwndDlg,IDC_AUTOFORMAT),SW_SHOW);
+ CheckDlgButton(hwndDlg, IDC_AUTOFORMAT, optsPagesData->webOptions[optsPagesData->lastPage]->sendFileName ? 1 : 0);
+ }
+ else
+ ShowWindow(GetDlgItem(hwndDlg,IDC_AUTOFORMAT),SW_HIDE);
+
+ if(optsPagesData->webOptions[optsPagesData->lastPage]->isPublicPaste)
+ {
+ ShowWindow(GetDlgItem(hwndDlg,IDC_PUBLICPASTE),SW_SHOW);
+ CheckDlgButton(hwndDlg, IDC_PUBLICPASTE, optsPagesData->webOptions[optsPagesData->lastPage]->publicPaste ? 1 : 0);
+ }
+ else
+ ShowWindow(GetDlgItem(hwndDlg,IDC_PUBLICPASTE),SW_HIDE);
+
+ if(optsPagesData->webOptions[optsPagesData->lastPage]->isCombo1)
+ {
+ ShowWindow(GetDlgItem(hwndDlg,IDC_COMBO1),SW_SHOW);
+ ShowWindow(GetDlgItem(hwndDlg,IDC_COMBO1_DESC),SW_SHOW);
+ int sel = 0;
+ int i = 0;
+ std::wstring &val = optsPagesData->webOptions[optsPagesData->lastPage]->combo1;
+ HWND cb = GetDlgItem(hwndDlg, IDC_COMBO1);
+ while(ComboBox_DeleteString(cb, 0) > 0);
+ for(std::list<PasteFormat>::iterator it = optsPagesData->webOptions[optsPagesData->lastPage]->combo1Values.begin(); it != optsPagesData->webOptions[optsPagesData->lastPage]->combo1Values.end(); ++it)
+ {
+ ComboBox_AddString(cb, it->name.c_str());
+ if(val == it->id)
+ sel = i;
+ ++i;
+ }
+ ComboBox_SetCurSel(cb, sel);
+ SetWindowText(GetDlgItem(hwndDlg,IDC_COMBO1_DESC), optsPagesData->webOptions[optsPagesData->lastPage]->combo1Desc.c_str());
+ }
+ else
+ {
+ ShowWindow(GetDlgItem(hwndDlg,IDC_COMBO1),SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg,IDC_COMBO1_DESC),SW_HIDE);
+ }
+
+
+ if(optsPagesData->webOptions[optsPagesData->lastPage]->isPastebin)
+ {
+ ShowWindow(GetDlgItem(hwndDlg, IDC_GUEST), SW_SHOW);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), SW_SHOW);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), SW_SHOW);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN), SW_SHOW);
+ std::wstring pastebinUserKey = optsPagesData->webOptions[optsPagesData->lastPage]->pastebinUserKey;
+ if(pastebinUserKey.empty())
+ {
+ CheckDlgButton(hwndDlg, IDC_GUEST, TRUE);
+ Edit_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), FALSE);
+ Static_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), FALSE);
+ Button_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN), FALSE);
+ }
+ else
+ {
+ CheckDlgButton(hwndDlg, IDC_GUEST, FALSE);
+ Edit_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), TRUE);
+ Static_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), TRUE);
+ Button_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN), TRUE);
+ }
+
+ Edit_SetText(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), pastebinUserKey.c_str());
+ }
+ else
+ {
+ ShowWindow(GetDlgItem(hwndDlg, IDC_GUEST), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN), SW_HIDE);
+ }
+
+ optsPagesData->init = true;
+ }
+
+ if (optsPagesData->init && ((HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) != IDC_CONFIGURE && LOWORD(wParam) != IDC_PASTEBIN_LOGIN) || (HIWORD(wParam)==CBN_SELCHANGE && LOWORD(wParam) != IDC_WEBPAGE) || HIWORD(wParam) == EN_CHANGE))
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ return TRUE;
+ }
+ case WM_NOTIFY:
+ {
+ if(((LPNMHDR)lParam)->code == PSN_APPLY)
+ {
+ OptsPagesData* optsPagesData = (OptsPagesData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ GetPagesSettings(hwndDlg, optsPagesData);
+ for(int i = 0 ; i < PasteToWeb::pages; ++i)
+ {
+ *Options::instance->webOptions[i] = *optsPagesData->webOptions[i];
+ }
+
+ Options::instance->Save();
+ }
+ return TRUE;
+ }
+ case WM_CLOSE:
+ {
+ OptsPagesData* optsPagesData = (OptsPagesData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ delete optsPagesData;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, NULL);
+ break;
+ }
+ }
+
+ return FALSE;
+}
+
+void SelectLbConfigure(HWND hwndDlg, int sel, OptsConfigureData* optsConfigureData)
+{
+ if(sel >= 0 && sel < optsConfigureData->tempFormats.size())
+ {
+ Button_Enable(GetDlgItem(hwndDlg, IDC_DELETE), TRUE);
+ if(sel == 0)
+ Button_Enable(GetDlgItem(hwndDlg, IDC_UP), FALSE);
+ else
+ Button_Enable(GetDlgItem(hwndDlg, IDC_UP), TRUE);
+ if(sel + 1 == optsConfigureData->tempFormats.size())
+ Button_Enable(GetDlgItem(hwndDlg, IDC_DOWN), FALSE);
+ else
+ Button_Enable(GetDlgItem(hwndDlg, IDC_DOWN), TRUE);
+ }
+ else
+ {
+ Button_Enable(GetDlgItem(hwndDlg, IDC_DELETE), FALSE);
+ Button_Enable(GetDlgItem(hwndDlg, IDC_UP), FALSE);
+ Button_Enable(GetDlgItem(hwndDlg, IDC_DOWN), FALSE);
+ }
+}
+
+INT_PTR CALLBACK Options::DlgProcOptsConfigure(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg)
+ {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwndDlg);
+ OptsConfigureData* optsConfigureData = (OptsConfigureData*)lParam;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+
+ HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
+ for(std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it)
+ {
+ ListBox_AddString(lb, it->name.c_str());
+ }
+
+ SelectLbConfigure(hwndDlg, -1, optsConfigureData);
+ return TRUE;
+ }
+ case WM_COMMAND:
+ {
+ if (HIWORD(wParam) == BN_CLICKED)
+ {
+ if (LOWORD(wParam) == IDOK)
+ {
+ EndDialog(hwndDlg, IDOK);
+ }
+ else if (LOWORD(wParam) == IDCANCEL)
+ {
+ EndDialog(hwndDlg, IDCANCEL);
+ }
+ else if (LOWORD(wParam) == IDC_DELETE)
+ {
+ HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
+ OptsConfigureData* optsConfigureData = (OptsConfigureData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ int sel = ListBox_GetCurSel(lb);
+ if(sel >= 0)
+ {
+ ListBox_DeleteString(lb, sel);
+ int i = sel;
+ for(std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it)
+ {
+ if(i-- <= 0)
+ {
+ optsConfigureData->tempFormats.erase(it);
+ ListBox_SetCurSel(lb, sel);
+ SelectLbConfigure(hwndDlg, sel, optsConfigureData);
+ break;
+ }
+ }
+ }
+ }
+ else if (LOWORD(wParam) == IDC_UP)
+ {
+ HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
+ OptsConfigureData* optsConfigureData = (OptsConfigureData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ int sel = ListBox_GetCurSel(lb);
+ if(sel > 0)
+ {
+ int i = sel;
+ for(std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it)
+ {
+ if(i-- <= 0)
+ {
+ PasteFormat pf = *it;
+ std::list<PasteFormat>::iterator prevIt = it;
+ --prevIt;
+ optsConfigureData->tempFormats.erase(it);
+ optsConfigureData->tempFormats.insert(prevIt, pf);
+ ListBox_DeleteString(lb, sel--);
+ ListBox_InsertString(lb, sel, pf.name.c_str());
+ ListBox_SetCurSel(lb, sel);
+ SelectLbConfigure(hwndDlg, sel, optsConfigureData);
+ break;
+ }
+ }
+ }
+ }
+ else if (LOWORD(wParam) == IDC_DOWN)
+ {
+ HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
+ OptsConfigureData* optsConfigureData = (OptsConfigureData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ int sel = ListBox_GetCurSel(lb);
+ if(sel >= 0 && sel + 1 < optsConfigureData->tempFormats.size())
+ {
+ int i = sel;
+ for(std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it)
+ {
+ if(i-- <= 0)
+ {
+ PasteFormat pf = *it;
+ std::list<PasteFormat>::iterator nextIt = it;
+ ++(++nextIt);
+ optsConfigureData->tempFormats.erase(it);
+ optsConfigureData->tempFormats.insert(nextIt, pf);
+ ListBox_DeleteString(lb, sel++);
+ ListBox_InsertString(lb, sel, pf.name.c_str());
+ ListBox_SetCurSel(lb, sel);
+ SelectLbConfigure(hwndDlg, sel, optsConfigureData);
+ break;
+ }
+ }
+ }
+ }
+ else if(LOWORD(wParam) == IDC_DOWNLOAD)
+ {
+ OptsConfigureData* optsConfigureData = (OptsConfigureData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
+ while(ListBox_DeleteString(lb, 0) > 0);
+ SelectLbConfigure(hwndDlg, -1, optsConfigureData);
+ optsConfigureData->tempFormats = pasteToWebs[optsConfigureData->page]->GetFormats();
+ for(std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it)
+ {
+ ListBox_AddString(lb, it->name.c_str());
+ }
+ }
+ else if(LOWORD(wParam) == IDC_RESTORE)
+ {
+ OptsConfigureData* optsConfigureData = (OptsConfigureData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
+ while(ListBox_DeleteString(lb, 0) > 0);
+ SelectLbConfigure(hwndDlg, -1, optsConfigureData);
+ optsConfigureData->tempFormats = pasteToWebs[optsConfigureData->page]->GetDefFormats();
+ for(std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it)
+ {
+ ListBox_AddString(lb, it->name.c_str());
+ }
+ }
+ }
+ else if(HIWORD(wParam) == LBN_SELCHANGE && LOWORD(wParam) == IDC_FORMATTING)
+ {
+ OptsConfigureData* optsConfigureData = (OptsConfigureData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ int sel = ListBox_GetCurSel(GetDlgItem(hwndDlg, IDC_FORMATTING));
+ SelectLbConfigure(hwndDlg, sel, optsConfigureData);
+ }
+ return TRUE;
+ }
+ case WM_VKEYTOITEM:
+ if(LOWORD(wParam) == VK_DELETE && (HWND)lParam == GetDlgItem(hwndDlg, IDC_FORMATTING))
+ {
+ DlgProcOptsConfigure(hwndDlg, WM_COMMAND, MAKELONG(IDC_DELETE, BN_CLICKED), NULL);
+ return -2;
+ }
+ return -1;
+ case WM_NOTIFY:
+ {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+INT_PTR CALLBACK Options::DlgProcOptsLogin(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg)
+ {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwndDlg);
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+ Edit_LimitText(GetDlgItem(hwndDlg, IDC_PASTEBIN_USER), 99);
+ Edit_LimitText(GetDlgItem(hwndDlg, IDC_PASTEBIN_PASSWORD), 99);
+ return TRUE;
+ }
+ case WM_COMMAND:
+ {
+ if (HIWORD(wParam) == BN_CLICKED)
+ {
+ if (LOWORD(wParam) == IDOK)
+ {
+ TCHAR buf[100];
+ OptsLoginData* optsLoginData = (OptsLoginData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ Edit_GetText(GetDlgItem(hwndDlg, IDC_PASTEBIN_USER), buf, 100);
+ optsLoginData->user = buf;
+ Edit_GetText(GetDlgItem(hwndDlg, IDC_PASTEBIN_PASSWORD), buf, 100);
+ optsLoginData->password = buf;
+ EndDialog(hwndDlg, IDOK);
+ }
+ else if (LOWORD(wParam) == IDCANCEL)
+ {
+ EndDialog(hwndDlg, IDCANCEL);
+ }
+ }
+ return TRUE;
+ }
+ case WM_NOTIFY:
+ {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+unsigned int Options::GetCodepageCB(HWND hwndCB, bool errorReport, unsigned int defCp)
+{
+ int selCpIdx = ComboBox_GetCurSel(hwndCB);
+ if(selCpIdx < 0)
+ {
+ TCHAR text[128];
+ ComboBox_GetText(hwndCB, text, 128);
+ TCHAR * stopOn = NULL;
+ long cp = _tcstol(text, &stopOn, 10);
+ if(errorReport && (stopOn == text || *stopOn != '\0' || cp < 0 || cp > 0xffff))
+ {
+ MessageBox(GetParent(hwndCB), TranslateT("You've entered invalid codepage. Select codepage from combo box or enter correct number."), TranslateT("Invalid codepage"), MB_OK | MB_ICONERROR);
+ SetFocus(hwndCB);
+ SetCodepageCB(hwndCB, defCp);
+ return defCp;
+ }
+
+ return cp;
+ }
+ else return cpTable[selCpIdx].cpId;
+}
+
+void Options::SetDefWeb(int web)
+{
+ defWeb = web;
+ DBWriteContactSettingWString(0, MODULE, "defWeb", pasteToWebs[web]->GetName());
+ DefWebPageChanged();
+}
+
+void Options::InitCodepageCB(HWND hwndCB, unsigned int codepage)
+{
+ int cpCount = sizeof(cpTable) / sizeof(cpTable[0]);
+ int selCpIdx = -1;
+ for(int i = 0; i < cpCount; ++i)
+ {
+ ComboBox_AddString(hwndCB, TranslateTS(cpTable[i].cpName));
+ if(cpTable[i].cpId == codepage)
+ selCpIdx = i;
+ }
+
+ if(selCpIdx == -1)
+ {
+ TCHAR buf[10];
+ _stprintf_s(buf, 10, _T("%d"), codepage);
+ ComboBox_SetText(hwndCB, buf);
+ }
+ else
+ {
+ ComboBox_SetCurSel(hwndCB, selCpIdx);
+ }
+
+ ComboBox_LimitText(hwndCB, 127);
+}
+
+void Options::SetCodepageCB(HWND hwndCB, unsigned int codepage)
+{
+ int cpCount = sizeof(cpTable) / sizeof(cpTable[0]);
+ int selCpIdx = -1;
+ for(int i = 0; i < cpCount; ++i)
+ {
+ if(cpTable[i].cpId == codepage)
+ selCpIdx = i;
+ }
+
+ if(selCpIdx == -1)
+ {
+ TCHAR buf[10];
+ _stprintf_s(buf, 10, _T("%d"), codepage);
+ ComboBox_SetText(hwndCB, buf);
+ }
+ else
+ {
+ ComboBox_SetCurSel(hwndCB, selCpIdx);
+ }
+}
+
+int Options::InitOptions(WPARAM wParam, LPARAM lParam)
+{
+ OPTIONSDIALOGPAGE odp = {0};
+
+ odp.cbSize = sizeof(odp);
+ odp.position = 100000000;
+ odp.hInstance = hInst;
+ odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR;
+ odp.ptszTitle = LPGENT("Paste It");
+ odp.ptszGroup = LPGENT("Services");
+
+ odp.ptszTab = LPGENT("Main");
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_MAIN);
+ odp.pfnDlgProc = Options::DlgProcOptsMain;
+ CallService(MS_OPT_ADDPAGE, wParam, (LPARAM)&odp);
+
+ odp.ptszTab = LPGENT("Web page");
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_PAGES);
+ odp.pfnDlgProc = Options::DlgProcOptsPages;
+ CallService(MS_OPT_ADDPAGE, wParam, (LPARAM)&odp);
+
+ return 0;
+}
+
+void Options::Save()
+{
+ DBWriteContactSettingWString(0, MODULE, "defWeb", pasteToWebs[defWeb]->GetName());
+ DBWriteContactSettingDword(0, MODULE, "codepage", codepage);
+ DBWriteContactSettingByte(0, MODULE, "autoUTF", autoUTF ? 1 : 0);
+ DBWriteContactSettingByte(0, MODULE, "confDlg", confDlg ? 1 : 0);
+ DBWriteContactSettingByte(0, MODULE, "autoSend", autoSend ? 1 : 0);
+ for(int i = 0 ; i < PasteToWeb::pages; ++i)
+ {
+ char buf[256];
+ TCHAR* name = pasteToWebs[i]->GetName();
+ int j = 0;
+ while(name[j])
+ {
+ buf[j] = (char)name[j];
+ ++j;
+ }
+ buf[j++] = '_';
+
+ strcpy_s(buf + j, 256 - j, "formats");
+ std::wstring forms;
+ for(std::list<PasteFormat>::iterator it = webOptions[i]->formats.begin(); it != webOptions[i]->formats.end(); ++it)
+ {
+ forms += it->id + L'=' + it->name + L';';
+ }
+
+ DBWriteContactSettingWString(0, MODULE, buf, forms.c_str());
+
+ strcpy_s(buf + j, 256 - j, "defFormatId");
+ DBWriteContactSettingWString(0, MODULE, buf, webOptions[i]->defFormatId.c_str());
+
+ if(webOptions[i]->isSendFileName)
+ {
+ strcpy_s(buf + j, 256 - j, "sendFileName");
+ DBWriteContactSettingByte(0, MODULE, buf, webOptions[i]->sendFileName ? 1 : 0);
+ }
+
+ if(webOptions[i]->isPublicPaste)
+ {
+ strcpy_s(buf + j, 256 - j, "publicPaste");
+ DBWriteContactSettingByte(0, MODULE, buf, webOptions[i]->publicPaste ? 1 : 0);
+ }
+
+ if(webOptions[i]->isCombo1)
+ {
+ strcpy_s(buf + j, 256 - j, "combo1");
+ DBWriteContactSettingWString(0, MODULE, buf, webOptions[i]->combo1.c_str());
+ }
+
+ if(webOptions[i]->isPastebin)
+ {
+ strcpy_s(buf + j, 256 - j, "pastebinUserKey");
+ DBWriteContactSettingWString(0, MODULE, buf, webOptions[i]->pastebinUserKey.c_str());
+ }
+ }
+}
+
+void Options::Load()
+{
+ DBVARIANT defWebV;
+ if(!DBGetContactSettingWString(0, MODULE, "defWeb", &defWebV))
+ {
+ for(int i = 0; i < PasteToWeb::pages; ++i)
+ {
+ if(!wcscmp(pasteToWebs[i]->GetName(), defWebV.pwszVal))
+ {
+ defWeb = i;
+ break;
+ }
+ }
+ DBFreeVariant(&defWebV);
+ }
+ codepage = DBGetContactSettingDword(0, MODULE, "codepage", CP_ACP);
+ autoUTF = DBGetContactSettingByte(0, MODULE, "autoUTF", 1) ? true : false;
+ confDlg = DBGetContactSettingByte(0, MODULE, "confDlg", 1) ? true : false;
+ autoSend = DBGetContactSettingByte(0, MODULE, "autoSend", 0) ? true : false;
+ for(int i = 0 ; i < PasteToWeb::pages; ++i)
+ {
+ char buf[256];
+ TCHAR* name = pasteToWebs[i]->GetName();
+ int j = 0;
+ while(name[j])
+ {
+ buf[j] = (char)name[j];
+ ++j;
+ }
+ buf[j++] = '_';
+
+ strcpy_s(buf + j, 256 - j, "formats");
+ DBVARIANT forms;
+ if(!DBGetContactSettingWString(0, MODULE, buf, &forms))
+ {
+ webOptions[i]->formats.clear();
+ int k = 0;
+ wchar_t * id = forms.pwszVal;
+ wchar_t * name = NULL;
+ while(forms.pwszVal[k])
+ {
+ if(forms.pwszVal[k] == L'=')
+ {
+ forms.pwszVal[k] = 0;
+ name = forms.pwszVal + k + 1;
+ }
+ else if(forms.pwszVal[k] == L';')
+ {
+ forms.pwszVal[k] = 0;
+ PasteFormat pf;
+ pf.id = id;
+ pf.name = name;
+ webOptions[i]->formats.push_back(pf);
+ id = forms.pwszVal + k + 1;
+ }
+
+ ++k;
+ }
+
+ DBFreeVariant(&forms);
+ }
+
+ strcpy_s(buf + j, 256 - j, "defFormatId");
+ DBVARIANT defForm;
+ if(!DBGetContactSettingWString(0, MODULE, buf, &defForm))
+ {
+ webOptions[i]->defFormatId = defForm.pwszVal;
+ DBFreeVariant(&defForm);
+ }
+
+ if(webOptions[i]->isSendFileName)
+ {
+ strcpy_s(buf + j, 256 - j, "sendFileName");
+ webOptions[i]->sendFileName = DBGetContactSettingByte(0, MODULE, buf, 1) ? true : false;
+ }
+
+ if(webOptions[i]->isPublicPaste)
+ {
+ strcpy_s(buf + j, 256 - j, "publicPaste");
+ webOptions[i]->publicPaste = DBGetContactSettingByte(0, MODULE, buf, 0) ? true : false;
+ }
+
+ if(webOptions[i]->isCombo1)
+ {
+ strcpy_s(buf + j, 256 - j, "combo1");
+ DBVARIANT combo1;
+ if(!DBGetContactSettingWString(0, MODULE, buf, &combo1))
+ {
+ webOptions[i]->combo1 = combo1.pwszVal;
+ DBFreeVariant(&combo1);
+ }
+ }
+
+ if(webOptions[i]->isPastebin)
+ {
+ strcpy_s(buf + j, 256 - j, "pastebinUserKey");
+ DBVARIANT pastebinUserKey;
+ if(!DBGetContactSettingWString(0, MODULE, buf, &pastebinUserKey))
+ {
+ webOptions[i]->pastebinUserKey = pastebinUserKey.pwszVal;
+ DBFreeVariant(&pastebinUserKey);
+ }
+ }
+ }
+}
+
+WebOptions::WebOptions(int serv)
+ :server(serv),
+ formats(pasteToWebs[serv]->GetDefFormats()),
+ sendFileName(true),
+ isSendFileName(true),
+ publicPaste(false),
+ isPublicPaste(false),
+ isCombo1(false),
+ isPastebin(false)
+{
+ defFormatId = formats.front().id;
+}
+
+
+WebOptions::~WebOptions()
+{
+}
+
+WebOptions* WebOptions::Copy()
+{
+ return new WebOptions(*this);
+}
diff --git a/plugins/PasteIt/Options.h b/plugins/PasteIt/Options.h new file mode 100644 index 0000000000..9e58e44d7f --- /dev/null +++ b/plugins/PasteIt/Options.h @@ -0,0 +1,72 @@ +/*
+Paste It plugin
+Copyright (C) 2011 Krzysztof Kral
+
+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 version 2
+of the License.
+
+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, see <http://www.gnu.org/licenses/>.
+*/
+
+#pragma once
+#include "PasteToWeb.h"
+
+class WebOptions
+{
+public:
+ WebOptions(int serv);
+ virtual ~WebOptions();
+ virtual WebOptions* Copy();
+ int server;
+ bool isSendFileName;
+ bool isPublicPaste;
+ bool isCombo1;
+ std::list<PasteFormat> combo1Values;
+ std::wstring combo1Desc;
+ bool isPastebin;
+
+ std::list<PasteFormat> formats;
+ std::wstring defFormatId;
+ bool sendFileName;
+ bool publicPaste;
+ std::wstring combo1;
+ std::wstring pastebinUserKey;
+};
+
+class Options
+{
+public:
+ Options();
+ ~Options();
+ static int InitOptions(WPARAM wParam, LPARAM lParam);
+
+ static INT_PTR CALLBACK DlgProcOptsMain(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+ static INT_PTR CALLBACK DlgProcOptsPages(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+ static INT_PTR CALLBACK DlgProcOptsConfigure(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+ static INT_PTR CALLBACK DlgProcOptsLogin(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+
+ static void InitCodepageCB(HWND hwndCB, unsigned int codepage);
+ static void SetCodepageCB(HWND hwndCB, unsigned int codepage);
+ static unsigned int GetCodepageCB(HWND hwndCB, bool errorReport, unsigned int defCp);
+
+ static Options *instance;
+ void Save();
+ void Load();
+
+ int defWeb;
+ unsigned int codepage;
+ bool autoUTF;
+ bool confDlg;
+ bool autoSend;
+ void SetDefWeb(int web);
+ WebOptions* webOptions[PasteToWeb::pages];
+};
+
diff --git a/plugins/PasteIt/PasteIt.cpp b/plugins/PasteIt/PasteIt.cpp new file mode 100644 index 0000000000..1ae7e1d7e9 --- /dev/null +++ b/plugins/PasteIt/PasteIt.cpp @@ -0,0 +1,596 @@ +/*
+Paste It plugin
+Copyright (C) 2011 Krzysztof Kral
+
+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 version 2
+of the License.
+
+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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "stdafx.h"
+#include "PasteToWeb1.h"
+#include "PasteToWeb2.h"
+#include "version.h"
+#include "resource.h"
+#include "Options.h"
+
+// {1AAC15E8-DCEC-4050-B66F-2AA0E6120C22}
+#define MIID_PASTEIT { 0x1aac15e8, 0xdcec, 0x4050, { 0xb6, 0x6f, 0x2a, 0xa0, 0xe6, 0x12, 0xc, 0x22 } }
+
+PLUGINLINK *pluginLink;
+PasteToWeb* pasteToWebs[PasteToWeb::pages];
+std::map<HANDLE, HWND>* contactWindows;
+DWORD gMirandaVersion;
+
+extern HINSTANCE hInst;
+HANDLE hModulesLoaded, hTabsrmmButtonPressed;
+HANDLE g_hNetlibUser;
+HANDLE hPrebuildContactMenu;
+HANDLE hServiceContactMenu;
+HGENMENU hContactMenu;
+HGENMENU hWebPageMenus[PasteToWeb::pages];
+HANDLE hMainIcon;
+HANDLE hOptionsInit;
+HANDLE hWindowEvent = NULL;
+
+#define MODULE "PasteIt"
+#define FROM_CLIPBOARD 10
+#define FROM_FILE 11
+#define DEF_PAGES_START 20
+#define MS_PASTEIT_CONTACTMENU "PasteIt/ContactMenu"
+
+PLUGININFOEX pluginInfo={
+ sizeof(PLUGININFOEX),
+ __PLUGIN_NAME,
+ PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
+ __DESCRIPTION,
+ __AUTHOR,
+ __AUTHOREMAIL,
+ __COPYRIGHT,
+ __AUTHORWEB,
+ UNICODE_AWARE,
+ 0,
+ MIID_PASTEIT
+};
+
+MM_INTERFACE mmi = {0};
+XML_API xi = {0};
+int hLangpack = 0;
+
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
+{
+ gMirandaVersion = mirandaVersion;
+ if (mirandaVersion < PLUGIN_MAKE_VERSION(0, 8, 0, 0))
+ return NULL;
+
+ return &pluginInfo;
+}
+
+static const MUUID interfaces[] = {MIID_PASTEIT, MIID_LAST};
+extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void)
+{
+ return interfaces;
+}
+
+std::wstring GetFile()
+{
+ TCHAR filter[512];
+ _tcscpy_s(filter, 512, TranslateT("All Files (*.*)"));
+ memcpy(filter + _tcslen(filter), _T("\0*.*\0"), 6 * sizeof(TCHAR));
+ TCHAR stzFilePath[1024];
+ stzFilePath[0] = 0;
+ stzFilePath[1] = 0;
+ OPENFILENAME ofn = {0};
+ ofn.lStructSize = sizeof(ofn);
+ ofn.hwndOwner = 0;
+ ofn.lpstrFilter = filter;
+ ofn.nFilterIndex = 1;
+ ofn.lpstrFile = stzFilePath;
+ ofn.lpstrTitle = TranslateT("Paste It - Select file");
+ ofn.nMaxFile = 1024;
+ ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_EXPLORER | OFN_NOCHANGEDIR;
+ if(GetOpenFileName(&ofn))
+ {
+ return stzFilePath;
+ }
+
+ return L"";
+}
+
+void PasteIt(HANDLE hContact, int mode)
+{
+ PasteToWeb* pasteToWeb = pasteToWebs[Options::instance->defWeb];
+ if(mode == FROM_CLIPBOARD)
+ {
+ pasteToWeb->FromClipboard();
+ }
+ else if(mode == FROM_FILE)
+ {
+ std::wstring file = GetFile();
+ if(file.length() > 0)
+ {
+ pasteToWeb->FromFile(file);
+ }
+ else return;
+ }
+ else return;
+
+ if(pasteToWeb->szFileLink[0] == 0 && pasteToWeb->error != NULL)
+ {
+ MessageBox(NULL, pasteToWeb->error, TranslateT("Error"), MB_OK | MB_ICONERROR);
+ }
+ else if(hContact != NULL && pasteToWeb->szFileLink[0] != 0)
+ {
+ char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ if (szProto && (INT_PTR)szProto != CALLSERVICE_NOTFOUND)
+ {
+ BOOL isChat = DBGetContactSettingByte(hContact, szProto, "ChatRoom", 0);
+ if(Options::instance->autoSend)
+ {
+ if(!isChat)
+ {
+ DBEVENTINFO dbei = {0};
+ dbei.cbSize = sizeof(dbei);
+ dbei.eventType = EVENTTYPE_MESSAGE;
+ dbei.flags = DBEF_SENT;
+ dbei.szModule = szProto;
+ dbei.timestamp = (DWORD)time(NULL);
+ dbei.cbBlob = (DWORD)strlen(pasteToWeb->szFileLink) + 1;
+ dbei.pBlob = (PBYTE)pasteToWeb->szFileLink;
+ CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&dbei);
+ CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)pasteToWeb->szFileLink);
+ }
+ else
+ {
+ // PSS_MESSAGE is not compatible with chat rooms
+ // there are no simple method to send text to all users
+ // in chat room.
+ // First I check if protocol is unicode or ascii.
+ BOOL isUnicodePlugin = TRUE;
+ PROTOACCOUNT* protoAc = ProtoGetAccount(szProto);
+ if(protoAc != NULL)
+ {
+ // protoAc->ppro is abstract class, that contains
+ // methods implemented in protocol ddl`s segment.
+ // Method address in vptr table must be converted
+ // to hInstance of protocol dll.
+ PROTO_INTERFACE* protoInt = protoAc->ppro;
+ MEMORY_BASIC_INFORMATION mb;
+ INT_PTR *vptr = *(INT_PTR**)&protoAc->ppro;
+ INT_PTR *vtable = (INT_PTR *)*vptr;
+ if(VirtualQuery((void*)vtable[0], &mb, sizeof(MEMORY_BASIC_INFORMATION)))
+ {
+ typedef PLUGININFO * (__cdecl * Miranda_Plugin_Info) ( DWORD mirandaVersion );
+ typedef PLUGININFOEX * (__cdecl * Miranda_Plugin_InfoEx) ( DWORD mirandaVersion );
+ HINSTANCE hInst = (HINSTANCE)mb.AllocationBase;
+ // Now I can get PLUGININFOEX from protocol
+ Miranda_Plugin_Info info = (Miranda_Plugin_Info) GetProcAddress(hInst, "MirandaPluginInfo");
+ Miranda_Plugin_InfoEx infoEx = (Miranda_Plugin_InfoEx) GetProcAddress(hInst, "MirandaPluginInfoEx");
+ PLUGININFOEX* pi = NULL;
+ if(infoEx != NULL)
+ {
+ pi = infoEx(gMirandaVersion);
+ }
+ else if(info != NULL)
+ {
+ pi = (PLUGININFOEX*)info(gMirandaVersion);
+ }
+
+ // If PLUGININFOEX flags contains UNICODE_AWARE,
+ // this mean that protocol is unicode.
+ if(pi != NULL && pi->cbSize >= sizeof(PLUGININFO))
+ {
+ isUnicodePlugin = pi->flags & UNICODE_AWARE;
+ }
+ }
+ }
+
+ // Next step is to get all protocol sessions and find
+ // one with correct hContact
+ GC_INFO gci = {0};
+ GCDEST gcd = {0};
+ GCEVENT gce = {0};
+ int cnt = (int)CallService(MS_GC_GETSESSIONCOUNT, 0, (LPARAM)szProto);
+ for (int i = 0; i < cnt ; i++ )
+ {
+ gci.iItem = i;
+ gci.pszModule = szProto;
+ gci.Flags = BYINDEX | HCONTACT | ID;
+ CallService(MS_GC_GETINFO, 0, (LPARAM)(GC_INFO *) &gci);
+ if (gci.hContact == hContact)
+ {
+ // In this place session was finded, gci.pszID contains
+ // session ID, but it is in unicode or ascii format,
+ // depends on protocol wersion
+ gcd.pszModule = szProto;
+ gcd.iType = GC_EVENT_SENDMESSAGE;
+ gcd.ptszID = gci.pszID;
+ gce.cbSize = sizeof(GCEVENT);
+ gce.pDest = &gcd;
+ gce.bIsMe = TRUE;
+ gce.dwFlags = isUnicodePlugin ? (GCEF_ADDTOLOG | GC_UNICODE) : GCEF_ADDTOLOG;
+ wchar_t* s = NULL;
+ if(isUnicodePlugin)
+ {
+ // If session ID is in unicode, text must be too in unicode
+ s = mir_a2u_cp(pasteToWeb->szFileLink, CP_ACP);
+ gce.ptszText = s;
+ }
+ else
+ {
+ // If session ID is in ascii, text must be too in ascii
+ gce.pszText = pasteToWeb->szFileLink;
+ }
+ gce.time = time(NULL);
+ CallService(MS_GC_EVENT, 0, (LPARAM)(GCEVENT *) &gce);
+ if(s != NULL)
+ mir_free(s);
+ break;
+ }
+ }
+ }
+
+ // Send message to focus window
+ CallServiceSync(MS_MSG_SENDMESSAGE, (WPARAM)hContact, 0);
+ }
+ else
+ {
+ if(isChat)
+ {
+ // MS_MSG_SENDMESSAGE in incompatible with chat rooms,
+ // because it sends text to IDC_MESSAGE window,
+ // but in chat rooms is only IDC_CHAT_MESSAGE window.
+ // contactWindows map contains all opened hContact
+ // with assaigned to them chat windows.
+ // This map is prepared in ME_MSG_WINDOWEVENT event.
+ std::map<HANDLE, HWND>::iterator it = contactWindows->find(hContact);
+ if(it != contactWindows->end())
+ {
+ // it->second is imput window, so now I can send to them
+ // new text. Afterr all is sended MS_MSG_SENDMESSAGE
+ // to focus window.
+ SendMessage(it->second, EM_SETSEL, -1, SendMessage(it->second, WM_GETTEXTLENGTH, 0, 0));
+ SendMessageA(it->second, EM_REPLACESEL, FALSE, (LPARAM)pasteToWeb->szFileLink);
+ CallServiceSync(MS_MSG_SENDMESSAGE, (WPARAM)hContact, NULL);
+ }
+ else
+ {
+ // If window do not exist, maybe it is not chat
+ CallServiceSync(MS_MSG_SENDMESSAGE, (WPARAM)hContact, (LPARAM)pasteToWeb->szFileLink);
+ }
+ }
+ else
+ {
+ CallServiceSync(MS_MSG_SENDMESSAGE, (WPARAM)hContact, (LPARAM)pasteToWeb->szFileLink);
+ }
+ }
+ }
+ }
+}
+
+int TabsrmmButtonPressed(WPARAM wParam, LPARAM lParam)
+{
+ CustomButtonClickData *cbc = (CustomButtonClickData *)lParam;
+ HANDLE hContact = (HANDLE)wParam;
+
+ if (!strcmp(cbc->pszModule, MODULE) && cbc->dwButtonId == 1 && hContact)
+ {
+ if (cbc->flags == BBCF_ARROWCLICKED)
+ {
+ HMENU hMenu = CreatePopupMenu();
+ if (hMenu)
+ {
+ AppendMenu(hMenu, MF_STRING, FROM_CLIPBOARD, TranslateT("Paste from clipboard"));
+ AppendMenu(hMenu, MF_STRING, FROM_FILE, TranslateT("Paste from file"));
+ HMENU hDefMenu = CreatePopupMenu();
+ for(int i = 0 ; i < PasteToWeb::pages; ++i)
+ {
+ UINT flags = MF_STRING;
+ if(Options::instance->defWeb == i)
+ flags |= MF_CHECKED;
+
+ AppendMenu(hDefMenu, flags, DEF_PAGES_START + i, pasteToWebs[i]->GetName());
+ }
+
+ AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT_PTR)hDefMenu, TranslateT("Default web page"));
+
+ POINT pt;
+ GetCursorPos(&pt);
+ HWND hwndBtn = WindowFromPoint(pt);
+ if (hwndBtn)
+ {
+ RECT rc;
+ GetWindowRect(hwndBtn, &rc);
+ SetForegroundWindow(cbc->hwndFrom);
+ int selected = TrackPopupMenu(hMenu, TPM_RETURNCMD, rc.left, rc.bottom, 0, cbc->hwndFrom, 0);
+ if (selected != 0)
+ {
+ if(selected >= DEF_PAGES_START)
+ {
+ Options::instance->SetDefWeb(selected - DEF_PAGES_START);
+ }
+ else
+ {
+ PasteIt(hContact, selected);
+ }
+ }
+ }
+
+ DestroyMenu(hDefMenu);
+ DestroyMenu(hMenu);
+ }
+ }
+ else
+ {
+ PasteIt(hContact, FROM_CLIPBOARD);
+ }
+ }
+
+ return 0;
+}
+
+int PrebuildContactMenu(WPARAM wParam, LPARAM lParam)
+{
+ bool bIsContact = false;
+
+ char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0);
+ if (szProto && (INT_PTR)szProto != CALLSERVICE_NOTFOUND) bIsContact = (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IM) ? true : false;
+
+ CLISTMENUITEM mi = {0};
+ mi.cbSize = sizeof(mi);
+ mi.flags = CMIM_FLAGS;
+
+ if (!bIsContact) mi.flags |= CMIF_HIDDEN;
+ else mi.flags &= ~CMIF_HIDDEN;
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hContactMenu, (LPARAM)&mi);
+
+ return 0;
+}
+
+INT_PTR ContactMenuService(WPARAM wParam, LPARAM lParam)
+{
+ if(lParam >= DEF_PAGES_START)
+ {
+ Options::instance->SetDefWeb(lParam - DEF_PAGES_START);
+ }
+ else
+ {
+ HANDLE hContact = (HANDLE)wParam;
+ PasteIt(hContact, lParam);
+ }
+ return 0;
+}
+
+void InitIcolib()
+{
+ TCHAR stzFile[MAX_PATH];
+
+ SKINICONDESC sid = {0};
+ sid.cbSize = sizeof(sid);
+ sid.cx = sid.cy = 16;
+ sid.ptszDefaultFile = stzFile;
+ sid.ptszSection = LPGENT("Paste It");
+ sid.flags = SIDF_ALL_TCHAR;
+
+ GetModuleFileName(hInst, stzFile, MAX_PATH);
+
+ sid.pszName = "PasteIt_main";
+ sid.ptszDescription = LPGENT("Paste It");
+ sid.iDefaultIndex = -IDI_MENU;
+ hMainIcon = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+}
+
+void InitMenuItems()
+{
+ CLISTMENUITEM mi = {0};
+ CLISTMENUITEM mi2 = {0};
+
+ mi.cbSize = sizeof(mi);
+ mi.flags = CMIF_ROOTPOPUP | CMIF_ICONFROMICOLIB | CMIF_TCHAR;
+ mi.icolibItem = hMainIcon;
+ mi.position = 3000090005;
+ mi.ptszName = _T("Paste It");
+
+ hContactMenu = (HGENMENU)CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM)&mi);
+
+ memset(&mi, 0, sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.flags = CMIF_CHILDPOPUP | CMIF_ROOTHANDLE | CMIF_TCHAR;
+ mi.pszService = MS_PASTEIT_CONTACTMENU;
+ mi.hParentMenu = hContactMenu;
+ mi.popupPosition = FROM_CLIPBOARD;
+ mi.ptszName = _T("Paste from clipboard");
+ CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM)&mi);
+
+ mi.popupPosition = FROM_FILE;
+ mi.ptszName = _T("Paste from file");
+ CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM)&mi);
+
+ mi.popupPosition = DEF_PAGES_START - 1;
+ mi.ptszName = _T("Default web page");
+ HGENMENU hDefWebMenu = (HGENMENU)CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM)&mi);
+
+ mi2.cbSize = sizeof(mi2);
+ mi2.pszService = MS_PASTEIT_CONTACTMENU;
+ mi2.hParentMenu = hDefWebMenu;
+ for(int i = 0 ; i < PasteToWeb::pages; ++i)
+ {
+ mi2.flags = CMIF_CHILDPOPUP | CMIF_ROOTHANDLE | CMIF_TCHAR;
+ if(Options::instance->defWeb == i)
+ mi2.flags |= CMIF_CHECKED;
+ mi2.ptszName = pasteToWebs[i]->GetName();
+ mi2.popupPosition = mi2.position = DEF_PAGES_START + i;
+ hWebPageMenus[i] = (HGENMENU)CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM)&mi2);
+ }
+
+ hPrebuildContactMenu = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PrebuildContactMenu);
+}
+
+void DefWebPageChanged()
+{
+ CLISTMENUITEM mi = {0};
+ mi.cbSize = sizeof(mi);
+
+ for (int i = 0; i < PasteToWeb::pages; i++)
+ {
+ mi.flags = CMIM_FLAGS;
+ if (Options::instance->defWeb == i)
+ {
+ mi.flags |= CMIF_CHECKED;
+ }
+
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hWebPageMenus[i], (LPARAM)&mi);
+ }
+}
+
+void InitTabsrmmButton()
+{
+ if (ServiceExists(MS_BB_ADDBUTTON))
+ {
+ BBButton btn = {0};
+ btn.cbSize = sizeof(btn);
+ btn.dwButtonID = 1;
+ btn.pszModuleName = MODULE;
+ btn.dwDefPos = 110;
+ btn.hIcon = hMainIcon;
+ btn.bbbFlags = BBBF_ISARROWBUTTON | BBBF_ISIMBUTTON | BBBF_ISLSIDEBUTTON | BBBF_CANBEHIDDEN | BBBF_ISCHATBUTTON;
+ btn.ptszTooltip = TranslateT("Paste It");
+ CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&btn);
+ if(hTabsrmmButtonPressed != NULL)
+ {
+ UnhookEvent(hTabsrmmButtonPressed);
+ }
+
+ hTabsrmmButtonPressed = HookEvent(ME_MSG_BUTTONPRESSED, TabsrmmButtonPressed);
+ }
+}
+
+void InitUpdater()
+{
+ if (ServiceExists(MS_UPDATE_REGISTER))
+ {
+ Update update = {0};
+ char szVersion[16];
+ update.cbSize = sizeof(Update);
+ update.szComponentName = pluginInfo.shortName;
+ update.pbVersion = (BYTE *)CreateVersionStringPluginEx(&pluginInfo, szVersion);
+ update.cpbVersion = (int)strlen((char *)update.pbVersion);
+
+#ifdef _WIN64
+ update.szUpdateURL = "http://programista.free.of.pl/miranda/PasteIt64.zip";
+#else
+ update.szUpdateURL = "http://programista.free.of.pl/miranda/PasteIt.zip";
+#endif
+ update.szVersionURL = "http://programista.free.of.pl/miranda/PasteItVersion.txt";
+ update.pbVersionPrefix = (BYTE *)"Paste It ";
+ update.cpbVersionPrefix = (int)strlen((char *)update.pbVersionPrefix);
+ CallService(MS_UPDATE_REGISTER, 0, (WPARAM)&update);
+ }
+}
+
+int WindowEvent(WPARAM wParam, MessageWindowEventData* lParam)
+{
+ if(lParam->uType == MSG_WINDOW_EVT_OPEN)
+ {
+ char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)lParam->hContact, 0);
+ if (szProto && (INT_PTR)szProto != CALLSERVICE_NOTFOUND)
+ {
+ if(DBGetContactSettingByte(lParam->hContact, szProto, "ChatRoom", 0))
+ {
+ (*contactWindows)[lParam->hContact] = lParam->hwndInput;
+ }
+ }
+ }
+ else if(lParam->uType == MSG_WINDOW_EVT_CLOSE)
+ {
+ std::map<HANDLE, HWND>::iterator it = contactWindows->find(lParam->hContact);
+ if(it != contactWindows->end())
+ {
+ contactWindows->erase(it);
+ }
+ }
+
+ return 0;
+}
+
+int ModulesLoaded(WPARAM wParam, LPARAM lParam)
+{
+ InitIcolib();
+ InitMenuItems();
+ InitTabsrmmButton();
+ InitUpdater();
+ hWindowEvent = HookEvent(ME_MSG_WINDOWEVENT, (MIRANDAHOOK)WindowEvent);
+
+ return 0;
+}
+
+extern "C" int __declspec(dllexport) Load(PLUGINLINK *link)
+{
+ pluginLink = link;
+ mir_getMMI(&mmi);
+ mir_getXI(&xi);
+ mir_getLP(&pluginInfo);
+ NETLIBUSER nlu = {0};
+ nlu.cbSize = sizeof(nlu);
+ nlu.flags = NUF_TCHAR | NUF_OUTGOING | NUF_HTTPCONNS;
+ nlu.szSettingsModule = MODULE;
+ nlu.ptszDescriptiveName = TranslateT("Paste It HTTP connections");
+ g_hNetlibUser = ( HANDLE )CallService( MS_NETLIB_REGISTERUSER, 0, ( LPARAM )&nlu );
+
+ pasteToWebs[0] = new PasteToWeb1();
+ pasteToWebs[0]->pageIndex = 0;
+ pasteToWebs[1] = new PasteToWeb2();
+ pasteToWebs[1]->pageIndex = 1;
+ Options::instance = new Options();
+ pasteToWebs[0]->ConfigureSettings();
+ pasteToWebs[1]->ConfigureSettings();
+ Options::instance->Load();
+ hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
+ hOptionsInit = HookEvent(ME_OPT_INITIALISE, Options::InitOptions);
+ hTabsrmmButtonPressed = NULL;
+ hServiceContactMenu = CreateServiceFunction(MS_PASTEIT_CONTACTMENU, ContactMenuService);
+ contactWindows = new std::map<HANDLE, HWND>();
+ return 0;
+}
+
+extern "C" int __declspec(dllexport) Unload(void)
+{
+ UnhookEvent(hModulesLoaded);
+ UnhookEvent(hPrebuildContactMenu);
+ UnhookEvent(hOptionsInit);
+ if(hWindowEvent != NULL)
+ {
+ UnhookEvent(hWindowEvent);
+ }
+ DestroyServiceFunction(hServiceContactMenu);
+ Netlib_CloseHandle(g_hNetlibUser);
+ if(hTabsrmmButtonPressed != NULL)
+ {
+ UnhookEvent(hTabsrmmButtonPressed);
+ }
+ for(int i=0; i < PasteToWeb::pages; ++i)
+ {
+ if(pasteToWebs[i] != NULL)
+ {
+ delete pasteToWebs[i];
+ pasteToWebs[i] = NULL;
+ }
+ }
+ if(Options::instance != NULL)
+ {
+ delete Options::instance;
+ Options::instance = NULL;
+ }
+
+ delete contactWindows;
+ return 0;
+}
diff --git a/plugins/PasteIt/PasteIt.rc b/plugins/PasteIt/PasteIt.rc new file mode 100644 index 0000000000..e428a849ab --- /dev/null +++ b/plugins/PasteIt/PasteIt.rc @@ -0,0 +1,140 @@ +#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+//#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+#include <winres.h>
+#include <windows.h>
+
+/////////////////////////////////////////////////////////////////////////////
+// Neutral resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
+#ifdef _WIN32
+LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+#pragma code_page(1250)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_OPT_MAIN DIALOGEX 0, 0, 285, 225
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ GROUPBOX "Settings",IDC_STATIC,7,5,274,220
+ COMBOBOX IDC_WEBLIST,134,20,135,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ LTEXT "Default web page",IDC_STATIC,14,23,117,8
+ COMBOBOX IDC_CODEPAGE,134,43,135,30,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
+ LTEXT "Default file encoding",IDC_STATIC,14,45,114,8
+ CONTROL "Auto-detect UTF-8",IDC_AUTOUTF,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,66,236,10
+ CONTROL "Show confirmation dialog box",IDC_CONFDLG,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,80,236,10
+ CONTROL "Autosend download link to contact",IDC_AUTOSEND,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,94,236,10
+END
+
+IDD_OPT_PAGES DIALOGEX 0, 0, 285, 225
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ GROUPBOX "Web page settings",IDC_STATIC,7,30,274,195
+ COMBOBOX IDC_WEBPAGE,145,7,135,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ LTEXT "Web page to configure",IDC_STATIC,14,10,125,8
+ COMBOBOX IDC_DEFFORMAT,138,43,80,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ PUSHBUTTON "Configure",IDC_CONFIGURE,223,43,50,14
+ LTEXT "Default formatting",IDC_STATIC,14,45,120,8
+ CONTROL "Auto-detect format from file extension",IDC_AUTOFORMAT,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,66,236,10
+ CONTROL "Public paste",IDC_PUBLICPASTE,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,66,236,10
+ COMBOBOX IDC_COMBO1,138,83,135,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ LTEXT "",IDC_COMBO1_DESC,14,86,120,8
+ CONTROL "Login as guest",IDC_GUEST,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,106,236,10
+ EDITTEXT IDC_PASTEBIN_KEY,138,123,135,12,WS_TABSTOP|ES_AUTOHSCROLL
+ LTEXT "User key",IDC_PASTEBIN_KEY_DESC,14,126,90,8
+ PUSHBUTTON "Get user key",IDC_PASTEBIN_LOGIN,14,143,80,14, BS_MULTILINE
+END
+
+IDD_DLG_CONFIGURE DIALOGEX 0, 0, 214, 178
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Configure formatting"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ DEFPUSHBUTTON "OK",IDOK,120,159,40,14
+ PUSHBUTTON "Cancel",IDCANCEL,164,159,40,14
+ LISTBOX IDC_FORMATTING,10,10,150,144, WS_VSCROLL | LBS_WANTKEYBOARDINPUT
+ PUSHBUTTON "Up",IDC_UP,164,10,40,14
+ PUSHBUTTON "Down",IDC_DOWN,164,26,40,14
+ PUSHBUTTON "Delete",IDC_DELETE,164,42,40,14
+ PUSHBUTTON "Restore defaults",IDC_RESTORE,164,90,40,28, BS_MULTILINE
+ PUSHBUTTON "Download more",IDC_DOWNLOAD,164,120,40,28, BS_MULTILINE
+END
+
+IDD_DLG_PASTEBIN_LOGIN DIALOGEX 0, 0, 154, 60
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Login to pastebin.com"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ EDITTEXT IDC_PASTEBIN_USER,70,10,75,12,WS_TABSTOP|ES_AUTOHSCROLL
+ LTEXT "User name",IDC_STATIC,10,13,55,8
+ EDITTEXT IDC_PASTEBIN_PASSWORD,70,25,75,12,WS_TABSTOP|ES_PASSWORD|ES_AUTOHSCROLL
+ LTEXT "Password",IDC_STATIC,10,28,55,8
+ DEFPUSHBUTTON "OK",IDOK,60,40,40,14
+ PUSHBUTTON "Cancel",IDCANCEL,104,40,40,14
+END
+
+IDD_DLG_FROM_CLIPBOARD DIALOGEX 0, 0, 214, 178
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Paste It"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ DEFPUSHBUTTON "OK",IDOK,120,159,40,14
+ PUSHBUTTON "Cancel",IDCANCEL,164,159,40,14
+ EDITTEXT IDC_CLIPBOARD_DATA,10,10,194,129,WS_HSCROLL | WS_VSCROLL | ES_READONLY | ES_MULTILINE
+ COMBOBOX IDC_FORMAT,65,142,139,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ LTEXT "Format",IDC_STATIC,10,144,50,8
+END
+
+IDD_DLG_FROM_FILE DIALOGEX 0, 0, 214, 208
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Paste It"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ DEFPUSHBUTTON "OK",IDOK,120,189,40,14
+ PUSHBUTTON "Cancel",IDCANCEL,164,189,40,14
+ EDITTEXT IDC_FILE_PATH,10,10,194,12,ES_READONLY | ES_AUTOHSCROLL
+ EDITTEXT IDC_FILE_DATA,10,27,194,112,WS_HSCROLL | WS_VSCROLL | ES_READONLY | ES_MULTILINE
+ COMBOBOX IDC_CODEPAGE,65,142,139,30,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
+ LTEXT "Encoding",IDC_STATIC,10,144,50,8
+ CONTROL "Auto-detect format from file extension",IDC_AUTOFORMAT,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,159,180,10
+ COMBOBOX IDC_FORMAT,65,172,139,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ LTEXT "Format",IDC_FORMATTEXT,10,174,50,8
+ PUSHBUTTON "Recode",IDC_RECODE,10,189,60,14
+END
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_MENU ICON "icons\\Paste.ico"
+#endif // Neutral resources
+/////////////////////////////////////////////////////////////////////////////
+
diff --git a/plugins/PasteIt/PasteIt.sln b/plugins/PasteIt/PasteIt.sln new file mode 100644 index 0000000000..45c1f9274a --- /dev/null +++ b/plugins/PasteIt/PasteIt.sln @@ -0,0 +1,26 @@ +
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual C++ Express 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PasteIt", "PasteIt.vcxproj", "{BAEBC482-CDA9-4053-A7D0-08222E85118E}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {BAEBC482-CDA9-4053-A7D0-08222E85118E}.Debug|Win32.ActiveCfg = Debug|Win32
+ {BAEBC482-CDA9-4053-A7D0-08222E85118E}.Debug|Win32.Build.0 = Debug|Win32
+ {BAEBC482-CDA9-4053-A7D0-08222E85118E}.Debug|x64.ActiveCfg = Debug|x64
+ {BAEBC482-CDA9-4053-A7D0-08222E85118E}.Debug|x64.Build.0 = Debug|x64
+ {BAEBC482-CDA9-4053-A7D0-08222E85118E}.Release|Win32.ActiveCfg = Release|Win32
+ {BAEBC482-CDA9-4053-A7D0-08222E85118E}.Release|Win32.Build.0 = Release|Win32
+ {BAEBC482-CDA9-4053-A7D0-08222E85118E}.Release|x64.ActiveCfg = Release|x64
+ {BAEBC482-CDA9-4053-A7D0-08222E85118E}.Release|x64.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/plugins/PasteIt/PasteIt.vcxproj b/plugins/PasteIt/PasteIt.vcxproj new file mode 100644 index 0000000000..0cb427047b --- /dev/null +++ b/plugins/PasteIt/PasteIt.vcxproj @@ -0,0 +1,226 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{BAEBC482-CDA9-4053-A7D0-08222E85118E}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>PasteIt</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v90</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>obj\$(Platform)\$(Configuration)\</IntDir>
+ <OutDir>C:\Miranda\Plugins\</OutDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>obj\$(Platform)\$(Configuration)\</IntDir>
+ <OutDir>C:\Miranda Im\Plugins\</OutDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+ <IntDir>obj\$(Platform)\$(Configuration)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>obj\$(Platform)\$(Configuration)\</IntDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;PASTEIT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <ResourceCompile>
+ <AdditionalIncludeDirectories>..\..\include\msapi;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;PASTEIT_EXPORTS;_WIN64;_AMD64_;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <ResourceCompile>
+ <AdditionalIncludeDirectories>..\..\include\msapi;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PASTEIT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <ResourceCompile>
+ <AdditionalIncludeDirectories>..\..\include\msapi;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <PostBuildEvent>
+ <Command>if not exist "$(TargetDir)Docs\" mkdir "$(TargetDir)Docs\"
+copy "$(ProjectDir)Docs\*.*" "$(TargetDir)Docs\"</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PASTEIT_EXPORTS;_WIN64;_AMD64_;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <ResourceCompile>
+ <AdditionalIncludeDirectories>..\..\include\msapi;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ResourceCompile>
+ <PostBuildEvent>
+ <Command>if not exist "$(TargetDir)Docs\" mkdir "$(TargetDir)Docs\"
+copy "$(ProjectDir)Docs\*.*" "$(TargetDir)Docs\"</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClInclude Include="Options.h" />
+ <ClInclude Include="PasteToWeb.h" />
+ <ClInclude Include="PasteToWeb1.h" />
+ <ClInclude Include="PasteToWeb2.h" />
+ <ClInclude Include="resource.h" />
+ <ClInclude Include="stdafx.h" />
+ <ClInclude Include="targetver.h" />
+ <ClInclude Include="version.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="dllmain.cpp">
+ <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
+ <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsManaged>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ </PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ </PrecompiledHeader>
+ <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
+ <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsManaged>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ </PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ </PrecompiledHeader>
+ </ClCompile>
+ <ClCompile Include="Options.cpp" />
+ <ClCompile Include="PasteIt.cpp" />
+ <ClCompile Include="PasteToWeb.cpp" />
+ <ClCompile Include="PasteToWeb1.cpp" />
+ <ClCompile Include="PasteToWeb2.cpp" />
+ <ClCompile Include="stdafx.cpp">
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="PasteIt.rc" />
+ <ResourceCompile Include="version.rc" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Docs\PasteIt_langpack_polish.txt" />
+ <None Include="Docs\PasteIt_licence.txt" />
+ <None Include="Docs\PasteIt_readme.txt" />
+ <None Include="Docs\PasteIt_translate.txt">
+ <DeploymentContent>false</DeploymentContent>
+ </None>
+ <None Include="icons\Paste.ico" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/plugins/PasteIt/PasteIt.vcxproj.filters b/plugins/PasteIt/PasteIt.vcxproj.filters new file mode 100644 index 0000000000..afdb460375 --- /dev/null +++ b/plugins/PasteIt/PasteIt.vcxproj.filters @@ -0,0 +1,94 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+ </Filter>
+ <Filter Include="Resource Files\Docs">
+ <UniqueIdentifier>{e6bd3d70-0d30-4cf4-a284-c0fd38c83fa5}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="stdafx.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="targetver.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="PasteToWeb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="PasteToWeb1.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="PasteToWeb2.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="version.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="resource.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="Options.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="stdafx.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="PasteIt.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="dllmain.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="PasteToWeb.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="PasteToWeb1.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="PasteToWeb2.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="Options.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="version.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ <ResourceCompile Include="PasteIt.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="icons\Paste.ico">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="Docs\PasteIt_licence.txt">
+ <Filter>Resource Files\Docs</Filter>
+ </None>
+ <None Include="Docs\PasteIt_translate.txt">
+ <Filter>Resource Files\Docs</Filter>
+ </None>
+ <None Include="Docs\PasteIt_langpack_polish.txt">
+ <Filter>Resource Files\Docs</Filter>
+ </None>
+ <None Include="Docs\PasteIt_readme.txt">
+ <Filter>Resource Files\Docs</Filter>
+ </None>
+ </ItemGroup>
+</Project>
\ No newline at end of file diff --git a/plugins/PasteIt/PasteToWeb.cpp b/plugins/PasteIt/PasteToWeb.cpp new file mode 100644 index 0000000000..a7cc9a3b5f --- /dev/null +++ b/plugins/PasteIt/PasteToWeb.cpp @@ -0,0 +1,577 @@ +/*
+Paste It plugin
+Copyright (C) 2011 Krzysztof Kral
+
+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 version 2
+of the License.
+
+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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "StdAfx.h"
+#include "PasteToWeb.h"
+#include "Options.h"
+#include "resource.h"
+
+extern HINSTANCE hInst;
+
+PasteToWeb::PasteToWeb()
+{
+}
+
+
+PasteToWeb::~PasteToWeb()
+{
+}
+
+struct FromClipboardData
+{
+ std::wstring content;
+ int page;
+ std::wstring format;
+};
+
+struct FromFileData
+{
+ char* content;
+ int contentLen;
+ wchar_t* contentW;
+ UINT codepage;
+ std::wstring *fileName;
+ int page;
+ std::wstring format;
+ bool sendFileName;
+};
+
+INT_PTR CALLBACK DlgProcFromClipboard(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwndDlg);
+ FromClipboardData* data = (FromClipboardData*)lParam;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+ int ts = 4;
+ Edit_SetTabStops(GetDlgItem(hwndDlg, IDC_CLIPBOARD_DATA), 1, &ts);
+ SetDlgItemText(hwndDlg, IDC_CLIPBOARD_DATA, data->content.c_str());
+ int sel = 0;
+ int i = 0;
+ std::wstring &defFormat = Options::instance->webOptions[data->page]->defFormatId;
+ HWND cb = GetDlgItem(hwndDlg, IDC_FORMAT);
+ for(std::list<PasteFormat>::iterator it = Options::instance->webOptions[data->page]->formats.begin(); it != Options::instance->webOptions[data->page]->formats.end(); ++it)
+ {
+ ComboBox_AddString(cb, it->name.c_str());
+ if(it->id == defFormat)
+ sel = i;
+ ++i;
+ }
+ if(!Options::instance->webOptions[data->page]->formats.empty())
+ {
+ ComboBox_SetCurSel(cb, sel);
+ }
+ return TRUE;
+ }
+ case WM_COMMAND:
+ {
+ if (HIWORD(wParam) == BN_CLICKED)
+ {
+ if (LOWORD(wParam) == IDOK)
+ {
+ FromClipboardData *clipboardData = (FromClipboardData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ int sel = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_FORMAT));
+ for(std::list<PasteFormat>::iterator it = Options::instance->webOptions[clipboardData->page]->formats.begin(); it != Options::instance->webOptions[clipboardData->page]->formats.end(); ++it)
+ {
+ if(sel-- <= 0)
+ {
+ clipboardData->format = it->id;
+ break;
+ }
+ }
+
+ EndDialog(hwndDlg, IDC_BTN_OK);
+ }
+ else if (LOWORD(wParam) == IDCANCEL)
+ {
+ EndDialog(hwndDlg, IDCANCEL);
+ }
+ }
+
+ break;
+ }
+ }
+
+ return FALSE;
+}
+
+void RecodeDlg(HWND hwndDlg)
+{
+ ShowWindow(GetDlgItem(hwndDlg,IDC_RECODE),SW_HIDE);
+ FromFileData *fromFileData = (FromFileData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ unsigned int cp = Options::GetCodepageCB(GetDlgItem(hwndDlg, IDC_CODEPAGE), false, fromFileData->codepage);
+ mir_free(fromFileData->contentW);
+ int cbLen = 0;
+ if(cp == 1200 || cp == 1201)
+ {
+ // UTF-16
+ cbLen = fromFileData->contentLen / 2;
+ }
+ else
+ {
+ cbLen = MultiByteToWideChar( cp, 0, fromFileData->content, fromFileData->contentLen, NULL, 0 );
+ }
+
+ fromFileData->contentW = ( wchar_t* )mir_alloc( sizeof( wchar_t )*(cbLen+1));
+ if ( fromFileData->contentW != NULL )
+ {
+ if(cp == 1200)
+ {
+ memcpy_s(fromFileData->contentW, sizeof( wchar_t )*(cbLen+1), fromFileData->content, sizeof( wchar_t )*cbLen);
+ }
+ else if(cp == 1201)
+ {
+ for(int i = 0 ; i < cbLen; ++i)
+ {
+ fromFileData->contentW[i] = ((unsigned char)fromFileData->content[i*2] << 8) | (unsigned char)fromFileData->content[i*2 + 1];
+ }
+ }
+ else
+ {
+ MultiByteToWideChar( cp, 0, fromFileData->content, fromFileData->contentLen, fromFileData->contentW, cbLen );
+ }
+
+ fromFileData->contentW[ cbLen ] = 0;
+ SetDlgItemText(hwndDlg, IDC_FILE_DATA, fromFileData->contentW);
+ }
+ else
+ {
+ SetDlgItemText(hwndDlg, IDC_FILE_DATA, _T(""));
+ }
+
+ fromFileData->codepage = cp;
+}
+
+INT_PTR CALLBACK DlgProcFromFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwndDlg);
+ FromFileData *fromFileData = (FromFileData*)lParam;
+ int ts = 4;
+ Edit_SetTabStops(GetDlgItem(hwndDlg, IDC_FILE_DATA), 1, &ts);
+ SetDlgItemText(hwndDlg, IDC_FILE_DATA, fromFileData->contentW);
+ SetDlgItemText(hwndDlg, IDC_FILE_PATH, fromFileData->fileName->c_str());
+ Options::InitCodepageCB(GetDlgItem(hwndDlg, IDC_CODEPAGE), fromFileData->codepage);
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+ ShowWindow(GetDlgItem(hwndDlg,IDC_RECODE),SW_HIDE);
+
+ int sel = 0;
+ int i = 0;
+ std::wstring &defFormat = Options::instance->webOptions[fromFileData->page]->defFormatId;
+ HWND cb = GetDlgItem(hwndDlg, IDC_FORMAT);
+ for(std::list<PasteFormat>::iterator it = Options::instance->webOptions[fromFileData->page]->formats.begin(); it != Options::instance->webOptions[fromFileData->page]->formats.end(); ++it)
+ {
+ ComboBox_AddString(cb, it->name.c_str());
+ if(it->id == defFormat)
+ sel = i;
+ ++i;
+ }
+ if(!Options::instance->webOptions[fromFileData->page]->formats.empty())
+ {
+ ComboBox_SetCurSel(cb, sel);
+ }
+
+ if(Options::instance->webOptions[fromFileData->page]->isSendFileName)
+ {
+ bool sendFileName = Options::instance->webOptions[fromFileData->page]->sendFileName;
+ CheckDlgButton(hwndDlg, IDC_AUTOFORMAT, sendFileName ? 1 : 0);
+ Button_Enable(GetDlgItem(hwndDlg, IDC_FORMAT), sendFileName ? 0 : 1);
+ Button_Enable(GetDlgItem(hwndDlg, IDC_FORMATTEXT), sendFileName ? 0 : 1);
+ }
+ else
+ Button_Enable(GetDlgItem(hwndDlg, IDC_AUTOFORMAT), FALSE);
+ return TRUE;
+ }
+ case WM_COMMAND:
+ {
+ if (HIWORD(wParam) == BN_CLICKED)
+ {
+ if (LOWORD(wParam) == IDOK)
+ {
+ FromFileData *fromFileData = (FromFileData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ int sel = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_FORMAT));
+ for(std::list<PasteFormat>::iterator it = Options::instance->webOptions[fromFileData->page]->formats.begin(); it != Options::instance->webOptions[fromFileData->page]->formats.end(); ++it)
+ {
+ if(sel-- <= 0)
+ {
+ fromFileData->format = it->id;
+ break;
+ }
+ }
+
+ if(Options::instance->webOptions[fromFileData->page]->isSendFileName)
+ fromFileData->sendFileName = IsDlgButtonChecked(hwndDlg, IDC_AUTOFORMAT) ? true : false;
+ else
+ fromFileData->sendFileName = false;
+
+ EndDialog(hwndDlg, IDC_BTN_OK);
+ }
+ else if (LOWORD(wParam) == IDCANCEL)
+ {
+ EndDialog(hwndDlg, IDCANCEL);
+ }
+ else if(LOWORD(wParam) == IDC_RECODE)
+ {
+ RecodeDlg(hwndDlg);
+ }
+ else if(LOWORD(wParam) == IDC_AUTOFORMAT)
+ {
+ UINT sendFileName = IsDlgButtonChecked(hwndDlg, IDC_AUTOFORMAT);
+ Button_Enable(GetDlgItem(hwndDlg, IDC_FORMAT), sendFileName ? 0 : 1);
+ Button_Enable(GetDlgItem(hwndDlg, IDC_FORMATTEXT), sendFileName ? 0 : 1);
+ }
+ }
+ else if(LOWORD(wParam) == IDC_CODEPAGE)
+ {
+ if(HIWORD(wParam) == CBN_SELCHANGE)
+ {
+ RecodeDlg(hwndDlg);
+ }
+ else if(HIWORD(wParam) == CBN_EDITCHANGE)
+ {
+ ShowWindow(GetDlgItem(hwndDlg,IDC_RECODE),SW_SHOW);
+ }
+ else if(HIWORD(wParam) == CBN_KILLFOCUS)
+ {
+ FromFileData *fromFileData = (FromFileData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ Options::GetCodepageCB(GetDlgItem(hwndDlg, IDC_CODEPAGE), true, fromFileData->codepage);
+ }
+ }
+
+ break;
+ }
+ }
+
+ return FALSE;
+}
+
+void PasteToWeb::FromClipboard()
+{
+ szFileLink[0] = 0;
+ error = NULL;
+ std::wstring str;
+ BOOL isFile = 0;
+ if(OpenClipboard(NULL))
+ {
+ HANDLE obj = GetClipboardData(CF_UNICODETEXT);
+ if(obj != NULL)
+ {
+ LPCWSTR wStr = (LPCWSTR)GlobalLock(obj);
+ str.append(wStr, wStr + wcslen(wStr));
+ GlobalUnlock(obj);
+ // Sometimes clipboard CF_UNICODETEXT format returns only 2 characters,
+ // to fix this I check if CF_TEXT contains more characters,
+ // if this is true, this mean that CF_UNICODETEXT is invalid.
+ obj = GetClipboardData(CF_TEXT);
+ if(obj != NULL)
+ {
+ LPCSTR cStr = (LPCSTR)GlobalLock(obj);
+ if(strlen(cStr) > str.length())
+ {
+ str = L"";
+ LPWSTR wStr = mir_a2u_cp(cStr, CP_ACP);
+ str.append(wStr, wStr + wcslen(wStr));
+ mir_free(wStr);
+ }
+ GlobalUnlock(obj);
+ }
+ }
+ else
+ {
+ obj = GetClipboardData(CF_TEXT);
+ if(obj != NULL)
+ {
+ LPCSTR cStr = (LPCSTR)GlobalLock(obj);
+ LPWSTR wStr = mir_a2u_cp(cStr, CP_ACP);
+ str.append(wStr, wStr + wcslen(wStr));
+ mir_free(wStr);
+ GlobalUnlock(obj);
+ }
+ else
+ {
+ obj = GetClipboardData(CF_HDROP);
+ if(obj != NULL)
+ {
+ LPDROPFILES df = (LPDROPFILES) GlobalLock(obj);
+ isFile = 1;
+ if(df->fWide)
+ {
+ // Unicode
+ WCHAR* file = (WCHAR*)((BYTE*)obj + df->pFiles);
+ size_t len = wcslen(file);
+ if(*(file + len + 1) == L'\0')
+ {
+ str.append(file, file + len);
+ }
+ else
+ {
+ error = TranslateT("You can only paste 1 file");
+ }
+ }
+ else
+ {
+ // ANSI
+ char* file = (char*)obj + df->pFiles;
+ size_t len = strlen(file);
+ if(*(file + len + 1) == '\0')
+ {
+ LPWSTR wStr = mir_a2u_cp(file, CP_ACP);
+ str.append(wStr, wStr + wcslen(wStr));
+ mir_free(wStr);
+ }
+ else
+ {
+ error = TranslateT("You can only paste 1 file");
+ }
+ }
+ GlobalUnlock(obj);
+ }
+ }
+ }
+
+ CloseClipboard();
+ }
+
+ if(str.length() > 0)
+ {
+ if(isFile)
+ FromFile(str);
+ else
+ {
+ FromClipboardData data;
+ data.content = str;
+ data.page = pageIndex;
+ if (Options::instance->confDlg && DialogBoxParam (hInst, MAKEINTRESOURCE(IDD_DLG_FROM_CLIPBOARD), 0, DlgProcFromClipboard, (LPARAM)&data) != IDC_BTN_OK)
+ return;
+
+ SendToServer(str, L"", data.format);
+ }
+ }
+ else if(error == NULL)
+ {
+ error = TranslateT("Cannot get data from clipboard");
+ }
+}
+
+void PasteToWeb::FromFile(std::wstring file)
+{
+ error = NULL;
+ szFileLink[0] = 0;
+ HANDLE hFile = CreateFile(file.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
+ FromFileData fromFileData;
+ fromFileData.content = NULL;
+ fromFileData.contentLen = 0;
+ fromFileData.fileName = &file;
+ if(hFile != INVALID_HANDLE_VALUE)
+ {
+ LARGE_INTEGER fileSize;
+ if(GetFileSizeEx(hFile, &fileSize))
+ {
+ if(fileSize.QuadPart <= 10485760LL)
+ {
+ if(fileSize.QuadPart > 512000LL)
+ {
+ _stprintf_s(bufErr, 1024, TranslateT("File size is %dKB, do you realy want to paste such large file?"), fileSize.LowPart / 1024);
+ if(MessageBox(NULL, bufErr, TranslateT("Are You sure?"), MB_YESNO | MB_ICONQUESTION) != IDYES)
+ {
+ CloseHandle(hFile);
+ return;
+ }
+ }
+ DWORD readed;
+ fromFileData.contentLen = fileSize.LowPart;
+ fromFileData.content = (char*)mir_alloc(fromFileData.contentLen);
+ if(!ReadFile(hFile, fromFileData.content, fromFileData.contentLen, &readed, NULL))
+ {
+ mir_free(fromFileData.content);
+ fromFileData.content = NULL;
+ fromFileData.contentLen = 0;
+ _stprintf_s(bufErr, 1024, TranslateT("Cannot read file '%s'"), file.c_str());
+ error = bufErr;
+ }
+ }
+ else
+ {
+ error = TranslateT("File size is larger then 10MB, cannot be send");
+ }
+ }
+
+ CloseHandle(hFile);
+ }
+ else
+ {
+ _stprintf_s(bufErr, 1024, TranslateT("Cannot open file '%s'"), file.c_str());
+ error = bufErr;
+ }
+
+ if(fromFileData.content != NULL)
+ {
+ int cbLen = 0;
+ bool isDefTranslation = true;
+ if(Options::instance->autoUTF)
+ {
+ isDefTranslation = false;
+ fromFileData.codepage = CP_UTF8;
+ cbLen = MultiByteToWideChar( fromFileData.codepage, MB_ERR_INVALID_CHARS, fromFileData.content, fromFileData.contentLen, NULL, 0 );
+ if(cbLen == 0)
+ {
+ int errorN = GetLastError();
+ if(errorN == ERROR_NO_UNICODE_TRANSLATION)
+ {
+ isDefTranslation = true;
+ }
+ }
+ }
+
+ if(isDefTranslation)
+ {
+ fromFileData.codepage = Options::instance->codepage;
+ if(fromFileData.codepage == 1200 || fromFileData.codepage == 1201)
+ {
+ // UTF-16
+ cbLen = fromFileData.contentLen / 2;
+ }
+ else
+ {
+ cbLen = MultiByteToWideChar( fromFileData.codepage, 0, fromFileData.content, fromFileData.contentLen, NULL, 0 );
+ }
+ }
+
+ if(cbLen > 0)
+ {
+ fromFileData.contentW = ( wchar_t* )mir_alloc( sizeof( wchar_t )*(cbLen+1));
+ if ( fromFileData.contentW != NULL )
+ {
+ if(fromFileData.codepage == 1200)
+ {
+ memcpy_s(fromFileData.contentW, sizeof( wchar_t )*(cbLen+1), fromFileData.content, sizeof( wchar_t )*cbLen);
+ }
+ else if(fromFileData.codepage == 1201)
+ {
+ for(int i = 0 ; i < cbLen; ++i)
+ {
+ fromFileData.contentW[i] = (fromFileData.content[i*2] << 8) | fromFileData.content[i*2 + 1];
+ }
+ }
+ else
+ {
+ MultiByteToWideChar( fromFileData.codepage, 0, fromFileData.content, fromFileData.contentLen, fromFileData.contentW, cbLen );
+ }
+
+ fromFileData.contentW[ cbLen ] = 0;
+ fromFileData.page = pageIndex;
+ if (!Options::instance->confDlg || DialogBoxParam (hInst, MAKEINTRESOURCE(IDD_DLG_FROM_FILE), 0, DlgProcFromFile, (LPARAM)&fromFileData) == IDC_BTN_OK)
+ {
+ std::wstring fileName;
+ std::wstring::size_type pos1 = file.find_last_of(L'\\');
+ std::wstring::size_type pos2 = file.find_last_of(L'/');
+ if(pos2 > pos1 && pos2 < file.length())
+ pos1 = pos2;
+ if(pos1 >= 0 && pos1 + 1 < file.length())
+ fileName = file.substr(pos1 + 1);
+ else
+ fileName = file;
+ SendToServer(fromFileData.contentW, fromFileData.sendFileName ? fileName : L"", fromFileData.format);
+ }
+ mir_free(fromFileData.contentW);
+ }
+ }
+ else
+ {
+ _stprintf_s(bufErr, 1024, TranslateT("File '%s' is empty"), file.c_str());
+ error = bufErr;
+ }
+ mir_free(fromFileData.content);
+ }
+}
+
+extern HANDLE g_hNetlibUser;
+
+wchar_t* PasteToWeb::SendToWeb(char* url, std::map<std::string, std::string>& headers, std::wstring content)
+{
+ wchar_t* resCont = NULL;
+ int cbLen = WideCharToMultiByte( CP_UTF8, 0, content.c_str(), -1, NULL, 0, NULL, NULL );
+ char* contentBytes = ( char* )mir_alloc(cbLen);
+ if ( contentBytes == NULL )
+ return resCont;
+
+ WideCharToMultiByte( CP_UTF8, 0, content.c_str(), -1, contentBytes, cbLen, NULL, NULL );
+ --cbLen;
+
+ int nHeaders = 0;
+ for(std::map<std::string, std::string>::iterator it = headers.begin(); it != headers.end(); ++it)
+ {
+ ++nHeaders;
+ }
+
+ NETLIBHTTPREQUEST nlhr={0};
+ NETLIBHTTPHEADER* httpHeaders = new NETLIBHTTPHEADER[nHeaders];
+ nlhr.cbSize=sizeof(nlhr);
+ nlhr.requestType=REQUEST_POST;
+ nlhr.flags=NLHRF_NODUMPSEND|NLHRF_DUMPASTEXT|NLHPIF_HTTP11;
+ nlhr.szUrl=url;
+ nlhr.headers = httpHeaders;
+ nlhr.pData = contentBytes;
+ nlhr.dataLength = cbLen;
+ nHeaders = 0;
+ std::list<char*> mallBuf;
+ for(std::map<std::string, std::string>::iterator it = headers.begin(); it != headers.end(); ++it)
+ {
+ char* b1 = new char[it->first.length() + 1];
+ char* b2 = new char[it->second.length() + 1];
+ strcpy_s(b1, it->first.length() + 1, it->first.c_str());
+ strcpy_s(b2, it->second.length() + 1, it->second.c_str());
+ httpHeaders[nHeaders].szName = b1;
+ httpHeaders[nHeaders].szValue = b2;
+ mallBuf.push_back(b1);
+ mallBuf.push_back(b2);
+ ++nHeaders;
+ }
+
+ nlhr.headersCount = nHeaders;
+ NETLIBHTTPREQUEST* nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION,(WPARAM)g_hNetlibUser,(LPARAM)&nlhr);
+ if(nlhrReply != NULL)
+ {
+ if(nlhrReply->resultCode == 200)
+ {
+ int resLen = MultiByteToWideChar(CP_UTF8, 0, nlhrReply->pData, nlhrReply->dataLength, NULL, 0);
+ ++resLen;
+ resCont = ( wchar_t* )mir_alloc(resLen * sizeof(wchar_t));
+ if ( resCont != NULL )
+ {
+ resLen = MultiByteToWideChar( CP_UTF8, 0, nlhrReply->pData, nlhrReply->dataLength, resCont, resLen);
+ resCont[resLen] = 0;
+ }
+ }
+
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply);
+ }
+ delete httpHeaders;
+ for(std::list<char*>::iterator it = mallBuf.begin(); it != mallBuf.end(); ++it)
+ {
+ delete *it;
+ }
+
+ mir_free(contentBytes);
+ return resCont;
+}
diff --git a/plugins/PasteIt/PasteToWeb.h b/plugins/PasteIt/PasteToWeb.h new file mode 100644 index 0000000000..51e2141790 --- /dev/null +++ b/plugins/PasteIt/PasteToWeb.h @@ -0,0 +1,47 @@ +/*
+Paste It plugin
+Copyright (C) 2011 Krzysztof Kral
+
+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 version 2
+of the License.
+
+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, see <http://www.gnu.org/licenses/>.
+*/
+
+#pragma once
+
+struct PasteFormat
+{
+ std::wstring id;
+ std::wstring name;
+};
+
+class PasteToWeb
+{
+protected:
+ virtual void SendToServer(std::wstring str, std::wstring fileName, std::wstring format) = 0;
+ wchar_t* SendToWeb(char* url, std::map<std::string, std::string>& headers, std::wstring content);
+ PasteToWeb();
+ TCHAR bufErr[1024];
+public:
+ virtual ~PasteToWeb();
+ char szFileLink[256];
+ TCHAR* error;
+ void FromClipboard();
+ void FromFile(std::wstring file);
+ virtual TCHAR* GetName() = 0;
+ virtual void ConfigureSettings() = 0;
+ int pageIndex;
+ virtual std::list<PasteFormat> GetFormats() = 0;
+ virtual std::list<PasteFormat> GetDefFormats() = 0;
+ static const int pages = 2;
+};
+
diff --git a/plugins/PasteIt/PasteToWeb1.cpp b/plugins/PasteIt/PasteToWeb1.cpp new file mode 100644 index 0000000000..bbdc2e1ba5 --- /dev/null +++ b/plugins/PasteIt/PasteToWeb1.cpp @@ -0,0 +1,393 @@ +/*
+Paste It plugin
+Copyright (C) 2011 Krzysztof Kral
+
+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 version 2
+of the License.
+
+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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "StdAfx.h"
+#include "PasteToWeb1.h"
+#include "Options.h"
+
+PasteFormat PasteToWeb1::formats[] =
+{
+ {L"4cs", L"4CS"},
+ {L"6502acme", L"6502 ACME Cross Assembler"},
+ {L"6502kickass", L"6502 Kick Assembler"},
+ {L"6502tasm", L"6502 TASM/64TASS"},
+ {L"abap", L"ABAP"},
+ {L"actionscript", L"ActionScript"},
+ {L"actionscript3", L"ActionScript 3"},
+ {L"ada", L"Ada"},
+ {L"algol68", L"ALGOL 68"},
+ {L"apache", L"Apache Log"},
+ {L"applescript", L"AppleScript"},
+ {L"apt_sources", L"APT Sources"},
+ {L"asm", L"ASM (NASM)"},
+ {L"asp", L"ASP"},
+ {L"autoconf", L"autoconf"},
+ {L"autohotkey", L"Autohotkey"},
+ {L"autoit", L"AutoIt"},
+ {L"avisynth", L"Avisynth"},
+ {L"awk", L"Awk"},
+ {L"bascomavr", L"BASCOM AVR"},
+ {L"bash", L"Bash"},
+ {L"basic4gl", L"Basic4GL"},
+ {L"bibtex", L"BibTeX"},
+ {L"blitzbasic", L"Blitz Basic"},
+ {L"bnf", L"BNF"},
+ {L"boo", L"BOO"},
+ {L"bf", L"BrainFuck"},
+ {L"c", L"C"},
+ {L"c_mac", L"C for Macs"},
+ {L"cil", L"C Intermediate Language"},
+ {L"csharp", L"C#"},
+ {L"cpp", L"C++"},
+ {L"cpp-qt", L"C++ (with QT extensions)"},
+ {L"c_loadrunner", L"C: Loadrunner"},
+ {L"caddcl", L"CAD DCL"},
+ {L"cadlisp", L"CAD Lisp"},
+ {L"cfdg", L"CFDG"},
+ {L"chaiscript", L"ChaiScript"},
+ {L"clojure", L"Clojure"},
+ {L"klonec", L"Clone C"},
+ {L"klonecpp", L"Clone C++"},
+ {L"cmake", L"CMake"},
+ {L"cobol", L"COBOL"},
+ {L"coffeescript", L"CoffeeScript"},
+ {L"cfm", L"ColdFusion"},
+ {L"css", L"CSS"},
+ {L"cuesheet", L"Cuesheet"},
+ {L"d", L"D"},
+ {L"dcs", L"DCS"},
+ {L"delphi", L"Delphi"},
+ {L"oxygene", L"Delphi Prism (Oxygene)"},
+ {L"diff", L"Diff"},
+ {L"div", L"DIV"},
+ {L"dos", L"DOS"},
+ {L"dot", L"DOT"},
+ {L"e", L"E"},
+ {L"ecmascript", L"ECMAScript"},
+ {L"eiffel", L"Eiffel"},
+ {L"email", L"Email"},
+ {L"epc", L"EPC"},
+ {L"erlang", L"Erlang"},
+ {L"fsharp", L"F#"},
+ {L"falcon", L"Falcon"},
+ {L"fo", L"FO Language"},
+ {L"f1", L"Formula One"},
+ {L"fortran", L"Fortran"},
+ {L"freebasic", L"FreeBasic"},
+ {L"gambas", L"GAMBAS"},
+ {L"gml", L"Game Maker"},
+ {L"gdb", L"GDB"},
+ {L"genero", L"Genero"},
+ {L"genie", L"Genie"},
+ {L"gettext", L"GetText"},
+ {L"go", L"Go"},
+ {L"groovy", L"Groovy"},
+ {L"gwbasic", L"GwBasic"},
+ {L"haskell", L"Haskell"},
+ {L"hicest", L"HicEst"},
+ {L"hq9plus", L"HQ9 Plus"},
+ {L"html4strict", L"HTML"},
+ {L"html5", L"HTML 5"},
+ {L"icon", L"Icon"},
+ {L"idl", L"IDL"},
+ {L"ini", L"INI file"},
+ {L"inno", L"Inno Script"},
+ {L"intercal", L"INTERCAL"},
+ {L"io", L"IO"},
+ {L"j", L"J"},
+ {L"java", L"Java"},
+ {L"java5", L"Java 5"},
+ {L"javascript", L"JavaScript"},
+ {L"jquery", L"jQuery"},
+ {L"kixtart", L"KiXtart"},
+ {L"latex", L"Latex"},
+ {L"lb", L"Liberty BASIC"},
+ {L"lsl2", L"Linden Scripting"},
+ {L"lisp", L"Lisp"},
+ {L"llvm", L"LLVM"},
+ {L"locobasic", L"Loco Basic"},
+ {L"logtalk", L"Logtalk"},
+ {L"lolcode", L"LOL Code"},
+ {L"lotusformulas", L"Lotus Formulas"},
+ {L"lotusscript", L"Lotus Script"},
+ {L"lscript", L"LScript"},
+ {L"lua", L"Lua"},
+ {L"m68k", L"M68000 Assembler"},
+ {L"magiksf", L"MagikSF"},
+ {L"make", L"Make"},
+ {L"mapbasic", L"MapBasic"},
+ {L"matlab", L"MatLab"},
+ {L"mirc", L"mIRC"},
+ {L"mmix", L"MIX Assembler"},
+ {L"modula2", L"Modula 2"},
+ {L"modula3", L"Modula 3"},
+ {L"68000devpac", L"Motorola 68000 HiSoft Dev"},
+ {L"mpasm", L"MPASM"},
+ {L"mxml", L"MXML"},
+ {L"mysql", L"MySQL"},
+ {L"newlisp", L"newLISP"},
+ {L"text", L"None"},
+ {L"nsis", L"NullSoft Installer"},
+ {L"oberon2", L"Oberon 2"},
+ {L"objeck", L"Objeck Programming Langua"},
+ {L"objc", L"Objective C"},
+ {L"ocaml-brief", L"OCalm Brief"},
+ {L"ocaml", L"OCaml"},
+ {L"pf", L"OpenBSD PACKET FILTER"},
+ {L"glsl", L"OpenGL Shading"},
+ {L"oobas", L"Openoffice BASIC"},
+ {L"oracle11", L"Oracle 11"},
+ {L"oracle8", L"Oracle 8"},
+ {L"oz", L"Oz"},
+ {L"pascal", L"Pascal"},
+ {L"pawn", L"PAWN"},
+ {L"pcre", L"PCRE"},
+ {L"per", L"Per"},
+ {L"perl", L"Perl"},
+ {L"perl6", L"Perl 6"},
+ {L"php", L"PHP"},
+ {L"php-brief", L"PHP Brief"},
+ {L"pic16", L"Pic 16"},
+ {L"pike", L"Pike"},
+ {L"pixelbender", L"Pixel Bender"},
+ {L"plsql", L"PL/SQL"},
+ {L"postgresql", L"PostgreSQL"},
+ {L"povray", L"POV-Ray"},
+ {L"powershell", L"Power Shell"},
+ {L"powerbuilder", L"PowerBuilder"},
+ {L"proftpd", L"ProFTPd"},
+ {L"progress", L"Progress"},
+ {L"prolog", L"Prolog"},
+ {L"properties", L"Properties"},
+ {L"providex", L"ProvideX"},
+ {L"purebasic", L"PureBasic"},
+ {L"pycon", L"PyCon"},
+ {L"python", L"Python"},
+ {L"q", L"q/kdb+"},
+ {L"qbasic", L"QBasic"},
+ {L"rsplus", L"R"},
+ {L"rails", L"Rails"},
+ {L"rebol", L"REBOL"},
+ {L"reg", L"REG"},
+ {L"robots", L"Robots"},
+ {L"rpmspec", L"RPM Spec"},
+ {L"ruby", L"Ruby"},
+ {L"gnuplot", L"Ruby Gnuplot"},
+ {L"sas", L"SAS"},
+ {L"scala", L"Scala"},
+ {L"scheme", L"Scheme"},
+ {L"scilab", L"Scilab"},
+ {L"sdlbasic", L"SdlBasic"},
+ {L"smalltalk", L"Smalltalk"},
+ {L"smarty", L"Smarty"},
+ {L"sql", L"SQL"},
+ {L"systemverilog", L"SystemVerilog"},
+ {L"tsql", L"T-SQL"},
+ {L"tcl", L"TCL"},
+ {L"teraterm", L"Tera Term"},
+ {L"thinbasic", L"thinBasic"},
+ {L"typoscript", L"TypoScript"},
+ {L"unicon", L"Unicon"},
+ {L"uscript", L"UnrealScript"},
+ {L"vala", L"Vala"},
+ {L"vbnet", L"VB.NET"},
+ {L"verilog", L"VeriLog"},
+ {L"vhdl", L"VHDL"},
+ {L"vim", L"VIM"},
+ {L"visualprolog", L"Visual Pro Log"},
+ {L"vb", L"VisualBasic"},
+ {L"visualfoxpro", L"VisualFoxPro"},
+ {L"whitespace", L"WhiteSpace"},
+ {L"whois", L"WHOIS"},
+ {L"winbatch", L"Win Batch"},
+ {L"xbasic", L"XBasic"},
+ {L"xml", L"XML"},
+ {L"xorg_conf", L"Xorg Config"},
+ {L"xpp", L"XPP"},
+ {L"yaml", L"YAML"},
+ {L"z80", L"Z80 Assembler"},
+ {L"zxbasic", L"ZXBasic"},
+};
+
+PasteFormat PasteToWeb1::defFormats[] =
+{
+ {L"text", L"None"},
+ {L"xml", L"XML"},
+ {L"html4strict", L"HTML"},
+ {L"html5", L"HTML 5"},
+ {L"javascript", L"JavaScript"},
+ {L"php", L"PHP"},
+ {L"c", L"C"},
+ {L"csharp", L"C#"},
+ {L"cpp", L"C++"},
+ {L"java", L"Java"},
+ {L"java5", L"Java 5"},
+ {L"ini", L"INI file"},
+ {L"css", L"CSS"},
+ {L"sql", L"SQL"},
+ {L"asm", L"ASM (NASM)"},
+ {L"asp", L"ASP"},
+ {L"caddcl", L"CAD DCL"},
+ {L"cadlisp", L"CAD Lisp"},
+ {L"delphi", L"Delphi"},
+ {L"diff", L"Diff"},
+ {L"jquery", L"jQuery"},
+ {L"latex", L"Latex"},
+ {L"pascal", L"Pascal"},
+ {L"perl", L"Perl"},
+ {L"perl6", L"Perl 6"},
+ {L"python", L"Python"},
+ {L"vbnet", L"VB.NET"},
+ {L"vb", L"VisualBasic"},
+};
+
+PasteToWeb1::PasteToWeb1()
+{
+}
+
+
+PasteToWeb1::~PasteToWeb1()
+{
+}
+
+void PasteToWeb1::SendToServer(std::wstring str, std::wstring fileName, std::wstring format)
+{
+ std::map<std::string, std::string> headers;
+ headers["Content-Type"] = "application/x-www-form-urlencoded";
+ std::wstring content = _T("api_option=paste&api_paste_private=");
+ content += Options::instance->webOptions[pageIndex]->publicPaste ? _T("0") : _T("1");
+ content += _T("&api_paste_expire_date=");
+ content += Options::instance->webOptions[pageIndex]->combo1.empty() ? _T("1M") : Options::instance->webOptions[pageIndex]->combo1;
+ content += _T("&api_dev_key=dcba056bf9cc71729fdad76dddcb0dcd&api_paste_format=");
+ content += format;
+ if(!Options::instance->webOptions[pageIndex]->pastebinUserKey.empty())
+ {
+ content += _T("&api_user_key=");
+ content += Options::instance->webOptions[pageIndex]->pastebinUserKey;
+ }
+ content += _T("&api_paste_code=");
+ for(std::wstring::iterator it = str.begin(); it != str.end(); ++it)
+ {
+ if(*it == L'%')
+ {
+ content += L"%25";
+ }
+ else if(*it ==L'&')
+ {
+ content += L"%26";
+ }
+ else if(*it ==L'=')
+ {
+ content += L"%3D";
+ }
+ else
+ {
+ content += *it;
+ }
+ }
+
+ wchar_t* resCont = SendToWeb("http://pastebin.com/api/api_post.php", headers, content);
+ if(resCont != NULL)
+ {
+ if(memcmp(L"Bad API request, ", resCont, 17 * sizeof(wchar_t)) == 0)
+ {
+ _stprintf_s(bufErr, 1024, TranslateT("Error during sending text to web page: %s"), resCont + 17);
+ error = bufErr;
+ }
+ else
+ {
+ char* s = mir_u2a_cp(resCont, CP_ACP);
+ strcpy_s(szFileLink, 256, s);
+ mir_free(s);
+ }
+ mir_free(resCont);
+ }
+ else
+ {
+ error = TranslateT("Error during sending text to web page");
+ }
+}
+
+std::wstring PasteToWeb1::GetUserKey(std::wstring& user, std::wstring& password)
+{
+ std::map<std::string, std::string> headers;
+ headers["Content-Type"] = "application/x-www-form-urlencoded";
+ std::wstring content = _T("api_user_name=");
+ content += user;
+ content += _T("&api_user_password=");
+ content += password;
+ content += _T("&api_dev_key=dcba056bf9cc71729fdad76dddcb0dcd");
+ wchar_t* resCont = SendToWeb("http://pastebin.com/api/api_login.php", headers, content);
+ std::wstring toRet;
+ if(resCont != NULL)
+ {
+ if(memcmp(L"Bad API request, ", resCont, 17 * sizeof(wchar_t)) == 0)
+ {
+ _stprintf_s(bufErr, 1024, TranslateT("Error during getting user key from web page: %s"), resCont + 17);
+ MessageBox(NULL, bufErr, TranslateT("Error"), MB_OK | MB_ICONERROR);
+ }
+ else
+ toRet = resCont;
+ mir_free(resCont);
+ }
+
+ return toRet;
+}
+
+std::list<PasteFormat> PasteToWeb1::GetFormats()
+{
+ int count = sizeof(formats) / sizeof(formats[0]);
+ std::list<PasteFormat> ret(formats, formats + count);
+
+ return ret;
+}
+
+std::list<PasteFormat> PasteToWeb1::GetDefFormats()
+{
+ int count = sizeof(defFormats) / sizeof(defFormats[0]);
+ std::list<PasteFormat> ret(defFormats, defFormats + count);
+
+ return ret;
+}
+
+void PasteToWeb1::ConfigureSettings()
+{
+ Options::instance->webOptions[pageIndex]->isSendFileName = false;
+ Options::instance->webOptions[pageIndex]->isPublicPaste = true;
+ Options::instance->webOptions[pageIndex]->isCombo1 = true;
+ Options::instance->webOptions[pageIndex]->combo1Desc = TranslateT("Paste expire date");
+ PasteFormat pf;
+ pf.id = L"N";
+ pf.name = TranslateT("Never");
+ Options::instance->webOptions[pageIndex]->combo1Values.push_back(pf);
+ pf.id = L"10M";
+ pf.name = TranslateT("10 minutes");
+ Options::instance->webOptions[pageIndex]->combo1Values.push_back(pf);
+ pf.id = L"1H";
+ pf.name = TranslateT("1 hour");
+ Options::instance->webOptions[pageIndex]->combo1Values.push_back(pf);
+ pf.id = L"1D";
+ pf.name = TranslateT("1 day");
+ Options::instance->webOptions[pageIndex]->combo1Values.push_back(pf);
+ pf.id = L"1M";
+ pf.name = TranslateT("1 month");
+ Options::instance->webOptions[pageIndex]->combo1Values.push_back(pf);
+ Options::instance->webOptions[pageIndex]->combo1 = L"1M";
+ Options::instance->webOptions[pageIndex]->isPastebin = true;
+}
+
diff --git a/plugins/PasteIt/PasteToWeb1.h b/plugins/PasteIt/PasteToWeb1.h new file mode 100644 index 0000000000..b1611855d6 --- /dev/null +++ b/plugins/PasteIt/PasteToWeb1.h @@ -0,0 +1,40 @@ +/*
+Paste It plugin
+Copyright (C) 2011 Krzysztof Kral
+
+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 version 2
+of the License.
+
+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, see <http://www.gnu.org/licenses/>.
+*/
+
+#pragma once
+#include "pastetoweb.h"
+class PasteToWeb1 :
+ public PasteToWeb
+{
+protected:
+ virtual void SendToServer(std::wstring str, std::wstring fileName, std::wstring format);
+ static PasteFormat formats[];
+ static PasteFormat defFormats[];
+public:
+ PasteToWeb1();
+ virtual ~PasteToWeb1();
+ virtual TCHAR* GetName()
+ {
+ return _T("pastebin.com");
+ }
+ virtual void ConfigureSettings();
+ virtual std::list<PasteFormat> GetFormats();
+ virtual std::list<PasteFormat> GetDefFormats();
+ std::wstring GetUserKey(std::wstring& user, std::wstring& password);
+};
+
diff --git a/plugins/PasteIt/PasteToWeb2.cpp b/plugins/PasteIt/PasteToWeb2.cpp new file mode 100644 index 0000000000..c2edbddeef --- /dev/null +++ b/plugins/PasteIt/PasteToWeb2.cpp @@ -0,0 +1,247 @@ +/*
+Paste It plugin
+Copyright (C) 2011 Krzysztof Kral
+
+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 version 2
+of the License.
+
+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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "StdAfx.h"
+#include "PasteToWeb2.h"
+
+PasteFormat PasteToWeb2::defFormats[] =
+{
+ {L"text", L"Text"},
+ {L"xml", L"XML"},
+ {L"html", L"HTML"},
+ {L"js", L"JavaScript"},
+ {L"php", L"PHP"},
+ {L"c", L"C"},
+ {L"csharp", L"C#"},
+ {L"cpp", L"C++"},
+ {L"java", L"Java"},
+ {L"ini", L"INI"},
+ {L"css", L"CSS"},
+ {L"sql", L"SQL"},
+ {L"nasm", L"NASM"},
+ {L"delphi", L"Delphi"},
+ {L"diff", L"Diff"},
+ {L"tex", L"TeX"},
+ {L"perl", L"Perl"},
+ {L"python", L"Python"},
+ {L"vb.net", L"VB.net"}
+};
+
+PasteToWeb2::PasteToWeb2()
+{
+}
+
+
+PasteToWeb2::~PasteToWeb2()
+{
+}
+
+void PasteToWeb2::SendToServer(std::wstring str, std::wstring fileName, std::wstring format)
+{
+ std::map<std::string, std::string> headers;
+ headers["Content-Type"] = "text/xml";
+ std::wstring content = _T("<?xml version=\"1.0\"?>\r\n<methodCall><methodName>create_paste</methodName><params><param><value>");
+ if(fileName == L"")
+ {
+ content += format;
+ content += _T("</value></param><param><value>");
+ }
+ else
+ {
+ content += _T("</value></param><param><value>");
+ }
+ for(std::wstring::iterator it = str.begin(); it != str.end(); ++it)
+ {
+ if(*it == L'&')
+ {
+ content += L"&";
+ }
+ else if(*it ==L'<')
+ {
+ content += L"<";
+ }
+ else
+ {
+ content += *it;
+ }
+ }
+
+ content += _T("</value></param><param><value></value></param><param><value>");
+ if(fileName != L"")
+ {
+ for(std::wstring::iterator it = fileName.begin(); it != fileName.end(); ++it)
+ {
+ if(*it == L'&')
+ {
+ content += L"&";
+ }
+ else if(*it ==L'<')
+ {
+ content += L"<";
+ }
+ else
+ {
+ content += *it;
+ }
+ }
+ }
+ content += _T("</value></param><param><value></value></param><param><value><double>1.5</double></value></param></params></methodCall>");
+
+ wchar_t* resCont = SendToWeb("http://wklej.to/api/", headers, content);
+ error = TranslateT("Error during sending text to web page");
+ if(resCont != NULL)
+ {
+ HXML hXml = xi.parseString(resCont, NULL, _T("methodResponse"));
+ if(hXml != NULL)
+ {
+ HXML node = xi.getChildByPath(hXml, _T("params/param/value/array/data/value/int"), 0);
+ if(node != NULL && !_tcscmp(xi.getText(node), _T("1")))
+ {
+ node = xi.getChildByPath(hXml, _T("params/param/value/array/data"), 0);
+ if(node != NULL)
+ {
+ node = xi.getNthChild(node, _T("value"), 1);
+ if(node != NULL)
+ {
+ node = xi.getChildByPath(node, _T("string"), 0);
+ if(node != NULL)
+ {
+ char* s = mir_t2a_cp(xi.getText(node), CP_ACP);
+ strcpy_s(szFileLink, 256, s);
+ mir_free(s);
+ error = NULL;
+ }
+ }
+ }
+ }
+ xi.destroyNode(hXml);
+ }
+ mir_free(resCont);
+ }
+}
+
+std::list<PasteFormat> PasteToWeb2::GetFormats()
+{
+ std::list<PasteFormat> ret;
+
+ std::map<std::string, std::string> headers;
+ headers["Content-Type"] = "text/xml";
+ std::wstring content = _T("<?xml version=\"1.0\"?>\r\n<methodCall><methodName>types</methodName></methodCall>");
+
+ wchar_t* resCont = SendToWeb("http://wklej.to/api/", headers, content);
+ if(resCont != NULL)
+ {
+ HXML hXml = xi.parseString(resCont, NULL, _T("methodResponse"));
+ if(hXml != NULL)
+ {
+ HXML node = xi.getChildByPath(hXml, _T("params/param/value/array/data/value/int"), 0);
+ if(node != NULL && !_tcscmp(xi.getText(node), _T("1")))
+ {
+ node = xi.getChildByPath(hXml, _T("params/param/value/array/data"), 0);
+ if(node != NULL)
+ {
+ node = xi.getNthChild(node, _T("value"), 1);
+ if(node != NULL)
+ {
+ node = xi.getChildByPath(node, _T("string"), 0);
+ if(node != NULL)
+ {
+ std::wstring str = xi.getText(node);
+ std::wstring::size_type pos = str.find(L'\n');
+ if(pos < str.length())
+ {
+ str = str.substr(pos + 1);
+ }
+ pos = str.find(L'\n');
+ if(pos < str.length())
+ {
+ str = str.substr(pos + 1);
+ }
+ pos = str.find(L'\n');
+ while(pos < str.length())
+ {
+ std::wstring line = str.substr(0, pos);
+ std::wstring::size_type sep = line.find(L':');
+ if(sep < line.length())
+ {
+ PasteFormat pf;
+ pf.name = line.substr(0, sep);
+ std::wstring::size_type sep2 = line.find(L',');
+ if(sep2 < line.length())
+ {
+ pf.id = line.substr(sep + 2, sep2 - sep - 2);
+ }
+ else
+ {
+ pf.id = line.substr(sep + 2);
+ }
+ ret.push_back(pf);
+ }
+
+ if(pos < str.length() - 1)
+ {
+ str = str.substr(pos + 1);
+ }
+ else
+ {
+ str = L"";
+ }
+ pos = str.find(L'\n');
+ }
+ {
+ std::wstring line = str;
+ std::wstring::size_type sep = line.find(L':');
+ if(sep < line.length())
+ {
+ PasteFormat pf;
+ pf.name = line.substr(0, sep);
+ std::wstring::size_type sep2 = line.find(L',');
+ if(sep2 < line.length())
+ {
+ pf.id = line.substr(sep + 2, sep2 - sep - 2);
+ }
+ else
+ {
+ pf.id = line.substr(sep + 2);
+ }
+ ret.push_back(pf);
+ }
+ }
+ }
+ }
+ }
+ }
+ xi.destroyNode(hXml);
+ }
+ mir_free(resCont);
+ }
+
+ return ret;
+}
+
+std::list<PasteFormat> PasteToWeb2::GetDefFormats()
+{
+ int count = sizeof(defFormats) / sizeof(defFormats[0]);
+ std::list<PasteFormat> ret(defFormats, defFormats + count);
+
+ return ret;
+}
+
+void PasteToWeb2::ConfigureSettings()
+{
+}
diff --git a/plugins/PasteIt/PasteToWeb2.h b/plugins/PasteIt/PasteToWeb2.h new file mode 100644 index 0000000000..364c6eb4e4 --- /dev/null +++ b/plugins/PasteIt/PasteToWeb2.h @@ -0,0 +1,38 @@ +/*
+Paste It plugin
+Copyright (C) 2011 Krzysztof Kral
+
+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 version 2
+of the License.
+
+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, see <http://www.gnu.org/licenses/>.
+*/
+
+#pragma once
+#include "pastetoweb.h"
+class PasteToWeb2 :
+ public PasteToWeb
+{
+protected:
+ virtual void SendToServer(std::wstring str, std::wstring fileName, std::wstring format);
+ static PasteFormat defFormats[];
+public:
+ PasteToWeb2();
+ virtual ~PasteToWeb2();
+ virtual TCHAR* GetName()
+ {
+ return _T("wklej.to");
+ }
+ virtual void ConfigureSettings();
+ virtual std::list<PasteFormat> GetFormats();
+ virtual std::list<PasteFormat> GetDefFormats();
+};
+
diff --git a/plugins/PasteIt/dllmain.cpp b/plugins/PasteIt/dllmain.cpp new file mode 100644 index 0000000000..ad89773ec8 --- /dev/null +++ b/plugins/PasteIt/dllmain.cpp @@ -0,0 +1,14 @@ +// dllmain.cpp : Defines the entry point for the DLL application.
+#include "stdafx.h"
+
+HINSTANCE hInst;
+
+BOOL APIENTRY DllMain( HMODULE hModule,
+ DWORD ul_reason_for_call,
+ LPVOID lpReserved
+ )
+{
+ hInst = hModule;
+ return TRUE;
+}
+
diff --git a/plugins/PasteIt/icons/Paste.ico b/plugins/PasteIt/icons/Paste.ico Binary files differnew file mode 100644 index 0000000000..54e8087326 --- /dev/null +++ b/plugins/PasteIt/icons/Paste.ico diff --git a/plugins/PasteIt/resource.h b/plugins/PasteIt/resource.h new file mode 100644 index 0000000000..cbfa566679 --- /dev/null +++ b/plugins/PasteIt/resource.h @@ -0,0 +1,50 @@ +
+#define IDD_OPT_MAIN 101
+#define IDD_DLG_FROM_CLIPBOARD 102
+#define IDD_DLG_FROM_FILE 103
+#define IDD_OPT_PAGES 104
+#define IDD_DLG_CONFIGURE 105
+#define IDD_DLG_PASTEBIN_LOGIN 106
+#define IDC_WEBLIST 1001
+#define IDC_CONFDLG 1002
+#define IDC_AUTOSEND 1003
+#define IDC_CODEPAGE 1004
+#define IDC_AUTOUTF 1005
+#define IDC_CLIPBOARD_DATA 1006
+#define IDC_BTN_OK 1007
+#define IDC_FILE_DATA 1008
+#define IDC_FILE_PATH 1009
+#define IDC_RECODE 1010
+#define IDC_WEBPAGE 1011
+#define IDC_DEFFORMAT 1012
+#define IDC_AUTOFORMAT 1013
+#define IDC_CONFIGURE 1014
+#define IDC_FORMATTING 1015
+#define IDC_RESTORE 1016
+#define IDC_DOWNLOAD 1017
+#define IDC_DELETE 1018
+#define IDC_UP 1019
+#define IDC_DOWN 1020
+#define IDC_FORMAT 1021
+#define IDC_FORMATTEXT 1022
+#define IDC_PUBLICPASTE 1023
+#define IDC_COMBO1 1024
+#define IDC_COMBO1_DESC 1025
+#define IDC_GUEST 1026
+#define IDC_PASTEBIN_KEY 1027
+#define IDC_PASTEBIN_KEY_DESC 1028
+#define IDC_PASTEBIN_LOGIN 1029
+#define IDC_PASTEBIN_USER 1031
+#define IDC_PASTEBIN_PASSWORD 1032
+#define IDI_MENU 20000
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 107
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1033
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/plugins/PasteIt/stdafx.cpp b/plugins/PasteIt/stdafx.cpp new file mode 100644 index 0000000000..12ae832e21 --- /dev/null +++ b/plugins/PasteIt/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes
+// PasteIt.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
diff --git a/plugins/PasteIt/stdafx.h b/plugins/PasteIt/stdafx.h new file mode 100644 index 0000000000..0089cbb943 --- /dev/null +++ b/plugins/PasteIt/stdafx.h @@ -0,0 +1,44 @@ +// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+#include "targetver.h"
+
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+// Windows Header Files:
+#include <windows.h>
+#include <winsock.h>
+#include <Shlobj.h>
+#include <commdlg.h>
+#include <windowsx.h>
+#include <time.h>
+
+#include <tchar.h>
+#include <string>
+#include <map>
+#include <list>
+
+#define MIRANDA_VER 0x0700
+#define MIRANDA_CUSTOM_LP
+
+#include <newpluginapi.h>
+#include <m_clist.h>
+#include <m_skin.h>
+#include <m_langpack.h>
+#include <m_system.h>
+#include <m_utils.h>
+#include <m_netlib.h>
+#include <m_xml.h>
+#include <m_message.h>
+#include <m_protosvc.h>
+#include <m_icolib.h>
+#include <m_options.h>
+#include <m_database.h>
+#include <m_chat.h>
+#include <m_protoint.h>
+
+#include "sdk/m_msg_buttonsbar.h"
+#include "sdk/m_updater.h"
diff --git a/plugins/PasteIt/targetver.h b/plugins/PasteIt/targetver.h new file mode 100644 index 0000000000..90e767bfce --- /dev/null +++ b/plugins/PasteIt/targetver.h @@ -0,0 +1,8 @@ +#pragma once
+
+// Including SDKDDKVer.h defines the highest available Windows platform.
+
+// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
+// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
+
+#include <SDKDDKVer.h>
diff --git a/plugins/PasteIt/version.h b/plugins/PasteIt/version.h new file mode 100644 index 0000000000..e7d016c0a4 --- /dev/null +++ b/plugins/PasteIt/version.h @@ -0,0 +1,20 @@ +#define __MAJOR_VERSION 1
+#define __MINOR_VERSION 0
+#define __RELEASE_NUM 0
+#define __BUILD_NUM 3
+
+#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
+#define __FILEVERSION_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM
+
+#define __STRINGIFY_IMPL(x) #x
+#define __STRINGIFY(x) __STRINGIFY_IMPL(x)
+#define __VERSION_STRING __STRINGIFY(__FILEVERSION_DOTS)
+
+#define __PLUGIN_NAME "Paste It"
+#define __INTERNAL_NAME "PasteIt"
+#define __FILENAME "PasteIt.dll"
+#define __DESCRIPTION "Uploads the text to web page and sends the URL to your friends."
+#define __AUTHOR "Krzysztof Kral"
+#define __AUTHOREMAIL "programista@poczta.of.pl"
+#define __AUTHORWEB "http://programista.free.of.pl/miranda/"
+#define __COPYRIGHT "Copyright (c) 2011 KrzysztofKral"
diff --git a/plugins/PasteIt/version.rc b/plugins/PasteIt/version.rc new file mode 100644 index 0000000000..3fcaa468d0 --- /dev/null +++ b/plugins/PasteIt/version.rc @@ -0,0 +1,37 @@ +
+#include <windows.h>
+#include "version.h"
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION __FILEVERSION_STRING
+ PRODUCTVERSION __FILEVERSION_STRING
+ FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
+#ifdef _DEBUG
+ FILEFLAGS VS_FF_DEBUG
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS VOS_NT_WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE VFT2_UNKNOWN
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "000004b0"
+ BEGIN
+ VALUE "Author", "Krzysztof Kral"
+ VALUE "CompanyName", "Krzysztof Kral"
+ VALUE "FileDescription", __DESCRIPTION
+ VALUE "FileVersion", __VERSION_STRING
+ VALUE "InternalName", __INTERNAL_NAME
+ VALUE "LegalCopyright", __COPYRIGHT
+ VALUE "OriginalFilename", __FILENAME
+ VALUE "ProductName", __PLUGIN_NAME
+ VALUE "ProductVersion", __VERSION_STRING
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x0, 1200
+ END
+END
|