From 3182d972021c69dc23d6a7968dc0d141032b4acc Mon Sep 17 00:00:00 2001 From: mataes2007 Date: Wed, 4 May 2011 19:22:26 +0000 Subject: added PackUpdater added TranslitSwitcher git-svn-id: http://miranda-plugins.googlecode.com/svn/trunk@69 e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb --- PackUpdater/Docs/Langpack.txt | 36 + PackUpdater/Docs/Readme_eng.txt | 139 ++++ PackUpdater/Docs/Readme_rus.txt | 139 ++++ .../Docs/Templates/Autoexec_PackUpdater.ini | 10 + PackUpdater/Docs/Templates/File1.ini | 24 + PackUpdater/Docs/ToDo.txt | 2 + PackUpdater/PackUpdater_10.vcxproj | 229 ++++++ PackUpdater/PackUpdater_10.vcxproj.filters | 79 ++ PackUpdater/PackUpdater_9.vcproj | 433 ++++++++++ PackUpdater/Res/BtnClose.ico | Bin 0 -> 2550 bytes PackUpdater/Res/BtnOk.ico | Bin 0 -> 2550 bytes PackUpdater/Res/Delete.ico | Bin 0 -> 2550 bytes PackUpdater/Res/Menu.ico | Bin 0 -> 894 bytes PackUpdater/Resource.rc | 198 +++++ PackUpdater/Src/Common.h | 140 ++++ PackUpdater/Src/Events.cpp | 71 ++ PackUpdater/Src/Notifications.cpp | 678 ++++++++++++++++ PackUpdater/Src/Notifications.h | 72 ++ PackUpdater/Src/Options.cpp | 411 ++++++++++ PackUpdater/Src/PackUpdater.cpp | 118 +++ PackUpdater/Src/Utils.cpp | 389 +++++++++ PackUpdater/Version.h | 28 + PackUpdater/Version.rc | 38 + PackUpdater/resource.h | 71 ++ TranslitSwitcher/Docs/Readme.txt | 4 + TranslitSwitcher/Res/InvertSend.ico | Bin 0 -> 2038 bytes TranslitSwitcher/Res/SwitchSend.ico | Bin 0 -> 2038 bytes TranslitSwitcher/Res/TranslitSend.ico | Bin 0 -> 2038 bytes TranslitSwitcher/Resource.h | 18 + TranslitSwitcher/Resource.rc | 48 ++ TranslitSwitcher/Src/Layoutproc.cpp | 870 +++++++++++++++++++++ TranslitSwitcher/Src/TranslitSwitcher.cpp | 230 ++++++ TranslitSwitcher/Src/TranslitSwitcher.h | 56 ++ TranslitSwitcher/TranslitSwitcher_10.vcxproj | 188 +++++ .../TranslitSwitcher_10.vcxproj.filters | 44 ++ TranslitSwitcher/Version.h | 28 + TranslitSwitcher/Version.rc | 38 + 37 files changed, 4829 insertions(+) create mode 100644 PackUpdater/Docs/Langpack.txt create mode 100644 PackUpdater/Docs/Readme_eng.txt create mode 100644 PackUpdater/Docs/Readme_rus.txt create mode 100644 PackUpdater/Docs/Templates/Autoexec_PackUpdater.ini create mode 100644 PackUpdater/Docs/Templates/File1.ini create mode 100644 PackUpdater/Docs/ToDo.txt create mode 100644 PackUpdater/PackUpdater_10.vcxproj create mode 100644 PackUpdater/PackUpdater_10.vcxproj.filters create mode 100644 PackUpdater/PackUpdater_9.vcproj create mode 100644 PackUpdater/Res/BtnClose.ico create mode 100644 PackUpdater/Res/BtnOk.ico create mode 100644 PackUpdater/Res/Delete.ico create mode 100644 PackUpdater/Res/Menu.ico create mode 100644 PackUpdater/Resource.rc create mode 100644 PackUpdater/Src/Common.h create mode 100644 PackUpdater/Src/Events.cpp create mode 100644 PackUpdater/Src/Notifications.cpp create mode 100644 PackUpdater/Src/Notifications.h create mode 100644 PackUpdater/Src/Options.cpp create mode 100644 PackUpdater/Src/PackUpdater.cpp create mode 100644 PackUpdater/Src/Utils.cpp create mode 100644 PackUpdater/Version.h create mode 100644 PackUpdater/Version.rc create mode 100644 PackUpdater/resource.h create mode 100644 TranslitSwitcher/Docs/Readme.txt create mode 100644 TranslitSwitcher/Res/InvertSend.ico create mode 100644 TranslitSwitcher/Res/SwitchSend.ico create mode 100644 TranslitSwitcher/Res/TranslitSend.ico create mode 100644 TranslitSwitcher/Resource.h create mode 100644 TranslitSwitcher/Resource.rc create mode 100644 TranslitSwitcher/Src/Layoutproc.cpp create mode 100644 TranslitSwitcher/Src/TranslitSwitcher.cpp create mode 100644 TranslitSwitcher/Src/TranslitSwitcher.h create mode 100644 TranslitSwitcher/TranslitSwitcher_10.vcxproj create mode 100644 TranslitSwitcher/TranslitSwitcher_10.vcxproj.filters create mode 100644 TranslitSwitcher/Version.h create mode 100644 TranslitSwitcher/Version.rc diff --git a/PackUpdater/Docs/Langpack.txt b/PackUpdater/Docs/Langpack.txt new file mode 100644 index 0000000..987e3ef --- /dev/null +++ b/PackUpdater/Docs/Langpack.txt @@ -0,0 +1,36 @@ +[Simple updater for Miranda IM premodified packs.] +[Pack Updater] +[Check for pack updates] +[Downloading pack updates...] +[No updates found.] +[View info] +[An error occured while downloading the update.] +[URL for checking updates not found.] +[Downloading version info...] +[Name of Update's file is not supported.] +[Download complete. Start updating? All your data will be saved and Miranda IM will be closed.] +[You have chosen not to install the pack update immediately.\nYou can install it manually from this location:\n\n%s] +[No files for update.] +[Update checking already started!] +[Automatically check for pack updates] +[Pack update options] +[Remind about not installed pack update] +[Message boxes (*)] +[Info messages] +[Progress dialogs] +[* Needs popup actions to be enabled] +[Not sets for "Message boxes"] +[Downloads complete. Start updating? All your data will be saved and Miranda IM will be closed.] +[Clear pack updates folder] +[Downloading update...] +[Update is not possible!\nYou have no Administrator's rights.\nPlease run Miranda IM with Administrator's rights.] +[Boxes] +[Message boxes] +[Pack Updater HTTP connection] +[Updates found!] +[PackUpdater has detected updated versions\nof the following Miranda components:] +[Component Name] +[Current Version] +[New Version] +['Yes' Button] +['No' Button] \ No newline at end of file diff --git a/PackUpdater/Docs/Readme_eng.txt b/PackUpdater/Docs/Readme_eng.txt new file mode 100644 index 0000000..858291b --- /dev/null +++ b/PackUpdater/Docs/Readme_eng.txt @@ -0,0 +1,139 @@ +================== +Pack Updater 0.0.9 +================== + +Miranda IM plugin that do automatic or manual Miranda packs update. + +Plugin maybe interesting for packs author, which wants do update of their pack automatically. + +0. Changelog +1. How to use? +2. How it works? +3. Copyrights and other + + +----------------- +0. Changelog +----------------- + +0.0.9 +* Fixed order in update list + +0.0.8 ++ Added Icolib support + +0.0.7 ++ disabled or not existed plugins not updated and not downloaded ++ added FileType 5. It ia as type 4 but without restart + +0.0.6 +* All updates shows in one list +* Fixed bug with no updating files +* Changeg version comparing algorithm + +0.0.5 ++ Added x64 version ++ Added Netlib support ++ Added ability to update plugins, icons and other miranda files ++ Added ability to clear folder with downloaded updates ++ Added hotkeys support (Customize-Hotkeys-Pack Updater) as default set Ctrl+F10 ++ Added Popup plus actions support +! Fixed frizing when downloaded files +* If extension of downloaded file is ".html" it will be opened in browser +* Fixed activation Apply button even you not change anything +* Changed name of plugin. now it us PackUpdater +* Plugin is Unicode now +* Changed storing format on server - all information about all files stored in one file +* In Pack for all files - one url for chexking +* Fixed logic in popups +- ZeroUpdate.ini not needed anymore, all settings storing in profile + +0.0.4 ++ Added partly support of popups + +0.0.3 ++ Added support of Folders plugin ++ Added ability to translate description of update from langpack +* Changed new version detection + +0.0.2 ++ Added support of path for dowloaded updates ++ Added ability don't start update automatically + +0.0.1 ++ Pre-release + +-------------------- +1. How to use? +-------------------- + +Import settings from Autoexec_PackUpdater.ini to profile and for server (file1.ini) are in Tamplates folder. Probably full langpack in this folder too. + +1. Add in your langpack_*.txt strings needed for plugin. + +Variables in Autoexec_PackUpdater.ini: + + FileCount - number of files for witch needs to check updates. Plugin supports checking for several files, but most time is only one (Pack setup file) + + AutoUpdate - Check updates automatically with Miranda startup. configured in Events->Pack updates + + File_VersionURL - URL where saved file with infirmation about versions of all files (file1.ini) + +[File_x_] (where x - serial number file, begining from 1) + + CurrentVersion - sets 1.0.0 (or another what you wants) and don't change any more + + LastVersion - the same + + +3. Create file with infirmation about versions (file1.ini). One for all checked files + + +Options of file1.ini: + +Handle [FileInfo_х], where х - serial number file, begining from 1 (must be equal with number in profile) + + +FileVersion - Current file version (Version of new pack file) + +Message - Description that user see when plugin found new version + +DownloadURL - URL of Update file + +DiskFileName - Name of file saved on user computer. + +FileType - type of file. Defines final destination of file. (1 - pack, 2 - plugin (will be installed into Plugins), 3 - icon (will be installed into Icons), 4 - files in miranda root (e.g. langpack, dbtool)) + +Descr - description witch shows in update list. + +InfoURL - Optional. If it writed, message box that user see have button "See information", click on it open this URL. + +AdvFolder - Optional. If it writed, set subfolder in folder defined FileType. + + +4. Download file with infirmation and updates on server. + + +-------------------- +2. How it works? +-------------------- + +Plugin has two modes: silent and normal. silent is used when checking for updates on startup, normal - click menu item. +First, plugin downloads file version information and compares the "local" (File_x_CurrentVersion from profile) version with the "remote" +(FileVersion). If they differ, that: +a). When you work in silent mode plugin checks the value LastVersion and if it differs from the FileVersion, shows the message about the update. +if not - there are no messages. +b). When working in normal mode plugin displays a message in any case. +If a user downloaded the update, but decided it just did not install, update is still considered to be established. + + +--------------------- +3. Copyrights and other +--------------------- + +Plugin written by ZERO_BiT, continued development by Mataes. +The author is not liable for any damages, the explicit or implied, caused by this plugin. Also wanted to ask not to delete the original copyright. + +For questions contacts: + e-mail: mataes2007@gmail.com + icq: 4618898 \ No newline at end of file diff --git a/PackUpdater/Docs/Readme_rus.txt b/PackUpdater/Docs/Readme_rus.txt new file mode 100644 index 0000000..05418b5 --- /dev/null +++ b/PackUpdater/Docs/Readme_rus.txt @@ -0,0 +1,139 @@ +================== +Pack Updater 0.0.9 +================== + +Плагин для Miranda IM, выполняющий автоматическое обновление сборок (паков). + +Плагин расчитан, в первую очередь, на создателей паков, которые хотят автоматизировать процесс обновления своих сборок. + +0. История версий +1. Как использовать? +2. Как оно работает? +3. Цопирайты и прочее + + +----------------- +0. История версий +----------------- + +0.0.9 +* Исправлен баг с порядком в списке обновлений + +0.0.8 ++ Добавлена поддержка Icolib + +0.0.7 ++ Отключенные или неустановленные плагины большен не обновляются и не загружаются ++ Тип файлов 5. точно такой же как 4, только без перезапуска + +0.0.6 +* Все обновления показываются в окне одним списком +* Поправлен баг с необновлением файлов +* Изменен алгоритм сравнения версий + +0.0.5 ++ Добавлена x64 версия ++ Добавлена поддержка Netlib ++ Добавлена возможность обновлять плагины, иконки, ленгпак и прочие компоненты миранды ++ Добавлена возможность очищать папку со скаченными обновлениями ++ Добавлена поддержка горячих клавиш (Тонкая настройка-Горячие клавиши-Обновление сборки) по умолчанию Ctrl+F10 ++ Добавлена поддержка действий плагина Popup plus +! Исправлено замерзание миранды при загрузке файлов +* Если расширение скачиваемого файла ".html", то он откроется в браузере +* Исправлен баг с Активацией кнопки применить на странице Всплывающие окна-Обновление сборки +* Изменено название плагина, теперь - это PackUpdater +* Теперь плагин стал юникодным +* Изменен формат хранения данных на сервере - все в одном файле +* В сборке для разных файлов - одна ссылка +* Исправлена логика всплывающих окон +- Убран ZeroUpdate.ini, все настройки теперь в профиле + +0.0.4 ++ Добавлена частичная поддержка всплывающих окон + +0.0.3 ++ Добавлена поддержка плагина Folders ++ Добавлена возможность переводить описание файла для загрузки +* Исправлен показ окна с обновление, даже если версия на сервере меньше текущей + +0.0.2 ++ Добавлена поддержка путей для сохранения апдейтов ++ Добавлена возможность отключения автоматического запуска скачанного апдейта + +0.0.1 ++ Собственно, пре-релиз. + +-------------------- +1. Как использовать? +-------------------- + +Шаблоны всех файлов лежат в папке Templates. + +1. Имортируем настройки их Autoexec_PackUpdater.ini в профиль и добавляем в лангпак блок с переводом. + +Поясню опции: + + FileCount - количество файлов, для которых нужно проверять апдейты. Плагин поддерживает проверку нескольких файлов, однако чаще всего бавает достаточно одного (сетапа сборки) + + AutoUpdate - Проверять ли апдейты при запуске Миранды. Настраивается в опциях, в разделе События->Обновление сборки + + File_VersionURL - Урл, по которому лежит файл с информацией о версиях для всех файлов(см. дальше) + +[File_x_] (где x - порядковый номер файла, начиная с 1) + + CurrentVersion - изначально выставляем в 1.0.0 (или любое другое значение) и больше не трогаем + + LastVersion - то же самое + + +3. Создаём файлы с информацией о версиях (один для всех проверяемых файлов) + + +Описание опций: + +Заголовок [FileInfo_х], где х - номер файла, начиная с 1 (должен совпадать с номером, импортированным в профиль) + + +FileVersion - Текущая версия файла (т. е. та, на которую обновляемся) + +Message - Сообщение, которое выводит плагин при нахождении этого апдейта + +DownloadURL - Урл, по которому лежит собственно файл апдейта (сетап) + +DiskFileName - Имя файла на диске. + +FileType - тип файла. Определяет конечное его расположение. (1 - сборка, 2 - плагин (будет установлен в папку Plugins), 3 - иконка (будет установлен в папку Icons), 4 - файлы в корне миранды (на пример, langpack, dbtool)) + +Descr - описание, которое будет выводится в окне обновления. + +InfoURL - Опционально. Если присутствует, то в окошке уведомления появляется кнопочка "Смотреть инфо", при нажатии на которую в новом окне откроется эта страница + +AdvFolder - Опционально. Если присутствует, то задает подпапку в папке определяемой типом файла. + + +4. Заливаем файл с инфой о версиях и апдейты на сервер. + + +-------------------- +2. Как оно работает? +-------------------- + +У плагина есть два режима работы: тихий и обычный. Тихий используется при проверке апдейтов при запуске, обычный - при выборе пункта меню. +Сначала плагин скачивает файл с информацией о версиях и сравнивает "локальную" (File_x_CurrentVersion из профиля) версию с "удалённой" (FileVersion). Если они отличаются, то: +а). При работе в тихом режиме плагин проверяет значение LastVersion и если оно отличается от FileVersion, выдаёт сообщение об обновлении, если нет - +сообщений об отсутствии обновлений не будет. +б). При работе в обычном режиме плагин выдаёт сообщение в любом случае. +Если юзер скачал апдейт, но решил сразу его не устанавливать, апдейт всё равно считается установленным. + + +--------------------- +3. Копирайты и прочее +--------------------- + +Плагин написал товарищЪ ZERO_BiT, продолжил развитие Mataes. +Автор не несёт никакой ответственности за ущерб, явный или подразумеваемый, нанесённый этим плагином. +Также хотелось бы попросить не удалять оригинальный копирайт. + +По вопросам обращаться + на мыло: mataes2007@gmail.com + в аську: 4618898 \ No newline at end of file diff --git a/PackUpdater/Docs/Templates/Autoexec_PackUpdater.ini b/PackUpdater/Docs/Templates/Autoexec_PackUpdater.ini new file mode 100644 index 0000000..9375457 --- /dev/null +++ b/PackUpdater/Docs/Templates/Autoexec_PackUpdater.ini @@ -0,0 +1,10 @@ +[PackUpdater] +AutoUpdate=b1 +File_VersionURL=uhttp://mataes.googlecode.com/files/Test5.ini +FileCount=d3 +File_1_CurrentVersion=u0.0.0 +File_1_LastVersion=u0.0.0 +File_2_CurrentVersion=u0.0.0 +File_2_LastVersion=u0.0.0 +File_3_CurrentVersion=u0.0.0 +File_3_LastVersion=u0.0.0 \ No newline at end of file diff --git a/PackUpdater/Docs/Templates/File1.ini b/PackUpdater/Docs/Templates/File1.ini new file mode 100644 index 0000000..ae99847 --- /dev/null +++ b/PackUpdater/Docs/Templates/File1.ini @@ -0,0 +1,24 @@ +[FileInfo_1] +FileVersion = 0.0.1 +Message = "Test Pack" +DownloadURL = "http://mataes.googlecode.com/files/Miranda%20IM%20Mataes%20Pack%20v0.8.3.exe" +DiskFileName = "Miranda IM Mataes Pack v0.8.3.exe" +InfoURL = "http://miranda-planet.com/forum/index.php?showtopic=6121" +Descr="Test1" +FileType="1" + +[FileInfo_2] +FileVersion = 0.0.1 +Message = "Test Plugin" +DownloadURL = "http://mataes.googlecode.com/files/Test_Plugin.dll" +DiskFileName = "Test_plugin.dll" +Descr="Test2" +FileType="2" + +[FileInfo_3] +FileVersion = 0.0.1 +Message = "Test Icon" +DownloadURL = "http://mataes.googlecode.com/files/Test_Icon.dll" +DiskFileName = "Test_Icon.dll" +Descr="Test3" +FileType="3" \ No newline at end of file diff --git a/PackUpdater/Docs/ToDo.txt b/PackUpdater/Docs/ToDo.txt new file mode 100644 index 0000000..50100bc --- /dev/null +++ b/PackUpdater/Docs/ToDo.txt @@ -0,0 +1,2 @@ +1. add second variant of update - external app. +2. add updater support (maybe). \ No newline at end of file diff --git a/PackUpdater/PackUpdater_10.vcxproj b/PackUpdater/PackUpdater_10.vcxproj new file mode 100644 index 0000000..4405947 --- /dev/null +++ b/PackUpdater/PackUpdater_10.vcxproj @@ -0,0 +1,229 @@ +п»ї + + + + Debug Unicode + Win32 + + + Debug Unicode + x64 + + + Release Unicode + Win32 + + + Release Unicode + x64 + + + + PackUpdater + {21F6C0E4-DD1A-49E6-82FD-64574BB902BD} + PackUpdater + Win32Proj + + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + ../../../Files/Debug/Plugins\ + ../../../Files/Debug64/Plugins\ + $(SolutionDir)$(Configuration)/Obj/$(ProjectName)\ + $(SolutionDir)$(Configuration)64/Obj/$(ProjectName)\ + ../../../Files/Release/Plugins\ + ../../../Files/Release64/Plugins\ + $(SolutionDir)$(Configuration)/Obj/$(ProjectName)\ + $(SolutionDir)$(Configuration)64/Obj/$(ProjectName)\ + AllRules.ruleset + AllRules.ruleset + + + + + AllRules.ruleset + AllRules.ruleset + + + + + + + + Disabled + ../../include;../../ExternalAPI + WIN32;_DEBUG;_WINDOWS;_USRDLL;PACKUPDATER_EXPORTS;%(PreprocessorDefinitions) + MultiThreadedDebug + Level3 + EditAndContinue + 4996 + Use + Common.h + + + Wininet.lib;urlmon.lib;%(AdditionalDependencies) + true + Windows + false + + + $(IntDir)$(TargetName).lib + MachineX86 + + + + + + + + + + + Disabled + ../../include;../../ExternalAPI + WIN32;_DEBUG;_WINDOWS;_USRDLL;PACKUPDATER_EXPORTS;%(PreprocessorDefinitions) + MultiThreadedDebug + Level3 + EditAndContinue + 4996 + Use + Common.h + + + Wininet.lib;urlmon.lib;%(AdditionalDependencies) + true + Windows + false + + + $(IntDir)$(TargetName).lib + + + + + + + + + Full + Size + ../../include;../../ExternalAPI + WIN32;NDEBUG;_WINDOWS;_USRDLL;PACKUPDATER_EXPORTS;%(PreprocessorDefinitions) + Level3 + ProgramDatabase + 4996 + MultiThreaded + Use + Common.h + + + Wininet.lib;urlmon.lib;%(AdditionalDependencies) + Windows + true + true + false + + + $(IntDir)$(TargetName).lib + MachineX86 + + + + + + + + + + + Full + Size + ../../include;../../ExternalAPI + WIN32;NDEBUG;_WINDOWS;_USRDLL;PACKUPDATER_EXPORTS;%(PreprocessorDefinitions) + Level3 + ProgramDatabase + 4996 + MultiThreaded + Use + Common.h + + + Wininet.lib;urlmon.lib;%(AdditionalDependencies) + Windows + true + true + false + + + $(IntDir)$(TargetName).lib + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/PackUpdater/PackUpdater_10.vcxproj.filters b/PackUpdater/PackUpdater_10.vcxproj.filters new file mode 100644 index 0000000..3157879 --- /dev/null +++ b/PackUpdater/PackUpdater_10.vcxproj.filters @@ -0,0 +1,79 @@ +п»ї + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Resource Files + + + Resource Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + \ No newline at end of file diff --git a/PackUpdater/PackUpdater_9.vcproj b/PackUpdater/PackUpdater_9.vcproj new file mode 100644 index 0000000..d2df893 --- /dev/null +++ b/PackUpdater/PackUpdater_9.vcproj @@ -0,0 +1,433 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PackUpdater/Res/BtnClose.ico b/PackUpdater/Res/BtnClose.ico new file mode 100644 index 0000000..f0d688b Binary files /dev/null and b/PackUpdater/Res/BtnClose.ico differ diff --git a/PackUpdater/Res/BtnOk.ico b/PackUpdater/Res/BtnOk.ico new file mode 100644 index 0000000..c83612c Binary files /dev/null and b/PackUpdater/Res/BtnOk.ico differ diff --git a/PackUpdater/Res/Delete.ico b/PackUpdater/Res/Delete.ico new file mode 100644 index 0000000..eea851d Binary files /dev/null and b/PackUpdater/Res/Delete.ico differ diff --git a/PackUpdater/Res/Menu.ico b/PackUpdater/Res/Menu.ico new file mode 100644 index 0000000..8f8fdb5 Binary files /dev/null and b/PackUpdater/Res/Menu.ico differ diff --git a/PackUpdater/Resource.rc b/PackUpdater/Resource.rc new file mode 100644 index 0000000..4f3d615 --- /dev/null +++ b/PackUpdater/Resource.rc @@ -0,0 +1,198 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Русский (Россия) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) +LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT +#pragma code_page(1251) + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_MENU ICON "res/menu.ico" +IDI_DELETE ICON "res/delete.ico" +IDI_OK ICON "res/btnOk.ico" +IDI_CANCEL ICON "res/btnClose.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_UPDATE DIALOGEX 0, 0, 241, 203 +STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Updates found!" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "Update",IDOK,24,187,50,14 + DEFPUSHBUTTON "View info",IDC_INFO,84,187,66,14,WS_DISABLED | NOT WS_TABSTOP + PUSHBUTTON "Cancel",IDCANCEL,160,187,50,14 + CTEXT "PackUpdater has detected updated versions\nof the following Miranda components:",IDC_UPDATETEXT,9,9,217,22 + CONTROL "",IDC_LIST_UPDATES,"SysListView32",LVS_REPORT | LVS_SINGLESEL | WS_BORDER | WS_TABSTOP,9,37,217,105 + GROUPBOX "Description",IDC_DESCR,9,142,217,43 + EDITTEXT IDC_MESSAGE,12,152,212,30,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL +END + +IDD_DOWNLOAD DIALOGEX 0, 0, 172, 39 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_SYSMENU +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + CONTROL "",IDC_PB,"msctls_progress32",WS_BORDER,7,23,158,9 + CTEXT "Downloading...",IDC_LABEL,7,7,158,12 +END + +IDD_POPUPDUMMI DIALOGEX 65526, 65526, 1, 1 +STYLE DS_ABSALIGN | DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_SYSMENU +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN +END + +IDD_OPT_UPDATENOTIFY DIALOGEX 0, 0, 258, 174 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + GROUPBOX "Pack update options",IDC_STATIC,2,32,253,56 + CONTROL "Automatically check for pack updates",IDC_ENABLEUPDATES, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,50,237,10 + CONTROL "Remind about not installed pack update",IDC_REMINDER, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,64,198,10 + GROUPBOX "Hotkey",IDC_STATIC,2,0,253,26 + CONTROL "Go to Customize -> Hotkeys to change the hotkey",IDC_LINK_HOTKEY, + "Hyperlink",WS_TABSTOP,9,11,199,10 + GROUPBOX "Notifications",IDC_NOTIFY2,1,92,253,79 + CONTROL "Message boxes",IDC_MSG_BOXES2,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,7,111,79,10 + CONTROL "Errors",IDC_ERRORS2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,124,57,10 + CONTROL "Info messages",IDC_INFO_MESSAGES2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,137,80,10 + CONTROL "Progress dialogs",IDC_PROGR_DLG2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,151,80,10 +END + +IDD_POPUP DIALOGEX 0, 0, 316, 182 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + GROUPBOX "Notifications",IDC_NOTIFY,1,0,172,79 + CONTROL "Message boxes (*)",IDC_MSG_BOXES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,19,79,10 + CONTROL "Errors",IDC_ERRORS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,32,57,10 + CONTROL "Info messages",IDC_INFO_MESSAGES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,45,80,10 + CONTROL "Progress dialogs",IDC_PROGR_DLG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,59,80,10 + CTEXT "Back",IDC_STATIC,90,8,24,8 + CTEXT "Text",IDC_STATIC,116,8,24,8 + CONTROL "",IDC_MSG_BOXES_BG,"ColourPicker",WS_TABSTOP,90,17,24,12 + CONTROL "",IDC_MSG_BOXES_TX,"ColourPicker",WS_TABSTOP,116,17,24,12 + CONTROL "",IDC_ERR_BG,"ColourPicker",WS_TABSTOP,90,31,24,12 + CONTROL "",IDC_ERR_TX,"ColourPicker",WS_TABSTOP,116,31,24,12 + CONTROL "",IDC_INFO_MESSAGES_BG,"ColourPicker",WS_TABSTOP,90,44,24,12 + CONTROL "",IDC_INFO_MESSAGES_TX,"ColourPicker",WS_TABSTOP,116,44,24,12 + CONTROL "",IDC_PROGR_DLG_BG,"ColourPicker",WS_TABSTOP,90,58,24,12 + CONTROL "",IDC_PROGR_DLG_TX,"ColourPicker",WS_TABSTOP,116,58,24,12 + GROUPBOX "Colours",IDC_COLORS,178,0,133,44,WS_GROUP + CONTROL "Use cus&tom colors",IDC_USEOWNCOLORS,"Button",BS_AUTORADIOBUTTON | BS_MULTILINE | BS_NOTIFY,186,8,122,13 + CONTROL "Use &Windows colours",IDC_USEWINCOLORS,"Button",BS_AUTORADIOBUTTON | BS_MULTILINE | BS_NOTIFY,186,30,121,13 + CONTROL "Use Pop&up colours",IDC_USEPOPUPCOLORS,"Button",BS_AUTORADIOBUTTON | BS_MULTILINE | BS_NOTIFY,186,19,102,13 + PUSHBUTTON "Preview",IDC_PREVIEW,189,104,57,12 + GROUPBOX "Click action",IDC_STATIC,1,83,145,67,WS_GROUP + COMBOBOX IDC_LC,6,103,127,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_RC,6,130,127,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "On left click",IDC_STATIC,8,94,121,8 + LTEXT "On right click",IDC_STATIC,8,120,121,8 + GROUPBOX "Timeout",IDC_STATIC,178,45,133,51 + EDITTEXT IDC_TIMEOUT_VALUE,194,59,32,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER + CONTROL "",IDC_TIMEOUT_VALUE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,215,59,12,12 + CTEXT "0 = Default",IDC_STATIC_DEFAULT,250,56,55,8 + CTEXT "-1 = Infinite",IDC_STATIC_INFINITE,249,66,54,8 + LTEXT "Sec",IDC_STATIC_SEC,230,61,17,8 + LTEXT "* Needs popup actions to be enabled",IDC_STATIC,4,156,190,8 + LTEXT "Not sets for ""Message boxes""",IDC_STATIC,185,80,123,8 + CONTROL "",IDC_MSG_BOXES_MSG,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,153,19,8,10 + CONTROL "",IDC_ERRORS_MSG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,153,32,8,10 + CONTROL "",IDC_INFO_MESSAGES_MSG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,153,45,8,10 + CONTROL "",IDC_PROGR_DLG_MSG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,153,59,8,10 + CTEXT "Boxes",IDC_STATIC,146,8,23,8 + CTEXT "PopUps",IDC_STATIC,7,9,79,8 +END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_UPDATE, DIALOG + BEGIN + BOTTOMMARGIN, 201 + END + + IDD_OPT_UPDATENOTIFY, DIALOG + BEGIN + BOTTOMMARGIN, 95 + END + + IDD_POPUP, DIALOG + BEGIN + END +END +#endif // APSTUDIO_INVOKED + +#endif // Русский (Россия) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/PackUpdater/Src/Common.h b/PackUpdater/Src/Common.h new file mode 100644 index 0000000..41b95dd --- /dev/null +++ b/PackUpdater/Src/Common.h @@ -0,0 +1,140 @@ +/* +Copyright (C) 2010 Mataes + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This 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 +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#define MIRANDA_VER 0x0900 +#define MIRANDA_CUSTOM_LP + +// Windows Header Files: +#include +#include +#include +#include "Wininet.h" +#include "Urlmon.h" +#include +#include +#include +#include "win2k.h" +#include "vector" // stl vector header +#include + +// Miranda header files +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "..\Sdk\m_popup2.h" +#include +#include + +#include "..\version.h" +#include "..\resource.h" +#include "Notifications.h" + +#define MODNAME "PackUpdater" +#define MODULEA "Pack Updater" +#define MODULEW L"Pack Updater" +#ifdef _UNICODE + #define DEFAULT_UPDATES_FOLDER L"Pack Updates" + #define MIRANDA_USERDATAT MIRANDA_USERDATAW + typedef std::wstring tString; + #define MODULE MODULEW +#else + #define DEFAULT_UPDATES_FOLDER "Pack Updates" + #define MIRANDA_USERDATAT MIRANDA_USERDATA + typedef std::string tString; + #define MODULE MODULEA +#endif + +struct FILEURL +{ + TCHAR tszDownloadURL[2048]; + TCHAR tszDiskPath[MAX_PATH]; +}; + +struct FILEINFO +{ + TCHAR tszCurVer[16]; + TCHAR tszNewVer[16]; + TCHAR tszLastVer[16]; + TCHAR tszAdvFolder[256]; + TCHAR tszInfoURL[2048]; + TCHAR tszMessage[5000]; + TCHAR tszDescr[256]; + FILEURL File; + BOOL enabled; + BYTE FileType; + INT FileNum; +}; + +struct PackUpdaterIconList +{ + char* szIconName; + TCHAR* tszDescr; + int IconID; +}; + +#define DEFAULT_REMINDER 1 +#define DEFAULT_AUTOUPDATE 1 +#define DEFAULT_FILECOUNT 0 +#define DEFAULT_FILETYPE 0 //0 - not defined, 1 - pack, 2 - plugin, 3 - icon, 4 - files in miranda root (e.g. langpack, dbtool), 5 - same as 4 without restart + +#define IDINFO 3 +#define IDDOWNLOAD 4 +#define IDDOWNLOADALL 5 + +using std::wstring; +using namespace std; + +extern HINSTANCE hInst; +extern INT FileCount, CurrentFile, Number, UpdatesCount; +extern BOOL Silent, DlgDld; +extern BYTE Reminder, AutoUpdate; +extern TCHAR tszRoot[MAX_PATH], tszDialogMsg[2048]; +extern FILEINFO* pFileInfo; +extern FILEURL* pFileUrl; +extern HANDLE CheckThread, hOnPreShutdown, hOptHook, hLoadHook; +extern MYOPTIONS MyOptions; +extern aPopups PopupsList[POPUPS]; +extern LPCTSTR Title, Text; + +VOID InitPopupList(); +VOID LoadOptions(); +BOOL NetlibInit(); +VOID IcoLibInit(); +VOID NetlibUnInit(); +INT ModulesLoaded(WPARAM wParam, LPARAM lParam); +INT_PTR MenuCommand(WPARAM wParam,LPARAM lParam); +INT_PTR EmptyFolder(WPARAM wParam,LPARAM lParam); +INT OnPreShutdown(WPARAM wParam, LPARAM lParam); +INT OptInit(WPARAM wParam, LPARAM lParam); +VOID DoCheck(INT iFlag, INT iFlag2); +BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal); +VOID show_popup(HWND hDlg, LPCTSTR Title, LPCTSTR Text, INT Number, INT ActType); +VOID DlgDownloadProc(); +INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK DlgMsgPop(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); +void __stdcall ExitMe(void*); +void __stdcall RestartMe(void*); \ No newline at end of file diff --git a/PackUpdater/Src/Events.cpp b/PackUpdater/Src/Events.cpp new file mode 100644 index 0000000..7c15ed0 --- /dev/null +++ b/PackUpdater/Src/Events.cpp @@ -0,0 +1,71 @@ +/* +Copyright (C) 2010 Mataes + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This 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 +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#include "common.h" + +BOOL Silent; + +int ModulesLoaded(WPARAM wParam, LPARAM lParam) +{ + UnhookEvent(hLoadHook); + Silent = true; + HOTKEYDESC hkd = {0}; + hkd.cbSize = sizeof(hkd); + hkd.dwFlags = HKD_TCHAR; + hkd.pszName = "Check for pack updates"; + hkd.ptszDescription = _T("Check for pack updates"); + hkd.ptszSection = _T("Pack Updater"); + hkd.pszService = MODNAME"/CheckUpdates"; + hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL, VK_F10) | HKF_MIRANDA_LOCAL; + hkd.lParam = FALSE; + CallService(MS_HOTKEY_REGISTER, 0, (LPARAM)&hkd); + + DoCheck(AutoUpdate, (int)CheckThread); + return 0; +} + +INT_PTR MenuCommand(WPARAM wParam,LPARAM lParam) +{ + Silent = false; + DoCheck(1, (int)CheckThread); + return 0; +} + +INT_PTR EmptyFolder(WPARAM wParam,LPARAM lParam) +{ + SHFILEOPSTRUCT file_op = { + NULL, + FO_DELETE, + tszRoot, + _T(""), + FOF_NOERRORUI | + FOF_SILENT, + false, + 0, + _T("") }; + SHFileOperation(&file_op); + return 0; +} + +INT OnPreShutdown(WPARAM wParam, LPARAM lParam) +{ + UnhookEvent(hOptHook); + UnhookEvent(hOnPreShutdown); + return 0; +} \ No newline at end of file diff --git a/PackUpdater/Src/Notifications.cpp b/PackUpdater/Src/Notifications.cpp new file mode 100644 index 0000000..7c4efd6 --- /dev/null +++ b/PackUpdater/Src/Notifications.cpp @@ -0,0 +1,678 @@ +/* +Copyright (C) 2010 Mataes + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This 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 +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#include "common.h" + +HWND hDlgDld = NULL; +INT UpdatesCount = 0; + +void PopupAction(HWND hWnd, BYTE action) +{ + switch (action) + { + case PCA_CLOSEPOPUP: + break; + case PCA_DONOTHING: + return; + }//end* switch + PUDeletePopUp(hWnd); +} + +static INT_PTR CALLBACK PopupDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch (uMsg) + { + case UM_POPUPACTION: + { + if (HIWORD(wParam) == BN_CLICKED) + { + LPMSGPOPUPDATA pmpd = (LPMSGPOPUPDATA)PUGetPluginData(hDlg); + + if (pmpd) + { + switch (LOWORD(wParam)) + { + case IDYES: + { + if (IsWindow(pmpd->hDialog)) + EndDialog(pmpd->hDialog, LOWORD(wParam)); + PUDeletePopUp(hDlg); + break; + } + case IDNO: + { + if (IsWindow(pmpd->hDialog)) + EndDialog(pmpd->hDialog, LOWORD(wParam)); + PUDeletePopUp(hDlg); + break; + } + } + } + } + } + break; + + case UM_FREEPLUGINDATA: + { + LPMSGPOPUPDATA pmpd = (LPMSGPOPUPDATA)PUGetPluginData(hDlg); + if (pmpd > 0) + mir_free(pmpd); + return TRUE; //TRUE or FALSE is the same, it gets ignored. + } + break; + + default: + break; + } + return DefWindowProc(hDlg, uMsg, wParam, lParam); +} + +static INT_PTR CALLBACK PopupDlgProc2(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch (uMsg) + { + case WM_COMMAND: + { + PopupAction(hDlg, MyOptions.LeftClickAction); + break; + } + case WM_CONTEXTMENU: + { + PopupAction(hDlg, MyOptions.RightClickAction); + break; + } + case UM_FREEPLUGINDATA: + { + LPMSGPOPUPDATA pmpd = (LPMSGPOPUPDATA)PUGetPluginData(hDlg); + if (pmpd > 0) + mir_free(pmpd); + return TRUE; //TRUE or FALSE is the same, it gets ignored. + } + break; + } + return DefWindowProc(hDlg, uMsg, wParam, lParam); +} + +static VOID MakePopupAction(POPUPACTION &pa, INT id) +{ + pa.cbSize = sizeof(POPUPACTION); + pa.flags = PAF_ENABLED; + pa.wParam = MAKEWORD(id, BN_CLICKED); + pa.lParam = 0; + switch (id) + { + case IDYES: + { + pa.lchIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"btn_ok"); + strncpy_s(pa.lpzTitle, MODNAME"/Yes", SIZEOF(pa.lpzTitle)); + } + break; + case IDNO: + { + pa.lchIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"btn_cancel"); + strncpy_s(pa.lpzTitle, MODNAME"/No", SIZEOF(pa.lpzTitle)); + } + break; + } +} + +VOID show_popup(HWND hDlg, LPCTSTR Title, LPCTSTR Text, int Number, int ActType) +{ + POPUPDATAT_V2 pd; + LPMSGPOPUPDATA pmpd; + pmpd = (LPMSGPOPUPDATA)mir_alloc(sizeof(MSGPOPUPDATA)); + if (pmpd) + { + ZeroMemory(&pd, sizeof(pd)); + pd.cbSize = sizeof(POPUPDATAT_V2); + pd.lchContact = NULL; //(HANDLE)wParam; + pd.lchIcon = LoadSkinnedIcon(PopupsList[Number].Icon); + lstrcpyn(pd.lptzText, Text, SIZEOF(pd.lptzText)); + lstrcpyn(pd.lptzContactName, Title, SIZEOF(pd.lptzContactName)); + switch (MyOptions.DefColors) + { + case byCOLOR_WINDOWS: + pd.colorBack = GetSysColor(COLOR_BTNFACE); + pd.colorText = GetSysColor(COLOR_WINDOWTEXT); + break; + case byCOLOR_OWN: + pd.colorBack = PopupsList[Number].colorBack; + pd.colorText = PopupsList[Number].colorText; + break; + case byCOLOR_POPUP: + pd.colorBack = pd.colorText = 0; + break; + }//end* switch + if (Number == 0 && ActType != 0) + pd.PluginWindowProc = (WNDPROC)PopupDlgProc; + else + pd.PluginWindowProc = (WNDPROC)PopupDlgProc2; + pd.PluginData = pmpd; + if (Number == 0) + pd.iSeconds = -1; + else + pd.iSeconds = MyOptions.Timeout; + pd.hNotification = NULL; + pd.lpActions = pmpd->pa; + } + pmpd->hDialog = hDlg; + switch (ActType) + { + case 0: + break; + case 1: + { + MakePopupAction(pmpd->pa[pd.actionCount++], IDYES); + MakePopupAction(pmpd->pa[pd.actionCount++], IDNO); + } + break; + } + + CallService(MS_POPUP_ADDPOPUPT, (WPARAM) &pd, APF_NEWDATA); +} + +INT_PTR CALLBACK DlgDownload(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_INITDIALOG: + SetWindowText(GetDlgItem(hDlg, IDC_LABEL), tszDialogMsg); + SetWindowLongPtr(GetDlgItem(hDlg, IDC_PB), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hDlg, IDC_PB), GWL_STYLE) | PBS_MARQUEE); + SendMessage(GetDlgItem(hDlg, IDC_PB), PBM_SETMARQUEE, 1, 50); + return TRUE; + }//end* switch + return FALSE; +} + +INT_PTR CALLBACK DlgDownloadPop(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch (uMsg) + { + case WM_INITDIALOG: + { + Number = 3; + show_popup(hDlg, Title, Text, Number, 0); + return TRUE; + } // end* WM_INITDIALOG: + } // end* switch (uMsg) + return FALSE; +} + +static void __stdcall CreateDownloadDialog(void*) +{ + if (ServiceExists(MS_POPUP_ADDPOPUPEX) && DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1) && DBGetContactSettingByte(NULL,MODNAME, "Popups3", DEFAULT_POPUP_ENABLED)) + hDlgDld = CreateDialog(hInst, MAKEINTRESOURCE(IDD_POPUPDUMMI), NULL, DlgDownloadPop); + else if (DBGetContactSettingByte(NULL,MODNAME, "Popups3M", DEFAULT_MESSAGE_ENABLED)) + { + lstrcpyn(tszDialogMsg, Text, SIZEOF(tszDialogMsg)); + hDlgDld = CreateDialog(hInst, MAKEINTRESOURCE(IDD_DOWNLOAD), NULL, DlgDownload); + } +} + +static void __stdcall DestroyDownloadDialog(void*) +{ + DestroyWindow(hDlgDld); +} + +void DlgDownloadProc() +{ + CallFunctionAsync(CreateDownloadDialog, 0); + if (!DownloadFile(pFileUrl->tszDownloadURL, pFileUrl->tszDiskPath)) + { + Title = TranslateT("Pack Updater"); + Text = TranslateT("An error occured while downloading the update."); + if (ServiceExists(MS_POPUP_ADDPOPUPEX) && DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1) && DBGetContactSettingByte(NULL, MODNAME, "Popups1", DEFAULT_POPUP_ENABLED)) + { + Number = 1; + show_popup(0, Title, Text, Number, 0); + } + else if (DBGetContactSettingByte(NULL, MODNAME, "Popups1M", DEFAULT_MESSAGE_ENABLED)) + MessageBox(NULL, Text, Title, MB_ICONSTOP); + } + CallFunctionAsync(DestroyDownloadDialog, 0); +} + +INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + HWND hwndList = GetDlgItem(hDlg, IDC_LIST_UPDATES); + + switch (message) + { + case WM_INITDIALOG: + { + TranslateDialogDefault( hDlg ); + SetWindowLongPtr(hDlg, GWLP_USERDATA, 0); + SendMessage(hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES); + + LVCOLUMN lvc = {0}; + // Initialize the LVCOLUMN structure. + // The mask specifies that the format, width, text, and + // subitem members of the structure are valid. + lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; + lvc.fmt = LVCFMT_LEFT; + + lvc.iSubItem = 0; + lvc.pszText = TranslateT("Component Name"); + lvc.cx = 145; // width of column in pixels + ListView_InsertColumn(hwndList, 0, &lvc); + + lvc.iSubItem = 1; + lvc.pszText = TranslateT("Current Version"); + lvc.cx = 95; // width of column in pixels + ListView_InsertColumn(hwndList, 1, &lvc); + + lvc.iSubItem = 2; + lvc.pszText = TranslateT("New Version"); + lvc.cx = 82; // width of column in pixels + ListView_InsertColumn(hwndList, 2, &lvc); + + //enumerate plugins, fill in list + //bool one_enabled = false; + ListView_DeleteAllItems(hwndList); + + LVITEM lvI = {0}; + + // Some code to create the list-view control. + // Initialize LVITEM members that are common to all + // items. + lvI.mask = LVIF_TEXT | LVIF_PARAM | LVIF_NORECOMPUTE;// | LVIF_IMAGE; + + vector &todo = *(vector *)lParam; + for (int i = 0; i < (int)todo.size(); ++i) + { + lvI.mask = LVIF_TEXT | LVIF_PARAM;// | LVIF_IMAGE; + lvI.iSubItem = 0; + lvI.lParam = (LPARAM)&todo[i]; + lvI.pszText = todo[i].tszDescr; + lvI.iItem = i; + ListView_InsertItem(hwndList, &lvI); + + lvI.mask = LVIF_TEXT;// | LVIF_IMAGE; + + lvI.iSubItem = 1; + lvI.pszText = todo[i].tszCurVer; + ListView_SetItem(hwndList, &lvI); + + lvI.iSubItem = 2; + lvI.pszText = todo[i].tszNewVer; + ListView_SetItem(hwndList, &lvI); + + // remember whether the user has decided not to update this component with this particular new version + /*char stored_setting[256]; + char* descr = mir_t2a(todo[i].tszDescr); + mir_snprintf(stored_setting, 256, "DisabledVer%s", descr); + mir_free(descr); + DBVARIANT dbv; + bool check = todo[i].enabled; + if(!DBGetContactSettingTString(0, MODNAME, stored_setting, &dbv)) + { + if(dbv.ptszVal && lstrcmp(dbv.ptszVal, todo[i].tszNewVer) == 0) + check = false; + else + DBDeleteContactSetting(0, MODNAME, stored_setting); + DBFreeVariant(&dbv); + } + one_enabled |= check;*/ + ListView_SetCheckState(hwndList, lvI.iItem, true); + todo[i].enabled = true; + } + HWND hwOk = GetDlgItem(hDlg, IDOK); + EnableWindow(hwOk, true/*one_enabled ? TRUE : FALSE*/); + // do this after filling list - enables 'ITEMCHANGED' below + SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam); + Utils_RestoreWindowPositionNoSize(hDlg,0,MODNAME,"ConfirmWindow"); + //if (!IsUserAnAdmin()) + //SendDlgItemMessage(hDlg, IDOK, BCM_SETSHIELD, 0, TRUE); + return TRUE; + } + case WM_NOTIFY: + { + if(((LPNMHDR) lParam)->hwndFrom == hwndList) + { + switch (((LPNMHDR) lParam)->code) + { + case LVN_ITEMCHANGED: + { + if(GetWindowLongPtr(hDlg, GWLP_USERDATA)) + { + NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam; + + LVITEM lvI = {0}; + + lvI.iItem = nmlv->iItem; + lvI.iSubItem = 0; + lvI.mask = LVIF_PARAM; + ListView_GetItem(hwndList, &lvI); + + vector &todo = *(vector *)GetWindowLongPtr(hDlg, GWLP_USERDATA); + if((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK) + { + todo[lvI.iItem].enabled = ListView_GetCheckState(hwndList, nmlv->iItem); + + /*char stored_setting[256]; + mir_snprintf(stored_setting, 256, "DisabledVer%s", ((UpdateInternal *)lvI.lParam)->update.szComponentName); + + if(((UpdateInternal *)lvI.lParam)->update_options.enabled) + DBDeleteContactSetting(0, "Updater", stored_setting); // user has re-enabled update to this version - remove setting from db + else + DBWriteContactSettingString(0, "Updater", stored_setting, ((UpdateInternal *)lvI.lParam)->newVersion); + //ListView_SetItem(hwndList, &lvI); + */ + + bool enableOk = false; + for(int i=0; i<(int)todo.size(); ++i) + { + if(todo[i].enabled) + { + enableOk = true; + break; + } + } + HWND hwOk = GetDlgItem(hDlg, IDOK); + EnableWindow(hwOk, enableOk ? TRUE : FALSE); + } + if(nmlv->uNewState & LVIS_SELECTED) + { + if (lstrcmp(todo[lvI.iItem].tszInfoURL, _T(""))) + EnableWindow(GetDlgItem(hDlg, IDC_INFO), TRUE); + else + EnableWindow(GetDlgItem(hDlg, IDC_INFO), FALSE); + SetDlgItemText(hDlg, IDC_MESSAGE, TranslateTS(todo[lvI.iItem].tszMessage)); + /*char stored_setting[256]; + char* descr = mir_t2a(todo[lvI.iItem].tszDescr); + mir_snprintf(stored_setting, 256, "DisabledVer%s", descr); + mir_free(descr); + DBVARIANT dbv; + if(!DBGetContactSettingTString(0, MODNAME, stored_setting, &dbv)) + { + if(dbv.ptszVal && lstrcmp(dbv.ptszVal, todo[lvI.iItem].tszNewVer) == 0) + CheckDlgButton(hDlg, IDC_DONOTREMIND, BST_CHECKED); + else + DBDeleteContactSetting(0, MODNAME, stored_setting); + DBFreeVariant(&dbv); + } + else + CheckDlgButton(hDlg, IDC_DONOTREMIND, BST_UNCHECKED); + */ + + } + } + break; + } + } + } + break; + } + case WM_COMMAND: + { + if (HIWORD( wParam ) == BN_CLICKED) + { + switch(LOWORD(wParam)) + { + case IDOK: + { + vector &todo = *(vector *)GetWindowLongPtr(hDlg, GWLP_USERDATA); + ShowWindow(hDlg, SW_HIDE); + TCHAR tszBuff[2048] = {0}, tszFileDest[MAX_PATH] = {0}, tszFilePathDest[MAX_PATH] = {0}, tszFilePathBack[MAX_PATH] = {0}, tszFileName[MAX_PATH] = {0}; + TCHAR* tszExt = NULL; + char szKey[64] = {0}; + vector arFileType; + vector arFilePath; + vector arFileName; + vector arAdvFolder; + vector arExt; + STARTUPINFO si; + PROCESS_INFORMATION pi; + + SetWindowLongPtr(hDlg, GWLP_USERDATA, 0); + Utils_SaveWindowPosition(hDlg, NULL, MODNAME, "ConfirmWindow"); + /*DBWriteContactSettingByte(NULL, "Updater", "DefaultConfAll", IsDlgButtonChecked(hwndDlg, IDC_CHK_CONFALL) ? 1 : 0); + DBWriteContactSettingByte(NULL, "Updater", "NoInstall", IsDlgButtonChecked(hwndDlg, IDC_CHK_NOINSTALL) ? 1 : 0); + + if(IsDlgButtonChecked(hDlg, IDC_CHK_CONFALL)) + EndDialog(hDlg, CD_CONFALL); + else if(IsDlgButtonChecked(hDlg, IDC_CHK_NOINSTALL)) + EndDialog(hDlg, CD_NOINSTALL); + else + */ + + arFileType.clear(); + arFilePath.clear(); + arFileName.clear(); + arAdvFolder.clear(); + arExt.clear(); + for(int i=0; i<(int)todo.size(); ++i) + { + if(todo[i].enabled) + { + switch (todo[i].FileType) + { + case 1: + mir_sntprintf(tszFileDest, SIZEOF(tszFileDest), _T("%s\\Pack"), tszRoot); + CreateDirectory(tszFileDest, NULL); + break; + case 2: + mir_sntprintf(tszFileDest, SIZEOF(tszFileDest), _T("%s\\Plugins"), tszRoot); + CreateDirectory(tszFileDest, NULL); + break; + case 3: + mir_sntprintf(tszFileDest, SIZEOF(tszFileDest), _T("%s\\Icons"), tszRoot); + CreateDirectory(tszFileDest, NULL); + break; + case 4: + mir_sntprintf(tszFileDest, SIZEOF(tszFileDest), _T("%s\\Others"), tszRoot); + CreateDirectory(tszFileDest, NULL); + break; + case 5: + mir_sntprintf(tszFileDest, SIZEOF(tszFileDest), _T("%s\\Others"), tszRoot); + CreateDirectory(tszFileDest, NULL); + break; + default: + lstrcpyn(tszFileDest, tszRoot, SIZEOF(tszFileDest)); + break; + }//end * switch (todo[i].FileType) + mir_sntprintf(tszBuff, SIZEOF(tszBuff), _T("%s\\Backups"), tszRoot); + CreateDirectory(tszBuff, NULL); + lstrcpyn(tszFileName, todo[i].File.tszDiskPath, SIZEOF(tszFileName)); + mir_sntprintf(todo[i].File.tszDiskPath, SIZEOF(todo[i].File.tszDiskPath), _T("%s\\%s"), tszFileDest, tszFileName); + UpdatesCount++; + + tszExt = &todo[i].File.tszDownloadURL[lstrlen(todo[i].File.tszDownloadURL)-5]; + if (lstrcmp(tszExt, _T(".html")) == 0) + { + char* szUrl = mir_t2a(todo[i].File.tszDownloadURL); + CallService(MS_UTILS_OPENURL, TRUE, (LPARAM)szUrl); + mir_free(szUrl); + } + else + { + // download update + pFileUrl = &todo[i].File; + Title = TranslateT("Pack Updater"); + if (todo[i].FileType == 1) + Text = TranslateT("Downloading pack updates..."); + else + Text = TranslateT("Downloading update..."); + DlgDownloadProc(); + if (!DlgDld) + { + if (UpdatesCount) + UpdatesCount--; + continue; + } + } + lstrcpyn(todo[i].tszCurVer, todo[i].tszNewVer, SIZEOF(todo[i].tszCurVer)); + mir_snprintf(szKey, SIZEOF(szKey), "File_%d_CurrentVersion", todo[i].FileNum); + DBWriteContactSettingTString(NULL, MODNAME, szKey, todo[i].tszCurVer); + arFileType.push_back(todo[i].FileType); + arFilePath.push_back(todo[i].File.tszDiskPath); + arFileName.push_back(tszFileName); + arAdvFolder.push_back(todo[i].tszAdvFolder); + arExt.push_back(tszExt); + if (todo[i].FileType == 1) + i = (int)todo.size(); + } + } + + if (UpdatesCount > 1 && lstrcmp(arExt[0].c_str(), _T(".html")) != 0) + lstrcpyn(tszBuff, TranslateT("Downloads complete. Start updating? All your data will be saved and Miranda IM will be closed."), SIZEOF(tszBuff)); + else if (UpdatesCount == 1 && lstrcmp(arExt[0].c_str(), _T(".html")) != 0) + lstrcpyn(tszBuff, TranslateT("Download complete. Start updating? All your data will be saved and Miranda IM will be closed."), SIZEOF(tszBuff)); + if (UpdatesCount > 0 && lstrcmp(arExt[0].c_str(), _T(".html")) != 0) + { + INT rc = -1; + Title = TranslateT("Pack Updater"); + Text = tszBuff; + if (ServiceExists(MS_POPUP_ADDPOPUPEX) && ServiceExists(MS_POPUP_REGISTERACTIONS) && DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1) && DBGetContactSettingByte(NULL,MODNAME, "Popups0", DEFAULT_POPUP_ENABLED) && (DBGetContactSettingDword(NULL, "PopUp", "Actions", 0) & 1)) + rc = DialogBox(hInst, MAKEINTRESOURCE(IDD_POPUPDUMMI), NULL, DlgMsgPop); + else + rc = MessageBox(NULL, tszBuff, Title, MB_YESNO | MB_ICONQUESTION); + if (rc == IDYES) + { + for (int i = 0; i < UpdatesCount; i++) + { + TCHAR* tszUtilRootPlug = NULL; + TCHAR* tszUtilRootIco = NULL; + TCHAR* tszUtilRoot = NULL; + + switch (arFileType[i]) + { + case 0: + break; + case 1: + if (Reminder == 2) + DBWriteContactSettingByte(NULL, MODNAME, "Reminder", 1); + memset(&si, 0, sizeof(STARTUPINFO)); + memset(&pi, 0, sizeof(PROCESS_INFORMATION)); + si.cb = sizeof(STARTUPINFO); + CreateProcess(arFilePath[i].c_str(), _T(""), NULL, NULL, FALSE, NULL, NULL, NULL, &si, &pi); + i = UpdatesCount; + CallFunctionAsync(ExitMe, 0); + break; + case 2: + tszUtilRootPlug = Utils_ReplaceVarsT(_T("%miranda_path%\\Plugins")); + if (lstrcmp(arAdvFolder[i].c_str(), _T("")) == 0) + mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s"), tszUtilRootPlug, arFileName[i].c_str()); + else + mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s\\%s"), tszUtilRootPlug, arAdvFolder[i].c_str(), arFileName[i].c_str()); + mir_sntprintf(tszFilePathBack, SIZEOF(tszFilePathBack), _T("%s\\Backups\\%s"), tszRoot, arFileName[i].c_str()); + MoveFile(tszFilePathDest, tszFilePathBack); + MoveFile(arFilePath[i].c_str(), tszFilePathDest); + mir_free(tszUtilRootPlug); + if (i == UpdatesCount - 1) + CallFunctionAsync(RestartMe, 0); + break; + case 3: + tszUtilRootIco = Utils_ReplaceVarsT(_T("%miranda_path%\\Icons")); + if (lstrcmp(arAdvFolder[i].c_str(), _T("")) == 0) + mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s"), tszUtilRootIco, arFileName[i].c_str()); + else + mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s\\%s"), tszUtilRootIco, arAdvFolder[i].c_str(), arFileName[i].c_str()); + mir_sntprintf(tszFilePathBack, SIZEOF(tszFilePathBack), _T("%s\\Backups\\%s"), tszRoot, arFileName[i].c_str()); + MoveFile(tszFilePathDest, tszFilePathBack); + MoveFile(arFilePath[i].c_str(), tszFilePathDest); + mir_free(tszUtilRootIco); + if (i == UpdatesCount - 1) + CallFunctionAsync(RestartMe, 0); + break; + case 4: + tszUtilRoot = Utils_ReplaceVarsT(_T("%miranda_path%")); + if (lstrcmp(arAdvFolder[i].c_str(), _T("")) == 0) + mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s"), tszUtilRoot, arFileName[i].c_str()); + else + mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s\\%s"), tszUtilRoot, arAdvFolder[i].c_str(), arFileName[i].c_str()); + mir_sntprintf(tszFilePathBack, SIZEOF(tszFilePathBack), _T("%s\\Backups\\%s"), tszRoot, arFileName[i].c_str()); + MoveFile(tszFilePathDest, tszFilePathBack); + MoveFile(arFilePath[i].c_str(), tszFilePathDest); + mir_free(tszUtilRoot); + if (i == UpdatesCount - 1) + CallFunctionAsync(RestartMe, 0); + break; + case 5: + tszUtilRoot = Utils_ReplaceVarsT(_T("%miranda_path%")); + if (lstrcmp(arAdvFolder[i].c_str(), _T("")) == 0) + mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s"), tszUtilRoot, arFileName[i].c_str()); + else + mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s\\%s"), tszUtilRoot, arAdvFolder[i].c_str(), arFileName[i].c_str()); + mir_sntprintf(tszFilePathBack, SIZEOF(tszFilePathBack), _T("%s\\Backups\\%s"), tszRoot, arFileName[i].c_str()); + MoveFile(tszFilePathDest, tszFilePathBack); + MoveFile(arFilePath[i].c_str(), tszFilePathDest); + mir_free(tszUtilRoot); + break; + }//end* switch (arFileType[i]) + }//end* for (int i = 0; i < UpdatesCount; i++) + }//end* if (IDYES == MessageBox(NULL, tszBuff, Title, MB_YESNO | MB_ICONQUESTION)) + else + {//reminder for not installed pack update + if (Reminder && (UpdatesCount == 1) && (arFileType[0] == 1)) + DBWriteContactSettingByte(NULL, MODNAME, "Reminder", 2); + mir_sntprintf(tszBuff, SIZEOF(tszBuff), TranslateT("You have chosen not to install the pack update immediately.\nYou can install it manually from this location:\n\n%s"), arFilePath[0].c_str()); + Title = TranslateT("Pack Updater"); + Text = tszBuff; + if (ServiceExists(MS_POPUP_ADDPOPUPEX) && DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1) && DBGetContactSettingByte(NULL, MODNAME, "Popups2", DEFAULT_POPUP_ENABLED)) + { + Number = 2; + show_popup(0, Title, Text, Number, 0); + } + else if (DBGetContactSettingByte(NULL, MODNAME, "Popups2M", DEFAULT_MESSAGE_ENABLED)) + MessageBox(NULL, Text, Title, MB_ICONINFORMATION); + } + }//end* if (UpdatesCount > 0) + + EndDialog(hDlg, IDOK); + return TRUE; + } + case IDCANCEL: + { + SetWindowLongPtr(hDlg, GWLP_USERDATA, 0); + Utils_SaveWindowPosition(hDlg, NULL, MODNAME, "ConfirmWindow"); + EndDialog(hDlg, IDCANCEL); + return TRUE; + } + case IDC_INFO: + { + int sel = ListView_GetSelectionMark(hwndList); + vector &todo = *(vector *)GetWindowLongPtr(hDlg, GWLP_USERDATA); + char* szUrl = mir_t2a(todo[sel].tszInfoURL); + CallService(MS_UTILS_OPENURL, TRUE, (LPARAM)szUrl); + mir_free(szUrl); + break; + } + } + } + break; + } + } + return FALSE; +} + +INT_PTR CALLBACK DlgMsgPop(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch (uMsg) + { + case WM_INITDIALOG: + { + Number = 0; + show_popup(hDlg, Title, Text, Number, 1); + return TRUE; + } // end* WM_INITDIALOG: + } // end* switch (uMsg) + ShowWindow(hDlg, SW_HIDE); + return FALSE; +} \ No newline at end of file diff --git a/PackUpdater/Src/Notifications.h b/PackUpdater/Src/Notifications.h new file mode 100644 index 0000000..09bc77a --- /dev/null +++ b/PackUpdater/Src/Notifications.h @@ -0,0 +1,72 @@ +/* +Copyright (C) 2010 Mataes + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This 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 +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#define POPUPS 4 + +//=== Objects ===== +//This one is used to easily tie status id, icon, text... +typedef struct +{ + int ID; + int Icon; + COLORREF colorBack; + COLORREF colorText; +} aPopups; + +typedef struct _MSGPOPUPDATA +{ + POPUPACTION pa[4]; + HWND hDialog; +} +MSGPOPUPDATA, *LPMSGPOPUPDATA; + +#define DEFAULT_POPUP_LCLICK 1 +#define DEFAULT_POPUP_RCLICK 0 +#define DEFAULT_POPUP_ENABLED 1 +#define DEFAULT_MESSAGE_ENABLED 1 +#define DEFAULT_TIMEOUT_VALUE 0 + +#define COLOR_BG_FIRSTDEFAULT RGB(173,206,247) +#define COLOR_BG_SECONDDEFAULT RGB(255,189,189) +#define COLOR_TX_DEFAULT RGB(0,0,0) + +#define byCOLOR_OWN 0x1 +#define byCOLOR_WINDOWS 0x2 +#define byCOLOR_POPUP 0x3 +#define DEFAULT_COLORS byCOLOR_POPUP + +// Actions on popup click +#define PCA_CLOSEPOPUP 0 // close popup +#define PCA_DONOTHING 1 // do nothing + +//===== Options flags +typedef struct tagMYOPTIONS { + BYTE DefColors; + BYTE LeftClickAction; + BYTE RightClickAction; + int Timeout; +} MYOPTIONS; + +static struct { + TCHAR *Text; + int Action; +} PopupActions[] = { + _T("Close popup"), PCA_CLOSEPOPUP, + _T("Do nothing"), PCA_DONOTHING +}; diff --git a/PackUpdater/Src/Options.cpp b/PackUpdater/Src/Options.cpp new file mode 100644 index 0000000..645a2ca --- /dev/null +++ b/PackUpdater/Src/Options.cpp @@ -0,0 +1,411 @@ +/* +Copyright (C) 2010 Mataes + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This 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 +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#include "common.h" + +INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + WORD i = 0; + char str[20] = {0}; + switch (msg) + { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + CheckDlgButton(hwndDlg, IDC_ENABLEUPDATES, (int)AutoUpdate); + CheckDlgButton(hwndDlg, IDC_REMINDER, (int)Reminder); + if (ServiceExists(MS_POPUP_ADDPOPUP)) + { + ShowWindow(GetDlgItem(hwndDlg, IDC_NOTIFY2), SW_HIDE); + ShowWindow(GetDlgItem(hwndDlg, IDC_MSG_BOXES2), SW_HIDE); + ShowWindow(GetDlgItem(hwndDlg, IDC_ERRORS2), SW_HIDE); + ShowWindow(GetDlgItem(hwndDlg, IDC_INFO_MESSAGES2), SW_HIDE); + ShowWindow(GetDlgItem(hwndDlg, IDC_PROGR_DLG2), SW_HIDE); + } + else + { + for (i = 1; i < POPUPS; i++) + { + mir_snprintf(str, SIZEOF(str), "Popups%dM", i); + CheckDlgButton(hwndDlg, (i+1029), (DBGetContactSettingByte(NULL, MODNAME, str, DEFAULT_MESSAGE_ENABLED)) ? BST_CHECKED: BST_UNCHECKED); + } + } + return TRUE; + + case WM_COMMAND: + { + switch (LOWORD(wParam)) + { + case IDC_ENABLEUPDATES: + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + case IDC_REMINDER: + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + case IDC_LINK_HOTKEY: + { + OPENOPTIONSDIALOG ood = {0}; + ood.cbSize = sizeof(ood); + ood.pszGroup = "Customize"; + ood.pszPage = "Hotkeys"; + CallService( MS_OPT_OPENOPTIONS, 0, (LPARAM)&ood ); + return (true); + } + case IDC_MSG_BOXES2: + case IDC_ERRORS2: + case IDC_INFO_MESSAGES2: + case IDC_PROGR_DLG2: + if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus()) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + } + break; + } + case WM_NOTIFY: + { + NMHDR *hdr = (NMHDR *)lParam; + if (hdr && hdr->code == PSN_APPLY) + { + AutoUpdate = IsDlgButtonChecked(hwndDlg, IDC_ENABLEUPDATES); + DBWriteContactSettingByte(NULL, MODNAME, "AutoUpdate", AutoUpdate); + Reminder = IsDlgButtonChecked(hwndDlg, IDC_REMINDER); + DBWriteContactSettingByte(NULL, MODNAME, "Reminder", Reminder); + if (!ServiceExists(MS_POPUP_ADDPOPUP)) + { + for (i = 1; i < POPUPS; i++) + { + mir_snprintf(str, SIZEOF(str), "Popups%dM", i); + DBWriteContactSettingByte(NULL, MODNAME, str, (BYTE)(IsDlgButtonChecked(hwndDlg, (i+1029)))); + } + } + } + break; + } + }//end* switch (msg) + return FALSE; +} + +INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + WORD i = 0; + char str[20] = {0}, str2[20] = {0}; + + switch (msg) + { + case WM_INITDIALOG: + { + TranslateDialogDefault(hdlg); + //Colors + if (MyOptions.DefColors == byCOLOR_OWN) + { + CheckDlgButton(hdlg, IDC_USEOWNCOLORS, BST_CHECKED); + CheckDlgButton(hdlg, IDC_USEPOPUPCOLORS, BST_UNCHECKED); + CheckDlgButton(hdlg, IDC_USEWINCOLORS, BST_UNCHECKED); + } + if (MyOptions.DefColors == byCOLOR_WINDOWS) + { + CheckDlgButton(hdlg, IDC_USEOWNCOLORS, BST_UNCHECKED); + CheckDlgButton(hdlg, IDC_USEPOPUPCOLORS, BST_UNCHECKED); + CheckDlgButton(hdlg, IDC_USEWINCOLORS, BST_CHECKED); + } + if (MyOptions.DefColors == byCOLOR_POPUP) + { + CheckDlgButton(hdlg, IDC_USEOWNCOLORS, BST_UNCHECKED); + CheckDlgButton(hdlg, IDC_USEPOPUPCOLORS, BST_CHECKED); + CheckDlgButton(hdlg, IDC_USEWINCOLORS, BST_UNCHECKED); + } + SendDlgItemMessage(hdlg, (42071), CPM_SETCOLOUR, 0, PopupsList[0].colorBack); + SendDlgItemMessage(hdlg, (41071), CPM_SETCOLOUR, 0, PopupsList[0].colorText); + for (i = 1; i < POPUPS; i++) + { + SendDlgItemMessage(hdlg, (i+42071), CPM_SETCOLOUR, 0, PopupsList[i].colorBack); + SendDlgItemMessage(hdlg, (i+41071), CPM_SETCOLOUR, 0, PopupsList[i].colorText); + EnableWindow(GetDlgItem(hdlg, (i+42071)), (MyOptions.DefColors == byCOLOR_OWN)); + EnableWindow(GetDlgItem(hdlg, (i+41071)), (MyOptions.DefColors == byCOLOR_OWN)); + } + //Timeout + SendDlgItemMessage(hdlg, IDC_TIMEOUT_VALUE, EM_LIMITTEXT, 4, 0); + SendDlgItemMessage(hdlg, IDC_TIMEOUT_VALUE_SPIN, UDM_SETRANGE32, -1, 9999); + SetDlgItemInt(hdlg, IDC_TIMEOUT_VALUE, MyOptions.Timeout, TRUE); + //Mouse actions + for (i = 0; i < SIZEOF(PopupActions); i++) + { + SendMessage(GetDlgItem(hdlg, IDC_LC), CB_SETITEMDATA, SendMessage(GetDlgItem(hdlg, IDC_LC), CB_ADDSTRING, 0, (LPARAM)TranslateTS(PopupActions[i].Text)), PopupActions[i].Action); + SendMessage(GetDlgItem(hdlg, IDC_RC), CB_SETITEMDATA, SendMessage(GetDlgItem(hdlg, IDC_RC), CB_ADDSTRING, 0, (LPARAM)TranslateTS(PopupActions[i].Text)), PopupActions[i].Action); + } + SendDlgItemMessage(hdlg, IDC_LC, CB_SETCURSEL, MyOptions.LeftClickAction, 0); + SendDlgItemMessage(hdlg, IDC_RC, CB_SETCURSEL, MyOptions.RightClickAction, 0); + //Popups nitified + for (i = 0; i < POPUPS; i++) + { + mir_snprintf(str, SIZEOF(str), "Popups%d", i); + mir_snprintf(str2, SIZEOF(str2), "Popups%dM", i); + CheckDlgButton(hdlg, (i+40071), (DBGetContactSettingByte(NULL, MODNAME, str, DEFAULT_POPUP_ENABLED)) ? BST_CHECKED: BST_UNCHECKED); + CheckDlgButton(hdlg, (i+1024), (DBGetContactSettingByte(NULL, MODNAME, str2, DEFAULT_MESSAGE_ENABLED)) ? BST_CHECKED: BST_UNCHECKED); + if (IsDlgButtonChecked(hdlg, (i+40071))) + EnableWindow(GetDlgItem(hdlg, (i+1024)), FALSE); + else if (i > 0) + EnableWindow(GetDlgItem(hdlg, (i+1024)), TRUE); + } + if (!(DBGetContactSettingDword(NULL, "PopUp", "Actions", 0) & 1) || !ServiceExists(MS_POPUP_REGISTERACTIONS)) + { + EnableWindow(GetDlgItem(hdlg, (40071)), FALSE); + EnableWindow(GetDlgItem(hdlg, (41071)), FALSE); + EnableWindow(GetDlgItem(hdlg, (42071)), FALSE); + } + else + { + EnableWindow(GetDlgItem(hdlg, (40071)), TRUE); + EnableWindow(GetDlgItem(hdlg, (41071)), (MyOptions.DefColors == byCOLOR_OWN)); + EnableWindow(GetDlgItem(hdlg, (42071)), (MyOptions.DefColors == byCOLOR_OWN)); + } + return TRUE; + } + case WM_SHOWWINDOW: + if (!(DBGetContactSettingDword(NULL, "PopUp", "Actions", 0) & 1) || !ServiceExists(MS_POPUP_REGISTERACTIONS)) + { + EnableWindow(GetDlgItem(hdlg, (40071)), FALSE); + EnableWindow(GetDlgItem(hdlg, (41071)), FALSE); + EnableWindow(GetDlgItem(hdlg, (42071)), FALSE); + } + else + { + EnableWindow(GetDlgItem(hdlg, (40071)), TRUE); + EnableWindow(GetDlgItem(hdlg, (41071)), (MyOptions.DefColors == byCOLOR_OWN)); + EnableWindow(GetDlgItem(hdlg, (42071)), (MyOptions.DefColors == byCOLOR_OWN)); + } + return TRUE; + case WM_COMMAND: + { + WORD idCtrl = LOWORD(wParam), wNotifyCode = HIWORD(wParam); + if (wNotifyCode == CPN_COLOURCHANGED) + { + if(idCtrl > 40070) + { + //It's a color picker change. idCtrl is the control id. + COLORREF color = SendDlgItemMessage(hdlg, idCtrl, CPM_GETCOLOUR, 0, 0); + int ctlID = idCtrl; + if ((ctlID > 41070) && (ctlID < 42070)) //It's 41071 or above => Text color. + PopupsList[ctlID-41071].colorText = color; + else if (ctlID > 42070)//Background color. + PopupsList[ctlID-42071].colorBack = color; + SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); + return TRUE; + } + } + if (wNotifyCode == CBN_SELCHANGE) + { + if (idCtrl == IDC_LC) + { + MyOptions.LeftClickAction = (BYTE)SendDlgItemMessage(hdlg, IDC_LC, CB_GETCURSEL, 0, 0); + } + else if(idCtrl == IDC_RC) + { + MyOptions.RightClickAction = (BYTE)SendDlgItemMessage(hdlg, IDC_RC, CB_GETCURSEL, 0, 0); + } + SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); + return TRUE; + } + switch(idCtrl) + { + case IDC_USEOWNCOLORS: + { + BOOL bEnableOthers = FALSE; + if (wNotifyCode != BN_CLICKED) + break; + MyOptions.DefColors = byCOLOR_OWN; + bEnableOthers = TRUE; + if (!(DBGetContactSettingDword(NULL, "PopUp", "Actions", 0) & 1) || !ServiceExists(MS_POPUP_REGISTERACTIONS)) + { + EnableWindow(GetDlgItem(hdlg, (41071)), FALSE); + EnableWindow(GetDlgItem(hdlg, (42071)), FALSE); + } + else + { + EnableWindow(GetDlgItem(hdlg, (41071)), bEnableOthers); + EnableWindow(GetDlgItem(hdlg, (42071)), bEnableOthers); + } + for (i = 1; i < POPUPS; i++) + { + EnableWindow(GetDlgItem(hdlg, (i+42071)), bEnableOthers); //Background + EnableWindow(GetDlgItem(hdlg, (i+41071)), bEnableOthers); //Text + } + SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); + break; + } + case IDC_USEWINCOLORS: + { + BOOL bEnableOthers = FALSE; + if (wNotifyCode != BN_CLICKED) + break; + //Use Windows colors + MyOptions.DefColors = byCOLOR_WINDOWS; + bEnableOthers = FALSE; + for (i = 0; i < POPUPS; i++) + { + EnableWindow(GetDlgItem(hdlg, (i+42071)), bEnableOthers); //Background + EnableWindow(GetDlgItem(hdlg, (i+41071)), bEnableOthers); //Text + } + SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); + break; + } + case IDC_USEPOPUPCOLORS: + { + BOOL bEnableOthers = FALSE; + if (wNotifyCode != BN_CLICKED) + break; + //Use Popup colors + MyOptions.DefColors = byCOLOR_POPUP; + bEnableOthers = FALSE; + for (i = 0; i < POPUPS; i++) + { + EnableWindow(GetDlgItem(hdlg, (i+42071)), bEnableOthers); //Background + EnableWindow(GetDlgItem(hdlg, (i+41071)), bEnableOthers); //Text + } + SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); + break; + } + case IDC_PREVIEW: + {//Declarations and initializations + Title = TranslateT("Pack Updater"); + Text = TranslateT("Test"); + for (int i = 0; i < POPUPS; i++) + { + if ((!IsDlgButtonChecked(hdlg, (i+40071))) || (!IsWindowEnabled(GetDlgItem(hdlg, (i+40071))))) + continue; + show_popup(0, Title, Text, i, 0); + } + break; + } + case IDC_TIMEOUT_VALUE: + case IDC_MSG_BOXES: + case IDC_ERRORS: + { + if (!IsDlgButtonChecked(hdlg, IDC_ERRORS)) + EnableWindow(GetDlgItem(hdlg, IDC_ERRORS_MSG), TRUE); + else + EnableWindow(GetDlgItem(hdlg, IDC_ERRORS_MSG), FALSE); + if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus()) + SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); + break; + } + case IDC_INFO_MESSAGES: + { + if (!IsDlgButtonChecked(hdlg, IDC_INFO_MESSAGES)) + EnableWindow(GetDlgItem(hdlg, IDC_INFO_MESSAGES_MSG), TRUE); + else + EnableWindow(GetDlgItem(hdlg, IDC_INFO_MESSAGES_MSG), FALSE); + if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus()) + SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); + break; + } + case IDC_PROGR_DLG: + { + if (!IsDlgButtonChecked(hdlg, IDC_PROGR_DLG)) + EnableWindow(GetDlgItem(hdlg, IDC_PROGR_DLG_MSG), TRUE); + else + EnableWindow(GetDlgItem(hdlg, IDC_PROGR_DLG_MSG), FALSE); + if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus()) + SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); + break; + } + case IDC_MSG_BOXES_MSG: + case IDC_ERRORS_MSG: + case IDC_INFO_MESSAGES_MSG: + case IDC_PROGR_DLG_MSG: + if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus()) + SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); + break; + }//end* switch(idCtrl) + break; + }//end* case WM_COMMAND: + case WM_NOTIFY: + switch (((LPNMHDR)lParam)->code) + { + case PSN_RESET: + { + //Restore the options stored in memory. + LoadOptions(); + InitPopupList(); + return TRUE; + } + case PSN_APPLY: + { + //Text color + char szSetting[20] = {0}; + DWORD ctlColor = 0; + for (i = 0; i <= POPUPS-1; i++) + { + ctlColor = SendDlgItemMessage(hdlg, (i+42071), CPM_GETCOLOUR, 0, 0); + PopupsList[i].colorBack = ctlColor; + mir_snprintf(szSetting, SIZEOF(szSetting), "Popups%iBg", i); + DBWriteContactSettingDword(NULL, MODNAME, szSetting, ctlColor); + ctlColor = SendDlgItemMessage(hdlg, (i+41071), CPM_GETCOLOUR, 0, 0); + PopupsList[i].colorText = ctlColor; + mir_snprintf(szSetting, SIZEOF(szSetting), "Popups%iTx", i); + DBWriteContactSettingDword(NULL, MODNAME, szSetting, ctlColor); + } + //Colors + DBWriteContactSettingByte(NULL, MODNAME, "DefColors", MyOptions.DefColors); + //Timeout + MyOptions.Timeout = GetDlgItemInt(hdlg, IDC_TIMEOUT_VALUE, 0, TRUE); + DBWriteContactSettingDword(NULL, MODNAME, "Timeout", MyOptions.Timeout); + //Left mouse click + DBWriteContactSettingByte(NULL, MODNAME, "LeftClickAction", MyOptions.LeftClickAction); + //Right mouse click + DBWriteContactSettingByte(NULL, MODNAME, "RightClickAction", MyOptions.RightClickAction); + //Notified popups + for (i = 0; i < POPUPS; i++) + { + mir_snprintf(str, SIZEOF(str), "Popups%d", i); + DBWriteContactSettingByte(NULL, MODNAME, str, (BYTE)(IsDlgButtonChecked(hdlg, (i+40071)))); + mir_snprintf(str2, SIZEOF(str2), "Popups%dM", i); + DBWriteContactSettingByte(NULL, MODNAME, str2, (BYTE)(IsDlgButtonChecked(hdlg, (i+1024)))); + } + return TRUE; + } //case PSN_APPLY + } // switch code + break; //End WM_NOTIFY + } //switch message +return FALSE; +} + +int OptInit(WPARAM wParam, LPARAM lParam) +{ + OPTIONSDIALOGPAGE odp = {0}; + + ZeroMemory(&odp, sizeof(odp)); + odp.cbSize = sizeof(odp); + odp.position = 100000000; + odp.hInstance = hInst; + odp.flags = ODPF_TCHAR | ODPF_BOLDGROUPS; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_UPDATENOTIFY); + odp.ptszGroup = _T("Events"); + odp.ptszTitle = _T("Pack Updater"); + odp.pfnDlgProc = UpdateNotifyOptsProc; + CallService(MS_OPT_ADDPAGE, wParam, (LPARAM)&odp); + if (ServiceExists(MS_POPUP_ADDPOPUP)) + { + odp.pszTemplate = MAKEINTRESOURCEA(IDD_POPUP); + odp.ptszGroup = _T("PopUps"); + odp.ptszTitle = _T("Pack Updater"); + odp.pfnDlgProc = DlgPopUpOpts; + CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp); + } + return 0; +} \ No newline at end of file diff --git a/PackUpdater/Src/PackUpdater.cpp b/PackUpdater/Src/PackUpdater.cpp new file mode 100644 index 0000000..fb43294 --- /dev/null +++ b/PackUpdater/Src/PackUpdater.cpp @@ -0,0 +1,118 @@ +/* +Copyright (C) 2010 Mataes + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This 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 +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#include "common.h" + +HINSTANCE hInst = NULL; +PLUGINLINK *pluginLink; +HANDLE hOptHook = NULL, hLoadHook = NULL, hPackUpdaterFolder = NULL, hCheckUpdates = NULL, hEmptyFolder = NULL, hOnPreShutdown = NULL; +TCHAR tszRoot[MAX_PATH] = {0}; +int hLangpack; +struct MM_INTERFACE mmi; + +PLUGININFOEX pluginInfoEx = { + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + 0, + //{29517BE5-779A-48e5-8950-CB4DE1D43172} + {0x29517be5, 0x779a, 0x48e5, {0x89, 0x50, 0xcb, 0x4d, 0xe1, 0xd4, 0x31, 0x72}} +}; + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + hInst = hinstDLL; + return TRUE; +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfoEx; +} + +static const MUUID interfaces[] = {{0x29517be5, 0x779a, 0x48e5, {0x89, 0x50, 0xcb, 0x4d, 0xe1, 0xd4, 0x31, 0x72}}, MIID_LAST}; + +extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) +{ + return interfaces; +} + +extern "C" __declspec(dllexport) int Load(PLUGINLINK *link) +{ + CLISTMENUITEM mi; + pluginLink = link; + mir_getLP(&pluginInfoEx); + mir_getMMI(&mmi); + TCHAR* tszFolder = Utils_ReplaceVarsT(_T("%miranda_userdata%\\"DEFAULT_UPDATES_FOLDER)); + lstrcpyn(tszRoot, tszFolder, SIZEOF(tszRoot)); + if (ServiceExists(MS_FOLDERS_REGISTER_PATH)) + { + hPackUpdaterFolder = FoldersRegisterCustomPathT(MODULEA, "Pack Updater", MIRANDA_USERDATAT _T("\\")DEFAULT_UPDATES_FOLDER); + FoldersGetCustomPathT(hPackUpdaterFolder, tszRoot, MAX_PATH, _T("")); + } + mir_free(tszFolder); + LoadOptions(); + InitPopupList(); + NetlibInit(); + IcoLibInit(); + + // Add cheking update menu item + hCheckUpdates = CreateServiceFunction(MODNAME"/CheckUpdates", MenuCommand); + ZeroMemory(&mi, sizeof(mi)); + mi.cbSize = sizeof(mi); + mi.position = -0x7FFFFFFF; + mi.flags = CMIF_TCHAR; + mi.hIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"check_update"); + mi.ptszName = _T("Check for pack updates"); + mi.pszService = MODNAME"/CheckUpdates"; + CallService(MS_CLIST_ADDMAINMENUITEM, 0, (LPARAM)&mi); + // Add empty updates folder menu item + hEmptyFolder = CreateServiceFunction(MODNAME"/EmptyFolder", EmptyFolder); + ZeroMemory(&mi, sizeof(mi)); + mi.cbSize = sizeof(mi); + mi.position = -0x7FFFFFFF; + mi.flags = CMIF_TCHAR; + mi.hIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"empty_folder"); + mi.ptszName = _T("Clear pack updates folder"); + mi.pszService = MODNAME"/EmptyFolder"; + CallService(MS_CLIST_ADDMAINMENUITEM, 0, (LPARAM)&mi); + + // Add options hook + hOptHook = HookEvent(ME_OPT_INITIALISE, OptInit); + hLoadHook = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded); + hOnPreShutdown = HookEvent(ME_SYSTEM_PRESHUTDOWN, OnPreShutdown); + + return 0; +} + +extern "C" __declspec(dllexport) int Unload(void) +{ + if (CheckThread) + CheckThread = NULL; + NetlibUnInit(); + DestroyServiceFunction(hCheckUpdates); + DestroyServiceFunction(hEmptyFolder); + return 0; +} \ No newline at end of file diff --git a/PackUpdater/Src/Utils.cpp b/PackUpdater/Src/Utils.cpp new file mode 100644 index 0000000..1c77076 --- /dev/null +++ b/PackUpdater/Src/Utils.cpp @@ -0,0 +1,389 @@ +/* +Copyright (C) 2010 Mataes + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This 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 +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#include "Common.h" + +vector Files; +BOOL DlgDld; +INT FileCount = 0, CurrentFile = 0, Number = 0; +BYTE Reminder, AutoUpdate; +TCHAR tszDialogMsg[2048] = {0}; +FILEINFO* pFileInfo = NULL; +FILEURL* pFileUrl = NULL; +HANDLE CheckThread = NULL, hNetlibUser = NULL; +MYOPTIONS MyOptions = {0}; +aPopups PopupsList[POPUPS]; +LPCTSTR Title = {0}, Text = {0}; + +PackUpdaterIconList iconList[] = +{ + { "check_update", _T("Check for pack updates"), IDI_MENU }, + { "empty_folder", _T("Clear pack updates folder"), IDI_DELETE }, + { "btn_ok", _T("'Yes' Button"), IDI_OK }, + { "btn_cancel", _T("'No' Button"), IDI_CANCEL } +}; + +VOID IcoLibInit() +{ + SKINICONDESC sid; + TCHAR destfile[MAX_PATH]; + + GetModuleFileName(hInst, destfile, MAX_PATH); + + sid.cbSize = sizeof(sid); + sid.flags = SIDF_ALL_TCHAR; + sid.cx = sid.cy = 16; + sid.ptszDefaultFile = destfile; + sid.ptszSection = MODULE; + + for (int i = 0; i < SIZEOF(iconList); i++) + { + sid.pszName = iconList[i].szIconName; + sid.ptszDescription = iconList[i].tszDescr; + sid.iDefaultIndex = -iconList[i].IconID; + CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid); + } +} + +BOOL NetlibInit() +{ + NETLIBUSER nlu = {0}; + nlu.cbSize = sizeof(nlu); + nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_HTTPCONNS | NUF_TCHAR; // | NUF_HTTPGATEWAY; + nlu.ptszDescriptiveName = TranslateT("Pack Updater HTTP connection"); + nlu.szSettingsModule = MODNAME; + hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu); + + return hNetlibUser != NULL; +} + +VOID NetlibUnInit() +{ + Netlib_CloseHandle(hNetlibUser); + hNetlibUser = NULL; +} + +VOID InitPopupList() +{ + int index = 0; + PopupsList[index].ID = index; + PopupsList[index].Icon = SKINICON_OTHER_MIRANDA; + PopupsList[index].colorBack = DBGetContactSettingDword(NULL, MODNAME, "Popups0Bg", COLOR_BG_FIRSTDEFAULT); + PopupsList[index].colorText = DBGetContactSettingDword(NULL, MODNAME, "Popups0Tx", COLOR_TX_DEFAULT); + + index = 1; + PopupsList[index].ID = index; + PopupsList[index].Icon = SKINICON_OTHER_MIRANDA; + PopupsList[index].colorBack = DBGetContactSettingDword(NULL, MODNAME, "Popups1Bg", COLOR_BG_SECONDDEFAULT); + PopupsList[index].colorText = DBGetContactSettingDword(NULL, MODNAME, "Popups1Tx", COLOR_TX_DEFAULT); + + index = 2; + PopupsList[index].ID = index; + PopupsList[index].Icon = SKINICON_OTHER_MIRANDA; + PopupsList[index].colorBack = DBGetContactSettingDword(NULL, MODNAME, "Popups2Bg", COLOR_BG_FIRSTDEFAULT); + PopupsList[index].colorText = DBGetContactSettingDword(NULL, MODNAME, "Popups2Tx", COLOR_TX_DEFAULT); + + index = 3; + PopupsList[index].ID = index; + PopupsList[index].Icon = SKINICON_OTHER_MIRANDA; + PopupsList[index].colorBack = DBGetContactSettingDword(NULL, MODNAME, "Popups3Bg", COLOR_BG_SECONDDEFAULT); + PopupsList[index].colorText = DBGetContactSettingDword(NULL, MODNAME, "Popups3Tx", COLOR_TX_DEFAULT); +} + +VOID LoadOptions() +{ + MyOptions.DefColors = DBGetContactSettingByte(NULL, MODNAME, "DefColors", DEFAULT_COLORS); + MyOptions.LeftClickAction= DBGetContactSettingByte(NULL, MODNAME, "LeftClickAction", DEFAULT_POPUP_LCLICK); + MyOptions.RightClickAction = DBGetContactSettingByte(NULL, MODNAME, "RightClickAction", DEFAULT_POPUP_RCLICK); + MyOptions.Timeout = DBGetContactSettingDword(NULL, MODNAME, "Timeout", DEFAULT_TIMEOUT_VALUE); + AutoUpdate = DBGetContactSettingByte(NULL, MODNAME, "AutoUpdate", DEFAULT_AUTOUPDATE); + Reminder = DBGetContactSettingByte(NULL, MODNAME, "Reminder", DEFAULT_REMINDER); + FileCount = DBGetContactSettingDword(NULL, MODNAME, "FileCount", DEFAULT_FILECOUNT); +} + +BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal) +{ + HANDLE hFile = NULL; + DWORD dwBytes; + + NETLIBHTTPREQUEST nlhr = {0}; + nlhr.cbSize = sizeof(nlhr); + nlhr.requestType = REQUEST_GET; + nlhr.flags = NLHRF_DUMPASTEXT | NLHRF_HTTP11; + char* szUrl = mir_t2a(tszURL); + nlhr.szUrl = szUrl; + nlhr.headersCount = 4; + nlhr.headers=(NETLIBHTTPHEADER*)mir_alloc(sizeof(NETLIBHTTPHEADER)*nlhr.headersCount); + nlhr.headers[0].szName = "User-Agent"; + nlhr.headers[0].szValue = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"; + nlhr.headers[1].szName = "Connection"; + nlhr.headers[1].szValue = "close"; + nlhr.headers[2].szName = "Cache-Control"; + nlhr.headers[2].szValue = "no-cache"; + nlhr.headers[3].szName = "Pragma"; + nlhr.headers[3].szValue = "no-cache"; + + bool ret = false; + NETLIBHTTPREQUEST* pReply = NULL; + pReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser,(LPARAM)&nlhr); + + if(pReply) + { + if((200 == pReply->resultCode) && (pReply->dataLength > 0)) + { + hFile = CreateFile(tszLocal, GENERIC_READ | GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + WriteFile(hFile, pReply->pData, (DWORD)pReply->dataLength, &dwBytes, NULL); + ret = true; + } + CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)pReply); + } + + mir_free(szUrl); + mir_free(nlhr.headers); + + if (hFile) + CloseHandle(hFile); + DlgDld = ret; + return ret; +} + +VOID __stdcall ExitMe(void*) +{ + CallService("CloseAction", 0, 0); +} + +VOID __stdcall RestartMe(void*) +{ + CallService("CloseAction", 0, 0); + CallService(MS_SYSTEM_RESTART, 0, 0); +} + +BOOL Exists(LPCTSTR strName) +{ + return GetFileAttributes(strName) != INVALID_FILE_ATTRIBUTES; +} + +BOOL IsPluginDisabled(TCHAR* filename) +{ + char* fname = mir_t2a(filename); + int res = DBGetContactSettingByte(NULL, "PluginDisable", fname, 0); + mir_free(fname); + return res; +} + +INT getVer(const TCHAR* verStr) +{ + INT v1 = 0, v2 = 0, v3 = 0, v4 = 0; + _stscanf(verStr, _T("%d.%d.%d.%d"), &v1, &v2, &v3, &v4); + return v1*1000000 + v2*10000 + v3*1000 + v4; +} + +static void CheckUpdates(void *) +{ + TCHAR tszBuff[2048] = {0}, tszFileInfo[30] = {0}, tszTmpIni[MAX_PATH] = {0}; + char szKey[64] = {0}; + INT upd_ret; + DBVARIANT dbVar = {0}; + vector UpdateFiles; + + if(!Exists(tszRoot)) + CreateDirectory(tszRoot, NULL); + Files.clear(); + Reminder = DBGetContactSettingByte(NULL, MODNAME, "Reminder", DEFAULT_REMINDER); + FileCount = DBGetContactSettingDword(NULL, MODNAME, "FileCount", DEFAULT_FILECOUNT); + + // Load files info + DBGetContactSettingTString(NULL, MODNAME, "File_VersionURL", &dbVar); + if (lstrcmp(dbVar.ptszVal, NULL) == 0)// URL is not set + { + Title=TranslateT("Pack Updater"); + Text = TranslateT("URL for checking updates not found."); + if (ServiceExists(MS_POPUP_ADDPOPUPEX) && DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1) && DBGetContactSettingByte(NULL, MODNAME, "Popups1", DEFAULT_POPUP_ENABLED)) + { + Number = 1; + show_popup(0, Title, Text, Number, 0); + } + else if (DBGetContactSettingByte(NULL, MODNAME, "Popups1M", DEFAULT_MESSAGE_ENABLED)) + MessageBox(NULL, Text, Title, MB_ICONSTOP); + DBFreeVariant(&dbVar); + CheckThread = NULL; + return; + } + // Download version info + pFileUrl = (FILEURL *)mir_alloc(sizeof(*pFileUrl)); + lstrcpyn(pFileUrl->tszDownloadURL, dbVar.ptszVal, SIZEOF(pFileUrl->tszDownloadURL)); + mir_sntprintf(tszBuff, SIZEOF(tszBuff), _T("%s\\tmp.ini"), tszRoot); + lstrcpyn(pFileUrl->tszDiskPath, tszBuff, SIZEOF(pFileUrl->tszDiskPath)); + lstrcpyn(tszTmpIni, tszBuff, SIZEOF(tszTmpIni)); + Title = TranslateT("Pack Updater"); + Text = TranslateT("Downloading version info..."); + DlgDownloadProc(); + mir_free(pFileUrl); + if (!DlgDld) + { + CheckThread = NULL; + return; + } + + for (CurrentFile = 0; CurrentFile < FileCount; CurrentFile++) + { + FILEINFO FileInfo = {_T(""), _T(""), _T(""), _T(""), _T(""), _T(""), _T(""), {_T(""), _T("")}}; + + dbVar.ptszVal = NULL; + mir_snprintf(szKey, SIZEOF(szKey), "File_%d_CurrentVersion", CurrentFile + 1); + DBGetContactSettingTString(NULL, MODNAME, szKey, &dbVar); + if (lstrcmp(dbVar.ptszVal, NULL) == 0) + { + DBFreeVariant(&dbVar); + lstrcpyn(FileInfo.tszCurVer, _T(""), SIZEOF(FileInfo.tszCurVer)); + } + else + lstrcpyn(FileInfo.tszCurVer, dbVar.ptszVal, SIZEOF(FileInfo.tszCurVer)); + dbVar.ptszVal = NULL; + mir_snprintf(szKey, SIZEOF(szKey), "File_%d_LastVersion", CurrentFile + 1); + DBGetContactSettingTString(NULL, MODNAME, szKey, &dbVar); + if (lstrcmp(dbVar.ptszVal, NULL) == 0) + { + DBFreeVariant(&dbVar); + lstrcpyn(FileInfo.tszLastVer, _T(""), SIZEOF(FileInfo.tszLastVer)); + } + else + lstrcpyn(FileInfo.tszLastVer, dbVar.ptszVal, SIZEOF(FileInfo.tszLastVer)); + Files.push_back(FileInfo); + + // Read version info + mir_sntprintf(tszFileInfo, SIZEOF(tszFileInfo), _T("FileInfo_%d"), CurrentFile + 1); + GetPrivateProfileString(tszFileInfo, _T("FileVersion"), _T(""), Files[CurrentFile].tszNewVer, SIZEOF(Files[CurrentFile].tszNewVer), tszTmpIni); + GetPrivateProfileString(tszFileInfo, _T("Message"), _T(""), Files[CurrentFile].tszMessage, SIZEOF(Files[CurrentFile].tszMessage), tszTmpIni); + GetPrivateProfileString(tszFileInfo, _T("DownloadURL"), _T(""), Files[CurrentFile].File.tszDownloadURL, SIZEOF(Files[CurrentFile].File.tszDownloadURL), tszTmpIni); + GetPrivateProfileString(tszFileInfo, _T("AdvFolder"), _T(""), Files[CurrentFile].tszAdvFolder, SIZEOF(Files[CurrentFile].tszAdvFolder), tszTmpIni); + GetPrivateProfileString(tszFileInfo, _T("Descr"), _T(""), Files[CurrentFile].tszDescr, SIZEOF(Files[CurrentFile].tszDescr), tszTmpIni); + GetPrivateProfileString(tszFileInfo, _T("DiskFileName"), _T(""), tszBuff, MAX_PATH, tszTmpIni); + + if (_tcsstr(tszBuff, _T("\\"))) //check update name + { + Title = TranslateT("Pack Updater"); + Text = TranslateT("Name of Update's file is not supported."); + if (ServiceExists(MS_POPUP_ADDPOPUPEX) && DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1) && DBGetContactSettingByte(NULL, MODNAME, "Popups1", DEFAULT_POPUP_ENABLED)) + { + Number = 1; + show_popup(0, Title, Text, Number, 0); + } + else if (DBGetContactSettingByte(NULL, MODNAME, "Popups1M", DEFAULT_MESSAGE_ENABLED)) + MessageBox(NULL, Text, Title, MB_ICONINFORMATION); + continue; + } // end check update name + lstrcpyn(Files[CurrentFile].File.tszDiskPath, tszBuff, SIZEOF(Files[CurrentFile].File.tszDiskPath)); + GetPrivateProfileString(tszFileInfo, _T("InfoURL"), _T(""), Files[CurrentFile].tszInfoURL, SIZEOF(Files[CurrentFile].tszInfoURL), tszTmpIni); + GetPrivateProfileString(tszFileInfo, _T("FileType"), _T(""), tszBuff, SIZEOF(tszBuff), tszTmpIni); + Files[CurrentFile].FileType = _tstoi(tszBuff); + Files[CurrentFile].FileNum = CurrentFile+1; + + if (Files[CurrentFile].FileType == 2) + { + TCHAR pluginFolgerName[MAX_PATH]; + if (lstrcmp(Files[CurrentFile].tszAdvFolder, _T("")) == 0) + mir_sntprintf(tszBuff, SIZEOF(tszBuff), _T("Plugins\\%s"), Files[CurrentFile].File.tszDiskPath); + else + mir_sntprintf(tszBuff, SIZEOF(tszBuff), _T("Plugins\\%s\\%s"), Files[CurrentFile].tszAdvFolder, Files[CurrentFile].File.tszDiskPath); + CallService(MS_UTILS_PATHTOABSOLUTET, (WPARAM)tszBuff, (LPARAM)pluginFolgerName); + if ((IsPluginDisabled(Files[CurrentFile].File.tszDiskPath) || !Exists(pluginFolgerName))) //check if plugin disabled or not exists + continue; + } + // Compare versions + if (getVer(Files[CurrentFile].tszCurVer) < getVer(Files[CurrentFile].tszNewVer)) // Yeah, we've got new version. + { + TCHAR* tszSysRoot = Utils_ReplaceVarsT(_T("%SystemRoot%")); + TCHAR* tszProgFiles = Utils_ReplaceVarsT(_T("%ProgramFiles%")); + + if (Files[CurrentFile].FileType != 1 && !IsUserAnAdmin() && (_tcsstr(tszRoot, tszSysRoot) || _tcsstr(tszRoot, tszProgFiles))) + { + MessageBox(NULL, TranslateT("Update is not possible!\nYou have no Administrator's rights.\nPlease run Miranda IM with Administrator's rights."), Title, MB_ICONINFORMATION); + DeleteFile(tszTmpIni); + CheckThread = NULL; + return; + } // user have not admin's rights + else + { + UpdateFiles.push_back(Files[CurrentFile]); + // Save last version + lstrcpyn(Files[CurrentFile].tszLastVer, Files[CurrentFile].tszNewVer, SIZEOF(Files[CurrentFile].tszLastVer)); + mir_snprintf(szKey, SIZEOF(szKey), "File_%d_LastVersion", CurrentFile + 1); + DBWriteContactSettingTString(NULL, MODNAME, szKey, Files[CurrentFile].tszLastVer); + } // user have admin's rights + mir_free(tszSysRoot); + mir_free(tszProgFiles); + } // end compare versions + } //end checking all files in for() + + // Show dialog + if (UpdateFiles.size()>0) + upd_ret = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_UPDATE), GetDesktopWindow(), DlgUpdate, (LPARAM)&UpdateFiles); + DeleteFile(tszTmpIni); + if (upd_ret == IDCANCEL) + { + CheckThread = NULL; + return; + } + if (!UpdatesCount && !Silent) + { + Title = TranslateT("Pack Updater"); + Text = TranslateT("No updates found."); + if (ServiceExists(MS_POPUP_ADDPOPUPEX) && DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1) && DBGetContactSettingByte(NULL, MODNAME, "Popups2", DEFAULT_POPUP_ENABLED)) + { + Number = 2; + show_popup(0, Title, Text, Number, 0); + } + else if (DBGetContactSettingByte(NULL, MODNAME, "Popups2M", DEFAULT_MESSAGE_ENABLED)) + MessageBox(NULL, Text, Title, MB_ICONINFORMATION); + } + if (!FileCount) + { + Title = TranslateT("Pack Updater"); + Text = TranslateT("No files for update."); + if (ServiceExists(MS_POPUP_ADDPOPUPEX) && DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1) && DBGetContactSettingByte(NULL, MODNAME, "Popups2", DEFAULT_POPUP_ENABLED)) + { + Number = 2; + show_popup(0, Title, Text, Number, 0); + } + else if (DBGetContactSettingByte(NULL, MODNAME, "Popups2M", DEFAULT_MESSAGE_ENABLED)) + MessageBox(NULL, Text, Title, MB_ICONINFORMATION); + } + CheckThread = NULL; +}//end* static void CheckUpdates(void *) + +void DoCheck(int iFlag, int iFlag2) +{ + if (iFlag2) + { + Title = TranslateT("Pack Updater"); + Text = TranslateT("Update checking already started!"); + if (ServiceExists(MS_POPUP_ADDPOPUPEX) && DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1) && DBGetContactSettingByte(NULL, MODNAME, "Popups2", DEFAULT_POPUP_ENABLED)) + { + Number = 2; + show_popup(0, Title, Text, Number, 0); + } + else if (DBGetContactSettingByte(NULL, MODNAME, "Popups2M", DEFAULT_MESSAGE_ENABLED)) + MessageBox(NULL, Text, Title, MB_ICONINFORMATION); + } + else if (iFlag) + { + CheckThread = mir_forkthread(CheckUpdates, 0); + } +} \ No newline at end of file diff --git a/PackUpdater/Version.h b/PackUpdater/Version.h new file mode 100644 index 0000000..14b51f7 --- /dev/null +++ b/PackUpdater/Version.h @@ -0,0 +1,28 @@ +#define __MAJOR_VERSION 0 +#define __MINOR_VERSION 0 +#define __RELEASE_NUM 0 +#define __BUILD_NUM 9 + +#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) + +#ifdef _UNICODE +#if defined(WIN64) || defined(_WIN64) + #define __PLUGIN_NAME "PackUpdater (Unicode x64)" +#else + #define __PLUGIN_NAME "PackUpdater (Unicode)" +#endif +#else + #define __PLUGIN_NAME "PackUpdater" +#endif +#define __INTERNAL_NAME "PackUpdater" +#define __FILENAME "PackUpdater.dll" +#define __DESCRIPTION "Simple updater for Miranda IM premodified packs." +#define __AUTHOR "Mataes, ZERO_BiT" +#define __AUTHOREMAIL "mataes2007@gmail.com, zero-bit@mail.ru" +#define __AUTHORWEB "http://mataes.googlecode.com/svn/Miranda/Plugins/PackUpdater/" +#define __COPYRIGHT "© 2010 Mataes, 2007 ZERO_BiT" diff --git a/PackUpdater/Version.rc b/PackUpdater/Version.rc new file mode 100644 index 0000000..e637f0c --- /dev/null +++ b/PackUpdater/Version.rc @@ -0,0 +1,38 @@ +// Microsoft Visual C++ generated resource script. +// +#include "afxres.h" +#include "version.h" + +#ifdef _WIN32 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +#endif //_WIN32 + +VS_VERSION_INFO VERSIONINFO + FILEVERSION __FILEVERSION_STRING + PRODUCTVERSION __FILEVERSION_STRING + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x0L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "FileDescription", __DESCRIPTION + VALUE "InternalName", __PLUGIN_NAME + VALUE "LegalCopyright", __COPYRIGHT + VALUE "OriginalFilename", __FILENAME + VALUE "ProductName", __PLUGIN_NAME + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END diff --git a/PackUpdater/resource.h b/PackUpdater/resource.h new file mode 100644 index 0000000..6a7041b --- /dev/null +++ b/PackUpdater/resource.h @@ -0,0 +1,71 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Resource.rc +// +#define IDI_MENU 101 +#define IDD_UPDATE 102 +#define IDD_DOWNLOAD 103 +#define IDD_OPT_UPDATENOTIFY 104 +#define IDD_POPUP 105 +#define IDD_POPUPDUMMI 106 +#define IDI_DELETE 107 +#define IDI_OK 108 +#define IDI_CANCEL 109 +#define IDC_UPDATETEXT 1001 +#define IDC_CURVER 1002 +#define IDC_NEWVER 1003 +#define IDC_INFO 1004 +#define IDC_PB 1005 +#define IDC_LABEL 1006 +#define IDC_USEWINCOLORS 1007 +#define IDC_RC 1008 +#define IDC_USEPOPUPCOLORS 1009 +#define IDC_COLORS 1010 +#define IDC_STATIC_INFINITE 1011 +#define IDC_STATIC_DEFAULT 1012 +#define IDC_TIMEOUT_VALUE_SPIN 1013 +#define IDC_STATIC_SEC 1014 +#define IDC_LC 1015 +#define IDC_PREVIEW 1016 +#define IDC_TIMEOUT_VALUE 1017 +#define IDC_USEOWNCOLORS 1018 +#define IDC_ENABLEUPDATES 1019 +#define IDC_REMINDER 1020 +#define IDC_LIST_UPDATES 1021 +#define IDC_MESSAGE 1022 +#define IDC_DESCR 1023 +#define IDC_MSG_BOXES_MSG 1024 +#define IDC_ERRORS_MSG 1025 +#define IDC_INFO_MESSAGES_MSG 1026 +#define IDC_PROGR_DLG_MSG 1027 +#define IDC_SYSLINK1 1028 +#define IDC_LINK_HOTKEY 1028 +#define IDC_MSG_BOXES2 1029 +#define IDC_ERRORS2 1030 +#define IDC_INFO_MESSAGES2 1031 +#define IDC_PROGR_DLG2 1032 +#define IDC_NOTIFY2 1033 +#define IDC_NOTIFY 1034 +#define IDC_MSG_BOXES 40071 +#define IDC_ERRORS 40072 +#define IDC_INFO_MESSAGES 40073 +#define IDC_PROGR_DLG 40074 +#define IDC_MSG_BOXES_TX 41071 +#define IDC_ERR_TX 41072 +#define IDC_INFO_MESSAGES_TX 41073 +#define IDC_PROGR_DLG_TX 41074 +#define IDC_MSG_BOXES_BG 42071 +#define IDC_ERR_BG 42072 +#define IDC_INFO_MESSAGES_BG 42073 +#define IDC_PROGR_DLG_BG 42074 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 110 +#define _APS_NEXT_COMMAND_VALUE 40075 +#define _APS_NEXT_CONTROL_VALUE 1035 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/TranslitSwitcher/Docs/Readme.txt b/TranslitSwitcher/Docs/Readme.txt new file mode 100644 index 0000000..adf6b52 --- /dev/null +++ b/TranslitSwitcher/Docs/Readme.txt @@ -0,0 +1,4 @@ +for adding symbol when you resend message add in your db: +[TranslitSwitcher] +ResendSymbol=u* +where * is resend symbol \ No newline at end of file diff --git a/TranslitSwitcher/Res/InvertSend.ico b/TranslitSwitcher/Res/InvertSend.ico new file mode 100644 index 0000000..67171c3 Binary files /dev/null and b/TranslitSwitcher/Res/InvertSend.ico differ diff --git a/TranslitSwitcher/Res/SwitchSend.ico b/TranslitSwitcher/Res/SwitchSend.ico new file mode 100644 index 0000000..7d5362d Binary files /dev/null and b/TranslitSwitcher/Res/SwitchSend.ico differ diff --git a/TranslitSwitcher/Res/TranslitSend.ico b/TranslitSwitcher/Res/TranslitSend.ico new file mode 100644 index 0000000..737ab57 Binary files /dev/null and b/TranslitSwitcher/Res/TranslitSend.ico differ diff --git a/TranslitSwitcher/Resource.h b/TranslitSwitcher/Resource.h new file mode 100644 index 0000000..b98a659 --- /dev/null +++ b/TranslitSwitcher/Resource.h @@ -0,0 +1,18 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by resources.rc +// +#define IDI_SWITCHSEND 101 +#define IDI_TRANSLITSEND 102 +#define IDI_INVERTSEND 103 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 104 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/TranslitSwitcher/Resource.rc b/TranslitSwitcher/Resource.rc new file mode 100644 index 0000000..b405fa8 --- /dev/null +++ b/TranslitSwitcher/Resource.rc @@ -0,0 +1,48 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Русский (Россия) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) +LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT +#pragma code_page(1251) + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_SWITCHSEND ICON "res/SwitchSend.ico" +IDI_TRANSLITSEND ICON "res/TranslitSend.ico" +IDI_INVERTSEND ICON "res/InvertSend.ico" + + +#endif // Русский (Россия) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/TranslitSwitcher/Src/Layoutproc.cpp b/TranslitSwitcher/Src/Layoutproc.cpp new file mode 100644 index 0000000..c610380 --- /dev/null +++ b/TranslitSwitcher/Src/Layoutproc.cpp @@ -0,0 +1,870 @@ +/* +Copyright (C) 2007 Dmitry Titkov (C) 2010 tico-tico, Mataes + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This 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 +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#include "TranslitSwitcher.h" + +SMADD_BATCHPARSE2 smgp; +SMADD_BATCHPARSERES *smileyPrs = NULL; + +BOOL isItSmiley(unsigned int position) +{ + unsigned int j; + + if (smileyPrs == NULL) + return FALSE; + + for (j = 0; j < smgp.numSmileys; j++) + { + if (position >= smileyPrs[j].startChar && position < (smileyPrs[j].startChar + smileyPrs[j].size)) + return TRUE; + } + + return FALSE; +} + +static DWORD CALLBACK StreamOutCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG * pcb) +{ + static int sendBufferSize; + char ** ppText = (char **) dwCookie; + + if (*ppText == NULL) + sendBufferSize = 0; + + *ppText = (char *)mir_realloc(*ppText, sendBufferSize + cb + 2); + memcpy (*ppText + sendBufferSize, pbBuff, cb); + sendBufferSize += cb; + *((TCHAR *)(*ppText + sendBufferSize)) = '\0'; + *pcb = cb; + return 0; +} + +TCHAR* Message_GetFromStream(HWND hwndRtf, DWORD dwPassedFlags) +{ + EDITSTREAM stream = {0}; + TCHAR *pszText = NULL; + + if (hwndRtf == 0) + return NULL; + + stream.pfnCallback = StreamOutCallback; + stream.dwCookie = (DWORD_PTR) & pszText; + SendMessage(hwndRtf, EM_STREAMOUT, (WPARAM)dwPassedFlags, (LPARAM) & stream); + + return pszText; +} + +VOID Transliterate(TCHAR*& str) +{ + TCHAR* newStr = (TCHAR*)mir_alloc(sizeof(TCHAR)*lstrlen(str)*3+1); + newStr[0] = 0; + for (; *str != 0; str++) + { + switch (str[0]) + { + case _T('а'): _tcscat(newStr, _T("a")); break; + case _T('б'): _tcscat(newStr, _T("b")); break; + case _T('в'): _tcscat(newStr, _T("v")); break; + case _T('г'): _tcscat(newStr, _T("g")); break; + case _T('д'): _tcscat(newStr, _T("d")); break; + case _T('е'): _tcscat(newStr, _T("e")); break; + case _T('ё'): _tcscat(newStr, _T("ye")); break; + case _T('ж'): _tcscat(newStr, _T("zh")); break; + case _T('з'): _tcscat(newStr, _T("z")); break; + case _T('и'): _tcscat(newStr, _T("i")); break; + case _T('й'): _tcscat(newStr, _T("y")); break; + case _T('к'): _tcscat(newStr, _T("k")); break; + case _T('л'): _tcscat(newStr, _T("l")); break; + case _T('м'): _tcscat(newStr, _T("m")); break; + case _T('н'): _tcscat(newStr, _T("n")); break; + case _T('о'): _tcscat(newStr, _T("o")); break; + case _T('п'): _tcscat(newStr, _T("p")); break; + case _T('р'): _tcscat(newStr, _T("r")); break; + case _T('с'): _tcscat(newStr, _T("s")); break; + case _T('т'): _tcscat(newStr, _T("t")); break; + case _T('у'): _tcscat(newStr, _T("u")); break; + case _T('ф'): _tcscat(newStr, _T("f")); break; + case _T('х'): _tcscat(newStr, _T("kh")); break; + case _T('ц'): _tcscat(newStr, _T("ts")); break; + case _T('ч'): _tcscat(newStr, _T("ch")); break; + case _T('ш'): _tcscat(newStr, _T("sh")); break; + case _T('щ'): _tcscat(newStr, _T("sch")); break; + case _T('ъ'): _tcscat(newStr, _T("'")); break; + case _T('ы'): _tcscat(newStr, _T("yi")); break; + case _T('ь'): _tcscat(newStr, _T("")); break; + case _T('э'): _tcscat(newStr, _T("e")); break; + case _T('ю'): _tcscat(newStr, _T("yu")); break; + case _T('я'): _tcscat(newStr, _T("ya")); break; + case _T('А'): _tcscat(newStr, _T("A")); break; + case _T('Б'): _tcscat(newStr, _T("B")); break; + case _T('В'): _tcscat(newStr, _T("V")); break; + case _T('Г'): _tcscat(newStr, _T("G")); break; + case _T('Д'): _tcscat(newStr, _T("D")); break; + case _T('Е'): _tcscat(newStr, _T("E")); break; + case _T('Ё'): _tcscat(newStr, _T("Ye")); break; + case _T('Ж'): _tcscat(newStr, _T("Zh")); break; + case _T('З'): _tcscat(newStr, _T("Z")); break; + case _T('И'): _tcscat(newStr, _T("I")); break; + case _T('Й'): _tcscat(newStr, _T("Y")); break; + case _T('К'): _tcscat(newStr, _T("K")); break; + case _T('Л'): _tcscat(newStr, _T("L")); break; + case _T('М'): _tcscat(newStr, _T("M")); break; + case _T('Н'): _tcscat(newStr, _T("N")); break; + case _T('О'): _tcscat(newStr, _T("O")); break; + case _T('П'): _tcscat(newStr, _T("P")); break; + case _T('Р'): _tcscat(newStr, _T("R")); break; + case _T('С'): _tcscat(newStr, _T("S")); break; + case _T('Т'): _tcscat(newStr, _T("T")); break; + case _T('У'): _tcscat(newStr, _T("U")); break; + case _T('Ф'): _tcscat(newStr, _T("F")); break; + case _T('Х'): _tcscat(newStr, _T("Kh")); break; + case _T('Ц'): _tcscat(newStr, _T("Ts")); break; + case _T('Ч'): _tcscat(newStr, _T("Ch")); break; + case _T('Ш'): _tcscat(newStr, _T("Sh")); break; + case _T('Щ'): _tcscat(newStr, _T("Sch")); break; + case _T('Ъ'): _tcscat(newStr, _T("'")); break; + case _T('Ы'): _tcscat(newStr, _T("Yi")); break; + case _T('Ь'): _tcscat(newStr, _T("")); break; + case _T('Э'): _tcscat(newStr, _T("E")); break; + case _T('Ю'): _tcscat(newStr, _T("Yu")); break; + case _T('Я'): _tcscat(newStr, _T("Ya")); break; + + case _T('a'): _tcscat(newStr, _T("а")); break; + case _T('b'): _tcscat(newStr, _T("б")); break; + case _T('v'): _tcscat(newStr, _T("в")); break; + case _T('g'): _tcscat(newStr, _T("г")); break; + case _T('d'): _tcscat(newStr, _T("д")); break; + case _T('e'): _tcscat(newStr, _T("е")); break; + case _T('z'): + { + if (str[1] == _T('h')) + { + _tcscat(newStr, _T("ж")); + str++; + break; + } + else + { + _tcscat(newStr, _T("з")); + break; + } + } + case _T('i'): _tcscat(newStr, _T("и")); break; + case _T('y'): + { + if (str[1] == _T('a')) + { + _tcscat(newStr, _T("я")); + str++; + break; + } + else if (str[1] == _T('e')) + { + _tcscat(newStr, _T("ё")); + str++; + break; + } + else if (str[1] == _T('u')) + { + _tcscat(newStr, _T("ю")); + str++; + break; + } + else if (str[1] == _T('i')) + { + _tcscat(newStr, _T("ы")); + str++; + break; + } + else + { + _tcscat(newStr, _T("й")); + break; + } + } + case _T('k'): + { + if (str[1] == _T('h')) + { + _tcscat(newStr, _T("х")); + str++; + break; + } + else + { + _tcscat(newStr, _T("к")); + break; + } + } + case _T('l'): _tcscat(newStr, _T("л")); break; + case _T('m'): _tcscat(newStr, _T("м")); break; + case _T('n'): _tcscat(newStr, _T("н")); break; + case _T('o'): _tcscat(newStr, _T("о")); break; + case _T('p'): _tcscat(newStr, _T("п")); break; + case _T('r'): _tcscat(newStr, _T("р")); break; + case _T('s'): + { + if (str[1] == _T('h')) + { + _tcscat(newStr, _T("ш")); + str++; + break; + } + else if (str[1] == _T('c') && str[2] == _T('h')) + { + _tcscat(newStr, _T("щ")); + str+=2; + break; + } + else + { + _tcscat(newStr, _T("с")); + break; + } + } + case _T('t'): + { + if (str[1] == _T('s')) + { + _tcscat(newStr, _T("ц")); + str++; + break; + } + else + { + _tcscat(newStr, _T("т")); + break; + } + } + case _T('u'): _tcscat(newStr, _T("у")); break; + case _T('f'): _tcscat(newStr, _T("ф")); break; + case _T('c'): + { + if (str[1] == _T('h')) + { + _tcscat(newStr, _T("ч")); + str++; + break; + } + } + case _T('A'): _tcscat(newStr, _T("А")); break; + case _T('B'): _tcscat(newStr, _T("Б")); break; + case _T('V'): _tcscat(newStr, _T("В")); break; + case _T('G'): _tcscat(newStr, _T("Г")); break; + case _T('D'): _tcscat(newStr, _T("Д")); break; + case _T('E'): _tcscat(newStr, _T("Е")); break; + case _T('Y'): + { + if (str[1] == _T('a')) + { + _tcscat(newStr, _T("Я")); + str++; + break; + } + else if (str[1] == _T('e')) + { + _tcscat(newStr, _T("Ё")); + str++; + break; + } + else if (str[1] == _T('u')) + { + _tcscat(newStr, _T("Ю")); + str++; + break; + } + else if (str[1] == _T('i')) + { + _tcscat(newStr, _T("Ы")); + str++; + break; + } + else + { + _tcscat(newStr, _T("Й")); + break; + } + } + case _T('Z'): + { + if (str[1] == _T('h')) + { + _tcscat(newStr, _T("Ж")); + str++; + break; + } + else + { + _tcscat(newStr, _T("З")); + break; + } + } + case _T('I'): _tcscat(newStr, _T("И")); break; + case _T('K'): + { + if (str[1] == _T('h')) + { + _tcscat(newStr, _T("Х")); + str++; + break; + } + else + { + _tcscat(newStr, _T("К")); + break; + } + } + case _T('L'): _tcscat(newStr, _T("Л")); break; + case _T('M'): _tcscat(newStr, _T("М")); break; + case _T('N'): _tcscat(newStr, _T("Н")); break; + case _T('O'): _tcscat(newStr, _T("О")); break; + case _T('P'): _tcscat(newStr, _T("П")); break; + case _T('R'): _tcscat(newStr, _T("Р")); break; + case _T('S'): + { + if (str[1] == _T('h')) + { + _tcscat(newStr, _T("Ш")); + str++; + break; + } + else if (str[1] == _T('c') && str[2] == _T('h')) + { + _tcscat(newStr, _T("Щ")); + str+=2; + break; + } + else + { + _tcscat(newStr, _T("С")); + break; + } + } + case _T('T'): + { + if (str[1] == _T('s')) + { + _tcscat(newStr, _T("Ц")); + str++; + break; + } + else + { + _tcscat(newStr, _T("Т")); + break; + } + } + case _T('U'): _tcscat(newStr, _T("У")); break; + case _T('F'): _tcscat(newStr, _T("Ф")); break; + case _T('C'): + { + if (str[1] == _T('h')) + { + _tcscat(newStr, _T("Ч")); + str++; + break; + } + } + case _T('\''): _tcscat(newStr, _T("ъ")); break; + + default: { TCHAR Temp[2] = { str[0], 0} ; _tcscat(newStr, &Temp[0]); } + } + } + int len = lstrlen(newStr); + str = (TCHAR*)mir_alloc((len+1)*sizeof(TCHAR)); + str[0] = 0; + _tcscpy(str, newStr); + mir_free(newStr); +} + +VOID Invert(TCHAR *str) +{ + while(*str) + { + if(IsCharUpper(*str)) + { + *str = (TCHAR)CharLower((LPTSTR)*str); + } + else if(IsCharLower(*str)) + *str = (TCHAR)CharUpper((LPTSTR)*str); + str++; + } + keybd_event(VK_CAPITAL,0x45,KEYEVENTF_EXTENDEDKEY|0,0); + keybd_event(VK_CAPITAL,0x45,KEYEVENTF_EXTENDEDKEY|KEYEVENTF_KEYUP,0); +} + +VOID SwitchLayout(BOOL lastword) +{ + HWND hwnd = GetForegroundWindow(); + + if(hwnd != NULL) + { + DWORD dwProcessID; + DWORD dwThreadID = GetWindowThreadProcessId(hwnd, &dwProcessID); + HWND hwnd2 = GetFocus(); + + if(hwnd2 != NULL) + { + TCHAR szClassName[16]; + + GetClassName(hwnd2, szClassName, SIZEOF(szClassName)); + + if(lstrcmp(szClassName, _T("RichEdit20W")) == 0) + { + DWORD dwStart, dwEnd; + int i, slen, start = 0, end = 0; + TCHAR *sel, tchr; + BOOL somethingIsSelected = TRUE; + SHORT vks; + BYTE keys[256] = {0}; + HKL hkl = GetKeyboardLayout(dwThreadID); + + SendMessage(hwnd2, EM_GETSEL, (WPARAM)&dwStart, (LPARAM)&dwEnd); + + if (dwStart == dwEnd) + somethingIsSelected = FALSE; + + if (somethingIsSelected) + sel = Message_GetFromStream(hwnd2, SF_TEXT|SF_UNICODE|SFF_SELECTION); + else + sel = Message_GetFromStream(hwnd2, SF_TEXT|SF_UNICODE); + + slen = lstrlen(sel); + + if (slen != 0) + { + ZeroMemory(&smgp, sizeof(smgp)); + smgp.cbSize = sizeof(smgp); + smgp.str = sel; + smgp.flag = SAFL_UNICODE; + + if (ServiceExists(MS_SMILEYADD_BATCHPARSE)) + smileyPrs = (SMADD_BATCHPARSERES *)CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&smgp); + + end = slen; + if (lastword && !somethingIsSelected) + { + end = dwStart; + while (end < slen) + { + if (_istspace(sel[end]) || isItSmiley(end)) + break; + end++; + } + start = dwStart-1; + while (start > 0 && start < (int)dwStart) + { + if ((_istspace(sel[start]) && (end-start>2)) || isItSmiley(start)) + break; + start--; + } + } + + ActivateKeyboardLayout((HKL)HKL_PREV, KLF_ACTIVATE); + + for(i = start; i < end; i++) + { + vks = VkKeyScanEx(sel[i], hkl); + + keys[VK_SHIFT] = (HIBYTE(vks) & 1) ? 0xFF : 0x00; // shift + keys[VK_CONTROL] = (HIBYTE(vks) & 2) ? 0xFF : 0x00; // ctrl + keys[VK_MENU] = (HIBYTE(vks) & 4) ? 0xFF : 0x00; // alt + + if (!isItSmiley(i)) + { + if(ToUnicodeEx(LOBYTE(vks), 0, keys, &tchr, 1, 0, GetKeyboardLayout(dwThreadID)) == 1) + sel[i] = tchr; + } + } + + if (smileyPrs != NULL) + CallService(MS_SMILEYADD_BATCHFREE, 0, (LPARAM)smileyPrs); + + if (somethingIsSelected) + SendMessage(hwnd2, EM_REPLACESEL, FALSE, (LPARAM)sel); + else + SendMessage(hwnd2, WM_SETTEXT, 0, (LPARAM)sel); + + SendMessage(hwnd2, EM_SETSEL, dwStart, dwEnd); + } + mir_free(sel); + } + } + } +} + +void TranslitLayout(BOOL lastword) +{ + HWND hwnd = GetForegroundWindow(); + + if(hwnd != NULL) + { + DWORD dwProcessID; + DWORD dwThreadID = GetWindowThreadProcessId(hwnd, &dwProcessID); + HWND hwnd2 = GetFocus(); + + if(hwnd2 != NULL) + { + TCHAR szClassName[16]; + + GetClassName(hwnd2, szClassName, SIZEOF(szClassName)); + + if(lstrcmp(szClassName, _T("RichEdit20W")) == 0) + { + DWORD dwStart, dwEnd; + int slen, start = 0, end = 0; + TCHAR *sel, *boo; + BOOL somethingIsSelected = TRUE; + + SendMessage(hwnd2, EM_GETSEL, (WPARAM)&dwStart, (LPARAM)&dwEnd); + + if (dwStart == dwEnd) + somethingIsSelected = FALSE; + + if (somethingIsSelected) + sel = Message_GetFromStream(hwnd2, SF_TEXT|SF_UNICODE|SFF_SELECTION); + else + sel = Message_GetFromStream(hwnd2, SF_TEXT|SF_UNICODE); + + slen = lstrlen(sel); + + if (slen != 0) + { + end = slen; + if (lastword && !somethingIsSelected) + { + end = dwStart; + while (end < slen) + { + if (_istspace(sel[end]) || isItSmiley(end)) + break; + end++; + } + start = dwStart-1; + while (start > 0 && start < (int)dwStart) + { + if ((_istspace(sel[start]) && (end-start>2)) || isItSmiley(start)) + break; + start--; + } + boo = (TCHAR*)mir_alloc((end-start+1 ) * sizeof(TCHAR)); + _tcsncpy(boo, sel+start, end-start); + boo[end-start] = 0; + } + else + { + boo = (TCHAR*)mir_alloc((slen+1 ) * sizeof(TCHAR)); + _tcscpy(boo, sel); + } + + Transliterate(boo); + + if (somethingIsSelected) + SendMessage(hwnd2, EM_REPLACESEL, FALSE, (LPARAM)boo); + else + { + TCHAR* NewText = (TCHAR*)mir_alloc((start+_tcslen(boo)+(slen-start)+1)* sizeof(TCHAR)); + NewText[0] = 0; + _tcsncat(NewText, sel, start); + _tcscat(NewText, boo); + _tcsncat(NewText, sel+end, slen-end); + SendMessage(hwnd2, WM_SETTEXT, 0, (LPARAM)NewText); + mir_free(NewText); + } + + SendMessage(hwnd2, EM_SETSEL, dwStart, dwEnd); + } + mir_free(sel); + mir_free(boo); + } + } + } +} + +void InvertCase(BOOL lastword) +{ + HWND hwnd = GetForegroundWindow(); + + if(hwnd != NULL) + { + DWORD dwProcessID; + DWORD dwThreadID = GetWindowThreadProcessId(hwnd, &dwProcessID); + HWND hwnd2 = GetFocus(); + + if(hwnd2 != NULL) + { + TCHAR szClassName[16]; + + GetClassName(hwnd2, szClassName, SIZEOF(szClassName)); + + if(lstrcmp(szClassName, _T("RichEdit20W")) == 0) + { + DWORD dwStart, dwEnd; + int slen, start = 0, end = 0; + TCHAR *sel, *boo; + BOOL somethingIsSelected = TRUE; + + SendMessage(hwnd2, EM_GETSEL, (WPARAM)&dwStart, (LPARAM)&dwEnd); + + if (dwStart == dwEnd) + somethingIsSelected = FALSE; + + if (somethingIsSelected) + sel = Message_GetFromStream(hwnd2, SF_TEXT|SF_UNICODE|SFF_SELECTION); + else + sel = Message_GetFromStream(hwnd2, SF_TEXT|SF_UNICODE); + + slen = lstrlen(sel); + + if (slen != 0) + { + end = slen; + if (lastword && !somethingIsSelected) + { + end = dwStart; + while (end < slen) + { + if (_istspace(sel[end]) || isItSmiley(end)) + break; + end++; + } + start = dwStart-1; + while (start > 0 && start < (int)dwStart) + { + if ((_istspace(sel[start]) && (end-start>2)) || isItSmiley(start)) + break; + start--; + } + boo = (TCHAR*)mir_alloc((end-start+1 ) * sizeof(TCHAR)); + _tcsncpy(boo, sel+start, end-start); + boo[end-start] = 0; + } + else + { + boo = (TCHAR*)mir_alloc((slen+1 ) * sizeof(TCHAR)); + _tcscpy(boo, sel); + } + + Invert(boo); + + if (somethingIsSelected) + SendMessage(hwnd2, EM_REPLACESEL, FALSE, (LPARAM)boo); + else + { + TCHAR* NewText = (TCHAR*)mir_alloc((start+_tcslen(boo)+(slen-start)+1)* sizeof(TCHAR)); + NewText[0] = 0; + _tcsncat(NewText, sel, start); + _tcscat(NewText, boo); + _tcsncat(NewText, sel+end, slen-end); + SendMessage(hwnd2, WM_SETTEXT, 0, (LPARAM)NewText); + mir_free(NewText); + } + + SendMessage(hwnd2, EM_SETSEL, dwStart, dwEnd); + } + mir_free(sel); + mir_free(boo); + } + } + } +} + +int OnButtonPressed(WPARAM wParam, LPARAM lParam) +{ + CustomButtonClickData *cbcd = (CustomButtonClickData *)lParam; + if (lstrcmpA(cbcd->pszModule, "SwitchLayout and Send") == 0) + { + HWND hEdit = GetDlgItem(cbcd->hwndFrom, IDC_MESSAGE); + if (!hEdit) hEdit = GetDlgItem(cbcd->hwndFrom, IDC_CHATMESSAGE); + + BYTE byKeybState[256]; + GetKeyboardState(byKeybState); + byKeybState[VK_CONTROL] = 128; + SetKeyboardState(byKeybState); + SendMessage(hEdit, WM_KEYDOWN, VK_UP, 0); + byKeybState[VK_CONTROL] = 0; + SetKeyboardState(byKeybState); + + DWORD dwProcessID; + DWORD dwThreadID = GetWindowThreadProcessId(cbcd->hwndFrom, &dwProcessID); + HKL hkl = GetKeyboardLayout(dwThreadID); + + TCHAR *sel = Message_GetFromStream(hEdit, SF_TEXT|SF_UNICODE); + int slen = lstrlen(sel); + + if (slen != 0) + { + ZeroMemory(&smgp, sizeof(smgp)); + smgp.cbSize = sizeof(smgp); + smgp.str = sel; + smgp.flag = SAFL_UNICODE; + + if (ServiceExists(MS_SMILEYADD_BATCHPARSE)) + smileyPrs = (SMADD_BATCHPARSERES *)CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&smgp); + + ActivateKeyboardLayout((HKL)HKL_PREV, KLF_ACTIVATE); + + for(int i = 0; i < slen; i++) + { + TCHAR tchr; + BYTE keys[256] = {0}; + SHORT vks = VkKeyScanEx(sel[i], hkl); + + keys[VK_SHIFT] = (HIBYTE(vks) & 1) ? 0xFF : 0x00; // shift + keys[VK_CONTROL] = (HIBYTE(vks) & 2) ? 0xFF : 0x00; // ctrl + keys[VK_MENU] = (HIBYTE(vks) & 4) ? 0xFF : 0x00; // alt + + if (!isItSmiley(i)) + { + if(ToUnicodeEx(LOBYTE(vks), 0, keys, &tchr, 1, 0, GetKeyboardLayout(dwThreadID)) == 1) + sel[i] = tchr; + } + } + if (smileyPrs != NULL) + CallService(MS_SMILEYADD_BATCHFREE, 0, (LPARAM)smileyPrs); + + DBVARIANT dbv = {0}; + DBGetContactSettingTString(NULL, "TranslitSwitcher", "ResendSymbol", &dbv); + if (lstrcmp(dbv.ptszVal, NULL) == 0) + { + DBFreeVariant(&dbv); + SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)sel); + SendMessage(hEdit, EM_SETSEL, 0, slen); + SendMessage(cbcd->hwndFrom, WM_COMMAND, IDOK, 0); + } + else + { + if (_tcsncmp(sel, dbv.ptszVal, _tcslen(dbv.ptszVal)) == 0) + { + SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)sel); + SendMessage(hEdit, EM_SETSEL, 0, slen); + SendMessage(cbcd->hwndFrom, WM_COMMAND, IDOK, 0); + } + else + { + int FinalLen = slen + SIZEOF(dbv.ptszVal) + 1; + TCHAR* FinalString = (TCHAR*)mir_alloc((FinalLen+1)*sizeof(TCHAR)); + mir_sntprintf(FinalString, FinalLen, _T("%s %s"), dbv.ptszVal, sel); + SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)FinalString); + SendMessage(hEdit, EM_SETSEL, 0, FinalLen); + SendMessage(cbcd->hwndFrom, WM_COMMAND, IDOK, 0); + mir_free(FinalString); + } + } + } + mir_free(sel); + return 1; + } + if (lstrcmpA(cbcd->pszModule, "Translit and Send") == 0) + { + HWND hEdit = GetDlgItem(cbcd->hwndFrom, IDC_MESSAGE); + if (!hEdit) hEdit = GetDlgItem(cbcd->hwndFrom, IDC_CHATMESSAGE); + + BYTE byKeybState[256]; + GetKeyboardState(byKeybState); + byKeybState[VK_CONTROL] = 128; + SetKeyboardState(byKeybState); + SendMessage(hEdit, WM_KEYDOWN, VK_UP, 0); + byKeybState[VK_CONTROL] = 0; + SetKeyboardState(byKeybState); + + TCHAR *sel = Message_GetFromStream(hEdit, SF_TEXT|SF_UNICODE); + int slen = lstrlen(sel); + if (slen != 0) + Transliterate(sel); + DBVARIANT dbv = {0}; + DBGetContactSettingTString(NULL, "TranslitSwitcher", "ResendSymbol", &dbv); + if (lstrcmp(dbv.ptszVal, NULL) == 0) + { + DBFreeVariant(&dbv); + SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)sel); + SendMessage(hEdit, EM_SETSEL, 0, slen); + SendMessage(cbcd->hwndFrom, WM_COMMAND, IDOK, 0); + } + else + { + if (_tcsncmp(sel, dbv.ptszVal, _tcslen(dbv.ptszVal)) == 0) + { + SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)sel); + SendMessage(hEdit, EM_SETSEL, 0, slen); + SendMessage(cbcd->hwndFrom, WM_COMMAND, IDOK, 0); + } + else + { + int FinalLen = slen + SIZEOF(dbv.ptszVal) + 1; + TCHAR* FinalString = (TCHAR*)mir_alloc((FinalLen+1)*sizeof(TCHAR)); + mir_sntprintf(FinalString, FinalLen, _T("%s %s"), dbv.ptszVal, sel); + SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)FinalString); + SendMessage(hEdit, EM_SETSEL, 0, FinalLen); + SendMessage(cbcd->hwndFrom, WM_COMMAND, IDOK, 0); + mir_free(FinalString); + } + } + mir_free(sel); + return 1; + } + if (lstrcmpA(cbcd->pszModule, "Invert Case and Send") == 0) + { + HWND hEdit = GetDlgItem(cbcd->hwndFrom, IDC_MESSAGE); + if (!hEdit) hEdit = GetDlgItem(cbcd->hwndFrom, IDC_CHATMESSAGE); + + BYTE byKeybState[256]; + GetKeyboardState(byKeybState); + byKeybState[VK_CONTROL] = 128; + SetKeyboardState(byKeybState); + SendMessage(hEdit, WM_KEYDOWN, VK_UP, 0); + byKeybState[VK_CONTROL] = 0; + SetKeyboardState(byKeybState); + + TCHAR *sel = Message_GetFromStream(hEdit, SF_TEXT|SF_UNICODE); + int slen = lstrlen(sel); + if (slen != 0) + Invert(sel); + DBVARIANT dbv = {0}; + DBGetContactSettingTString(NULL, "TranslitSwitcher", "ResendSymbol", &dbv); + if (lstrcmp(dbv.ptszVal, NULL) == 0) + { + DBFreeVariant(&dbv); + SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)sel); + SendMessage(hEdit, EM_SETSEL, 0, slen); + SendMessage(cbcd->hwndFrom, WM_COMMAND, IDOK, 0); + } + else + { + if (_tcsncmp(sel, dbv.ptszVal, _tcslen(dbv.ptszVal)) == 0) + { + SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)sel); + SendMessage(hEdit, EM_SETSEL, 0, slen); + SendMessage(cbcd->hwndFrom, WM_COMMAND, IDOK, 0); + } + else + { + int FinalLen = slen + SIZEOF(dbv.ptszVal) + 1; + TCHAR* FinalString = (TCHAR*)mir_alloc((FinalLen+1)*sizeof(TCHAR)); + mir_sntprintf(FinalString, FinalLen, _T("%s %s"), dbv.ptszVal, sel); + SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)FinalString); + SendMessage(hEdit, EM_SETSEL, 0, FinalLen); + SendMessage(cbcd->hwndFrom, WM_COMMAND, IDOK, 0); + mir_free(FinalString); + } + } + mir_free(sel); + return 1; + } + return 0; +} \ No newline at end of file diff --git a/TranslitSwitcher/Src/TranslitSwitcher.cpp b/TranslitSwitcher/Src/TranslitSwitcher.cpp new file mode 100644 index 0000000..9ae9ff3 --- /dev/null +++ b/TranslitSwitcher/Src/TranslitSwitcher.cpp @@ -0,0 +1,230 @@ +/* +Copyright (C) 2007 Dmitry Titkov (C) 2010 tico-tico, Mataes + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This 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 +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#include "TranslitSwitcher.h" + +HINSTANCE hInst = NULL; +PLUGINLINK *pluginLink; +struct MM_INTERFACE mmi; +struct UTF8_INTERFACE utfi; +HANDLE hOnButtonPressed; +int hLangpack; + +PLUGININFOEX pluginInfoEx = { + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + 0, + MIID_TS +}; + +HANDLE hHook; +HANDLE hService, hService2, hService3; + +BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) +{ + hInst=hinstDLL; + return TRUE; +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfoEx; +} + +static const MUUID interfaces[] = {MIID_TS, MIID_LAST}; +extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) +{ + return interfaces; +} + +//------------------------------------------------------------------------------------------------------- +#define MS_TS_SWITCHLAYOUT "TranslitSwitcher/SwitchLayout" +INT_PTR ServiceSwitch(WPARAM wParam, LPARAM lParam) +{ + SwitchLayout(lParam); + return 0; +} + +#define MS_TS_TRANSLITLAYOUT "TranslitSwitcher/TranslitLayout" +INT_PTR ServiceTranslit(WPARAM wParam, LPARAM lParam) +{ + TranslitLayout(lParam); + return 0; +} + +#define MS_TS_INVERTCASE "TranslitSwitcher/InvertCase" +INT_PTR ServiceInvert(WPARAM wParam, LPARAM lParam) +{ + InvertCase(lParam); + return 0; +} + +int OnModulesLoaded(WPARAM wParam, LPARAM lParam) +{ + HICON hSwitchIcon = NULL, hTranslitIcon = NULL, hInvertIcon = NULL; + + HOTKEYDESC hkd = {0}; + hkd.cbSize = sizeof(hkd); + hkd.dwFlags = HKD_TCHAR; + + hService = CreateServiceFunction(MS_TS_SWITCHLAYOUT, ServiceSwitch); + hService2 = CreateServiceFunction(MS_TS_TRANSLITLAYOUT, ServiceTranslit); + hService3 = CreateServiceFunction(MS_TS_INVERTCASE, ServiceInvert); + + hkd.pszName = "TranslitSwitcher/ConvertAllOrSelected"; + hkd.ptszDescription = _T("Convert All / Selected"); + hkd.ptszSection = _T("TranslitSwitcher"); + hkd.pszService = MS_TS_SWITCHLAYOUT; + hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL+HKCOMB_A, 'R') | HKF_MIRANDA_LOCAL; + hkd.lParam = FALSE; + + CallService(MS_HOTKEY_REGISTER, 0, (LPARAM)&hkd); + + hkd.pszName = "TranslitSwitcher/ConvertLastOrSelected"; + hkd.ptszDescription = _T("Convert Last / Selected"); + hkd.DefHotKey = HOTKEYCODE(HOTKEYF_ALT+HKCOMB_A, 'R') | HKF_MIRANDA_LOCAL; + hkd.lParam = TRUE; + + CallService(MS_HOTKEY_REGISTER, 0, (LPARAM)&hkd); + + hkd.pszName = "TranslitSwitcher/TranslitAllOrSelected"; + hkd.ptszDescription = _T("Translit All / Selected"); + hkd.pszService = MS_TS_TRANSLITLAYOUT; + hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL+HKCOMB_A, 'T') | HKF_MIRANDA_LOCAL; + hkd.lParam = FALSE; + + CallService(MS_HOTKEY_REGISTER, 0, (LPARAM)&hkd); + + hkd.pszName = "TranslitSwitcher/TranslitLastOrSelected"; + hkd.ptszDescription = _T("Translit Last / Selected"); + hkd.DefHotKey = HOTKEYCODE(HOTKEYF_ALT+HKCOMB_A, 'T') | HKF_MIRANDA_LOCAL; + hkd.lParam = TRUE; + + CallService(MS_HOTKEY_REGISTER, 0, (LPARAM)&hkd); + + hkd.pszName = "TranslitSwitcher/InvertCaseAllOrSelected"; + hkd.ptszDescription = _T("Invert Case All / Selected"); + hkd.pszService = MS_TS_INVERTCASE; + hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL+HKCOMB_A, 'Y') | HKF_MIRANDA_LOCAL; + hkd.lParam = FALSE; + + CallService(MS_HOTKEY_REGISTER, 0, (LPARAM)&hkd); + + hkd.pszName = "TranslitSwitcher/InvertCaseLastOrSelected"; + hkd.ptszDescription = _T("Invert Case Last / Selected"); + hkd.DefHotKey = HOTKEYCODE(HOTKEYF_ALT+HKCOMB_A, 'Y') | HKF_MIRANDA_LOCAL; + hkd.lParam = TRUE; + + CallService(MS_HOTKEY_REGISTER, 0, (LPARAM)&hkd); + + hOnButtonPressed = HookEvent(ME_MSG_BUTTONPRESSED, OnButtonPressed); + if (ServiceExists(MS_SKIN2_ADDICON)) + { + SKINICONDESC sid = {0}; + sid.cbSize = sizeof(SKINICONDESC); + sid.flags = SIDF_TCHAR; + sid.ptszSection = _T("TabSRMM/TranslitSwitcher"); + sid.cx = sid.cy = 16; + sid.ptszDescription = _T("SwitchLayout and Send"); + sid.pszName = "SwitchLayout and Send"; + sid.hDefaultIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_SWITCHSEND)); + hSwitchIcon = (HICON)CallService(MS_SKIN2_ADDICON, 0, (LPARAM) &sid); + + sid.ptszDescription = _T("Translit and Send"); + sid.pszName = "Translit and Send"; + sid.hDefaultIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_TRANSLITSEND)); + hTranslitIcon = (HICON)CallService(MS_SKIN2_ADDICON, 0, (LPARAM) &sid); + + sid.ptszDescription = _T("Invert Case and Send"); + sid.pszName = "Invert Case and Send"; + sid.hDefaultIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_INVERTSEND)); + hInvertIcon = (HICON)CallService(MS_SKIN2_ADDICON, 0, (LPARAM) &sid); + } + else + { + hSwitchIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_SWITCHSEND)); + hTranslitIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_TRANSLITSEND)); + hInvertIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_INVERTSEND)); + } + + if (ServiceExists(MS_BB_ADDBUTTON)) + { + BBButton bbd = {0}; + bbd.cbSize = sizeof(BBButton); + bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON; + bbd.pszModuleName = "SwitchLayout and Send"; + bbd.ptszTooltip = TranslateT("SwitchLayout and Send"); + bbd.hIcon = (HANDLE)hSwitchIcon; + bbd.dwButtonID = 1; + bbd.dwDefPos = 30; + CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd); + + bbd.pszModuleName = "Translit and Send"; + bbd.ptszTooltip = TranslateT("Translit and Send"); + bbd.hIcon = (HANDLE)hTranslitIcon; + bbd.dwButtonID = 1; + bbd.dwDefPos = 40; + CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd); + + bbd.pszModuleName = "Invert Case and Send"; + bbd.ptszTooltip = TranslateT("Invert Case and Send"); + bbd.hIcon = (HANDLE)hInvertIcon; + bbd.dwButtonID = 1; + bbd.dwDefPos = 50; + CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd); + } + + DestroyIcon(hSwitchIcon); + DestroyIcon(hTranslitIcon); + DestroyIcon(hInvertIcon); + + return 0; +} + +//------------------------------------------------------------------------------------------------------- + +extern "C" __declspec(dllexport) int Load(PLUGINLINK *link) +{ + pluginLink = link; + mir_getMMI(&mmi); + mir_getUTFI(&utfi); + mir_getLP(&pluginInfoEx); + + hHook = HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); + + return 0; +} + +extern "C" __declspec(dllexport) int Unload(void) +{ + DestroyServiceFunction(hService); + DestroyServiceFunction(hService2); + DestroyServiceFunction(hService3); + UnhookEvent(hHook); + UnhookEvent(hOnButtonPressed); + + return 0; +} \ No newline at end of file diff --git a/TranslitSwitcher/Src/TranslitSwitcher.h b/TranslitSwitcher/Src/TranslitSwitcher.h new file mode 100644 index 0000000..1672a61 --- /dev/null +++ b/TranslitSwitcher/Src/TranslitSwitcher.h @@ -0,0 +1,56 @@ +/* +Copyright (C) 2007 Dmitry Titkov (C) 2010 tico-tico, Mataes + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This 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 +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#define MIRANDA_VER 0x0900 +#define MIRANDA_CUSTOM_LP + +#ifndef __TRANSLITSWIITCHER_H__ +#define __TRANSLITSWIITCHER_H__ + +#include +#include +#include +#include + +#include "newpluginapi.h" +#include "m_options.h" +#include "m_langpack.h" +#include "m_database.h" +#include "m_hotkeys.h" +#include "m_protosvc.h" +#include "win2k.h" +#include +#include "m_msg_buttonsbar.h" + +#include "..\version.h" +#include "..\resource.h" +#include "m_smileyadd.h" + +#define IDC_MESSAGE 1002 +#define IDC_CHATMESSAGE 1009 + +VOID SwitchLayout(BOOL); +VOID TranslitLayout(BOOL); +VOID InvertCase(BOOL); +int OnButtonPressed(WPARAM wParam, LPARAM lParam); + +// {0286947D-3140-4222-B5AD-2C92315E1C1E} +#define MIID_TS { 0x286947d, 0x3140, 0x4222, { 0xb5, 0xad, 0x2c, 0x92, 0x31, 0x5e, 0x1c, 0x1e } } + +#endif diff --git a/TranslitSwitcher/TranslitSwitcher_10.vcxproj b/TranslitSwitcher/TranslitSwitcher_10.vcxproj new file mode 100644 index 0000000..bd85af7 --- /dev/null +++ b/TranslitSwitcher/TranslitSwitcher_10.vcxproj @@ -0,0 +1,188 @@ +п»ї + + + + Debug Unicode + Win32 + + + Debug Unicode + x64 + + + Release Unicode + Win32 + + + Release Unicode + x64 + + + + TranslitSwitcher + {82F96271-4136-4B0E-AB6F-040DE7A4DD1E} + TranslitSwitcher + Win32Proj + + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + ../../../Files/Debug/Plugins\ + ../../../Files/Debug64/Plugins\ + $(SolutionDir)$(Configuration)/Obj/$(ProjectName)\ + $(SolutionDir)$(Configuration)64/Obj/$(ProjectName)\ + ../../../Files/Release/Plugins\ + ../../../Files/Release64/Plugins\ + $(SolutionDir)$(Configuration)/Obj/$(ProjectName)\ + $(SolutionDir)$(Configuration)64/Obj/$(ProjectName)\ + AllRules.ruleset + AllRules.ruleset + + + + + AllRules.ruleset + AllRules.ruleset + + + + + + + + Disabled + ../../include;../../ExternalAPI + WIN32;_DEBUG;_WINDOWS;_USRDLL;TRANSLITSWIITCHER_EXPORTS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + Level3 + EditAndContinue + 4996 + + + true + Windows + $(IntDir)$(TargetName).lib + MachineX86 + + + + + Disabled + ../../include;../../ExternalAPI + WIN32;_DEBUG;_WINDOWS;_USRDLL;TRANSLITSWIITCHER_EXPORTS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + Level3 + EditAndContinue + 4996 + + + true + Windows + $(IntDir)$(TargetName).lib + + + + + Full + OnlyExplicitInline + Size + ../../include;../../ExternalAPI + WIN32;NDEBUG;_WINDOWS;_USRDLL;TRANSLITSWIITCHER_EXPORTS;%(PreprocessorDefinitions) + true + + + MultiThreaded + false + true + Fast + Level3 + ProgramDatabase + 4996 + + + Windows + true + true + $(IntDir)$(TargetName).lib + MachineX86 + + + + + Full + OnlyExplicitInline + Size + ../../include;../../ExternalAPI + WIN32;NDEBUG;_WINDOWS;_USRDLL;TRANSLITSWIITCHER_EXPORTS;%(PreprocessorDefinitions) + true + + + MultiThreaded + false + true + Fast + Level3 + ProgramDatabase + 4996 + + + Windows + true + true + $(IntDir)$(TargetName).lib + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TranslitSwitcher/TranslitSwitcher_10.vcxproj.filters b/TranslitSwitcher/TranslitSwitcher_10.vcxproj.filters new file mode 100644 index 0000000..409eda7 --- /dev/null +++ b/TranslitSwitcher/TranslitSwitcher_10.vcxproj.filters @@ -0,0 +1,44 @@ +п»ї + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + + + Resource Files + + + Resource Files + + + \ No newline at end of file diff --git a/TranslitSwitcher/Version.h b/TranslitSwitcher/Version.h new file mode 100644 index 0000000..af7d272 --- /dev/null +++ b/TranslitSwitcher/Version.h @@ -0,0 +1,28 @@ +#define __MAJOR_VERSION 0 +#define __MINOR_VERSION 0 +#define __RELEASE_NUM 0 +#define __BUILD_NUM 9 + +#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) + +#ifdef _UNICODE +#if defined(WIN64) || defined(_WIN64) + #define __PLUGIN_NAME "Switch Layout or Transliterate (Unicode x64)" +#else + #define __PLUGIN_NAME "Switch Layout or Transliterate (Unicode)" +#endif +#else + #define __PLUGIN_NAME "Switch Layout or Transliterate" +#endif +#define __INTERNAL_NAME "TranslitSwitcher" +#define __FILENAME "TranslitSwitcher.dll" +#define __DESCRIPTION "Allows to switch a layout or transliterate or invert case of the entered text in the message window with SmileyAdd support." +#define __AUTHOR "Mataes, tico-tico, Tim" +#define __AUTHOREMAIL "mataes2007@gmail.com" +#define __AUTHORWEB "http://mataes.googlecode.com/svn/Miranda/Plugins/TranslitSwitcher/" +#define __COPYRIGHT "© 2010 Mataes, tico-tico © 2007 Dmitry Titkov" diff --git a/TranslitSwitcher/Version.rc b/TranslitSwitcher/Version.rc new file mode 100644 index 0000000..936c89e --- /dev/null +++ b/TranslitSwitcher/Version.rc @@ -0,0 +1,38 @@ +// Microsoft Visual C++ generated resource script. +// +#include "afxres.h" +#include "version.h" + +#ifdef _WIN32 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +#endif //_WIN32 + +VS_VERSION_INFO VERSIONINFO + FILEVERSION __FILEVERSION_STRING + PRODUCTVERSION __FILEVERSION_STRING + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x0L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "FileDescription", __DESCRIPTION + VALUE "InternalName", __PLUGIN_NAME + VALUE "LegalCopyright", __COPYRIGHT + VALUE "OriginalFilename", __FILENAME + VALUE "ProductName", __PLUGIN_NAME + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END \ No newline at end of file -- cgit v1.2.3