From a9580df150d799246eaecbf3c1fb5cecf9f8ab49 Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Mon, 23 Jul 2012 13:49:28 +0000 Subject: SecureIM, SeenPlugin, SendSS, Sessions: changed folder structure git-svn-id: http://svn.miranda-ng.org/main/trunk@1122 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/SecureIM/!whatsnew.txt | 595 ------ plugins/SecureIM/commonheaders.cpp | 197 -- plugins/SecureIM/commonheaders.h | 192 -- plugins/SecureIM/crypt.h | 183 -- plugins/SecureIM/crypt_check.cpp | 267 --- plugins/SecureIM/crypt_dll.cpp | 236 --- plugins/SecureIM/crypt_icons.cpp | 151 -- plugins/SecureIM/crypt_lists.cpp | 327 ---- plugins/SecureIM/crypt_metacontacts.cpp | 60 - plugins/SecureIM/crypt_misc.cpp | 139 -- plugins/SecureIM/crypt_popups.cpp | 153 -- plugins/SecureIM/cryptopp.h | 73 - plugins/SecureIM/dbevent.cpp | 21 - plugins/SecureIM/dbevent.h | 8 - plugins/SecureIM/docs/!whatsnew.txt | 595 ++++++ plugins/SecureIM/docs/secureim-translation.txt | 106 ++ plugins/SecureIM/gettime.cpp | 29 - plugins/SecureIM/gettime.h | 8 - plugins/SecureIM/icons/cl_dis.ico | Bin 2550 -> 0 bytes plugins/SecureIM/icons/cl_est.ico | Bin 2550 -> 0 bytes plugins/SecureIM/icons/cm_dis.ico | Bin 2550 -> 0 bytes plugins/SecureIM/icons/cm_est.ico | Bin 2550 -> 0 bytes plugins/SecureIM/icons/mw_dis.ico | Bin 2550 -> 0 bytes plugins/SecureIM/icons/mw_est.ico | Bin 2550 -> 0 bytes plugins/SecureIM/icons/ov_gpg.ico | Bin 2550 -> 0 bytes plugins/SecureIM/icons/ov_nat.ico | Bin 2550 -> 0 bytes plugins/SecureIM/icons/ov_pgp.ico | Bin 2550 -> 0 bytes plugins/SecureIM/icons/ov_rsa.ico | Bin 2550 -> 0 bytes plugins/SecureIM/icons/pu_dis.ico | Bin 2550 -> 0 bytes plugins/SecureIM/icons/pu_est.ico | Bin 2550 -> 0 bytes plugins/SecureIM/icons/pu_msg.ico | Bin 2550 -> 0 bytes plugins/SecureIM/icons/pu_prc.ico | Bin 2550 -> 0 bytes plugins/SecureIM/icons/st_dis.ico | Bin 1406 -> 0 bytes plugins/SecureIM/icons/st_ena.ico | Bin 1406 -> 0 bytes plugins/SecureIM/icons/st_try.ico | Bin 1406 -> 0 bytes plugins/SecureIM/images.cpp | 358 ---- plugins/SecureIM/images.h | 8 - plugins/SecureIM/language.cpp | 104 -- plugins/SecureIM/language.h | 100 - plugins/SecureIM/loadicons.cpp | 96 - plugins/SecureIM/loadicons.h | 7 - plugins/SecureIM/loadlib.cpp | 76 - plugins/SecureIM/loadlib.h | 188 -- plugins/SecureIM/main.cpp | 534 ------ plugins/SecureIM/mmi.cpp | 155 -- plugins/SecureIM/mmi.h | 27 - plugins/SecureIM/options.cpp | 1928 -------------------- plugins/SecureIM/options.h | 40 - plugins/SecureIM/popupOptions.cpp | 239 --- plugins/SecureIM/popupOptions.h | 8 - plugins/SecureIM/res/cl_dis.ico | Bin 0 -> 2550 bytes plugins/SecureIM/res/cl_est.ico | Bin 0 -> 2550 bytes plugins/SecureIM/res/cm_dis.ico | Bin 0 -> 2550 bytes plugins/SecureIM/res/cm_est.ico | Bin 0 -> 2550 bytes plugins/SecureIM/res/mw_dis.ico | Bin 0 -> 2550 bytes plugins/SecureIM/res/mw_est.ico | Bin 0 -> 2550 bytes plugins/SecureIM/res/ov_gpg.ico | Bin 0 -> 2550 bytes plugins/SecureIM/res/ov_nat.ico | Bin 0 -> 2550 bytes plugins/SecureIM/res/ov_pgp.ico | Bin 0 -> 2550 bytes plugins/SecureIM/res/ov_rsa.ico | Bin 0 -> 2550 bytes plugins/SecureIM/res/pu_dis.ico | Bin 0 -> 2550 bytes plugins/SecureIM/res/pu_est.ico | Bin 0 -> 2550 bytes plugins/SecureIM/res/pu_msg.ico | Bin 0 -> 2550 bytes plugins/SecureIM/res/pu_prc.ico | Bin 0 -> 2550 bytes plugins/SecureIM/res/resource.rc | 331 ++++ plugins/SecureIM/res/resource_icons.rc | 63 + plugins/SecureIM/res/st_dis.ico | Bin 0 -> 1406 bytes plugins/SecureIM/res/st_ena.ico | Bin 0 -> 1406 bytes plugins/SecureIM/res/st_try.ico | Bin 0 -> 1406 bytes plugins/SecureIM/res/version.rc | 45 + plugins/SecureIM/res/version_icons.rc | 44 + plugins/SecureIM/resource.h | 160 -- plugins/SecureIM/resource.rc | 334 ---- plugins/SecureIM/resource_icons.rc | 66 - plugins/SecureIM/rtfconv.cpp | 46 - plugins/SecureIM/rtfconv.h | 23 - plugins/SecureIM/secureim-translation.txt | 106 -- plugins/SecureIM/secureim.h | 172 -- plugins/SecureIM/secureim.msp | 136 -- plugins/SecureIM/secureim_10.vcxproj | 105 +- plugins/SecureIM/secureim_10.vcxproj.filters | 99 +- plugins/SecureIM/secureim_icons_10.vcxproj | 3 +- plugins/SecureIM/secureim_icons_10.vcxproj.filters | 13 +- plugins/SecureIM/splitmsg.cpp | 124 -- plugins/SecureIM/splitmsg.h | 9 - plugins/SecureIM/src/commonheaders.cpp | 197 ++ plugins/SecureIM/src/commonheaders.h | 192 ++ plugins/SecureIM/src/crypt.h | 183 ++ plugins/SecureIM/src/crypt_check.cpp | 267 +++ plugins/SecureIM/src/crypt_dll.cpp | 236 +++ plugins/SecureIM/src/crypt_icons.cpp | 151 ++ plugins/SecureIM/src/crypt_lists.cpp | 327 ++++ plugins/SecureIM/src/crypt_metacontacts.cpp | 60 + plugins/SecureIM/src/crypt_misc.cpp | 139 ++ plugins/SecureIM/src/crypt_popups.cpp | 153 ++ plugins/SecureIM/src/cryptopp.h | 73 + plugins/SecureIM/src/dbevent.cpp | 21 + plugins/SecureIM/src/dbevent.h | 8 + plugins/SecureIM/src/gettime.cpp | 29 + plugins/SecureIM/src/gettime.h | 8 + plugins/SecureIM/src/images.cpp | 358 ++++ plugins/SecureIM/src/images.h | 8 + plugins/SecureIM/src/language.cpp | 104 ++ plugins/SecureIM/src/language.h | 100 + plugins/SecureIM/src/loadicons.cpp | 96 + plugins/SecureIM/src/loadicons.h | 7 + plugins/SecureIM/src/loadlib.cpp | 76 + plugins/SecureIM/src/loadlib.h | 188 ++ plugins/SecureIM/src/main.cpp | 534 ++++++ plugins/SecureIM/src/mmi.cpp | 155 ++ plugins/SecureIM/src/mmi.h | 27 + plugins/SecureIM/src/options.cpp | 1928 ++++++++++++++++++++ plugins/SecureIM/src/options.h | 40 + plugins/SecureIM/src/popupOptions.cpp | 239 +++ plugins/SecureIM/src/popupOptions.h | 8 + plugins/SecureIM/src/resource.h | 160 ++ plugins/SecureIM/src/rtfconv.cpp | 46 + plugins/SecureIM/src/rtfconv.h | 23 + plugins/SecureIM/src/secureim.h | 172 ++ plugins/SecureIM/src/splitmsg.cpp | 124 ++ plugins/SecureIM/src/splitmsg.h | 9 + plugins/SecureIM/src/svcs_clist.cpp | 224 +++ plugins/SecureIM/src/svcs_clist.h | 13 + plugins/SecureIM/src/svcs_menu.cpp | 232 +++ plugins/SecureIM/src/svcs_menu.h | 26 + plugins/SecureIM/src/svcs_popup.cpp | 115 ++ plugins/SecureIM/src/svcs_proto.cpp | 1130 ++++++++++++ plugins/SecureIM/src/svcs_proto.h | 14 + plugins/SecureIM/src/svcs_rsa.cpp | 226 +++ plugins/SecureIM/src/svcs_rsa.h | 20 + plugins/SecureIM/src/svcs_srmm.cpp | 37 + plugins/SecureIM/src/svcs_srmm.h | 9 + plugins/SecureIM/src/version.h | 16 + plugins/SecureIM/svcs_clist.cpp | 224 --- plugins/SecureIM/svcs_clist.h | 13 - plugins/SecureIM/svcs_menu.cpp | 232 --- plugins/SecureIM/svcs_menu.h | 26 - plugins/SecureIM/svcs_popup.cpp | 115 -- plugins/SecureIM/svcs_proto.cpp | 1130 ------------ plugins/SecureIM/svcs_proto.h | 14 - plugins/SecureIM/svcs_rsa.cpp | 226 --- plugins/SecureIM/svcs_rsa.h | 20 - plugins/SecureIM/svcs_srmm.cpp | 37 - plugins/SecureIM/svcs_srmm.h | 9 - plugins/SecureIM/version.h | 16 - plugins/SecureIM/version.rc | 45 - plugins/SecureIM/version_icons.rc | 44 - plugins/SeenPlugin/docs/readme_src.txt | 23 + plugins/SeenPlugin/docs/seen_info.txt | 216 +++ plugins/SeenPlugin/docs/seenplugin-translation.txt | 101 + plugins/SeenPlugin/file.cpp | 119 -- plugins/SeenPlugin/history.cpp | 347 ---- plugins/SeenPlugin/main.cpp | 136 -- plugins/SeenPlugin/menu.cpp | 113 -- plugins/SeenPlugin/missed.cpp | 301 --- plugins/SeenPlugin/options.cpp | 494 ----- plugins/SeenPlugin/readme_src.txt | 23 - plugins/SeenPlugin/res/resource.rc | 280 +++ plugins/SeenPlugin/resource.h | 93 - plugins/SeenPlugin/resource.rc | 284 --- plugins/SeenPlugin/seen.h | 134 -- plugins/SeenPlugin/seen_info.txt | 216 --- plugins/SeenPlugin/seenplugin-translation.txt | 101 - plugins/SeenPlugin/seenplugin_10.vcxproj | 38 +- plugins/SeenPlugin/seenplugin_10.vcxproj.filters | 26 +- plugins/SeenPlugin/src/file.cpp | 119 ++ plugins/SeenPlugin/src/history.cpp | 347 ++++ plugins/SeenPlugin/src/main.cpp | 136 ++ plugins/SeenPlugin/src/menu.cpp | 113 ++ plugins/SeenPlugin/src/missed.cpp | 301 +++ plugins/SeenPlugin/src/options.cpp | 494 +++++ plugins/SeenPlugin/src/resource.h | 93 + plugins/SeenPlugin/src/seen.h | 134 ++ plugins/SeenPlugin/src/userinfo.cpp | 95 + plugins/SeenPlugin/src/utils.cpp | 878 +++++++++ plugins/SeenPlugin/userinfo.cpp | 95 - plugins/SeenPlugin/utils.cpp | 878 --------- plugins/SendScreenshotPlus/CSend.cpp | 416 ----- plugins/SendScreenshotPlus/CSend.h | 113 -- plugins/SendScreenshotPlus/CSendEmail.cpp | 221 --- plugins/SendScreenshotPlus/CSendEmail.h | 63 - plugins/SendScreenshotPlus/CSendFTPFile.cpp | 99 - plugins/SendScreenshotPlus/CSendFTPFile.h | 59 - plugins/SendScreenshotPlus/CSendFile.cpp | 53 - plugins/SendScreenshotPlus/CSendFile.h | 55 - plugins/SendScreenshotPlus/CSendHTTPServer.cpp | 140 -- plugins/SendScreenshotPlus/CSendHTTPServer.h | 67 - plugins/SendScreenshotPlus/CSendImageShack.cpp | 299 --- plugins/SendScreenshotPlus/CSendImageShack.h | 77 - plugins/SendScreenshotPlus/Main.cpp | 364 ---- plugins/SendScreenshotPlus/Main.h | 65 - plugins/SendScreenshotPlus/SendSS_10.vcxproj | 100 +- .../SendScreenshotPlus/SendSS_10.vcxproj.filters | 140 +- plugins/SendScreenshotPlus/UAboutForm.cpp | 212 --- plugins/SendScreenshotPlus/UAboutForm.h | 69 - plugins/SendScreenshotPlus/UMainForm.cpp | 1180 ------------ plugins/SendScreenshotPlus/UMainForm.h | 157 -- plugins/SendScreenshotPlus/Utils.cpp | 579 ------ plugins/SendScreenshotPlus/Utils.h | 81 - plugins/SendScreenshotPlus/ctrl_button.cpp | 699 ------- plugins/SendScreenshotPlus/ctrl_button.h | 43 - plugins/SendScreenshotPlus/dlg_msgbox.cpp | 854 --------- plugins/SendScreenshotPlus/dlg_msgbox.h | 108 -- plugins/SendScreenshotPlus/docs/credits.txt | 10 + plugins/SendScreenshotPlus/docs/license.txt | 15 + plugins/SendScreenshotPlus/global.h | 189 -- plugins/SendScreenshotPlus/mir_icolib.cpp | 382 ---- plugins/SendScreenshotPlus/mir_icolib.h | 139 -- plugins/SendScreenshotPlus/mir_string.cpp | 179 -- plugins/SendScreenshotPlus/mir_string.h | 107 -- plugins/SendScreenshotPlus/res/credits.txt | 10 - plugins/SendScreenshotPlus/res/license.txt | 15 - plugins/SendScreenshotPlus/res/resource.rc | 266 +++ plugins/SendScreenshotPlus/res/version.rc | 42 + plugins/SendScreenshotPlus/resource.h | 102 -- plugins/SendScreenshotPlus/resource.rc | 274 --- plugins/SendScreenshotPlus/sdk/DevKey.h | 3 - plugins/SendScreenshotPlus/sdk/icons.h | 112 -- plugins/SendScreenshotPlus/src/CSend.cpp | 416 +++++ plugins/SendScreenshotPlus/src/CSend.h | 113 ++ plugins/SendScreenshotPlus/src/CSendEmail.cpp | 221 +++ plugins/SendScreenshotPlus/src/CSendEmail.h | 63 + plugins/SendScreenshotPlus/src/CSendFTPFile.cpp | 99 + plugins/SendScreenshotPlus/src/CSendFTPFile.h | 59 + plugins/SendScreenshotPlus/src/CSendFile.cpp | 53 + plugins/SendScreenshotPlus/src/CSendFile.h | 55 + plugins/SendScreenshotPlus/src/CSendHTTPServer.cpp | 140 ++ plugins/SendScreenshotPlus/src/CSendHTTPServer.h | 67 + plugins/SendScreenshotPlus/src/CSendImageShack.cpp | 299 +++ plugins/SendScreenshotPlus/src/CSendImageShack.h | 77 + plugins/SendScreenshotPlus/src/DevKey.h | 3 + plugins/SendScreenshotPlus/src/Main.cpp | 364 ++++ plugins/SendScreenshotPlus/src/Main.h | 65 + plugins/SendScreenshotPlus/src/UAboutForm.cpp | 212 +++ plugins/SendScreenshotPlus/src/UAboutForm.h | 69 + plugins/SendScreenshotPlus/src/UMainForm.cpp | 1180 ++++++++++++ plugins/SendScreenshotPlus/src/UMainForm.h | 157 ++ plugins/SendScreenshotPlus/src/Utils.cpp | 579 ++++++ plugins/SendScreenshotPlus/src/Utils.h | 81 + plugins/SendScreenshotPlus/src/ctrl_button.cpp | 699 +++++++ plugins/SendScreenshotPlus/src/ctrl_button.h | 43 + plugins/SendScreenshotPlus/src/dlg_msgbox.cpp | 854 +++++++++ plugins/SendScreenshotPlus/src/dlg_msgbox.h | 108 ++ plugins/SendScreenshotPlus/src/global.h | 189 ++ plugins/SendScreenshotPlus/src/icons.h | 112 ++ plugins/SendScreenshotPlus/src/mir_icolib.cpp | 382 ++++ plugins/SendScreenshotPlus/src/mir_icolib.h | 139 ++ plugins/SendScreenshotPlus/src/mir_string.cpp | 179 ++ plugins/SendScreenshotPlus/src/mir_string.h | 107 ++ plugins/SendScreenshotPlus/src/resource.h | 102 ++ plugins/SendScreenshotPlus/src/version.h | 45 + plugins/SendScreenshotPlus/version.h | 45 - plugins/SendScreenshotPlus/version.rc | 42 - plugins/Sessions/Icons/Checked.ico | Bin 2038 -> 0 bytes plugins/Sessions/Icons/Load.ico | Bin 1150 -> 0 bytes plugins/Sessions/Icons/Loadlast.ico | Bin 1150 -> 0 bytes plugins/Sessions/Icons/Save.ico | Bin 1150 -> 0 bytes plugins/Sessions/Icons/Sessions.ico | Bin 1150 -> 0 bytes plugins/Sessions/Icons/Unchecked.ico | Bin 2038 -> 0 bytes plugins/Sessions/Resource.h | 58 - plugins/Sessions/Sessions.rc | 237 --- plugins/Sessions/Sessions_10.vcxproj | 16 +- plugins/Sessions/Sessions_10.vcxproj.filters | 28 +- plugins/Sessions/Src/Resource.h | 58 + plugins/Sessions/Src/Sessions.h | 4 +- plugins/Sessions/Src/Version.h | 21 + plugins/Sessions/Version.h | 21 - plugins/Sessions/Version.rc | 42 - plugins/Sessions/docs/sessions-translation.txt | 58 + plugins/Sessions/res/Checked.ico | Bin 0 -> 2038 bytes plugins/Sessions/res/Load.ico | Bin 0 -> 1150 bytes plugins/Sessions/res/Loadlast.ico | Bin 0 -> 1150 bytes plugins/Sessions/res/Save.ico | Bin 0 -> 1150 bytes plugins/Sessions/res/Sessions.ico | Bin 0 -> 1150 bytes plugins/Sessions/res/Sessions.rc | 236 +++ plugins/Sessions/res/Unchecked.ico | Bin 0 -> 2038 bytes plugins/Sessions/res/Version.rc | 42 + plugins/Sessions/sessions-translation.txt | 58 - 278 files changed, 21317 insertions(+), 21612 deletions(-) delete mode 100644 plugins/SecureIM/!whatsnew.txt delete mode 100644 plugins/SecureIM/commonheaders.cpp delete mode 100644 plugins/SecureIM/commonheaders.h delete mode 100644 plugins/SecureIM/crypt.h delete mode 100644 plugins/SecureIM/crypt_check.cpp delete mode 100644 plugins/SecureIM/crypt_dll.cpp delete mode 100644 plugins/SecureIM/crypt_icons.cpp delete mode 100644 plugins/SecureIM/crypt_lists.cpp delete mode 100644 plugins/SecureIM/crypt_metacontacts.cpp delete mode 100644 plugins/SecureIM/crypt_misc.cpp delete mode 100644 plugins/SecureIM/crypt_popups.cpp delete mode 100644 plugins/SecureIM/cryptopp.h delete mode 100644 plugins/SecureIM/dbevent.cpp delete mode 100644 plugins/SecureIM/dbevent.h create mode 100644 plugins/SecureIM/docs/!whatsnew.txt create mode 100644 plugins/SecureIM/docs/secureim-translation.txt delete mode 100644 plugins/SecureIM/gettime.cpp delete mode 100644 plugins/SecureIM/gettime.h delete mode 100644 plugins/SecureIM/icons/cl_dis.ico delete mode 100644 plugins/SecureIM/icons/cl_est.ico delete mode 100644 plugins/SecureIM/icons/cm_dis.ico delete mode 100644 plugins/SecureIM/icons/cm_est.ico delete mode 100644 plugins/SecureIM/icons/mw_dis.ico delete mode 100644 plugins/SecureIM/icons/mw_est.ico delete mode 100644 plugins/SecureIM/icons/ov_gpg.ico delete mode 100644 plugins/SecureIM/icons/ov_nat.ico delete mode 100644 plugins/SecureIM/icons/ov_pgp.ico delete mode 100644 plugins/SecureIM/icons/ov_rsa.ico delete mode 100644 plugins/SecureIM/icons/pu_dis.ico delete mode 100644 plugins/SecureIM/icons/pu_est.ico delete mode 100644 plugins/SecureIM/icons/pu_msg.ico delete mode 100644 plugins/SecureIM/icons/pu_prc.ico delete mode 100644 plugins/SecureIM/icons/st_dis.ico delete mode 100644 plugins/SecureIM/icons/st_ena.ico delete mode 100644 plugins/SecureIM/icons/st_try.ico delete mode 100644 plugins/SecureIM/images.cpp delete mode 100644 plugins/SecureIM/images.h delete mode 100644 plugins/SecureIM/language.cpp delete mode 100644 plugins/SecureIM/language.h delete mode 100644 plugins/SecureIM/loadicons.cpp delete mode 100644 plugins/SecureIM/loadicons.h delete mode 100644 plugins/SecureIM/loadlib.cpp delete mode 100644 plugins/SecureIM/loadlib.h delete mode 100644 plugins/SecureIM/main.cpp delete mode 100644 plugins/SecureIM/mmi.cpp delete mode 100644 plugins/SecureIM/mmi.h delete mode 100644 plugins/SecureIM/options.cpp delete mode 100644 plugins/SecureIM/options.h delete mode 100644 plugins/SecureIM/popupOptions.cpp delete mode 100644 plugins/SecureIM/popupOptions.h create mode 100644 plugins/SecureIM/res/cl_dis.ico create mode 100644 plugins/SecureIM/res/cl_est.ico create mode 100644 plugins/SecureIM/res/cm_dis.ico create mode 100644 plugins/SecureIM/res/cm_est.ico create mode 100644 plugins/SecureIM/res/mw_dis.ico create mode 100644 plugins/SecureIM/res/mw_est.ico create mode 100644 plugins/SecureIM/res/ov_gpg.ico create mode 100644 plugins/SecureIM/res/ov_nat.ico create mode 100644 plugins/SecureIM/res/ov_pgp.ico create mode 100644 plugins/SecureIM/res/ov_rsa.ico create mode 100644 plugins/SecureIM/res/pu_dis.ico create mode 100644 plugins/SecureIM/res/pu_est.ico create mode 100644 plugins/SecureIM/res/pu_msg.ico create mode 100644 plugins/SecureIM/res/pu_prc.ico create mode 100644 plugins/SecureIM/res/resource.rc create mode 100644 plugins/SecureIM/res/resource_icons.rc create mode 100644 plugins/SecureIM/res/st_dis.ico create mode 100644 plugins/SecureIM/res/st_ena.ico create mode 100644 plugins/SecureIM/res/st_try.ico create mode 100644 plugins/SecureIM/res/version.rc create mode 100644 plugins/SecureIM/res/version_icons.rc delete mode 100644 plugins/SecureIM/resource.h delete mode 100644 plugins/SecureIM/resource.rc delete mode 100644 plugins/SecureIM/resource_icons.rc delete mode 100644 plugins/SecureIM/rtfconv.cpp delete mode 100644 plugins/SecureIM/rtfconv.h delete mode 100644 plugins/SecureIM/secureim-translation.txt delete mode 100644 plugins/SecureIM/secureim.h delete mode 100644 plugins/SecureIM/secureim.msp delete mode 100644 plugins/SecureIM/splitmsg.cpp delete mode 100644 plugins/SecureIM/splitmsg.h create mode 100644 plugins/SecureIM/src/commonheaders.cpp create mode 100644 plugins/SecureIM/src/commonheaders.h create mode 100644 plugins/SecureIM/src/crypt.h create mode 100644 plugins/SecureIM/src/crypt_check.cpp create mode 100644 plugins/SecureIM/src/crypt_dll.cpp create mode 100644 plugins/SecureIM/src/crypt_icons.cpp create mode 100644 plugins/SecureIM/src/crypt_lists.cpp create mode 100644 plugins/SecureIM/src/crypt_metacontacts.cpp create mode 100644 plugins/SecureIM/src/crypt_misc.cpp create mode 100644 plugins/SecureIM/src/crypt_popups.cpp create mode 100644 plugins/SecureIM/src/cryptopp.h create mode 100644 plugins/SecureIM/src/dbevent.cpp create mode 100644 plugins/SecureIM/src/dbevent.h create mode 100644 plugins/SecureIM/src/gettime.cpp create mode 100644 plugins/SecureIM/src/gettime.h create mode 100644 plugins/SecureIM/src/images.cpp create mode 100644 plugins/SecureIM/src/images.h create mode 100644 plugins/SecureIM/src/language.cpp create mode 100644 plugins/SecureIM/src/language.h create mode 100644 plugins/SecureIM/src/loadicons.cpp create mode 100644 plugins/SecureIM/src/loadicons.h create mode 100644 plugins/SecureIM/src/loadlib.cpp create mode 100644 plugins/SecureIM/src/loadlib.h create mode 100644 plugins/SecureIM/src/main.cpp create mode 100644 plugins/SecureIM/src/mmi.cpp create mode 100644 plugins/SecureIM/src/mmi.h create mode 100644 plugins/SecureIM/src/options.cpp create mode 100644 plugins/SecureIM/src/options.h create mode 100644 plugins/SecureIM/src/popupOptions.cpp create mode 100644 plugins/SecureIM/src/popupOptions.h create mode 100644 plugins/SecureIM/src/resource.h create mode 100644 plugins/SecureIM/src/rtfconv.cpp create mode 100644 plugins/SecureIM/src/rtfconv.h create mode 100644 plugins/SecureIM/src/secureim.h create mode 100644 plugins/SecureIM/src/splitmsg.cpp create mode 100644 plugins/SecureIM/src/splitmsg.h create mode 100644 plugins/SecureIM/src/svcs_clist.cpp create mode 100644 plugins/SecureIM/src/svcs_clist.h create mode 100644 plugins/SecureIM/src/svcs_menu.cpp create mode 100644 plugins/SecureIM/src/svcs_menu.h create mode 100644 plugins/SecureIM/src/svcs_popup.cpp create mode 100644 plugins/SecureIM/src/svcs_proto.cpp create mode 100644 plugins/SecureIM/src/svcs_proto.h create mode 100644 plugins/SecureIM/src/svcs_rsa.cpp create mode 100644 plugins/SecureIM/src/svcs_rsa.h create mode 100644 plugins/SecureIM/src/svcs_srmm.cpp create mode 100644 plugins/SecureIM/src/svcs_srmm.h create mode 100644 plugins/SecureIM/src/version.h delete mode 100644 plugins/SecureIM/svcs_clist.cpp delete mode 100644 plugins/SecureIM/svcs_clist.h delete mode 100644 plugins/SecureIM/svcs_menu.cpp delete mode 100644 plugins/SecureIM/svcs_menu.h delete mode 100644 plugins/SecureIM/svcs_popup.cpp delete mode 100644 plugins/SecureIM/svcs_proto.cpp delete mode 100644 plugins/SecureIM/svcs_proto.h delete mode 100644 plugins/SecureIM/svcs_rsa.cpp delete mode 100644 plugins/SecureIM/svcs_rsa.h delete mode 100644 plugins/SecureIM/svcs_srmm.cpp delete mode 100644 plugins/SecureIM/svcs_srmm.h delete mode 100644 plugins/SecureIM/version.h delete mode 100644 plugins/SecureIM/version.rc delete mode 100644 plugins/SecureIM/version_icons.rc create mode 100644 plugins/SeenPlugin/docs/readme_src.txt create mode 100644 plugins/SeenPlugin/docs/seen_info.txt create mode 100644 plugins/SeenPlugin/docs/seenplugin-translation.txt delete mode 100644 plugins/SeenPlugin/file.cpp delete mode 100644 plugins/SeenPlugin/history.cpp delete mode 100644 plugins/SeenPlugin/main.cpp delete mode 100644 plugins/SeenPlugin/menu.cpp delete mode 100644 plugins/SeenPlugin/missed.cpp delete mode 100644 plugins/SeenPlugin/options.cpp delete mode 100644 plugins/SeenPlugin/readme_src.txt create mode 100644 plugins/SeenPlugin/res/resource.rc delete mode 100644 plugins/SeenPlugin/resource.h delete mode 100644 plugins/SeenPlugin/resource.rc delete mode 100644 plugins/SeenPlugin/seen.h delete mode 100644 plugins/SeenPlugin/seen_info.txt delete mode 100644 plugins/SeenPlugin/seenplugin-translation.txt create mode 100644 plugins/SeenPlugin/src/file.cpp create mode 100644 plugins/SeenPlugin/src/history.cpp create mode 100644 plugins/SeenPlugin/src/main.cpp create mode 100644 plugins/SeenPlugin/src/menu.cpp create mode 100644 plugins/SeenPlugin/src/missed.cpp create mode 100644 plugins/SeenPlugin/src/options.cpp create mode 100644 plugins/SeenPlugin/src/resource.h create mode 100644 plugins/SeenPlugin/src/seen.h create mode 100644 plugins/SeenPlugin/src/userinfo.cpp create mode 100644 plugins/SeenPlugin/src/utils.cpp delete mode 100644 plugins/SeenPlugin/userinfo.cpp delete mode 100644 plugins/SeenPlugin/utils.cpp delete mode 100644 plugins/SendScreenshotPlus/CSend.cpp delete mode 100644 plugins/SendScreenshotPlus/CSend.h delete mode 100644 plugins/SendScreenshotPlus/CSendEmail.cpp delete mode 100644 plugins/SendScreenshotPlus/CSendEmail.h delete mode 100644 plugins/SendScreenshotPlus/CSendFTPFile.cpp delete mode 100644 plugins/SendScreenshotPlus/CSendFTPFile.h delete mode 100644 plugins/SendScreenshotPlus/CSendFile.cpp delete mode 100644 plugins/SendScreenshotPlus/CSendFile.h delete mode 100644 plugins/SendScreenshotPlus/CSendHTTPServer.cpp delete mode 100644 plugins/SendScreenshotPlus/CSendHTTPServer.h delete mode 100644 plugins/SendScreenshotPlus/CSendImageShack.cpp delete mode 100644 plugins/SendScreenshotPlus/CSendImageShack.h delete mode 100644 plugins/SendScreenshotPlus/Main.cpp delete mode 100644 plugins/SendScreenshotPlus/Main.h delete mode 100644 plugins/SendScreenshotPlus/UAboutForm.cpp delete mode 100644 plugins/SendScreenshotPlus/UAboutForm.h delete mode 100644 plugins/SendScreenshotPlus/UMainForm.cpp delete mode 100644 plugins/SendScreenshotPlus/UMainForm.h delete mode 100644 plugins/SendScreenshotPlus/Utils.cpp delete mode 100644 plugins/SendScreenshotPlus/Utils.h delete mode 100644 plugins/SendScreenshotPlus/ctrl_button.cpp delete mode 100644 plugins/SendScreenshotPlus/ctrl_button.h delete mode 100644 plugins/SendScreenshotPlus/dlg_msgbox.cpp delete mode 100644 plugins/SendScreenshotPlus/dlg_msgbox.h create mode 100644 plugins/SendScreenshotPlus/docs/credits.txt create mode 100644 plugins/SendScreenshotPlus/docs/license.txt delete mode 100644 plugins/SendScreenshotPlus/global.h delete mode 100644 plugins/SendScreenshotPlus/mir_icolib.cpp delete mode 100644 plugins/SendScreenshotPlus/mir_icolib.h delete mode 100644 plugins/SendScreenshotPlus/mir_string.cpp delete mode 100644 plugins/SendScreenshotPlus/mir_string.h delete mode 100644 plugins/SendScreenshotPlus/res/credits.txt delete mode 100644 plugins/SendScreenshotPlus/res/license.txt create mode 100644 plugins/SendScreenshotPlus/res/resource.rc create mode 100644 plugins/SendScreenshotPlus/res/version.rc delete mode 100644 plugins/SendScreenshotPlus/resource.h delete mode 100644 plugins/SendScreenshotPlus/resource.rc delete mode 100644 plugins/SendScreenshotPlus/sdk/DevKey.h delete mode 100644 plugins/SendScreenshotPlus/sdk/icons.h create mode 100644 plugins/SendScreenshotPlus/src/CSend.cpp create mode 100644 plugins/SendScreenshotPlus/src/CSend.h create mode 100644 plugins/SendScreenshotPlus/src/CSendEmail.cpp create mode 100644 plugins/SendScreenshotPlus/src/CSendEmail.h create mode 100644 plugins/SendScreenshotPlus/src/CSendFTPFile.cpp create mode 100644 plugins/SendScreenshotPlus/src/CSendFTPFile.h create mode 100644 plugins/SendScreenshotPlus/src/CSendFile.cpp create mode 100644 plugins/SendScreenshotPlus/src/CSendFile.h create mode 100644 plugins/SendScreenshotPlus/src/CSendHTTPServer.cpp create mode 100644 plugins/SendScreenshotPlus/src/CSendHTTPServer.h create mode 100644 plugins/SendScreenshotPlus/src/CSendImageShack.cpp create mode 100644 plugins/SendScreenshotPlus/src/CSendImageShack.h create mode 100644 plugins/SendScreenshotPlus/src/DevKey.h create mode 100644 plugins/SendScreenshotPlus/src/Main.cpp create mode 100644 plugins/SendScreenshotPlus/src/Main.h create mode 100644 plugins/SendScreenshotPlus/src/UAboutForm.cpp create mode 100644 plugins/SendScreenshotPlus/src/UAboutForm.h create mode 100644 plugins/SendScreenshotPlus/src/UMainForm.cpp create mode 100644 plugins/SendScreenshotPlus/src/UMainForm.h create mode 100644 plugins/SendScreenshotPlus/src/Utils.cpp create mode 100644 plugins/SendScreenshotPlus/src/Utils.h create mode 100644 plugins/SendScreenshotPlus/src/ctrl_button.cpp create mode 100644 plugins/SendScreenshotPlus/src/ctrl_button.h create mode 100644 plugins/SendScreenshotPlus/src/dlg_msgbox.cpp create mode 100644 plugins/SendScreenshotPlus/src/dlg_msgbox.h create mode 100644 plugins/SendScreenshotPlus/src/global.h create mode 100644 plugins/SendScreenshotPlus/src/icons.h create mode 100644 plugins/SendScreenshotPlus/src/mir_icolib.cpp create mode 100644 plugins/SendScreenshotPlus/src/mir_icolib.h create mode 100644 plugins/SendScreenshotPlus/src/mir_string.cpp create mode 100644 plugins/SendScreenshotPlus/src/mir_string.h create mode 100644 plugins/SendScreenshotPlus/src/resource.h create mode 100644 plugins/SendScreenshotPlus/src/version.h delete mode 100644 plugins/SendScreenshotPlus/version.h delete mode 100644 plugins/SendScreenshotPlus/version.rc delete mode 100644 plugins/Sessions/Icons/Checked.ico delete mode 100644 plugins/Sessions/Icons/Load.ico delete mode 100644 plugins/Sessions/Icons/Loadlast.ico delete mode 100644 plugins/Sessions/Icons/Save.ico delete mode 100644 plugins/Sessions/Icons/Sessions.ico delete mode 100644 plugins/Sessions/Icons/Unchecked.ico delete mode 100644 plugins/Sessions/Resource.h delete mode 100644 plugins/Sessions/Sessions.rc create mode 100644 plugins/Sessions/Src/Resource.h create mode 100644 plugins/Sessions/Src/Version.h delete mode 100644 plugins/Sessions/Version.h delete mode 100644 plugins/Sessions/Version.rc create mode 100644 plugins/Sessions/docs/sessions-translation.txt create mode 100644 plugins/Sessions/res/Checked.ico create mode 100644 plugins/Sessions/res/Load.ico create mode 100644 plugins/Sessions/res/Loadlast.ico create mode 100644 plugins/Sessions/res/Save.ico create mode 100644 plugins/Sessions/res/Sessions.ico create mode 100644 plugins/Sessions/res/Sessions.rc create mode 100644 plugins/Sessions/res/Unchecked.ico create mode 100644 plugins/Sessions/res/Version.rc delete mode 100644 plugins/Sessions/sessions-translation.txt diff --git a/plugins/SecureIM/!whatsnew.txt b/plugins/SecureIM/!whatsnew.txt deleted file mode 100644 index eeb792d864..0000000000 --- a/plugins/SecureIM/!whatsnew.txt +++ /dev/null @@ -1,595 +0,0 @@ - -Verison 1.0.12.4 [28-04-2010] - -[*] fix bug with advanced icon set to "NONE" && enable extaicons plugin - - -Verison 1.0.12.3 [18-05-2009] - -[*] fixed crash on filetransfer -[*] advanced messages for replaced RSA keys -[+] show SHA1 for all public keys -[*] new format private key -[+] export/import public keys -[+] export/import my private key - - -Verison 1.0.12.2 [07-05-2009] - -[*] some memory leak fixed -[*] some security fixes -[+] use KeyExchangeTimeout for RSA/AES keyexchange -[+] show RSA Public key flag in Options dialog -[+] reset RSA public key for contact -[+] copy SHA1 of my RSA public key to Clipboard -[*] context menu on RClick in columns "Mode","Status","-" - - -Verison 1.0.12.1 [04-05-2009] - -[*] native mode fixes -[+] add support for folders plugin -[+] auto switch to RSA/AES mode, if possible -[+] _Filter sequence fixed (last in sent & first in recv) -[+] GPG temp path - - -Verison 1.0.12.0 [28-04-2009] - -[*] rewrite icons library -[+] add support for extraicon plugin -[+] RSA/AES Secure File Transfer -[+] mode in context menu - - -Verison 1.0.11.4 [22-04-2009] - -[*] patch from Billy_Bons - - -Verison 1.0.11.3 [22-04-2009] - -[+] option "Disabled" for RSA/AES -[+] change status to "Disabled" for "Disabled" on other side - - -Verison 1.0.11.2 [21-04-2009] - -[+] option "Not secured for NotOnList" -[+] auto switch mode to RSA/AES and to Native on message type -[+] auto accept RSA key -[+] auto established RSA/AES connection ("Always if Possible" flag) - - -Verison 1.0.11.1 [20-04-2009] - -[*] compile with new Miranda headers -[*] fix metacontacts handling - - -Verison 1.0.11.0 [08-08-2008] - -[*] some code rewrite -[*] fix UTF8 in PGP/GPG messages -[+] split long messages (per protocol) -[+] new encryption algorithm RSA/AES -[*] rewrite handling metacontacts - - -Verison 1.0.10.8 [09-04-2008] - -[*] fix store subcontact history in metacontacts (only with today meta svn) - - -Verison 1.0.10.7 [19-01-2008] - -[*] change select contact list icon slot - - -Verison 1.0.10.6 [24-12-2007] - -[*] some code rewrite - - -Verison 1.0.10.5 [24-12-2007] - -[*] fix Load/Unload keys for PGP/GPG - - -Verison 1.0.10.4 [21-12-2007] - -[*] fix double UTF8 encoding in PGP/GPG messages -[*] applied patch from Garthower (MetaContacts & IRC protocol) - - -Verison 1.0.10.3 [15-09-2007] - -[*] change work with metacontacts (to work need disable sync subcontact history with metacontact) -[*] fix secure filesend over metacontact -[+] new features in options dialog -[*] unicode fix SetPSK dialog -[*] change memory allocation functions - - -Verison 1.0.10.2 [19-06-2007] - -[*] fix PREF_UTF flag in messages (new bug) - - -Verison 1.0.10.1 [08-06-2007] - -[*] fix PREF_UTF flag in messages - - -Verison 1.0.9.37 [04-04-2007] - -[*] remove internal SecureIM messages from MetaContacts history - - -Verison 1.0.9.36 [02-04-2007] - -[*] fix Established Secure Connection over RTF (in MRA) -[*] disable icon && menus for non-secured protocols -[*] hide GPG menu items for no-secured protocols - - -Verison 1.0.9.35 [14-03-2007] - -[*] add PluginInfoEx support - - -Verison 1.0.9.34 [28-02-2007] - -[*] fix for Secure File Transfer - - -Verison 1.0.9.33 [26-02-2007] - -[*] file encryption from RO FS fixed - - -Verison 1.0.9.32 [25-02-2007] - -[*] some PGP+GPG fixes -[+] option "save GPG passphrases" (saved on exit) - - -Verison 1.0.9.31 [22-02-2007] - -[*] fix VC71 project -[*] PGP & GPG can worked anytime -[+] options 'disable' CList icon - - -Verison 1.0.9.30 [12-01-2007] - -[*] hide SecureIM icon in TabSRMM for ChatRoom -[+] add unicode support in Options Dialog - - -Verison 1.0.9.29 [10-01-2007] - -[+] support Unicode in Popups -[*] fixed Metacontact icon in TabSRMM - - -Verison 1.0.9.28 - -[*] internal build - - -Verison 1.0.9.27 - -[*] internal build - - -Verison 1.0.9.26 - -[*] GPG fixes - - -Verison 1.0.9.25 - -[*] GPG fixes - - -Verison 1.0.9.24 - -[*] support ANSI codepage for GPG - - -Verison 1.0.9.23 - -[*] GPG bugfixes - - -Verison 1.0.9.22 - -[*] more GPG fixes - - -Verison 1.0.9.21 - -[+] add option "Log to file" on GPG tab -[*] small fixes - - -Verison 1.0.9.20 - -[*] GPG fixes - - -Verison 1.0.9.19 - -[*] add secureim_icons.dll in installpack - - -Verison 1.0.9.18 - -[*] small fixes - - -Verison 1.0.9.17 - -[+] add decode incoming RTF messages -[+] add GnuPG support - - -Verison 1.0.9.16 - -[*] fixed language in IcoLib support - - -Verison 1.0.9.15 - -[*] fixed show not-32bit icons -[*] fixed IcoLib support - - -Verison 1.0.9.14 - -[*] resend unencrypted messages fixed - - -Verison 1.0.9.13 - -[+] add IcoLib support - - -Verison 1.0.9.12 - -[*] fixed filetransfer - - -Verison 1.0.9.11 - -[+] split SecureIM & IconPack in different modules - - -Verison 1.0.9.10 - -[*] fixed "Status in context menu" - - -Verison 1.0.9.9 - -[+] option "Always secured if possible" (need ICQ.dll from SSS on both side) -[*] fixed send unencrypted messages, if connection not established -[*] on default PGP is disabled -[*] some fixes - - -Verison 1.0.9.8 - -[*] fix use black background color on popups - - -Verison 1.0.9.7 - -[+] rename received files (file.dll, file (1).dll, ...) -[+] increment encrypted filename (file.AESHELL0, file.AESHELL1, ...) for send one file to multiple contacts - - -Verison 1.0.9.6 - -[+] add ChatRoom checking - - -Verison 1.0.9.5 - -[*] fix autoload keyrings on PGP6 - - -Verison 1.0.9.4 - -[*] fix remove PGPprivkey -[*] fix add new contact -[+] add PopUp plugin detection -[+] rebuild function for work with lists -[*] some fixes - - -Verison 1.0.9.3 - -[+] option "Disable PGP" -[+] option "Disable keyring use" -[+] pgp encryption working without installed PGP, only with PGP SDK dlls -[*] check "MirVer" fixed - -Verison 1.0.9.3 - -[*] internal build - - -Verison 1.0.9.1 - -[+] PGP v8 are supported (PGP v7 not tested, PGP v9 - NOT supported) -[+] save sort order in options dialog -[*] some fixes - - -Verison 1.0.8.4 - -[*] show icon on CList on Load & Unload PGP keys (you will get "Load PGP KeyID" contact menu item ONLY if you have pre-installed PGP 6) - - -Verison 1.0.8.3 - -[*] some fixes - - -Verison 1.0.8.2 - -[+] support for PGP SDK 658 (new menuitem "Load PGP KeyID" | "Unload PGP KeyID") - - -Verison 1.0.8.1 - -[+] work's on icons ;-) -[+] some fixes - - -Verison 1.0.8.0 - -[+] new parameters "p" and "g" in DH keyexchange -[*] disable keyexchange with invisible contacts ;-) - - -Verison 1.0.7.10 - -[*] change SecureIM status from context menu (suport for CList_classic) -[+] add sort in SecureIM options dialog by clicking on column header - - -Verison 1.0.7.9 - -[+] "Offline Key Timeout" -[+] "Disable encryption for game plugins" -[*] change icons :-) - - -Verison 1.0.7.8 - -[*] bugfixes for "Secure Offline Messages" -[+] change SecureIM status from context menu (not worked in CList_classic) - - -Verison 1.0.7.7 - -[*] PSK dialog fixed - - -Verison 1.0.7.6 - -[+] remake "SecureIM Translate.txt" -[*] more fixes - - -Verison 1.0.7.5 - -[*] more fixes - - -Verison 1.0.7.4 - -[+] add updater support for Crypto++ - - -Verison 1.0.7.3 - -[+] add combine splitted messages (WinPopup proto etc...) - - -Verison 1.0.7.2 - -[+] add pre-shared keys for Diffie-Hellman key exchange - - -Verison 1.0.7.1 - -[+] UTF8 encoding moved to Crypto++ -[*] more fixes - - -Verison 1.0.6.5 - -[+] check version of cryptopp.dll -[*] fixed "always try" - - -Verison 1.0.6.4 - -[+] add compress long messages (GZip), need update Crypto++ -[*] more fixes - - -Verison 1.0.6.3 - -[*] rewrite SecureRecvMsg and SecureSendMsg - - -Verison 1.0.6.2 - -[*] rewrite SecureFileTransfer, worked in ICQ,Jabber,MSN - - -Verison 1.0.6.1 - -[+] split crypto engenie and miranda plugin... - - -Version 1.0.5.23 - -[*] some fixes - - -Version 1.0.5.22 - -[*] some fixes - - -Version 1.0.5.21 - -[+] add options "Show a popup on established connection" and "Show a popup on disabled connection" - - -Version 1.0.5.20 - -[*] rebuild in static mode - - -Version 1.0.5.19 - -[*] more fixes - - -Version 1.0.5.18 - -[+] selection of protocols added - - -Version 1.0.5.17 - -[*] fixed break event chain ME_CLIST_EXTRA_LIST_REBUILD & ME_CLIST_EXTRA_IMAGE_APPLY - - -Version 1.0.5.16 - -[+] add SecureIM handover on MetaContacts -[+] Updater plugin support - - -Version 1.0.5.15 - -[+] MetaContacts removed from options list -[+] add support for MetaContacts -[*] any cosmetic fixes - - -Version 1.0.5.14 - -[+] option "Miranda Client Detection" - check or not client ICQ version (Miranda) -[*] any cosmetic fixes - - -Version 1.0.5.13 - -[*] continue of x-status bugfixes - - -Version 1.0.5.12 - -[*] bug with show x-status icon on icq status bar clist_nicer++ fixed - - -Version 1.0.5.11 - -[*] plugin version info fixed -[*] the key exchange timeout limited by 65535 seconds value -[*] more fixes - - -Version 1.0.5.10 - -[+] build with msvcr71.dll -[+] use crypto++ 5.2.3 -[*] more fixes - - -Version 1.0.5.8 - -[*] rewrite options dialog, work "Apply" button ;-) -[*] offline key timeout only for send message -[*] send encrypted offline message if enable flag "Secure Offline Message" and SecureIM status on contact is "Always Try" -[+] support for IRC protocol - - -Version 1.0.5.7 - -[*] rewrite more code -[*] the key exchange timeout limited by 9999 seconds value. -[+] offline key timeout (2 day) - - -Version 1.0.5.5 - -[*] plugin check client ICQ version (Miranda,ICQ,QIP,&RQ,...) - - -Version 1.0.5.4c - -[*] build in VS 6.0 -[*] miranda memory allocation - - -Version 1.0.5.4 - -[*] rewrite more code -[*] the key exchange timeout limited by 999999999 ms value. - - -Version 1.0.5.3b - -[*] fix message size detection - - -Version 1.0.5.3 - -[*] rewrite options dialog and any function -[+] automatic detect maximum length of message -[*] always send encrypted offline message if enable flag "Secure Offline Message" and SecureIM status on contact NOT "Disabled" - - -Version 1.0.5.1a - -[*] "always try" work fine -[-] remove indicator from NickName -[+] base64 encode -[*] rewite hexconverter -[+] selective adv1 or adv2 icon -[+] truecolor icons -[+] feature "always show icons" - - -Version 1.0.5.0a - -[+] unicode support (thanks Nightwish) -[+] triggered menu (thanks Ghost) -[-] remove SecureIM Protocols menu (thanks George Hazan) -[*] change icons (thanks Faith Healer) -[+] backward compatible (unicode only with new version SecureIM) -[+] fix any small bags - - -Version 1.0.4.6c - -[+] apply all __alex SEH - - -Version 1.0.4.6 - -[+] crypto++ 5.2 -[+] adv2 icon in CList -[+] support tabSRMM icon -[+] apply patches of __alex - diff --git a/plugins/SecureIM/commonheaders.cpp b/plugins/SecureIM/commonheaders.cpp deleted file mode 100644 index 3697abea6e..0000000000 --- a/plugins/SecureIM/commonheaders.cpp +++ /dev/null @@ -1,197 +0,0 @@ -#include "commonheaders.h" - -HINSTANCE g_hInst, g_hIconInst; - -LPCSTR szModuleName = MODULENAME; -LPCSTR szVersionStr = MODULENAME" DLL ("__VERSION_STRING")"; -char TEMP[MAX_PATH]; -int TEMP_SIZE = 0; - -HANDLE g_hEvent[2], g_hMenu[15], g_hCLIcon=0, g_hFolders=0; -HANDLE *g_hService=NULL; -HANDLE *g_hHook=NULL; -int iService=0; -int iHook=0; - -HICON g_hICO[ICO_CNT], g_hPOP[POP_CNT], g_hIEC[1+IEC_CNT*MODE_CNT] = {0}; -IconExtraColumn g_IEC[1+IEC_CNT*MODE_CNT]; - -int iBmpDepth; -BOOL bCoreUnicode = false, bMetaContacts = false, bPopupExists = false, bPopupUnicode = false; -BOOL bPGPloaded = false, bPGPkeyrings = false, bUseKeyrings = false, bPGPprivkey = false; -BOOL bGPGloaded = false, bGPGkeyrings = false, bSavePass = false; -BOOL bSFT, bSOM, bASI, bMCD, bSCM, bDGP, bAIP, bNOL, bAAK, bMCM; -BYTE bADV, bPGP, bGPG; -DWORD iCoreVersion = 0; -CRITICAL_SECTION localQueueMutex; - -PLUGININFOEX pluginInfoEx = { - sizeof(PLUGININFOEX), - MODULENAME, - __VERSION_DWORD, - MODULENAME" plugin for Miranda IM ("__DATE__")", - "Johell, Ghost, Nightwish, __alex, Baloo", - "Johell@ifrance.com, baloo@bk.ru", - "© 2003 Johell, © 2005-09 Baloo", - "http://nightly.miranda.im/", - 0, - MIID_SECUREIM -}; - -LPSTR myDBGetString(HANDLE hContact,const char *szModule,const char *szSetting) { - char *val=NULL; - DBVARIANT dbv; - dbv.type = DBVT_ASCIIZ; - DBGetContactSetting(hContact,szModule,szSetting,&dbv); - if ( dbv.pszVal && (dbv.type==DBVT_ASCIIZ || dbv.type==DBVT_UTF8 || dbv.type==DBVT_WCHAR)) - val = mir_strdup(dbv.pszVal); - DBFreeVariant(&dbv); - return val; -} - - -LPSTR myDBGetStringDecode(HANDLE hContact,const char *szModule,const char *szSetting) { - char *val = myDBGetString(hContact,szModule,szSetting); - if (!val) return NULL; - size_t len = strlen(val)+64; - char *buf = (LPSTR)mir_alloc(len); - strncpy(buf,val,len); mir_free(val); - CallService(MS_DB_CRYPT_DECODESTRING,(WPARAM)len,(LPARAM)buf); - return buf; -} - - -int myDBWriteStringEncode(HANDLE hContact,const char *szModule,const char *szSetting,const char *val) { - int len = (int)strlen(val)+64; - char *buf = (LPSTR)alloca(len); - strncpy(buf,val,len); - CallService(MS_DB_CRYPT_ENCODESTRING,(WPARAM)len,(LPARAM)buf); - int ret = DBWriteContactSettingString(hContact,szModule,szSetting,buf); - return ret; -} - -void GetFlags() { - bSFT = DBGetContactSettingByte(0,szModuleName,"sft",0); - bSOM = DBGetContactSettingByte(0,szModuleName,"som",0); - bASI = DBGetContactSettingByte(0,szModuleName,"asi",0); - bMCD = DBGetContactSettingByte(0,szModuleName,"mcd",0); - bSCM = DBGetContactSettingByte(0,szModuleName,"scm",0); - bDGP = DBGetContactSettingByte(0,szModuleName,"dgp",0); - bAIP = DBGetContactSettingByte(0,szModuleName,"aip",0); - bADV = DBGetContactSettingByte(0,szModuleName,"adv",0); - bNOL = DBGetContactSettingByte(0,szModuleName,"nol",0); - bAAK = DBGetContactSettingByte(0,szModuleName,"aak",0); - bMCM = DBGetContactSettingByte(0,szModuleName,"mcm",0); -} - - -void SetFlags() { - DBWriteContactSettingByte(0,szModuleName,"sft",bSFT); - DBWriteContactSettingByte(0,szModuleName,"som",bSOM); - DBWriteContactSettingByte(0,szModuleName,"asi",bASI); - DBWriteContactSettingByte(0,szModuleName,"mcd",bMCD); - DBWriteContactSettingByte(0,szModuleName,"scm",bSCM); - DBWriteContactSettingByte(0,szModuleName,"dgp",bDGP); - DBWriteContactSettingByte(0,szModuleName,"aip",bAIP); - DBWriteContactSettingByte(0,szModuleName,"adv",bADV); - DBWriteContactSettingByte(0,szModuleName,"nol",bNOL); - DBWriteContactSettingByte(0,szModuleName,"aak",bAAK); - DBWriteContactSettingByte(0,szModuleName,"mcm",bMCM); -} - -struct A2U { - LPSTR a; - LPSTR u; -}; -typedef A2U* pA2U; - -pA2U pa2u; -int ca2u=0; - -LPSTR TranslateU( LPCSTR lpText ) { - int i; - for(i=0;iutf8encode(lpwTran)); - } - else { - LPSTR lpTran = Translate(lpText); - LPWSTR lpwTran = mir_a2u(lpTran); - lpTran = exp->utf8encode(lpwTran); - mir_free(lpwTran); - pa2u[i].u = mir_strdup(lpTran); - } - return pa2u[i].u; -} - -int msgbox( HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType) { - if ( bCoreUnicode ) { - LPWSTR lpwText = mir_a2u(lpText); - LPWSTR lpwCaption = mir_a2u(lpCaption); - int r = MessageBoxW(hWnd,TranslateW(lpwText),TranslateW(lpwCaption),uType); - mir_free(lpwCaption); - mir_free(lpwText); - return r; - } - return MessageBoxA(hWnd,Translate(lpText),Translate(lpCaption),uType); -} - -void CopyToClipboard(HWND hwnd,LPSTR msg) -{ - HGLOBAL hglbCopy; - LPSTR lpstrCopy; - - hglbCopy = GlobalAlloc(GMEM_MOVEABLE, lstrlenA(msg)+1); - lpstrCopy = (LPSTR)GlobalLock(hglbCopy); - lstrcpyA(lpstrCopy, msg); - GlobalUnlock(hglbCopy); - - OpenClipboard(NULL); - EmptyClipboard(); - SetClipboardData(CF_TEXT, hglbCopy); - CloseClipboard(); -} - -#if defined(_DEBUG) || defined(NETLIB_LOG) -HANDLE hNetlibUser; - -void InitNetlib() { - NETLIBUSER nl_user; - memset(&nl_user,0,sizeof(nl_user)); - nl_user.cbSize = sizeof(nl_user); - nl_user.szSettingsModule = (LPSTR)szModuleName; - nl_user.szDescriptiveName = (LPSTR)szModuleName; - nl_user.flags = NUF_NOOPTIONS; - - hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nl_user); -} - -void DeinitNetlib() { - if(hNetlibUser) - CallService(MS_NETLIB_CLOSEHANDLE, (WPARAM)hNetlibUser, 0); -} - -int Sent_NetLog(const char *fmt,...) -{ - va_list va; - char szText[1024]; - - va_start(va,fmt); - mir_vsnprintf(szText,sizeof(szText),fmt,va); - va_end(va); - return CallService(MS_NETLIB_LOG,(WPARAM)hNetlibUser,(LPARAM)szText); -} -#endif - - -// EOF diff --git a/plugins/SecureIM/commonheaders.h b/plugins/SecureIM/commonheaders.h deleted file mode 100644 index c848d43484..0000000000 --- a/plugins/SecureIM/commonheaders.h +++ /dev/null @@ -1,192 +0,0 @@ -// Windows API - -#define WIN32_LEAN_AND_MEAN -#define NETLIB_LOG - -#ifdef _MSC_VER -#pragma once -#define _CRT_SECURE_NO_WARNINGS -// _MSC_VER: 1200=6.0 1300=7.0(2003) 1400=8.0(2005) 1500=9.0(2008) -#if _MSC_VER >= 1300 -// MSVC 7.0 and above -#define mir_itoa _itoa -#define mir_unlink _unlink -#else -// MSVC 6.0 and below -#ifndef _DEBUG -#pragma optimize("gsy", on) -#endif -#endif -#endif - -#ifndef mir_itoa -#define mir_itoa itoa -#endif - -#ifndef mir_unlink -#define mir_unlink unlink -#endif - -#ifndef WINVER -#define WINVER 0x0501 -#endif - -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0501 -#endif - -#ifndef _WIN32_IE -#define _WIN32_IE 0x0501 -#endif - -#ifndef M_SIM_COMMONHEADERS_H -#define M_SIM_COMMONHEADERS_H - -#define MIRANDA_VER 0x0A00 -#include - -// Windows API -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define MODULENAME "SecureIM" - -#ifndef ListView_SetCheckState -#define ListView_SetCheckState(hwndLV, i, fCheck) \ - ListView_SetItemState(hwndLV, i, INDEXTOSTATEIMAGEMASK((fCheck)?2:1), LVIS_STATEIMAGEMASK) -#endif - -#ifndef SIZEOF -#define SIZEOF(X) (sizeof(X)/sizeof(X[0])) -#endif - -#ifndef M_API_H__ -#define M_API_H__ - -// Miranda API -#include "newpluginapi.h" -#include "m_stdhdr.h" -#include "m_system.h" -#include "m_database.h" -#include "m_protomod.h" -#include "m_protosvc.h" -#include "m_langpack.h" -#include "m_options.h" -#include "m_clist.h" -#include "m_clc.h" -#include "m_clui.h" -#include "m_cluiframes.h" -#include "m_utils.h" -#include "m_skin.h" -#include "m_popup.h" -#include "m_genmenu.h" -#include "m_icolib.h" -#include "m_message.h" -#include "m_netlib.h" -#include "m_metacontacts.h" -#include "m_extraicons.h" -#include "m_folders.h" - -#endif - -// my libs -#include "secureim.h" -#include "version.h" -#include "resource.h" -#include "language.h" -#include "loadlib.h" -#include "mmi.h" -#include "crypt.h" -#include "gettime.h" -#include "language.h" -#include "options.h" -#include "popupoptions.h" -#include "loadicons.h" -#include "rtfconv.h" -#include "cryptopp.h" -#include "images.h" -#include "dbevent.h" -#include "splitmsg.h" -#include "svcs_proto.h" -#include "svcs_clist.h" -#include "svcs_menu.h" -#include "svcs_srmm.h" -#include "svcs_rsa.h" - -extern LPCSTR szModuleName; -extern LPCSTR szVersionStr; -extern char TEMP[MAX_PATH]; -extern int TEMP_SIZE; - -// shared vars -extern HINSTANCE g_hInst, g_hIconInst; -extern PLUGININFOEX pluginInfoEx; - -#define MIID_SECUREIM {0x1B2A39E5, 0xE2F6, 0x494D, { 0x95, 0x8D, 0x18, 0x08, 0xFD, 0x11, 0x0D, 0xD5 }} //1B2A39E5-E2F6-494D-958D-1808FD110DD5 - -#define PREF_METANODB 0x2000 //!< Flag to indicate message should not be added to db by filter when sending -#define PREF_SIMNOMETA 0x4000 //!< Flag to indicate message should not be inspected by filter on metacontact - -extern HANDLE g_hEvent[2], g_hMenu[15], g_hCLIcon, g_hFolders; -extern HANDLE *g_hService; -extern HANDLE *g_hHook; -extern int iService, iHook; -extern HICON g_hICO[ICO_CNT], g_hIEC[1+IEC_CNT*MODE_CNT], g_hPOP[POP_CNT]; -extern IconExtraColumn g_IEC[1+IEC_CNT*MODE_CNT]; -extern int iBmpDepth; -extern BOOL bCoreUnicode, bMetaContacts, bPopupExists, bPopupUnicode; -extern BOOL bPGPloaded, bPGPkeyrings, bUseKeyrings, bPGPprivkey; -extern BOOL bGPGloaded, bGPGkeyrings, bSavePass; -extern BOOL bSFT, bSOM, bASI, bMCD, bSCM, bDGP, bAIP, bNOL, bAAK, bMCM; -extern BYTE bADV, bPGP, bGPG; -extern DWORD iCoreVersion; -extern CRITICAL_SECTION localQueueMutex; - -int onModulesLoaded(WPARAM,LPARAM); -int onSystemOKToExit(WPARAM,LPARAM); - -void AddServiceFunction(LPCSTR,MIRANDASERVICE); -void AddProtoServiceFunction(LPCSTR,MIRANDASERVICE); -void AddHookFunction(LPCSTR,MIRANDAHOOK); - -LPSTR myDBGetString(HANDLE,const char *,const char *); -LPSTR myDBGetStringDecode(HANDLE,const char *,const char *); -int myDBWriteStringEncode(HANDLE,const char *,const char *,const char *); - -#if defined(_DEBUG) || defined(NETLIB_LOG) -extern HANDLE hNetlibUser; -void InitNetlib(); -void DeinitNetlib(); -int Sent_NetLog(const char *,...); -#endif -/* -int DBWriteString(HANDLE,const char *,const char *,const char *); -int DBGetByte(HANDLE,const char *,const char *,int); -int DBWriteByte(HANDLE,const char *,const char *,BYTE); -int DBGetWord(HANDLE,const char *,const char *,int); -int DBWriteWord(HANDLE,const char *,const char *,WORD); -*/ -void GetFlags(); -void SetFlags(); -/* -LPSTR u2a( LPCWSTR src ); -LPWSTR a2u( LPCSTR src ); -*/ -LPSTR TranslateU( LPCSTR lpText ); -int msgbox( HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType ); -void CopyToClipboard(HWND hwnd,LPSTR msg); -#define msgbox0(a,b,c,d) msgbox(a,b,c,d) -#define msgbox1(a,b,c,d) msgbox(a,b,c,d) - -#endif - -// EOF diff --git a/plugins/SecureIM/crypt.h b/plugins/SecureIM/crypt.h deleted file mode 100644 index e626570f9e..0000000000 --- a/plugins/SecureIM/crypt.h +++ /dev/null @@ -1,183 +0,0 @@ -#ifndef __CRYPT_H__ -#define __CRYPT_H__ - -#include "secureim.h" -#include "cryptopp.h" -#include "gettime.h" - -#define KEYSIZE 256 -#define NAMSIZE 512 -#define DEFMSGS 4096 - -#define KEY_A_SIG 0x000000 -#define KEY_B_SIG 0x010000 - -// struct to store all supported protocols -struct SupPro { - LPSTR name; - BOOL inspecting; - int split_on,tsplit_on; - int split_off,tsplit_off; -}; -typedef SupPro *pSupPro; - -// struct to store wainting messages -struct waitingMessage { - LPSTR Message; - WPARAM wParam; - waitingMessage *nextMessage; -}; -typedef waitingMessage* pWM; - -struct partitionMessage { - int id; - LPSTR *message; // array of message parts - partitionMessage *nextMessage; -}; -typedef partitionMessage* pPM; - -#define HEADER 0xABCD1234 -#define FOOTER 0x9876FEDC -#define EMPTYH 0xF1E2D3C4 - -// memory struct for keys -struct UinKey { - u_int header; // HEADER - HANDLE hContact; // handle of contact - pSupPro proto; // proto struct - BYTE mode,tmode; // mode: Native,PGP,GPG,RSA/AES,RSA [0..4] - BYTE status,tstatus; // status: Disabled,Enabled,AlwaysTry [0..2] for Native mode - LPSTR msgSplitted; // message to combine - pPM msgPart; // parts of message - pWM msgQueue; // last messages not sended or to resend; - BOOL sendQueue; // идет отсылка очереди - не обрабатываются сообщения - BOOL offlineKey; - char waitForExchange; // 0 - сбросить очередь - // 1 - ожидаем - // 2 - дослать с шифрованием - // 3 - дослать без шифрования с вопросом - BOOL decoded; // false on decode error - short features; - HANDLE cntx; // crypto context - BYTE keyLoaded; // ( 1-PGP, 2-GPG ) | 1-RSA - BYTE gpgMode,tgpgMode; // 0-UTF8, 1-ANSI - char *lastFileRecv; - char *lastFileSend; - char **fileSend; - BOOL finFileRecv; - BOOL finFileSend; - LPSTR tmp; // tmp text string - u_int footer; // FOOTER -}; -typedef UinKey* pUinKey; - -struct TFakeAckParams { - inline TFakeAckParams( HANDLE p1, HANDLE p2, LONG p3, LPCSTR p4 ) : - hEvent( p1 ), - hContact( p2 ), - id( p3 ), - msg( p4 ) - {} - - HANDLE hEvent; - HANDLE hContact; - LONG id; - LPCSTR msg; -}; - -struct TWaitForExchange { - inline TWaitForExchange( HANDLE p1, HANDLE p2 ) : - hEvent( p1 ), - hContact( p2 ) - {} - - HANDLE hEvent; - HANDLE hContact; -}; - -extern char szUIN[NAMSIZE]; -extern char szName[NAMSIZE]; -extern pSupPro proto; -extern pUinKey clist; -extern int proto_cnt; -extern int clist_cnt; - -// crypt_lists.cpp -void loadContactList(); -void freeContactList(); -pUinKey addContact(HANDLE); -void delContact(HANDLE); -pSupPro getSupPro(HANDLE); -pUinKey getUinKey(HANDLE); -pUinKey getUinCtx(HANDLE); -void addMsg2Queue(pUinKey,WPARAM,LPSTR); - -void getContactName(HANDLE hContact, LPSTR szName); -void getContactNameA(HANDLE hContact, LPSTR szName); -void getContactUin(HANDLE hContact, LPSTR szUIN); -void getContactUinA(HANDLE hContact, LPSTR szUIN); - -// crypt_check.cpp -int getContactStatus(HANDLE); - -BOOL isSecureProtocol(HANDLE); -BYTE isContactSecured(HANDLE); -BOOL isClientMiranda(pUinKey ptr, BOOL emptyMirverAsMiranda=FALSE); -BOOL isClientMiranda(HANDLE hContact, BOOL emptyMirverAsMiranda=FALSE); -BOOL isProtoSmallPackets(HANDLE); -BOOL isContactInvisible(HANDLE); -BOOL isNotOnList(HANDLE); -BOOL isContactNewPG(HANDLE); -BOOL isContactPGP(HANDLE); -BOOL isContactGPG(HANDLE); -BOOL isContactRSAAES(HANDLE); -BOOL isContactRSA(HANDLE); -BOOL isChatRoom(HANDLE); -BOOL isFileExist(LPCSTR); -BOOL isSecureIM(pUinKey ptr, BOOL emptyMirverAsSecureIM=FALSE); -BOOL isSecureIM(HANDLE hContact, BOOL emptyMirverAsSecureIM=FALSE); - -// crypt_icons.cpp -HICON mode2icon(int,int); -HICON mode2icon2(int,int); // создает КОПИЮ иконки, которую надо разрушить -IconExtraColumn mode2iec(int); -void RefreshContactListIcons(void); -void ShowStatusIcon(HANDLE,UINT); -void ShowStatusIcon(HANDLE); -void ShowStatusIconNotify(HANDLE); - -// crypt_popups.cpp -//static int CALLBACK PopupDlgProc(HWND,UINT,WPARAM,LPARAM); -void showPopUp(LPCSTR,HANDLE,HICON,UINT); -void showPopUpEC(HANDLE); -void showPopUpDCmsg(HANDLE,LPCSTR); -void showPopUpDC(HANDLE); -void showPopUpKS(HANDLE); -void showPopUpKRmsg(HANDLE,LPCSTR); -void showPopUpKR(HANDLE); -void showPopUpSM(HANDLE); -void showPopUpRM(HANDLE); - -// crypt_meta.cpp -BOOL isProtoMetaContacts(HANDLE); -BOOL isDefaultSubContact(HANDLE); -HANDLE getMetaContact(HANDLE); -HANDLE getMostOnline(HANDLE); -void DeinitMetaContact(HANDLE); - -// crypt_dll.cpp -LPSTR InitKeyA(pUinKey,int); -int InitKeyB(pUinKey,LPCSTR); -void InitKeyX(pUinKey,BYTE*); -BOOL CalculateKeyX(pUinKey,HANDLE); -LPSTR encodeMsg(pUinKey,LPARAM); -LPSTR decodeMsg(pUinKey,LPARAM,LPSTR); -BOOL LoadKeyPGP(pUinKey); -BOOL LoadKeyGPG(pUinKey); - -// crypt_misc.cpp -unsigned __stdcall sttFakeAck(LPVOID); -unsigned __stdcall sttWaitForExchange(LPVOID); -void waitForExchange(pUinKey ptr, int flag = 1); - -#endif diff --git a/plugins/SecureIM/crypt_check.cpp b/plugins/SecureIM/crypt_check.cpp deleted file mode 100644 index 3a4a0e0c30..0000000000 --- a/plugins/SecureIM/crypt_check.cpp +++ /dev/null @@ -1,267 +0,0 @@ -#include "commonheaders.h" - - -int getContactStatus(HANDLE hContact) { - - pSupPro ptr = getSupPro(hContact); - if (ptr) - return DBGetContactSettingWord(hContact, ptr->name, "Status", ID_STATUS_OFFLINE); - - return -1; -} - - -BOOL isSecureProtocol(HANDLE hContact) { - - pSupPro ptr = getSupPro(hContact); - if (!ptr) return false; - - return ptr->inspecting; -} - - -BYTE isContactSecured(HANDLE hContact) { - // нужна проверка на Offline и в этом случае другие статусы - if (!clist_cnt) return 0; - - BYTE r=0; - if ( isProtoMetaContacts(hContact)) - hContact = getMostOnline(hContact); // возьмем тот, через который пойдет сообщение - - for(int j=0;jinspecting ) break; - DBVARIANT dbv; - r=clist[j].mode; - switch(r) { - case MODE_NATIVE: - if(cpp_keyx(clist[j].cntx)!=0) r|=SECURED; - break; - case MODE_PGP: - DBGetContactSetting(hContact,szModuleName,"pgp",&dbv); - if ( dbv.type!=0 ) r|=SECURED; - DBFreeVariant(&dbv); - break; - case MODE_GPG: - DBGetContactSetting(hContact,szModuleName,"gpg",&dbv); - if ( dbv.type!=0 ) r|=SECURED; - DBFreeVariant(&dbv); - break; - case MODE_RSAAES: - if(exp->rsa_get_state(clist[j].cntx)==7) r|=SECURED; - break; - case MODE_RSA: - if(clist[j].cntx) r|=SECURED; - break; - } - break; - } - } - return r; // (mode&SECURED) - проверка на EST/DIS -} - - -BOOL isClientMiranda(pUinKey ptr, BOOL emptyMirverAsMiranda) { - - if ( !bMCD ) return true; - if ( !ptr->proto->inspecting ) return false; - - BOOL isMiranda = true; - LPSTR mirver = myDBGetString(ptr->hContact,ptr->proto->name,"MirVer"); - if ( mirver ) { - isMiranda = (emptyMirverAsMiranda && !*mirver) || (strstr(mirver,"Miranda")!=NULL); - mir_free(mirver); - } - return isMiranda; -} - - -BOOL isClientMiranda(HANDLE hContact, BOOL emptyMirverAsMiranda) { - - if ( !bMCD ) return true; - if ( !clist_cnt ) return false; - - for(int j=0;jinspecting ) break; - return strstr(clist[j].proto->name,"IRC")!=NULL || - strstr(clist[j].proto->name,"WinPopup")!=NULL || - strstr(clist[j].proto->name,"VyChat")!=NULL; - } - } - return false; -} - - -BOOL isContactInvisible(HANDLE hContact) { - - if ( !DBGetContactSettingByte(hContact,"CList","Hidden",0)) { - if ( !clist_cnt ) return false; - for(int j=0;jinspecting ) return false; - if ( clist[j].waitForExchange ) return false; - switch( (int)DBGetContactSettingWord(hContact,clist[j].proto->name,"ApparentMode",0)) { - case 0: - return (CallProtoService(clist[j].proto->name,PS_GETSTATUS,0,0)==ID_STATUS_INVISIBLE); - case ID_STATUS_ONLINE: - return false; - case ID_STATUS_OFFLINE: - return true; - } //switch - break; - } - }// for - } - return true; -} - - -BOOL isNotOnList(HANDLE hContact) { - return DBGetContactSettingByte(hContact, "CList", "NotOnList", 0); -} - - -BOOL isContactNewPG(HANDLE hContact) { - - if (!clist_cnt) return false; - for(int j=0;jinspecting ) break; - if ( !clist[j].cntx ) break; - return (clist[j].features & CPP_FEATURES_NEWPG) != 0; - } - } - return false; -} - - -BOOL isContactPGP(HANDLE hContact) { - - if (!bPGPloaded || (!bPGPkeyrings && !bPGPprivkey)) return false; - if (!clist_cnt) return false; - for(int j=0;jinspecting ) break; - if ( clist[j].mode!=MODE_PGP ) break; - DBVARIANT dbv; - DBGetContactSetting(hContact,szModuleName,"pgp",&dbv); - BOOL r=(dbv.type!=0); - DBFreeVariant(&dbv); - return r; - } - } - return false; -} - - -BOOL isContactGPG(HANDLE hContact) { - - if (!bGPGloaded || !bGPGkeyrings) return false; - if (!clist_cnt) return false; - for(int j=0;jinspecting ) break; - if ( clist[j].mode!=MODE_GPG ) break; - DBVARIANT dbv; - DBGetContactSetting(hContact,szModuleName,"gpg",&dbv); - BOOL r=(dbv.type!=0); - DBFreeVariant(&dbv); - return r; - } - } - return false; -} - - -BOOL isContactRSAAES(HANDLE hContact) { - - if (!clist_cnt) return false; - for(int j=0;jinspecting ) break; - if ( clist[j].mode!=MODE_RSAAES ) break; - return true; - } - } - return false; -} - - -BOOL isContactRSA(HANDLE hContact) { - - if (!clist_cnt) return false; - for(int j=0;jinspecting ) break; - if ( clist[j].mode!=MODE_RSA ) break; - return true; - } - } - return false; -} - - -BOOL isChatRoom(HANDLE hContact) { - - if (!clist_cnt) return false; - for(int j=0;jinspecting ) break; - return (DBGetContactSettingByte(hContact,clist[j].proto->name,"ChatRoom",0)!=0); - } - } - return false; -} - - -BOOL isFileExist(LPCSTR filename) { - return (GetFileAttributes(filename)!=(UINT)-1); -} - - -BOOL isSecureIM(pUinKey ptr, BOOL emptyMirverAsSecureIM) { - - if ( !bAIP ) return false; - if ( !ptr->proto->inspecting ) return false; - - BOOL isSecureIM = false; - if ( bNOL && DBGetContactSettingByte(ptr->hContact,"CList","NotOnList",0)) { - return false; - } - LPSTR mirver = myDBGetString(ptr->hContact,ptr->proto->name,"MirVer"); - if ( mirver ) { - isSecureIM = (emptyMirverAsSecureIM && !*mirver) || (strstr(mirver,"SecureIM")!=NULL) || (strstr(mirver,"secureim")!=NULL); - mir_free(mirver); - } - return isSecureIM; -} - - -BOOL isSecureIM(HANDLE hContact, BOOL emptyMirverAsSecureIM) { - - if ( !bAIP ) return false; - if ( !clist_cnt ) return false; - - for(int j=0;jcntx ) - ptr->cntx = cpp_create_context(isProtoSmallPackets(ptr->hContact)?CPP_MODE_BASE64:0); - - char *tmp = myDBGetString(ptr->hContact,szModuleName,"PSK"); - if(tmp) { - cpp_init_keyp(ptr->cntx,tmp); // make pre-shared key from password - mir_free(tmp); - } - - LPSTR pub_text = cpp_init_keya(ptr->cntx,features); // calculate public and private key & fill KeyA - - LPSTR keysig; - if(features&CPP_FEATURES_NEWPG) { - if(features&KEY_B_SIG) - keysig = (LPSTR)SIG_KEYB; - else - keysig = (LPSTR)SIG_KEYA; - } - else - if(isProtoSmallPackets(ptr->hContact)) - keysig = (LPSTR)SIG_KEY4; - else - keysig = (LPSTR)SIG_KEY3; - - int slen = (int)strlen(keysig); - int tlen = (int)strlen(pub_text); - - LPSTR keyToSend = (LPSTR) mir_alloc(slen+tlen+1); - - memcpy(keyToSend,keysig,slen); - memcpy(keyToSend+slen,pub_text,tlen+1); - - return keyToSend; -} - -// store KeyB into context -int InitKeyB(pUinKey ptr,LPCSTR key) { -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("InitKeyB: %s", key); -#endif - if (!ptr->cntx) - ptr->cntx = cpp_create_context(isProtoSmallPackets(ptr->hContact)?CPP_MODE_BASE64:0); - - if (!cpp_keyp(ptr->cntx)) { - char *tmp = myDBGetString(ptr->hContact,szModuleName,"PSK"); - if(tmp) { - cpp_init_keyp(ptr->cntx,tmp); // make pre-shared key from password - mir_free(tmp); - } - } - - cpp_init_keyb(ptr->cntx,key); - ptr->features = cpp_get_features(ptr->cntx); - - return cpp_get_error(ptr->cntx); -} - - -// store KeyX into context -void InitKeyX(pUinKey ptr,BYTE *key) { - - if (!ptr->cntx) - ptr->cntx = cpp_create_context(isProtoSmallPackets(ptr->hContact)?CPP_MODE_BASE64:0); - - cpp_set_keyx(ptr->cntx,key); -} - - -// calculate secret key -BOOL CalculateKeyX(pUinKey ptr,HANDLE hContact) { - - int agr = cpp_calc_keyx(ptr->cntx); - if ( agr ) { - // do this only if key exchanged is ok - // we use a 192bit key - int keysize = cpp_size_keyx(); - PBYTE buffer = (PBYTE) alloca(keysize); // buffer for hash - - // store key - cpp_get_keyx(ptr->cntx,buffer); - - DBCONTACTWRITESETTING cws; - cws.szModule = szModuleName; - - // store key in database - cws.szSetting = "offlineKey"; - cws.value.type = DBVT_BLOB; - cws.value.cpbVal = keysize; - cws.value.pbVal = buffer; - CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)hContact, (LPARAM)&cws); - - // store timeout of key in database (2 days) - cws.szSetting = "offlineKeyTimeout"; - cws.value.type = DBVT_DWORD; - cws.value.dVal = gettime()+(60*60*24*DBGetContactSettingWord(0,szModuleName,"okt",2)); - CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)hContact, (LPARAM)&cws); - - // key exchange is finished - showPopUpEC(ptr->hContact); - } - else { - // agree value problem - showPopUp(sim002,hContact,g_hPOP[POP_PU_DIS],0); - } - return agr!=0; -} - - -// encrypt message -LPSTR encrypt(pUinKey ptr, LPCSTR szEncMsg) { - - LPSTR szSig = (LPSTR) (ptr->offlineKey?SIG_ENOF:SIG_ENON); - - int slen = (int)strlen(szSig); - int clen = (int)strlen(szEncMsg); - - LPSTR szMsg = (LPSTR) mir_alloc(clen+slen+1); - memcpy(szMsg, szSig, slen); - memcpy(szMsg+slen, szEncMsg, clen+1); - - return szMsg; -} - - -// encode message -LPSTR encodeMsg(pUinKey ptr, LPARAM lParam) { - - CCSDATA *pccsd = (CCSDATA *)lParam; - LPSTR szNewMsg = NULL; - LPSTR szOldMsg = (LPSTR) pccsd->lParam; - - if ( pccsd->wParam & PREF_UTF ) - szNewMsg = encrypt(ptr,cpp_encodeU(ptr->cntx,szOldMsg)); - else - if ( pccsd->wParam & PREF_UNICODE ) - szNewMsg = encrypt(ptr,cpp_encodeW(ptr->cntx,(LPWSTR)(szOldMsg+strlen(szOldMsg)+1))); - else - szNewMsg = encrypt(ptr,cpp_encodeA(ptr->cntx,szOldMsg)); - -// pccsd->wParam &= ~(PREF_UNICODE|PREF_UTF); - pccsd->wParam &= ~PREF_UNICODE; - - return szNewMsg; -} - - -// decode message -LPSTR decodeMsg(pUinKey ptr, LPARAM lParam, LPSTR szEncMsg) { - - CCSDATA *pccsd = (CCSDATA *)lParam; - PROTORECVEVENT *ppre = (PROTORECVEVENT *)pccsd->lParam; - - LPSTR szNewMsg = NULL; - LPSTR szOldMsg = (ppre->flags&PREF_UTF)?cpp_decodeU(ptr->cntx,szEncMsg):cpp_decode(ptr->cntx,szEncMsg); - - if(szOldMsg == NULL) { - ptr->decoded=false; - switch(cpp_get_error(ptr->cntx)) { - case CPP_ERROR_BAD_LEN: - szNewMsg = mir_strdup(Translate(sim102)); - break; - case CPP_ERROR_BAD_CRC: - szNewMsg = mir_strdup(Translate(sim103)); - break; - default: { - ptr->decoded=true; - szNewMsg = mir_strdup(Translate(sim101)); - } - break; - } - ppre->flags &= ~(PREF_UNICODE|PREF_UTF); - pccsd->wParam &= ~(PREF_UNICODE|PREF_UTF); - } - else { - ptr->decoded=true; - if ( ppre->flags & PREF_UTF ) { // Ґб«Ё Їа®в®Є®« Ї®¤¤Ґа¦Ёў Ґв utf8 - в®Ј¤  ®вЇа ў«пҐ¬ ў utf8 - int olen = (int)strlen(szOldMsg)+1; - szNewMsg = (LPSTR) mir_alloc(olen); - memcpy(szNewMsg,szOldMsg,olen); - } - else { - int olen = ((int)strlen(szOldMsg)+1)*(sizeof(WCHAR)+1); - szNewMsg = (LPSTR) mir_alloc(olen); - memcpy(szNewMsg,szOldMsg,olen); - ppre->flags |= PREF_UNICODE; - pccsd->wParam |= PREF_UNICODE; - } - } - ppre->szMessage = szNewMsg; - return szNewMsg; -} - - -BOOL LoadKeyPGP(pUinKey ptr) { - int mode = DBGetContactSettingByte(ptr->hContact,szModuleName,"pgp_mode",255); - if(mode==0) { - DBVARIANT dbv; - DBGetContactSetting(ptr->hContact,szModuleName,"pgp",&dbv); - BOOL r=(dbv.type==DBVT_BLOB); - if(r) pgp_set_keyid(ptr->cntx,(PVOID)dbv.pbVal); - DBFreeVariant(&dbv); - return r; - } - else - if(mode==1) { - LPSTR key = myDBGetStringDecode(ptr->hContact,szModuleName,"pgp"); - if ( key ) { - pgp_set_key(ptr->cntx,key); - mir_free(key); - return 1; - } - } - return 0; -} - - -BOOL LoadKeyGPG(pUinKey ptr) { - - LPSTR key = myDBGetString(ptr->hContact,szModuleName,"gpg"); - if ( key ) { - gpg_set_keyid(ptr->cntx,key); - mir_free(key); - return 2; - } - return 0; -} - -// EOF diff --git a/plugins/SecureIM/crypt_icons.cpp b/plugins/SecureIM/crypt_icons.cpp deleted file mode 100644 index 6c5984c345..0000000000 --- a/plugins/SecureIM/crypt_icons.cpp +++ /dev/null @@ -1,151 +0,0 @@ -#include "commonheaders.h" - - -typedef struct { - HICON icon; - SHORT mode; -} ICON_CACHE; - - -ICON_CACHE *ICONS_CACHE = NULL; -int icons_cache = 0; - - -// преобразует mode в HICON который НЕ НУЖНО разрушать в конце -HICON mode2icon(int mode,int type) { - - int m=mode&0x0f,s=(mode&SECURED)>>4,i; // разобрали на части - режим и состояние - HICON icon; - - if ( icons_cache ) { - for(i=0;i>4; // разобрали на части - режим и состояние - - if ( mode==-1 || (!s && !bASI && m!=MODE_PGP && m!=MODE_GPG)) { - return g_IEC[0]; // вернем пустое место - } - - int i=1+m*IEC_CNT+IEC_CL_DIS+s; - if ( g_IEC[i].hImage==(HANDLE)-1 ) { -/* g_hIEC[i] = mode2icon(mode,1); - g_IEC[i].hImage = (HANDLE) CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)g_hIEC[i], (LPARAM)0);*/ - HICON icon = mode2icon(mode,1); - g_IEC[i].hImage = (HANDLE) CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)icon, (LPARAM)0); - } - return g_IEC[i]; -} - - -// обновляет иконки в clist и в messagew -void ShowStatusIcon(HANDLE hContact,int mode) { - - HANDLE hMC = getMetaContact(hContact); - if ( bADV || g_hCLIcon ) { // обновить иконки в clist - if ( mode!= -1 ) { - IconExtraColumn iec=mode2iec(mode); - if ( g_hCLIcon ) { - ExtraIcon_SetIcon(g_hCLIcon, hContact, iec.hImage); - if ( hMC ) - ExtraIcon_SetIcon(g_hCLIcon, hMC, iec.hImage); - } - else { - CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM)hContact, (LPARAM)&iec); - if ( hMC ) - CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM)hMC, (LPARAM)&iec); - } - } - } - if ( ServiceExists(MS_MSG_MODIFYICON)) { // обновить иконки в srmm - StatusIconData sid; - memset(&sid,0,sizeof(sid)); - sid.cbSize = sizeof(sid); - sid.szModule = (char*)szModuleName; - for(int i=MODE_NATIVE; itype == PROTOTYPE_PROTOCOL && protos[i]->szName && (CallProtoService(protos[i]->szName,PS_GETCAPS,PFLAGNUM_2,0)||strcmp(protos[i]->szName,"MetaContacts")==0)) { - if (protos[i]->type == PROTOTYPE_PROTOCOL && protos[i]->szName && CallProtoService(protos[i]->szName,PS_GETCAPS,PFLAGNUM_2,0)) { - int j = proto_cnt; proto_cnt++; - proto = (pSupPro) mir_realloc(proto,sizeof(SupPro)*proto_cnt); - memset(&proto[j],0,sizeof(SupPro)); - proto[j].name = mir_strdup(protos[i]->szName); - if ( szNames ) { - if ( proto[j].name ) { - char tmp[128]; strcpy(tmp,proto[j].name); strcat(tmp,":"); - LPSTR szName = strstr(szNames,tmp); - if ( szName ) { - szName = strchr(szName,':'); - if ( szName ) { - proto[j].inspecting = (*++szName == '1'); - szName = strchr(szName,':'); - if ( szName ) { - proto[j].split_on = atoi(++szName); proto[j].tsplit_on = proto[j].split_on; - szName = strchr(szName,':'); - if ( szName ) { - proto[j].split_off = atoi(++szName); proto[j].tsplit_off = proto[j].split_off; - } - } - } - } - } - } - else { - proto[j].inspecting = true; - } - } - } - SAFE_FREE(szNames); -} - - -void freeSupportedProtocols() { - for (int j=0;jmsgQueue==NULL){ - // create new - ptr->msgQueue = (pWM) mir_alloc(sizeof(struct waitingMessage)); - ptrMessage = ptr->msgQueue; - } - else { - // add to list - ptrMessage = ptr->msgQueue; - while (ptrMessage->nextMessage) { - ptrMessage = ptrMessage->nextMessage; - } - ptrMessage->nextMessage = (pWM) mir_alloc(sizeof(struct waitingMessage)); - ptrMessage = ptrMessage->nextMessage; - } - - ptrMessage->wParam = wParam; - ptrMessage->nextMessage = NULL; - - if(wParam & PREF_UNICODE) { - int slen = (int)strlen(szMsg)+1; - int wlen = (int)wcslen((wchar_t *)(szMsg+slen))+1; - ptrMessage->Message = (LPSTR) mir_alloc(slen+wlen*sizeof(WCHAR)); - memcpy(ptrMessage->Message,szMsg,slen+wlen*sizeof(WCHAR)); - } - else{ - ptrMessage->Message = mir_strdup(szMsg); - } - - LeaveCriticalSection(&localQueueMutex); -} - - -void getContactNameA(HANDLE hContact, LPSTR szName) { - strcpy(szName,(LPCSTR)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,0)); -} - - -void getContactName(HANDLE hContact, LPSTR szName) { - if ( bCoreUnicode ) wcscpy((LPWSTR)szName,(LPWSTR)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,GSMDF_UNICODE)); - else getContactNameA(hContact, szName); -} - - -void getContactUinA(HANDLE hContact, LPSTR szUIN) { - - *szUIN = 0; - - pSupPro ptr = getSupPro(hContact); - if (!ptr) return; - - DBVARIANT dbv_uniqueid; - LPSTR uID = (LPSTR) CallProtoService(ptr->name, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); - if ( uID==(LPSTR)CALLSERVICE_NOTFOUND ) uID = 0; // Billy_Bons - if ( uID && DBGetContactSetting(hContact, ptr->name, uID, &dbv_uniqueid)==0 ) { - if (dbv_uniqueid.type == DBVT_WORD) - sprintf(szUIN, "%u [%s]", dbv_uniqueid.wVal, ptr->name); - else - if (dbv_uniqueid.type == DBVT_DWORD) - sprintf(szUIN, "%u [%s]", (UINT)dbv_uniqueid.dVal, ptr->name); - else - if (dbv_uniqueid.type == DBVT_BLOB) - sprintf(szUIN, "%s [%s]", dbv_uniqueid.pbVal, ptr->name); - else - sprintf(szUIN, "%s [%s]", dbv_uniqueid.pszVal, ptr->name); - } - else { - strcpy(szUIN, "=== unknown ==="); - } - DBFreeVariant(&dbv_uniqueid); -} - - -void getContactUin(HANDLE hContact, LPSTR szUIN) { - getContactUinA(hContact, szUIN); - if ( bCoreUnicode && *szUIN ) { - LPWSTR tmp = mir_a2u(szUIN); - wcscpy((LPWSTR)szUIN, tmp); - mir_free(tmp); - } -} - - -// EOF diff --git a/plugins/SecureIM/crypt_metacontacts.cpp b/plugins/SecureIM/crypt_metacontacts.cpp deleted file mode 100644 index f36c7e4dd3..0000000000 --- a/plugins/SecureIM/crypt_metacontacts.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include "commonheaders.h" - - -BOOL isProtoMetaContacts(HANDLE hContact) { - if(bMetaContacts) { - LPSTR proto = (LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if ( proto && strcmp(proto,"MetaContacts")==0 ) { - return true; - } - } -// for(int j=0;jinspecting) -// return strstr(clist[j].proto->name,"MetaContacts")!=NULL; - return false; -} - - -BOOL isDefaultSubContact(HANDLE hContact) { - - if(bMetaContacts) { - return (HANDLE)CallService(MS_MC_GETDEFAULTCONTACT,(WPARAM)CallService(MS_MC_GETMETACONTACT,(WPARAM)hContact,0),0)==hContact; - } - return false; -} - - -HANDLE getMetaContact(HANDLE hContact) { - - if(bMetaContacts) { - return (HANDLE)CallService(MS_MC_GETMETACONTACT,(WPARAM)hContact,0); - } - return 0; -} - - -HANDLE getMostOnline(HANDLE hContact) { - - if(bMetaContacts) { - return (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT,(WPARAM)hContact,0); - } - return 0; -} - - -// remove all secureim connections on subcontacts -void DeinitMetaContact(HANDLE hContact) { - - HANDLE hMetaContact = isProtoMetaContacts(hContact) ? hContact : getMetaContact(hContact); - - if ( hMetaContact ) { - for(int i=0;ihEvent, INFINITE ); - - Sleep( 100 ); - if ( tParam->msg == NULL ) - SendBroadcast( tParam->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, ( HANDLE )tParam->id, 0 ); - else - SendBroadcast( tParam->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, ( HANDLE )tParam->id, LPARAM( tParam->msg )); - - CloseHandle( tParam->hEvent ); - delete tParam; - - return 0; -} - - -unsigned __stdcall sttWaitForExchange( LPVOID param ) { - - TWaitForExchange* tParam = ( TWaitForExchange* )param; - WaitForSingleObject( tParam->hEvent, INFINITE ); - - pUinKey ptr = getUinKey(tParam->hContact); - delete tParam; - - if ( !ptr ) return 0; - - for(int i=0;iwaitForExchange != 1 ) break; - } // for - -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("sttWaitForExchange: %d",ptr->waitForExchange); -#endif - // if keyexchange failed or timeout - if ( ptr->waitForExchange==1 || ptr->waitForExchange==3 ) { // Їа®вге«® - ®вЇа ў«пҐ¬ ­Ґ§ иЁда®ў ­­®, Ґб«Ё ­ ¤® - if ( ptr->msgQueue && msgbox1(0,sim104,szModuleName,MB_YESNO|MB_ICONQUESTION)==IDYES ) { - EnterCriticalSection(&localQueueMutex); - ptr->sendQueue = true; - pWM ptrMessage = ptr->msgQueue; - while( ptrMessage ) { -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("Sent (unencrypted) message from queue: %s",ptrMessage->Message); -#endif - // send unencrypted messages - CallContactService(ptr->hContact,PSS_MESSAGE,(WPARAM)ptrMessage->wParam|PREF_METANODB,(LPARAM)ptrMessage->Message); - mir_free(ptrMessage->Message); - pWM tmp = ptrMessage; - ptrMessage = ptrMessage->nextMessage; - mir_free(tmp); - } - ptr->msgQueue = NULL; - ptr->sendQueue = false; - LeaveCriticalSection(&localQueueMutex); - } - ptr->waitForExchange = 0; - ShowStatusIconNotify(ptr->hContact); - } - else - if ( ptr->waitForExchange==2 ) { // ¤®б« вм ®зҐаҐ¤м зҐаҐ§ гбв ­®ў«Ґ­­®Ґ ᮥ¤Ё­Ґ­ЁҐ - EnterCriticalSection(&localQueueMutex); - // we need to resend last send back message with new crypto Key - pWM ptrMessage = ptr->msgQueue; - while (ptrMessage) { -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("Sent (encrypted) message from queue: %s",ptrMessage->Message); -#endif - // send unencrypted messages - CallContactService(ptr->hContact,PSS_MESSAGE,(WPARAM)ptrMessage->wParam|PREF_METANODB,(LPARAM)ptrMessage->Message); - mir_free(ptrMessage->Message); - pWM tmp = ptrMessage; - ptrMessage = ptrMessage->nextMessage; - mir_free(tmp); - } - ptr->msgQueue = NULL; - ptr->waitForExchange = 0; - LeaveCriticalSection(&localQueueMutex); - } - else - if ( ptr->waitForExchange==0 ) { // ®зЁбвЁвм ®зҐаҐ¤м - EnterCriticalSection(&localQueueMutex); - // we need to resend last send back message with new crypto Key - pWM ptrMessage = ptr->msgQueue; - while (ptrMessage) { - mir_free(ptrMessage->Message); - pWM tmp = ptrMessage; - ptrMessage = ptrMessage->nextMessage; - mir_free(tmp); - } - ptr->msgQueue = NULL; - LeaveCriticalSection(&localQueueMutex); - } - return 0; -} - - -// set wait flag and run thread -void waitForExchange(pUinKey ptr, int flag) { - switch( flag ) { - case 0: // бЎа®бЁвм - case 2: // ¤®б« вм иЁда®ў ­® - case 3: // ¤®б« вм ­ҐиЁда®ў ­® - if ( ptr->waitForExchange ) - ptr->waitForExchange = flag; - break; - case 1: // § ЇгбвЁвм - if ( ptr->waitForExchange ) - break; - ptr->waitForExchange = 1; - // § ЇгбЄ Ґ¬ ван¤ - HANDLE hEvent = CreateEvent( NULL, TRUE, FALSE, NULL ); - unsigned int tID; - CloseHandle( (HANDLE) _beginthreadex(NULL, 0, sttWaitForExchange, new TWaitForExchange(hEvent,ptr->hContact), 0, &tID)); - SetEvent( hEvent ); - break; - } -} - - -// EOF diff --git a/plugins/SecureIM/crypt_popups.cpp b/plugins/SecureIM/crypt_popups.cpp deleted file mode 100644 index 836a68efc1..0000000000 --- a/plugins/SecureIM/crypt_popups.cpp +++ /dev/null @@ -1,153 +0,0 @@ -#include "commonheaders.h" - -/* -static int CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - switch(message) { - case WM_COMMAND: - if (wParam == STN_CLICKED) { // It was a click on the Popup. - PUDeletePopUp(hWnd); - return TRUE; - } - break; - case UM_FREEPLUGINDATA: { - return TRUE; //TRUE or FALSE is the same, it gets ignored. - } - default: - break; - } - return DefWindowProc(hWnd, message, wParam, lParam); -} -*/ - -void showPopUp(LPCSTR lpzText,HANDLE hContact,HICON hIcon, UINT type) { - //type=0 key colors - //type=1 session colors - //type=2 SR colors - - if (!bPopupExists) return; - - //hContact = A_VALID_HANDLE_YOU_GOT_FROM_SOMEWHERE; - COLORREF colorBackKey = RGB(230,230,255); - COLORREF colorTextKey = RGB(0,0,0); - COLORREF colorBackSec = RGB(255,255,200); - COLORREF colorTextSec = RGB(0,0,0); - COLORREF colorBackSR = RGB(200,255,200); - COLORREF colorTextSR = RGB(0,0,0); - COLORREF colorBack = 0; - COLORREF colorText = 0; - int timeout=0; - int res; - - DBVARIANT dbv_timeout; - - if (type==0) { - colorBack=DBGetContactSettingDword(0,szModuleName,"colorKeyb",(UINT)-1); - colorText=DBGetContactSettingDword(0,szModuleName,"colorKeyt",(UINT)-1); - if (colorBack==(UINT)-1) colorBack=colorBackKey; - if (colorText==(UINT)-1) colorText=colorTextKey; - - res=DBGetContactSetting(0,szModuleName,"timeoutKey",&dbv_timeout); - if (res==0) timeout=atoi(dbv_timeout.pszVal); - DBFreeVariant(&dbv_timeout); - } - else if (type==1) { - colorBack=DBGetContactSettingDword(0,szModuleName,"colorSecb",(UINT)-1); - colorText=DBGetContactSettingDword(0,szModuleName,"colorSect",(UINT)-1); - if (colorBack==(UINT)-1) colorBack=colorBackSec; - if (colorText==(UINT)-1) colorText=colorTextSec; - - res=DBGetContactSetting(0,szModuleName,"timeoutSec",&dbv_timeout); - if (res==0) timeout=atoi(dbv_timeout.pszVal); - DBFreeVariant(&dbv_timeout); - } - else if (type>=2) { - colorBack=DBGetContactSettingDword(0, szModuleName, "colorSRb", (UINT)-1); - colorText=DBGetContactSettingDword(0, szModuleName, "colorSRt", (UINT)-1); - if (colorBack==(UINT)-1) colorBack=colorBackSR; - if (colorText==(UINT)-1) colorText=colorTextSR; - - res=DBGetContactSetting(0,szModuleName,"timeoutSR",&dbv_timeout); - if (res==0) timeout=atoi(dbv_timeout.pszVal); - DBFreeVariant(&dbv_timeout); - } - - if ( bCoreUnicode && bPopupUnicode ) { - POPUPDATAW ppd = {0}; - - ppd.lchContact = hContact; //Be sure to use a GOOD handle, since this will not be checked. - ppd.lchIcon = hIcon; - LPWSTR lpwzContactName = (LPWSTR)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,GSMDF_UNICODE); - wcscpy(ppd.lpwzContactName, lpwzContactName); - LPWSTR lpwzText = mir_a2u(lpzText); - wcscpy(ppd.lpwzText, TranslateW(lpwzText)); - mir_free(lpwzText); - ppd.colorBack = colorBack; - ppd.colorText = colorText; - ppd.iSeconds = timeout; -// ppd.PluginWindowProc = (WNDPROC)PopupDlgProc; - - //Now that the plugin data has been filled, we add it to the PopUpData. -// ppd.PluginData = NULL; - - //Now that every field has been filled, we want to see the popup. - PUAddPopUpW(&ppd); - } - else { - POPUPDATAEX ppd = {0}; - - ppd.lchContact = hContact; //Be sure to use a GOOD handle, since this will not be checked. - ppd.lchIcon = hIcon; - LPSTR lpzContactName = (LPSTR)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,0); - strcpy(ppd.lpzContactName, lpzContactName); - strcpy(ppd.lpzText, Translate(lpzText)); - ppd.colorBack = colorBack; - ppd.colorText = colorText; - ppd.iSeconds = timeout; -// ppd.PluginWindowProc = (WNDPROC)PopupDlgProc; - - //Now that the plugin data has been filled, we add it to the PopUpData. -// ppd.PluginData = NULL; - - //Now that every field has been filled, we want to see the popup. - PUAddPopUpEx(&ppd); - } -} - - -void showPopUpDCmsg(HANDLE hContact,LPCSTR msg) { - int indic=DBGetContactSettingByte(0, szModuleName, "dc",1); - if (indic==1) showPopUp(msg,hContact,g_hPOP[POP_PU_DIS],1); -} -void showPopUpDC(HANDLE hContact) { - int indic=DBGetContactSettingByte(0, szModuleName, "dc",1); - if (indic==1) showPopUp(sim006,hContact,g_hPOP[POP_PU_DIS],1); -} -void showPopUpEC(HANDLE hContact) { - int indic=DBGetContactSettingByte(0, szModuleName, "ec",1); - if (indic==1) showPopUp(sim001,hContact,g_hPOP[POP_PU_EST],1); -} -void showPopUpKS(HANDLE hContact) { - int indic=DBGetContactSettingByte(0, szModuleName, "ks",1); - if (indic==1) showPopUp(sim007,hContact,g_hPOP[POP_PU_PRC],0); -} -void showPopUpKRmsg(HANDLE hContact,LPCSTR msg) { - int indic=DBGetContactSettingByte(0, szModuleName, "kr",1); - if (indic==1) showPopUp(msg,hContact,g_hPOP[POP_PU_PRC],0); -} -void showPopUpKR(HANDLE hContact) { - int indic=DBGetContactSettingByte(0, szModuleName, "kr",1); - if (indic==1) showPopUp(sim008,hContact,g_hPOP[POP_PU_PRC],0); -} -void showPopUpSM(HANDLE hContact) { - int indic=DBGetContactSettingByte(0, szModuleName, "ss",0); - if (indic==1) showPopUp(sim009,hContact,g_hPOP[POP_PU_MSS],2); - SkinPlaySound("OutgoingSecureMessage"); -} -void showPopUpRM(HANDLE hContact) { - int indic=DBGetContactSettingByte(0, szModuleName, "sr",0); - if (indic==1) showPopUp(sim010,hContact,g_hPOP[POP_PU_MSR],2); - SkinPlaySound("IncomingSecureMessage"); -} - - -// EOF diff --git a/plugins/SecureIM/cryptopp.h b/plugins/SecureIM/cryptopp.h deleted file mode 100644 index bfa4e097b3..0000000000 --- a/plugins/SecureIM/cryptopp.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef __CRYPTOPP_H__ -#define __CRYPTOPP_H__ - -#define CPP_FEATURES_UTF8 0x01 -#define CPP_FEATURES_BASE64 0x02 -#define CPP_FEATURES_GZIP 0x04 -#define CPP_FEATURES_CRC32 0x08 -#define CPP_FEATURES_PSK 0x10 -#define CPP_FEATURES_NEWPG 0x20 -#define CPP_FEATURES_RSA 0x40 - -#define CPP_MODE_BASE16 0x0000 -#define CPP_MODE_BASE64 0x0001 -#define CPP_MODE_PGP 0x0002 -#define CPP_MODE_GPG 0x0004 -#define CPP_MODE_GPG_ANSI 0x0008 -#define CPP_MODE_PRIV_KEY 0x0010 -#define CPP_MODE_RSA_2048 0x0020 -#define CPP_MODE_RSA_4096 0x0040 -#define CPP_MODE_RSA CPP_MODE_RSA_4096 -#define CPP_MODE_RSA_ONLY 0x0080 -#define CPP_MODE_RSA_ZLIB 0x0100 -#define CPP_MODE_RSA_BER 0x0200 - -#define CPP_ERROR_NONE 0 -#define CPP_ERROR_SEH 1 -#define CPP_ERROR_NO_KEYA 2 -#define CPP_ERROR_NO_KEYB 3 -#define CPP_ERROR_NO_KEYX 4 -#define CPP_ERROR_BAD_LEN 5 -#define CPP_ERROR_BAD_CRC 6 -#define CPP_ERROR_NO_PSK 7 -#define CPP_ERROR_BAD_PSK 8 -#define CPP_ERROR_BAD_KEYB 9 -#define CPP_ERROR_NO_PGP_KEY 10 - -typedef struct { - int (__cdecl *rsa_gen_keypair)(short); // генерит RSA-ключи для указанной длины (либо тока 2048, либо 2048 и 4096) - int (__cdecl *rsa_get_keypair)(short,PBYTE,int*,PBYTE,int*); // возвращает пару ключей для указанной длины - int (__cdecl *rsa_get_keyhash)(short,PBYTE,int*,PBYTE,int*); // возвращает hash пары ключей для указанной длины - int (__cdecl *rsa_set_keypair)(short,PBYTE,int); // устанавливает ключи, указанной длины - int (__cdecl *rsa_get_pubkey)(HANDLE,PBYTE,int*); // возвращает паблик ключ из указанного контекста - int (__cdecl *rsa_set_pubkey)(HANDLE,PBYTE,int); // загружает паблик ключ для указанного контекста - void (__cdecl *rsa_set_timeout)(int); // установить таймаут для установки секюрного соединения - int (__cdecl *rsa_get_state)(HANDLE); // получить статус указанного контекста - int (__cdecl *rsa_get_hash)(PBYTE,int,PBYTE,int*); // вычисляет SHA1(key) - int (__cdecl *rsa_connect)(HANDLE); // запускает процесс установки содинения с указанным контекстом - int (__cdecl *rsa_disconnect)(HANDLE); // разрывает соединение с указанным контекстом - int (__cdecl *rsa_disabled)(HANDLE); // разрывает соединение по причине "disabled" - LPSTR (__cdecl *rsa_recv)(HANDLE,LPCSTR); // необходимо передавать сюда все входящие протокольные сообщения - int (__cdecl *rsa_send)(HANDLE,LPCSTR); // вызываем для отправки сообщения клиенту - int (__cdecl *rsa_encrypt_file)(HANDLE,LPCSTR,LPCSTR); - int (__cdecl *rsa_decrypt_file)(HANDLE,LPCSTR,LPCSTR); - LPSTR (__cdecl *utf8encode)(LPCWSTR); - LPWSTR (__cdecl *utf8decode)(LPCSTR); - int (__cdecl *is_7bit_string)(LPCSTR); - int (__cdecl *is_utf8_string)(LPCSTR); - int (__cdecl *rsa_export_keypair)(short,LPSTR,LPSTR,LPSTR); // export private key - int (__cdecl *rsa_import_keypair)(short,LPSTR,LPSTR); // import & activate private key - int (__cdecl *rsa_export_pubkey)(HANDLE,LPSTR); // export public key from context - int (__cdecl *rsa_import_pubkey)(HANDLE,LPSTR); // import public key into context -} RSA_EXPORT; -typedef RSA_EXPORT* pRSA_EXPORT; - -typedef struct { - int (__cdecl *rsa_inject)(HANDLE,LPCSTR); // вставляет сообщение в очередь на отправку - int (__cdecl *rsa_check_pub)(HANDLE,PBYTE,int,PBYTE,int); // проверяет интерактивно SHA и сохраняет ключ, если все нормально - void (__cdecl *rsa_notify)(HANDLE,int); // нотификация о смене состояния -} RSA_IMPORT; -typedef RSA_IMPORT* pRSA_IMPORT; - - -#endif diff --git a/plugins/SecureIM/dbevent.cpp b/plugins/SecureIM/dbevent.cpp deleted file mode 100644 index 9b7d8f10c0..0000000000 --- a/plugins/SecureIM/dbevent.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "commonheaders.h" - - -void HistoryLog(HANDLE hContact, LPCSTR szText) { - - DBEVENTINFO dbei; - memset(&dbei, 0, sizeof(dbei)); - - dbei.cbSize = sizeof(dbei); - dbei.szModule = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - dbei.flags = DBEF_SENT|DBEF_READ; - dbei.timestamp = time(NULL); - dbei.eventType = EVENTTYPE_MESSAGE; - dbei.cbBlob = (int)strlen(szText) + 1; - dbei.pBlob = (PBYTE)szText; - - CallService(MS_DB_EVENT_ADD, (WPARAM)0, (LPARAM)&dbei); -} - - -// EOF diff --git a/plugins/SecureIM/dbevent.h b/plugins/SecureIM/dbevent.h deleted file mode 100644 index 68719c21c0..0000000000 --- a/plugins/SecureIM/dbevent.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __DBEVENT_H__ -#define __DBEVENT_H__ - -#include - -void HistoryLog(HANDLE,LPCSTR); - -#endif diff --git a/plugins/SecureIM/docs/!whatsnew.txt b/plugins/SecureIM/docs/!whatsnew.txt new file mode 100644 index 0000000000..eeb792d864 --- /dev/null +++ b/plugins/SecureIM/docs/!whatsnew.txt @@ -0,0 +1,595 @@ + +Verison 1.0.12.4 [28-04-2010] + +[*] fix bug with advanced icon set to "NONE" && enable extaicons plugin + + +Verison 1.0.12.3 [18-05-2009] + +[*] fixed crash on filetransfer +[*] advanced messages for replaced RSA keys +[+] show SHA1 for all public keys +[*] new format private key +[+] export/import public keys +[+] export/import my private key + + +Verison 1.0.12.2 [07-05-2009] + +[*] some memory leak fixed +[*] some security fixes +[+] use KeyExchangeTimeout for RSA/AES keyexchange +[+] show RSA Public key flag in Options dialog +[+] reset RSA public key for contact +[+] copy SHA1 of my RSA public key to Clipboard +[*] context menu on RClick in columns "Mode","Status","-" + + +Verison 1.0.12.1 [04-05-2009] + +[*] native mode fixes +[+] add support for folders plugin +[+] auto switch to RSA/AES mode, if possible +[+] _Filter sequence fixed (last in sent & first in recv) +[+] GPG temp path + + +Verison 1.0.12.0 [28-04-2009] + +[*] rewrite icons library +[+] add support for extraicon plugin +[+] RSA/AES Secure File Transfer +[+] mode in context menu + + +Verison 1.0.11.4 [22-04-2009] + +[*] patch from Billy_Bons + + +Verison 1.0.11.3 [22-04-2009] + +[+] option "Disabled" for RSA/AES +[+] change status to "Disabled" for "Disabled" on other side + + +Verison 1.0.11.2 [21-04-2009] + +[+] option "Not secured for NotOnList" +[+] auto switch mode to RSA/AES and to Native on message type +[+] auto accept RSA key +[+] auto established RSA/AES connection ("Always if Possible" flag) + + +Verison 1.0.11.1 [20-04-2009] + +[*] compile with new Miranda headers +[*] fix metacontacts handling + + +Verison 1.0.11.0 [08-08-2008] + +[*] some code rewrite +[*] fix UTF8 in PGP/GPG messages +[+] split long messages (per protocol) +[+] new encryption algorithm RSA/AES +[*] rewrite handling metacontacts + + +Verison 1.0.10.8 [09-04-2008] + +[*] fix store subcontact history in metacontacts (only with today meta svn) + + +Verison 1.0.10.7 [19-01-2008] + +[*] change select contact list icon slot + + +Verison 1.0.10.6 [24-12-2007] + +[*] some code rewrite + + +Verison 1.0.10.5 [24-12-2007] + +[*] fix Load/Unload keys for PGP/GPG + + +Verison 1.0.10.4 [21-12-2007] + +[*] fix double UTF8 encoding in PGP/GPG messages +[*] applied patch from Garthower (MetaContacts & IRC protocol) + + +Verison 1.0.10.3 [15-09-2007] + +[*] change work with metacontacts (to work need disable sync subcontact history with metacontact) +[*] fix secure filesend over metacontact +[+] new features in options dialog +[*] unicode fix SetPSK dialog +[*] change memory allocation functions + + +Verison 1.0.10.2 [19-06-2007] + +[*] fix PREF_UTF flag in messages (new bug) + + +Verison 1.0.10.1 [08-06-2007] + +[*] fix PREF_UTF flag in messages + + +Verison 1.0.9.37 [04-04-2007] + +[*] remove internal SecureIM messages from MetaContacts history + + +Verison 1.0.9.36 [02-04-2007] + +[*] fix Established Secure Connection over RTF (in MRA) +[*] disable icon && menus for non-secured protocols +[*] hide GPG menu items for no-secured protocols + + +Verison 1.0.9.35 [14-03-2007] + +[*] add PluginInfoEx support + + +Verison 1.0.9.34 [28-02-2007] + +[*] fix for Secure File Transfer + + +Verison 1.0.9.33 [26-02-2007] + +[*] file encryption from RO FS fixed + + +Verison 1.0.9.32 [25-02-2007] + +[*] some PGP+GPG fixes +[+] option "save GPG passphrases" (saved on exit) + + +Verison 1.0.9.31 [22-02-2007] + +[*] fix VC71 project +[*] PGP & GPG can worked anytime +[+] options 'disable' CList icon + + +Verison 1.0.9.30 [12-01-2007] + +[*] hide SecureIM icon in TabSRMM for ChatRoom +[+] add unicode support in Options Dialog + + +Verison 1.0.9.29 [10-01-2007] + +[+] support Unicode in Popups +[*] fixed Metacontact icon in TabSRMM + + +Verison 1.0.9.28 + +[*] internal build + + +Verison 1.0.9.27 + +[*] internal build + + +Verison 1.0.9.26 + +[*] GPG fixes + + +Verison 1.0.9.25 + +[*] GPG fixes + + +Verison 1.0.9.24 + +[*] support ANSI codepage for GPG + + +Verison 1.0.9.23 + +[*] GPG bugfixes + + +Verison 1.0.9.22 + +[*] more GPG fixes + + +Verison 1.0.9.21 + +[+] add option "Log to file" on GPG tab +[*] small fixes + + +Verison 1.0.9.20 + +[*] GPG fixes + + +Verison 1.0.9.19 + +[*] add secureim_icons.dll in installpack + + +Verison 1.0.9.18 + +[*] small fixes + + +Verison 1.0.9.17 + +[+] add decode incoming RTF messages +[+] add GnuPG support + + +Verison 1.0.9.16 + +[*] fixed language in IcoLib support + + +Verison 1.0.9.15 + +[*] fixed show not-32bit icons +[*] fixed IcoLib support + + +Verison 1.0.9.14 + +[*] resend unencrypted messages fixed + + +Verison 1.0.9.13 + +[+] add IcoLib support + + +Verison 1.0.9.12 + +[*] fixed filetransfer + + +Verison 1.0.9.11 + +[+] split SecureIM & IconPack in different modules + + +Verison 1.0.9.10 + +[*] fixed "Status in context menu" + + +Verison 1.0.9.9 + +[+] option "Always secured if possible" (need ICQ.dll from SSS on both side) +[*] fixed send unencrypted messages, if connection not established +[*] on default PGP is disabled +[*] some fixes + + +Verison 1.0.9.8 + +[*] fix use black background color on popups + + +Verison 1.0.9.7 + +[+] rename received files (file.dll, file (1).dll, ...) +[+] increment encrypted filename (file.AESHELL0, file.AESHELL1, ...) for send one file to multiple contacts + + +Verison 1.0.9.6 + +[+] add ChatRoom checking + + +Verison 1.0.9.5 + +[*] fix autoload keyrings on PGP6 + + +Verison 1.0.9.4 + +[*] fix remove PGPprivkey +[*] fix add new contact +[+] add PopUp plugin detection +[+] rebuild function for work with lists +[*] some fixes + + +Verison 1.0.9.3 + +[+] option "Disable PGP" +[+] option "Disable keyring use" +[+] pgp encryption working without installed PGP, only with PGP SDK dlls +[*] check "MirVer" fixed + +Verison 1.0.9.3 + +[*] internal build + + +Verison 1.0.9.1 + +[+] PGP v8 are supported (PGP v7 not tested, PGP v9 - NOT supported) +[+] save sort order in options dialog +[*] some fixes + + +Verison 1.0.8.4 + +[*] show icon on CList on Load & Unload PGP keys (you will get "Load PGP KeyID" contact menu item ONLY if you have pre-installed PGP 6) + + +Verison 1.0.8.3 + +[*] some fixes + + +Verison 1.0.8.2 + +[+] support for PGP SDK 658 (new menuitem "Load PGP KeyID" | "Unload PGP KeyID") + + +Verison 1.0.8.1 + +[+] work's on icons ;-) +[+] some fixes + + +Verison 1.0.8.0 + +[+] new parameters "p" and "g" in DH keyexchange +[*] disable keyexchange with invisible contacts ;-) + + +Verison 1.0.7.10 + +[*] change SecureIM status from context menu (suport for CList_classic) +[+] add sort in SecureIM options dialog by clicking on column header + + +Verison 1.0.7.9 + +[+] "Offline Key Timeout" +[+] "Disable encryption for game plugins" +[*] change icons :-) + + +Verison 1.0.7.8 + +[*] bugfixes for "Secure Offline Messages" +[+] change SecureIM status from context menu (not worked in CList_classic) + + +Verison 1.0.7.7 + +[*] PSK dialog fixed + + +Verison 1.0.7.6 + +[+] remake "SecureIM Translate.txt" +[*] more fixes + + +Verison 1.0.7.5 + +[*] more fixes + + +Verison 1.0.7.4 + +[+] add updater support for Crypto++ + + +Verison 1.0.7.3 + +[+] add combine splitted messages (WinPopup proto etc...) + + +Verison 1.0.7.2 + +[+] add pre-shared keys for Diffie-Hellman key exchange + + +Verison 1.0.7.1 + +[+] UTF8 encoding moved to Crypto++ +[*] more fixes + + +Verison 1.0.6.5 + +[+] check version of cryptopp.dll +[*] fixed "always try" + + +Verison 1.0.6.4 + +[+] add compress long messages (GZip), need update Crypto++ +[*] more fixes + + +Verison 1.0.6.3 + +[*] rewrite SecureRecvMsg and SecureSendMsg + + +Verison 1.0.6.2 + +[*] rewrite SecureFileTransfer, worked in ICQ,Jabber,MSN + + +Verison 1.0.6.1 + +[+] split crypto engenie and miranda plugin... + + +Version 1.0.5.23 + +[*] some fixes + + +Version 1.0.5.22 + +[*] some fixes + + +Version 1.0.5.21 + +[+] add options "Show a popup on established connection" and "Show a popup on disabled connection" + + +Version 1.0.5.20 + +[*] rebuild in static mode + + +Version 1.0.5.19 + +[*] more fixes + + +Version 1.0.5.18 + +[+] selection of protocols added + + +Version 1.0.5.17 + +[*] fixed break event chain ME_CLIST_EXTRA_LIST_REBUILD & ME_CLIST_EXTRA_IMAGE_APPLY + + +Version 1.0.5.16 + +[+] add SecureIM handover on MetaContacts +[+] Updater plugin support + + +Version 1.0.5.15 + +[+] MetaContacts removed from options list +[+] add support for MetaContacts +[*] any cosmetic fixes + + +Version 1.0.5.14 + +[+] option "Miranda Client Detection" - check or not client ICQ version (Miranda) +[*] any cosmetic fixes + + +Version 1.0.5.13 + +[*] continue of x-status bugfixes + + +Version 1.0.5.12 + +[*] bug with show x-status icon on icq status bar clist_nicer++ fixed + + +Version 1.0.5.11 + +[*] plugin version info fixed +[*] the key exchange timeout limited by 65535 seconds value +[*] more fixes + + +Version 1.0.5.10 + +[+] build with msvcr71.dll +[+] use crypto++ 5.2.3 +[*] more fixes + + +Version 1.0.5.8 + +[*] rewrite options dialog, work "Apply" button ;-) +[*] offline key timeout only for send message +[*] send encrypted offline message if enable flag "Secure Offline Message" and SecureIM status on contact is "Always Try" +[+] support for IRC protocol + + +Version 1.0.5.7 + +[*] rewrite more code +[*] the key exchange timeout limited by 9999 seconds value. +[+] offline key timeout (2 day) + + +Version 1.0.5.5 + +[*] plugin check client ICQ version (Miranda,ICQ,QIP,&RQ,...) + + +Version 1.0.5.4c + +[*] build in VS 6.0 +[*] miranda memory allocation + + +Version 1.0.5.4 + +[*] rewrite more code +[*] the key exchange timeout limited by 999999999 ms value. + + +Version 1.0.5.3b + +[*] fix message size detection + + +Version 1.0.5.3 + +[*] rewrite options dialog and any function +[+] automatic detect maximum length of message +[*] always send encrypted offline message if enable flag "Secure Offline Message" and SecureIM status on contact NOT "Disabled" + + +Version 1.0.5.1a + +[*] "always try" work fine +[-] remove indicator from NickName +[+] base64 encode +[*] rewite hexconverter +[+] selective adv1 or adv2 icon +[+] truecolor icons +[+] feature "always show icons" + + +Version 1.0.5.0a + +[+] unicode support (thanks Nightwish) +[+] triggered menu (thanks Ghost) +[-] remove SecureIM Protocols menu (thanks George Hazan) +[*] change icons (thanks Faith Healer) +[+] backward compatible (unicode only with new version SecureIM) +[+] fix any small bags + + +Version 1.0.4.6c + +[+] apply all __alex SEH + + +Version 1.0.4.6 + +[+] crypto++ 5.2 +[+] adv2 icon in CList +[+] support tabSRMM icon +[+] apply patches of __alex + diff --git a/plugins/SecureIM/docs/secureim-translation.txt b/plugins/SecureIM/docs/secureim-translation.txt new file mode 100644 index 0000000000..1242476fc9 --- /dev/null +++ b/plugins/SecureIM/docs/secureim-translation.txt @@ -0,0 +1,106 @@ +; Common strings that belong to many files +;[] + +; ../../plugins/SecureIM/main.cpp +;[Incoming Secure Message] +;[Outgoing Secure Message] +;[SecureIM [GPG]] +;[SecureIM [Native]] +;[SecureIM [PGP]] +;[SecureIM [RSA/AES]] +;[SecureIM status] + +; ../../plugins/SecureIM/options.cpp +;[Services] + +; ../../plugins/SecureIM/popupOptions.cpp +;[Popups] + +; ../../plugins/SecureIM/resource.rc +;[&Copy SHA1] +;[&Export] +;[&Import] +;[0 = Default PopUp Timeout Value] +;[Always Try to Establish Secure IM] +;[Always secured if possible] +;[Always show status icons in contact list] +;[Auto accept RSA key (NOT SECURED)] +;[Back] +;[Basic] +;[Cancel] +;[Context Menu only for \"Miranda\" clients] +;[Debug] +;[Delete key] +;[Delete pre-shared key] +;[Delete public key] +;[Disable encryption for game plugins] +;[Disable keyrings use] +;[E&xport] +;[Enable Secure File Transfer] +;[Enable Secure Offline messages] +;[Enter passphrase for the secret key:] +;[Events] +;[Executable:] +;[Export key] +;[Export public key] +;[GPG] +;[GPG SecureIM] +;[Home Directory:] +;[Import key] +;[Import public key] +;[Key Assignment] +;[Key Exchange Timeout :] +;[Key agreement colors] +;[Load &Private key] +;[Log to File] +;[Mode] +;[Mode in Context Menu] +;[Native SecureIM] +;[Not secured for NotOnList] +;[OK] +;[Offline Key Timeout :] +;[Offline:] +;[Ok] +;[Online:] +;[PGP] +;[PGP SecureIM] +;[Password:] +;[Please type in your password] +;[PopUp Timeout] +;[Pre-shared key] +;[Preview] +;[Private] +;[Protocols] +;[Public] +;[Public key] +;[RSA Key] +;[RSA SecureIM] +;[RSA/AES SecureIM] +;[Reset All] +;[SHA1:] +;[Save Pass] +;[Secure IM Disabled] +;[Secure IM Enabled] +;[Secure connection colors] +;[SecureIM PopUp Colors] +;[SecureIM plugin Passphrase of private key] +;[Send/Receive encrypted colors] +;[Set &keyrings...] +;[Set key] +;[Set pre-shared key] +;[Show a popup on disabled connection] +;[Show a popup on each secure receive] +;[Show a popup on each secure send] +;[Show a popup on established connection] +;[Show a popup on key received] +;[Show a popup on key send] +;[Split Messages] +;[Status] +;[Status in Context Menu] +;[Temp Dir:] +;[Text] +;[Time in Seconds] +;[User List] +;[Username:] +;[days] +;[sec] diff --git a/plugins/SecureIM/gettime.cpp b/plugins/SecureIM/gettime.cpp deleted file mode 100644 index 529a8e0c8e..0000000000 --- a/plugins/SecureIM/gettime.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "commonheaders.h" - - -/* FILETIME unit is 100 nanoseconds */ -const static long div_100_nsec = 10000000; - -/* POSIX or Unix Epoch (1-Jan-1970 00:00) in FILETIME units */ -#ifdef _MSC_VER -const static ULONGLONG ix_epoch = 116444736000000000; -#else -const static ULONGLONG ix_epoch = 116444736000000000LL; -#endif - -DWORD gettime(void) { - - ULONGLONG diff_100_nsec; - union { - FILETIME f; - ULARGE_INTEGER u; - } now; - - GetSystemTimeAsFileTime( &now.f ); - - diff_100_nsec = now.u.QuadPart - ix_epoch; - - return (DWORD)( diff_100_nsec / div_100_nsec ); -} - -// EOF diff --git a/plugins/SecureIM/gettime.h b/plugins/SecureIM/gettime.h deleted file mode 100644 index e84276c609..0000000000 --- a/plugins/SecureIM/gettime.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __GETTIME_H__ -#define __GETTIME_H__ - -#include - -DWORD gettime(void); - -#endif diff --git a/plugins/SecureIM/icons/cl_dis.ico b/plugins/SecureIM/icons/cl_dis.ico deleted file mode 100644 index 53209bc652..0000000000 Binary files a/plugins/SecureIM/icons/cl_dis.ico and /dev/null differ diff --git a/plugins/SecureIM/icons/cl_est.ico b/plugins/SecureIM/icons/cl_est.ico deleted file mode 100644 index 8b42e2cb44..0000000000 Binary files a/plugins/SecureIM/icons/cl_est.ico and /dev/null differ diff --git a/plugins/SecureIM/icons/cm_dis.ico b/plugins/SecureIM/icons/cm_dis.ico deleted file mode 100644 index 53209bc652..0000000000 Binary files a/plugins/SecureIM/icons/cm_dis.ico and /dev/null differ diff --git a/plugins/SecureIM/icons/cm_est.ico b/plugins/SecureIM/icons/cm_est.ico deleted file mode 100644 index dd6f805868..0000000000 Binary files a/plugins/SecureIM/icons/cm_est.ico and /dev/null differ diff --git a/plugins/SecureIM/icons/mw_dis.ico b/plugins/SecureIM/icons/mw_dis.ico deleted file mode 100644 index 53209bc652..0000000000 Binary files a/plugins/SecureIM/icons/mw_dis.ico and /dev/null differ diff --git a/plugins/SecureIM/icons/mw_est.ico b/plugins/SecureIM/icons/mw_est.ico deleted file mode 100644 index 8b42e2cb44..0000000000 Binary files a/plugins/SecureIM/icons/mw_est.ico and /dev/null differ diff --git a/plugins/SecureIM/icons/ov_gpg.ico b/plugins/SecureIM/icons/ov_gpg.ico deleted file mode 100644 index d823cf83b6..0000000000 Binary files a/plugins/SecureIM/icons/ov_gpg.ico and /dev/null differ diff --git a/plugins/SecureIM/icons/ov_nat.ico b/plugins/SecureIM/icons/ov_nat.ico deleted file mode 100644 index 37000bd69b..0000000000 Binary files a/plugins/SecureIM/icons/ov_nat.ico and /dev/null differ diff --git a/plugins/SecureIM/icons/ov_pgp.ico b/plugins/SecureIM/icons/ov_pgp.ico deleted file mode 100644 index c365c48cde..0000000000 Binary files a/plugins/SecureIM/icons/ov_pgp.ico and /dev/null differ diff --git a/plugins/SecureIM/icons/ov_rsa.ico b/plugins/SecureIM/icons/ov_rsa.ico deleted file mode 100644 index a659463475..0000000000 Binary files a/plugins/SecureIM/icons/ov_rsa.ico and /dev/null differ diff --git a/plugins/SecureIM/icons/pu_dis.ico b/plugins/SecureIM/icons/pu_dis.ico deleted file mode 100644 index 53209bc652..0000000000 Binary files a/plugins/SecureIM/icons/pu_dis.ico and /dev/null differ diff --git a/plugins/SecureIM/icons/pu_est.ico b/plugins/SecureIM/icons/pu_est.ico deleted file mode 100644 index 8b42e2cb44..0000000000 Binary files a/plugins/SecureIM/icons/pu_est.ico and /dev/null differ diff --git a/plugins/SecureIM/icons/pu_msg.ico b/plugins/SecureIM/icons/pu_msg.ico deleted file mode 100644 index 5964ead2e1..0000000000 Binary files a/plugins/SecureIM/icons/pu_msg.ico and /dev/null differ diff --git a/plugins/SecureIM/icons/pu_prc.ico b/plugins/SecureIM/icons/pu_prc.ico deleted file mode 100644 index 822c55aeb7..0000000000 Binary files a/plugins/SecureIM/icons/pu_prc.ico and /dev/null differ diff --git a/plugins/SecureIM/icons/st_dis.ico b/plugins/SecureIM/icons/st_dis.ico deleted file mode 100644 index 16c5bcfa90..0000000000 Binary files a/plugins/SecureIM/icons/st_dis.ico and /dev/null differ diff --git a/plugins/SecureIM/icons/st_ena.ico b/plugins/SecureIM/icons/st_ena.ico deleted file mode 100644 index fa67cbd015..0000000000 Binary files a/plugins/SecureIM/icons/st_ena.ico and /dev/null differ diff --git a/plugins/SecureIM/icons/st_try.ico b/plugins/SecureIM/icons/st_try.ico deleted file mode 100644 index 9f4c6855aa..0000000000 Binary files a/plugins/SecureIM/icons/st_try.ico and /dev/null differ diff --git a/plugins/SecureIM/images.cpp b/plugins/SecureIM/images.cpp deleted file mode 100644 index eb4c87dea1..0000000000 --- a/plugins/SecureIM/images.cpp +++ /dev/null @@ -1,358 +0,0 @@ -#include "commonheaders.h" - - -void HalfBitmap32Alpha(HBITMAP hBitmap) -{ - BITMAP bmp; - DWORD dwLen; - BYTE *p; - int x, y; - - GetObject(hBitmap, sizeof(bmp), &bmp); - - if (bmp.bmBitsPixel != 32) - return; - - dwLen = bmp.bmWidth * bmp.bmHeight * (bmp.bmBitsPixel / 8); - p = (BYTE *)malloc(dwLen); - if (p == NULL) - return; - memset(p, 0, dwLen); - - GetBitmapBits(hBitmap, dwLen, p); - - for (y = 0; y < bmp.bmHeight; ++y) { - BYTE *px = p + bmp.bmWidth * 4 * y; - - for (x = 0; x < bmp.bmWidth; ++x) - { - px[3]>>=1; - px += 4; - } - } - - SetBitmapBits(hBitmap, dwLen, p); - - free(p); -} - - -// Make a bitmap all transparent, but only if it is a 32bpp -void MakeBmpTransparent(HBITMAP hBitmap) -{ - BITMAP bmp; - DWORD dwLen; - BYTE *p; - - GetObject(hBitmap, sizeof(bmp), &bmp); - - if (bmp.bmBitsPixel != 32) - return; - - dwLen = bmp.bmWidth * bmp.bmHeight * (bmp.bmBitsPixel / 8); - p = (BYTE *)malloc(dwLen); - if (p == NULL) - return; - - memset(p, 0, dwLen); - SetBitmapBits(hBitmap, dwLen, p); - - free(p); -} - - -// Correct alpha from bitmaps loaded without it (it cames with 0 and should be 255) -void CorrectBitmap32Alpha(HBITMAP hBitmap, BOOL force) -{ - BITMAP bmp; - DWORD dwLen; - BYTE *p; - int x, y; - BOOL fixIt; - - GetObject(hBitmap, sizeof(bmp), &bmp); - - if (bmp.bmBitsPixel != 32) - return; - - dwLen = bmp.bmWidth * bmp.bmHeight * (bmp.bmBitsPixel / 8); - p = (BYTE *)malloc(dwLen); - if (p == NULL) - return; - memset(p, 0, dwLen); - - GetBitmapBits(hBitmap, dwLen, p); - - fixIt = TRUE; - for (y = 0; fixIt && y < bmp.bmHeight; ++y) { - BYTE *px = p + bmp.bmWidth * 4 * y; - - for (x = 0; fixIt && x < bmp.bmWidth; ++x) - { - if (px[3] != 0 && !force) - { - fixIt = FALSE; - } - else - { - if (px[0] != 0 || px[1] != 0 || px[2] != 0) - px[3] = 255; - } - - px += 4; - } - } - - if (fixIt) - SetBitmapBits(hBitmap, dwLen, p); - - free(p); -} - - -HBITMAP CopyBitmapTo32(HBITMAP hBitmap) -{ - BITMAPINFO RGB32BitsBITMAPINFO; - BYTE * ptPixels; - HBITMAP hDirectBitmap; - - BITMAP bmp; - DWORD dwLen; - BYTE *p; - - GetObject(hBitmap, sizeof(bmp), &bmp); - - dwLen = bmp.bmWidth * bmp.bmHeight * 4; - p = (BYTE *)malloc(dwLen); - if (p == NULL) - return NULL; - - // Create bitmap - ZeroMemory(&RGB32BitsBITMAPINFO, sizeof(BITMAPINFO)); - RGB32BitsBITMAPINFO.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - RGB32BitsBITMAPINFO.bmiHeader.biWidth = bmp.bmWidth; - RGB32BitsBITMAPINFO.bmiHeader.biHeight = bmp.bmHeight; - RGB32BitsBITMAPINFO.bmiHeader.biPlanes = 1; - RGB32BitsBITMAPINFO.bmiHeader.biBitCount = 32; - - hDirectBitmap = CreateDIBSection(NULL, - (BITMAPINFO *)&RGB32BitsBITMAPINFO, - DIB_RGB_COLORS, - (void **)&ptPixels, - NULL, 0); - - // Copy data - if (bmp.bmBitsPixel != 32) - { - HDC hdcOrig, hdcDest; - HBITMAP oldOrig, oldDest; - - hdcOrig = CreateCompatibleDC(NULL); - oldOrig = (HBITMAP) SelectObject(hdcOrig, hBitmap); - - hdcDest = CreateCompatibleDC(NULL); - oldDest = (HBITMAP) SelectObject(hdcDest, hDirectBitmap); - - BitBlt(hdcDest, 0, 0, bmp.bmWidth, bmp.bmHeight, hdcOrig, 0, 0, SRCCOPY); - - SelectObject(hdcDest, oldDest); - DeleteObject(hdcDest); - SelectObject(hdcOrig, oldOrig); - DeleteObject(hdcOrig); - - // Set alpha - CorrectBitmap32Alpha(hDirectBitmap, FALSE); - } - else - { - GetBitmapBits(hBitmap, dwLen, p); - SetBitmapBits(hDirectBitmap, dwLen, p); - } - - free(p); - - return hDirectBitmap; -} - - -HBITMAP CreateBitmap32(int cx, int cy) -{ - BITMAPINFO RGB32BitsBITMAPINFO; - UINT * ptPixels; - HBITMAP DirectBitmap; - - ZeroMemory(&RGB32BitsBITMAPINFO,sizeof(BITMAPINFO)); - RGB32BitsBITMAPINFO.bmiHeader.biSize=sizeof(BITMAPINFOHEADER); - RGB32BitsBITMAPINFO.bmiHeader.biWidth=cx;//bm.bmWidth; - RGB32BitsBITMAPINFO.bmiHeader.biHeight=cy;//bm.bmHeight; - RGB32BitsBITMAPINFO.bmiHeader.biPlanes=1; - RGB32BitsBITMAPINFO.bmiHeader.biBitCount=32; - - DirectBitmap = CreateDIBSection(NULL, - (BITMAPINFO *)&RGB32BitsBITMAPINFO, - DIB_RGB_COLORS, - (void **)&ptPixels, - NULL, 0); - return DirectBitmap; -} - - -BOOL MakeBitmap32(HBITMAP *hBitmap) -{ - BITMAP bmp; - - GetObject(*hBitmap, sizeof(bmp), &bmp); - - if (bmp.bmBitsPixel != 32) { - // Convert to 32 bpp - HBITMAP hBmpTmp = CopyBitmapTo32(*hBitmap); - DeleteObject(*hBitmap); - *hBitmap = hBmpTmp; - } - - return TRUE; -} - - -#define GET_PIXEL(__P__, __X__, __Y__) ( __P__ + width * 4 * (__Y__) + 4 * (__X__)) - -BOOL MakeGrayscale(HBITMAP *hBitmap) -{ - BYTE *p = NULL; - BYTE *p1; - DWORD dwLen; - int width, height, x, y; - BITMAP bmp; - - GetObject(*hBitmap, sizeof(bmp), &bmp); - width = bmp.bmWidth; - height = bmp.bmHeight; - - dwLen = width * height * 4; - p = (BYTE *)malloc(dwLen); - if (p == NULL) - { - return FALSE; - } - - if (bmp.bmBitsPixel != 32) - { - // Convert to 32 bpp - HBITMAP hBmpTmp = CopyBitmapTo32(*hBitmap); - DeleteObject(*hBitmap); - *hBitmap = hBmpTmp; - } - GetBitmapBits(*hBitmap, dwLen, p); - - // Make grayscale - for (y = 0 ; y < height ; y++) - { - for (x = 0 ; x < width ; x++) - { - p1 = GET_PIXEL(p, x, y); - p1[0] = p1[1] = p1[2] = ( p1[0] + p1[1] + p1[2] ) / 3; - } - } - - dwLen = SetBitmapBits(*hBitmap, dwLen, p); - free(p); - - return TRUE; -} - - -HICON MakeHalfAlphaIcon(HICON SourceIcon) -{ - ICONINFO TargetIconInfo; - BITMAP TargetBitmapInfo; - HICON TargetIcon, TempIcon; - - TempIcon = CopyIcon(SourceIcon); - if ( !GetIconInfo(TempIcon, &TargetIconInfo)) - return NULL; - - if ( !GetObject(TargetIconInfo.hbmColor, sizeof(BITMAP), &TargetBitmapInfo)) - return NULL; - - MakeBitmap32(&TargetIconInfo.hbmColor); - HalfBitmap32Alpha(TargetIconInfo.hbmColor); - TargetIcon = CreateIconIndirect(&TargetIconInfo); - - DestroyIcon(TempIcon); - DeleteObject(TargetIconInfo.hbmColor); - DeleteObject(TargetIconInfo.hbmMask); - return TargetIcon; -} - - -HICON MakeGrayscaleIcon(HICON SourceIcon) -{ - ICONINFO TargetIconInfo; - BITMAP TargetBitmapInfo; - HICON TargetIcon, TempIcon; - - TempIcon = CopyIcon(SourceIcon); - if (! GetIconInfo(TempIcon, &TargetIconInfo) || GetObject(TargetIconInfo.hbmColor, sizeof(BITMAP), &TargetBitmapInfo)==0) return NULL; - - MakeGrayscale(&TargetIconInfo.hbmColor); - - TargetIcon = CreateIconIndirect(&TargetIconInfo); - DestroyIcon(TempIcon); - - return TargetIcon; -} - - -HICON BindOverlayIcon(HICON SourceIcon,HICON OverlayIcon) -{ - ICONINFO OverlayIconInfo, TargetIconInfo; - BITMAP OverlayBitmapInfo, TargetBitmapInfo; - HBITMAP OldOverlayBitmap, OldTargetBitmap; - HICON TargetIcon, TempIcon; - HDC OverlayDC, TargetDC; - BLENDFUNCTION bf = {0,0,255,1}; - - TempIcon = CopyIcon(SourceIcon); - if ( !GetIconInfo( TempIcon, &TargetIconInfo )) - return NULL; - - MakeBitmap32(&TargetIconInfo.hbmColor); - CorrectBitmap32Alpha(TargetIconInfo.hbmColor, FALSE); - GetObject(TargetIconInfo.hbmColor, sizeof(BITMAP), &TargetBitmapInfo); - - if ( !GetIconInfo(OverlayIcon, &OverlayIconInfo) || !GetObject(OverlayIconInfo.hbmColor, sizeof(BITMAP), &OverlayBitmapInfo)) - return NULL; - - TargetDC = CreateCompatibleDC(NULL); - OldTargetBitmap = (HBITMAP)SelectObject(TargetDC, TargetIconInfo.hbmColor); - - OverlayDC = CreateCompatibleDC(NULL); - OldOverlayBitmap = (HBITMAP)SelectObject(OverlayDC, OverlayIconInfo.hbmColor); - - AlphaBlend(TargetDC, 0, 0, TargetBitmapInfo.bmWidth, TargetBitmapInfo.bmHeight, - OverlayDC, 0, 0, OverlayBitmapInfo.bmWidth, OverlayBitmapInfo.bmHeight, bf); - - SelectObject(TargetDC, TargetIconInfo.hbmMask); - SelectObject(OverlayDC, OverlayIconInfo.hbmMask); - - BitBlt(TargetDC, 0, 0, TargetBitmapInfo.bmWidth, TargetBitmapInfo.bmHeight, - OverlayDC, 0, 0, SRCCOPY); - - TargetIcon = CreateIconIndirect(&TargetIconInfo); - DestroyIcon(TempIcon); - - SelectObject(TargetDC, OldTargetBitmap); - DeleteObject(TargetIconInfo.hbmColor); - DeleteObject(TargetIconInfo.hbmMask); - DeleteDC(TargetDC); - - SelectObject(OverlayDC, OldOverlayBitmap); - DeleteObject(OverlayIconInfo.hbmColor); - DeleteObject(OverlayIconInfo.hbmMask); - DeleteDC(OverlayDC); - - return TargetIcon; -} - - -// EOF diff --git a/plugins/SecureIM/images.h b/plugins/SecureIM/images.h deleted file mode 100644 index ea65b09893..0000000000 --- a/plugins/SecureIM/images.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __IMAGE_UTILS_H__ -#define __IMAGE_UTILS_H__ - -HICON BindOverlayIcon(HICON,HICON); -//HICON MakeGrayscaleIcon(HICON); -HICON MakeHalfAlphaIcon(HICON); - -#endif // __IMAGE_UTILS_H__ diff --git a/plugins/SecureIM/language.cpp b/plugins/SecureIM/language.cpp deleted file mode 100644 index 9bdf620cea..0000000000 --- a/plugins/SecureIM/language.cpp +++ /dev/null @@ -1,104 +0,0 @@ -#include "commonheaders.h" - -//Popup Messages -LPCSTR sim001 = "SecureIM established..."; -LPCSTR sim002 = "Key exchange failed..."; -LPCSTR sim003 = "Key from disabled..."; -LPCSTR sim004 = "Sended back message received..."; -LPCSTR sim005 = "Sending back secure message..."; -LPCSTR sim006 = "SecureIM disabled..."; -LPCSTR sim007 = "Sending Key..."; -LPCSTR sim008 = "Key Received..."; -LPCSTR sim009 = "Sending Message..."; -LPCSTR sim010 = "Message Received..."; -LPCSTR sim011 = "Encrypting File:"; -LPCSTR sim012 = "Decrypting File:"; -LPCSTR sim013 = "Bad key received..."; - -//Error Messages -LPCSTR sim101 = "SecureIM: Error while decrypting the message."; -LPCSTR sim102 = "SecureIM: Error while decrypting the message, bad message length."; -LPCSTR sim103 = "SecureIM: Error while decrypting the message, bad message CRC."; -LPCSTR sim104 = "User has not answered to key exchange !\nYour messages are still in SecureIM queue, do you want to send them Unencrypted now ?"; -LPCSTR sim105 = "SecureIM not enabled! You Must Enable SecureIM with this user..."; -LPCSTR sim106 = "Can't Send Encrypted Message !\nUser is offline now and his secure key has been expired, Do you want to send your message ?\nIt will be unencrypted !"; -LPCSTR sim107 = "SecureIM won't be loaded because cryptopp.dll is missing or wrong version !"; -LPCSTR sim108 = "SecureIM can't load PGP/GPG key! Check PGP/GPG settings!"; -LPCSTR sim109 = "SecureIM can't encrypt message! Check trust of PGP/GPG key!"; -LPCSTR sim110 = "Can't Send Encrypted Message !\nDo you want to send your message ?\nIt will be unencrypted !"; -LPCSTR sim111 = "Can't change mode! Secure connection established!"; -LPCSTR sim112 = "Can't export RSA private key!"; -LPCSTR sim113 = "Can't import RSA private key!"; -LPCSTR sim114 = "Can't export RSA public key!"; -LPCSTR sim115 = "Can't import RSA public key!"; - -//Options -LPCSTR sim201 = "General"; -LPCSTR sim202 = "Protocols"; -LPCSTR sim203 = "Nickname"; -LPCSTR sim204 = "UIN/Email/Jid/..."; -LPCSTR sim205 = "Status"; -LPCSTR sim206 = "PSK"; -LPCSTR sim210 = "Name"; -LPCSTR sim211 = "Password is too short!"; -LPCSTR sim212 = "ON"; -LPCSTR sim213 = "Off"; -LPCSTR sim214 = "PGP"; -LPCSTR sim215 = "Key ID"; -LPCSTR sim216 = "Keyrings loaded."; -LPCSTR sim217 = "Keyrings not loaded!"; -LPCSTR sim218 = "PGP SDK v%i.%i.%i found."; -LPCSTR sim219 = "PGP SDK not found!"; -LPCSTR sim220 = "This version not supported!"; -LPCSTR sim221 = "(none)"; -LPCSTR sim222 = "Private key loaded."; -LPCSTR sim223 = "Private key not loaded!"; -LPCSTR sim224 = "The new settings will become valid when you restart MirandaIM!"; -LPCSTR sim225 = "Keyrings disabled!"; -LPCSTR sim226 = "GPG"; -LPCSTR sim227 = "CP"; -LPCSTR sim228 = "ANSI"; -LPCSTR sim229 = "UTF8"; -LPCSTR sim230 = "Mode"; -LPCSTR sim231[] = { "Native", "PGP", "GPG", "RSA/AES", "RSA" }; -LPCSTR sim232[] = { "Disabled", "Enabled", "Always try" }; -LPCSTR sim233 = "PUB"; -LPCSTR sim234 = "SHA1"; - -//Context Menu -LPCSTR sim301 = "Create SecureIM connection"; -LPCSTR sim302 = "Disable SecureIM connection"; -LPCSTR sim306 = "Load PGP Key"; -LPCSTR sim307 = "Unload PGP Key"; -LPCSTR sim308 = "Load GPG Key"; -LPCSTR sim309 = "Unload GPG Key"; -LPCSTR sim310 = "Delete RSA Key"; -LPCSTR sim311[] = { "SecureIM mode (Native)", - "SecureIM mode (PGP)", - "SecureIM mode (GPG)", - "SecureIM mode (RSA/AES)", - "SecureIM mode (RSA)" }; -LPCSTR sim312[] = { "SecureIM status (disabled)", - "SecureIM status (enabled)", - "SecureIM status (always try)" }; - -//System messages -LPCSTR sim401 = "SecureIM: Sorry, unable to decrypt this message due you have no PGP/GPG installed. Visit www.pgp.com or www.gnupg.org for more info."; -LPCSTR sim402 = "SecureIM received unencryped message:\n"; -LPCSTR sim403 = "SecureIM received encryped message:\n"; - -//RSA messages -LPCSTR sim501 = "Session closed by receiving incorrect message type"; -LPCSTR sim502 = "Session closed by other side on error"; -LPCSTR sim505 = "Error while decoding AES message"; -LPCSTR sim506 = "Error while decoding RSA message"; -LPCSTR sim507 = "Session closed on timeout"; -LPCSTR sim508 = "Session closed by other side when status \"disabled\""; -LPCSTR sim510 = "Session closed on error: %02x"; -LPCSTR sim520 = "SecureIM received RSA Public Key from \"%s\"\n\nSHA1: %s\n\nDo you Accept this Key ?"; -LPCSTR sim521 = "SecureIM auto accepted RSA Public key from: %s uin: %s SHA1: %s"; -LPCSTR sim522 = "SecureIM received NEW RSA Public Key from \"%s\"\n\nNew SHA1: %s\n\nOld SHA1: %s\n\nDo you Replace this Key ?"; -LPCSTR sim523 = "SecureIM auto accepted NEW RSA Public key from: %s uin: %s New SHA1: %s Old SHA1: %s"; - - -// EOF diff --git a/plugins/SecureIM/language.h b/plugins/SecureIM/language.h deleted file mode 100644 index 154e306814..0000000000 --- a/plugins/SecureIM/language.h +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef __LANGUAGE_H__ -#define __LANGUAGE_H__ - -#include - -//Popup Messages -extern LPCSTR sim001; -extern LPCSTR sim002; -extern LPCSTR sim003; -extern LPCSTR sim004; -extern LPCSTR sim005; -extern LPCSTR sim006; -extern LPCSTR sim007; -extern LPCSTR sim008; -extern LPCSTR sim009; -extern LPCSTR sim010; -extern LPCSTR sim011; -extern LPCSTR sim012; -extern LPCSTR sim013; - -//Error Messages -extern LPCSTR sim101; -extern LPCSTR sim102; -extern LPCSTR sim103; -extern LPCSTR sim104; -extern LPCSTR sim105; -extern LPCSTR sim106; -extern LPCSTR sim107; -extern LPCSTR sim108; -extern LPCSTR sim109; -extern LPCSTR sim110; -extern LPCSTR sim111; -extern LPCSTR sim112; -extern LPCSTR sim113; -extern LPCSTR sim114; -extern LPCSTR sim115; - -//Options -extern LPCSTR sim201; -extern LPCSTR sim202; -extern LPCSTR sim203; -extern LPCSTR sim204; -extern LPCSTR sim205; -extern LPCSTR sim206; -extern LPCSTR sim210; -extern LPCSTR sim211; -extern LPCSTR sim212; -extern LPCSTR sim213; -extern LPCSTR sim214; -extern LPCSTR sim215; -extern LPCSTR sim216; -extern LPCSTR sim217; -extern LPCSTR sim218; -extern LPCSTR sim219; -extern LPCSTR sim220; -extern LPCSTR sim221; -extern LPCSTR sim222; -extern LPCSTR sim223; -extern LPCSTR sim224; -extern LPCSTR sim225; -extern LPCSTR sim226; -extern LPCSTR sim227; -extern LPCSTR sim228; -extern LPCSTR sim229; -extern LPCSTR sim230; -extern LPCSTR sim231[]; -extern LPCSTR sim232[]; -extern LPCSTR sim233; -extern LPCSTR sim234; - -//Context Menu -extern LPCSTR sim301; -extern LPCSTR sim302; -extern LPCSTR sim306; -extern LPCSTR sim307; -extern LPCSTR sim308; -extern LPCSTR sim309; -extern LPCSTR sim310; -extern LPCSTR sim311[]; -extern LPCSTR sim312[]; - -//System messages -extern LPCSTR sim401; -extern LPCSTR sim402; -extern LPCSTR sim403; - -//RSA messages -extern LPCSTR sim501; -extern LPCSTR sim502; -extern LPCSTR sim505; -extern LPCSTR sim506; -extern LPCSTR sim507; -extern LPCSTR sim508; -extern LPCSTR sim510; -extern LPCSTR sim520; -extern LPCSTR sim521; -extern LPCSTR sim522; -extern LPCSTR sim523; - -#endif diff --git a/plugins/SecureIM/loadicons.cpp b/plugins/SecureIM/loadicons.cpp deleted file mode 100644 index 3303424626..0000000000 --- a/plugins/SecureIM/loadicons.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include "commonheaders.h" - - -HINSTANCE LoadIconsPack(const char* szIconsPack) -{ - HINSTANCE hNewIconInst = NULL; - WORD i; - - hNewIconInst = LoadLibrary(szIconsPack); - - if (hNewIconInst != NULL) - { - for(i=ID_FIRSTICON; i<=ID_LASTICON; i++) - if (LoadIcon(hNewIconInst, MAKEINTRESOURCE(i)) == NULL) - { - FreeLibrary(hNewIconInst); - hNewIconInst = NULL; - break; - } - } - return hNewIconInst; -} - - - -int ReloadIcons(WPARAM wParam, LPARAM lParam) -{ - HICON hIcon; - for (int i=0; icons[i].key; i++) { - hIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)icons[i].name); - if(icons[i].tbl == TBL_IEC) - g_hIEC[icons[i].idx]=hIcon; - else - if(icons[i].tbl == TBL_ICO) - g_hICO[icons[i].idx]=hIcon; - else - if(icons[i].tbl == TBL_POP) - g_hPOP[icons[i].idx]=hIcon; - } - - return 0; -} - - -void InitIcons(void) -{ - HINSTANCE hNewIconInst = NULL; - - if ( g_hFolders ) { - LPSTR pathname = (LPSTR) alloca(MAX_PATH); - FoldersGetCustomPathEx(g_hFolders, pathname, MAX_PATH, "icons\\", "secureim_icons.dll"); - if (hNewIconInst == NULL) - hNewIconInst = LoadIconsPack(pathname); - } - - if (hNewIconInst == NULL) - hNewIconInst = LoadIconsPack("icons\\secureim_icons.dll"); - - if (hNewIconInst == NULL) - hNewIconInst = LoadIconsPack("plugins\\secureim_icons.dll"); - - if (hNewIconInst == NULL) - g_hIconInst = g_hInst; - else - g_hIconInst = hNewIconInst; - - - SKINICONDESC sid = { 0 }; - sid.cbSize = sizeof(sid); - sid.pszSection = "SecureIM"; - - HICON hIcon; - for (int i=0; icons[i].key; i++) { - sid.pszSection = icons[i].section; - sid.pszName = icons[i].name; - sid.pszDescription = icons[i].text; - sid.pszDefaultFile = "secureim_icons.dll"; - sid.iDefaultIndex = icons[i].key; - sid.hDefaultIcon = (HICON)LoadImage(g_hIconInst, MAKEINTRESOURCE(icons[i].key), IMAGE_ICON, 16, 16, LR_SHARED); - Skin_AddIcon(&sid); - hIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)icons[i].name); - - if(icons[i].tbl == TBL_IEC) - g_hIEC[icons[i].idx]=hIcon; - else - if(icons[i].tbl == TBL_ICO) - g_hICO[icons[i].idx]=hIcon; - else - if(icons[i].tbl == TBL_POP) - g_hPOP[icons[i].idx]=hIcon; - } - - AddHookFunction(ME_SKIN2_ICONSCHANGED, ReloadIcons); -} - -// EOF diff --git a/plugins/SecureIM/loadicons.h b/plugins/SecureIM/loadicons.h deleted file mode 100644 index f5258a41a0..0000000000 --- a/plugins/SecureIM/loadicons.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef __LOADICONS_H__ -#define __LOADICONS_H__ - -HINSTANCE LoadIconsPack(const char*); -void InitIcons(); - -#endif diff --git a/plugins/SecureIM/loadlib.cpp b/plugins/SecureIM/loadlib.cpp deleted file mode 100644 index ac0d2f9272..0000000000 --- a/plugins/SecureIM/loadlib.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "commonheaders.h" - -CRYPTOPP_INFO cpp; - -BOOL loadlib(void) { - - HMODULE h = LoadLibraryA("plugins/cryptopp.dll"); - if ( h == NULL ) { - h = LoadLibraryA("cryptopp.dll"); - if ( h == NULL ) return 0; - } - - cpp.cc = (_cpp_create_context) GetProcAddress(h, "cpp_create_context"); - cpp.dc = (_cpp_delete_context) GetProcAddress(h, "cpp_delete_context"); - cpp.rc = (_cpp_reset_context) GetProcAddress(h, "cpp_reset_context"); - cpp.ika = (_cpp_init_keya) GetProcAddress(h, "cpp_init_keya"); - cpp.ikb = (_cpp_init_keyb) GetProcAddress(h, "cpp_init_keyb"); - cpp.ckx = (_cpp_calc_keyx) GetProcAddress(h, "cpp_calc_keyx"); - cpp.ikp = (_cpp_init_keyp) GetProcAddress(h, "cpp_init_keyp"); - cpp.ea = (_cpp_encodeA) GetProcAddress(h, "cpp_encodeA"); - cpp.ew = (_cpp_encodeW) GetProcAddress(h, "cpp_encodeW"); - cpp.eu = (_cpp_encodeU) GetProcAddress(h, "cpp_encodeU"); - cpp.daw = (_cpp_decode) GetProcAddress(h, "cpp_decode"); - cpp.du = (_cpp_decodeU) GetProcAddress(h, "cpp_decodeU"); - cpp.ef = (_cpp_encrypt_file) GetProcAddress(h, "cpp_encrypt_file"); - cpp.df = (_cpp_decrypt_file) GetProcAddress(h, "cpp_decrypt_file"); - cpp.gf = (_cpp_get_features) GetProcAddress(h, "cpp_get_features"); - cpp.ge = (_cpp_get_error) GetProcAddress(h, "cpp_get_error"); - cpp.gv = (_cpp_get_version) GetProcAddress(h, "cpp_get_version"); - cpp.kxs = (_cpp_size_keyx) GetProcAddress(h, "cpp_size_keyx"); - cpp.gkx = (_cpp_get_keyx) GetProcAddress(h, "cpp_get_keyx"); - cpp.skx = (_cpp_set_keyx) GetProcAddress(h, "cpp_set_keyx"); - cpp.kps = (_cpp_size_keyp) GetProcAddress(h, "cpp_size_keyp"); - cpp.gkp = (_cpp_get_keyp) GetProcAddress(h, "cpp_get_keyp"); - cpp.skp = (_cpp_set_keyp) GetProcAddress(h, "cpp_set_keyp"); - cpp.ka = (_cpp_keya) GetProcAddress(h, "cpp_keya"); - cpp.kb = (_cpp_keyb) GetProcAddress(h, "cpp_keyb"); - cpp.kx = (_cpp_keyx) GetProcAddress(h, "cpp_keyx"); - cpp.kp = (_cpp_keyp) GetProcAddress(h, "cpp_keyp"); - - cpp.pgp_i = (_pgp_init ) GetProcAddress(h, "pgp_init"); - cpp.pgp_d = (_pgp_done ) GetProcAddress(h, "pgp_done"); - cpp.pgp_ok = (_pgp_open_keyrings ) GetProcAddress(h, "pgp_open_keyrings"); - cpp.pgp_ck = (_pgp_close_keyrings ) GetProcAddress(h, "pgp_close_keyrings"); - cpp.pgp_gv = (_pgp_get_version ) GetProcAddress(h, "pgp_get_version"); - cpp.pgp_ge = (_pgp_get_error ) GetProcAddress(h, "pgp_get_error"); - cpp.pgp_spk = (_pgp_set_priv_key ) GetProcAddress(h, "pgp_set_priv_key"); - cpp.pgp_sk = (_pgp_set_key ) GetProcAddress(h, "pgp_set_key"); - cpp.pgp_ski = (_pgp_set_keyid ) GetProcAddress(h, "pgp_set_keyid"); - cpp.pgp_szki = (_pgp_size_keyid ) GetProcAddress(h, "pgp_size_keyid"); - cpp.pgp_slki = (_pgp_select_keyid ) GetProcAddress(h, "pgp_select_keyid"); - cpp.pgp_eu = (_pgp_encode ) GetProcAddress(h, "pgp_encode"); - cpp.pgp_de = (_pgp_decode ) GetProcAddress(h, "pgp_decode"); - - cpp.gpg_i = (_gpg_init ) GetProcAddress(h, "gpg_init"); - cpp.gpg_d = (_gpg_done ) GetProcAddress(h, "gpg_done"); - cpp.gpg_ok = (_gpg_open_keyrings ) GetProcAddress(h, "gpg_open_keyrings"); - cpp.gpg_ck = (_gpg_close_keyrings ) GetProcAddress(h, "gpg_close_keyrings"); - cpp.gpg_sl = (_gpg_set_log ) GetProcAddress(h, "gpg_set_log"); - cpp.gpg_st = (_gpg_set_tmp ) GetProcAddress(h, "gpg_set_tmp"); - cpp.gpg_ge = (_gpg_get_error ) GetProcAddress(h, "gpg_get_error"); - cpp.gpg_ski = (_gpg_set_keyid ) GetProcAddress(h, "gpg_set_keyid"); - cpp.gpg_szki = (_gpg_size_keyid ) GetProcAddress(h, "gpg_size_keyid"); - cpp.gpg_slki = (_gpg_select_keyid ) GetProcAddress(h, "gpg_select_keyid"); - cpp.gpg_eu = (_gpg_encode ) GetProcAddress(h, "gpg_encode"); - cpp.gpg_de = (_gpg_decode ) GetProcAddress(h, "gpg_decode"); - cpp.gpg_gph = (_gpg_get_passphrases ) GetProcAddress(h, "gpg_get_passphrases"); - cpp.gpg_sph = (_gpg_set_passphrases ) GetProcAddress(h, "gpg_set_passphrases"); - - cpp.rsa_i = (_rsa_init) GetProcAddress(h, "rsa_init"); - cpp.rsa_d = (_rsa_done) GetProcAddress(h, "rsa_done"); - - return (cpp_get_version()>=0x01000403); -} - -// EOF diff --git a/plugins/SecureIM/loadlib.h b/plugins/SecureIM/loadlib.h deleted file mode 100644 index 105f441dc9..0000000000 --- a/plugins/SecureIM/loadlib.h +++ /dev/null @@ -1,188 +0,0 @@ -#ifndef __LOADLIB_H__ -#define __LOADLIB_H__ - -#include -#include "cryptopp.h" - -BOOL loadlib(void); - -typedef HANDLE (__cdecl * _cpp_create_context) (int); -typedef void (__cdecl * _cpp_delete_context) (HANDLE); -typedef void (__cdecl * _cpp_reset_context) (HANDLE); -typedef LPSTR (__cdecl * _cpp_init_keya) (HANDLE,int); -typedef int (__cdecl * _cpp_init_keyb) (HANDLE,LPCSTR); -typedef int (__cdecl * _cpp_calc_keyx) (HANDLE); -typedef int (__cdecl * _cpp_init_keyp) (HANDLE,LPCSTR); -typedef LPSTR (__cdecl * _cpp_encodeA) (HANDLE,LPCSTR); -typedef LPSTR (__cdecl * _cpp_encodeW) (HANDLE,LPWSTR); -typedef LPSTR (__cdecl * _cpp_encodeU) (HANDLE,LPCSTR); -typedef LPSTR (__cdecl * _cpp_decode) (HANDLE,LPCSTR); -typedef LPSTR (__cdecl * _cpp_decodeU) (HANDLE,LPCSTR); -typedef int (__cdecl * _cpp_encrypt_file) (HANDLE,LPCSTR,LPCSTR); -typedef int (__cdecl * _cpp_decrypt_file) (HANDLE,LPCSTR,LPCSTR); -typedef int (__cdecl * _cpp_get_features) (HANDLE); -typedef int (__cdecl * _cpp_get_error) (HANDLE); -typedef int (__cdecl * _cpp_get_version) (void); -typedef int (__cdecl * _cpp_size_keyx) (void); -typedef void (__cdecl * _cpp_get_keyx) (HANDLE,BYTE*); -typedef void (__cdecl * _cpp_set_keyx) (HANDLE,BYTE*); -typedef int (__cdecl * _cpp_size_keyp) (void); -typedef void (__cdecl * _cpp_get_keyp) (HANDLE,BYTE*); -typedef void (__cdecl * _cpp_set_keyp) (HANDLE,BYTE*); -typedef int (__cdecl * _cpp_keya) (HANDLE); -typedef int (__cdecl * _cpp_keyb) (HANDLE); -typedef int (__cdecl * _cpp_keyx) (HANDLE); -typedef int (__cdecl * _cpp_keyp) (HANDLE); - -typedef int (__cdecl * _pgp_init) (void); -typedef int (__cdecl * _pgp_done) (void); -typedef int (__cdecl * _pgp_open_keyrings) (LPSTR,LPSTR); -typedef int (__cdecl * _pgp_close_keyrings) (void); -typedef int (__cdecl * _pgp_get_version) (void); -typedef LPSTR (__cdecl * _pgp_get_error) (void); -typedef int (__cdecl * _pgp_set_priv_key) (LPCSTR); -typedef int (__cdecl * _pgp_set_key) (HANDLE,LPCSTR); -typedef int (__cdecl * _pgp_set_keyid) (HANDLE,PVOID); -typedef int (__cdecl * _pgp_size_keyid) (void); -typedef PVOID (__cdecl * _pgp_select_keyid) (HWND,LPSTR); -typedef LPSTR (__cdecl * _pgp_encode) (HANDLE,LPCSTR); -typedef LPSTR (__cdecl * _pgp_decode) (HANDLE,LPCSTR); - -typedef int (__cdecl * _gpg_init) (void); -typedef int (__cdecl * _gpg_done) (void); -typedef int (__cdecl * _gpg_open_keyrings) (LPSTR,LPSTR); -typedef int (__cdecl * _gpg_close_keyrings) (void); -typedef void (__cdecl * _gpg_set_log) (LPCSTR); -typedef void (__cdecl * _gpg_set_tmp) (LPCSTR); -typedef LPSTR (__cdecl * _gpg_get_error) (void); -typedef int (__cdecl * _gpg_set_keyid) (HANDLE,LPCSTR); -typedef int (__cdecl * _gpg_size_keyid) (void); -typedef int (__cdecl * _gpg_select_keyid) (HWND,LPSTR); -typedef LPSTR (__cdecl * _gpg_encode) (HANDLE,LPCSTR); -typedef LPSTR (__cdecl * _gpg_decode) (HANDLE,LPCSTR); -typedef LPSTR (__cdecl * _gpg_get_passphrases) (void); -typedef void (__cdecl * _gpg_set_passphrases) (LPCSTR); - -typedef int (__cdecl * _rsa_init) (pRSA_EXPORT*,pRSA_IMPORT); -typedef int (__cdecl * _rsa_done) (void); - - -typedef struct { - _cpp_create_context cc; - _cpp_delete_context dc; - _cpp_reset_context rc; - _cpp_init_keya ika; - _cpp_init_keyb ikb; - _cpp_calc_keyx ckx; - _cpp_init_keyp ikp; - _cpp_encodeA ea; - _cpp_encodeW ew; - _cpp_encodeU eu; - _cpp_decode daw; - _cpp_decodeU du; - _cpp_encrypt_file ef; - _cpp_decrypt_file df; - _cpp_get_features gf; - _cpp_get_error ge; - _cpp_get_version gv; - _cpp_size_keyx kxs; - _cpp_get_keyx gkx; - _cpp_set_keyx skx; - _cpp_size_keyp kps; - _cpp_get_keyp gkp; - _cpp_set_keyp skp; - _cpp_keya ka; - _cpp_keyb kb; - _cpp_keyx kx; - _cpp_keyp kp; - _pgp_init pgp_i; - _pgp_done pgp_d; - _pgp_open_keyrings pgp_ok; - _pgp_close_keyrings pgp_ck; - _pgp_get_version pgp_gv; - _pgp_get_error pgp_ge; - _pgp_set_keyid pgp_ski; - _pgp_set_key pgp_sk; - _pgp_set_priv_key pgp_spk; - _pgp_size_keyid pgp_szki; - _pgp_select_keyid pgp_slki; - _pgp_encode pgp_eu; - _pgp_decode pgp_de; - _gpg_init gpg_i; - _gpg_done gpg_d; - _gpg_open_keyrings gpg_ok; - _gpg_close_keyrings gpg_ck; - _gpg_set_log gpg_sl; - _gpg_set_tmp gpg_st; - _gpg_get_error gpg_ge; - _gpg_set_keyid gpg_ski; - _gpg_size_keyid gpg_szki; - _gpg_select_keyid gpg_slki; - _gpg_encode gpg_eu; - _gpg_decode gpg_de; - _gpg_get_passphrases gpg_gph; - _gpg_set_passphrases gpg_sph; - _rsa_init rsa_i; - _rsa_done rsa_d; -} CRYPTOPP_INFO; - -extern CRYPTOPP_INFO cpp; - -#define cpp_create_context cpp.cc -#define cpp_delete_context cpp.dc -#define cpp_reset_context cpp.rc -#define cpp_init_keya cpp.ika -#define cpp_init_keyb cpp.ikb -#define cpp_calc_keyx cpp.ckx -#define cpp_init_keyp cpp.ikp -#define cpp_encodeA cpp.ea -#define cpp_encodeW cpp.ew -#define cpp_encodeU cpp.eu -#define cpp_decode cpp.daw -#define cpp_decodeU cpp.du -#define cpp_encrypt_file cpp.ef -#define cpp_decrypt_file cpp.df -#define cpp_get_features cpp.gf -#define cpp_get_error cpp.ge -#define cpp_get_version cpp.gv -#define cpp_size_keyx cpp.kxs -#define cpp_get_keyx cpp.gkx -#define cpp_set_keyx cpp.skx -#define cpp_size_keyp cpp.kps -#define cpp_get_keyp cpp.gkp -#define cpp_set_keyp cpp.skp -#define cpp_keya cpp.ka -#define cpp_keyb cpp.kb -#define cpp_keyx cpp.kx -#define cpp_keyp cpp.kp -#define pgp_init cpp.pgp_i -#define pgp_done cpp.pgp_d -#define pgp_open_keyrings cpp.pgp_ok -#define pgp_close_keyrings cpp.pgp_ck -#define pgp_get_version cpp.pgp_gv -#define pgp_get_error cpp.pgp_ge -#define pgp_set_priv_key cpp.pgp_spk -#define pgp_set_key cpp.pgp_sk -#define pgp_set_keyid cpp.pgp_ski -#define pgp_size_keyid cpp.pgp_szki -#define pgp_select_keyid cpp.pgp_slki -#define pgp_encode cpp.pgp_eu -#define pgp_decode cpp.pgp_de -#define gpg_init cpp.gpg_i -#define gpg_done cpp.gpg_d -#define gpg_open_keyrings cpp.gpg_ok -#define gpg_close_keyrings cpp.gpg_ck -#define gpg_set_log cpp.gpg_sl -#define gpg_set_tmp cpp.gpg_st -#define gpg_get_error cpp.gpg_ge -#define gpg_set_keyid cpp.gpg_ski -#define gpg_size_keyid cpp.gpg_szki -#define gpg_select_keyid cpp.gpg_slki -#define gpg_encode cpp.gpg_eu -#define gpg_decode cpp.gpg_de -#define gpg_get_passphrases cpp.gpg_gph -#define gpg_set_passphrases cpp.gpg_sph -#define rsa_init cpp.rsa_i -#define rsa_done cpp.rsa_d - -#endif diff --git a/plugins/SecureIM/main.cpp b/plugins/SecureIM/main.cpp deleted file mode 100644 index 205a025ffe..0000000000 --- a/plugins/SecureIM/main.cpp +++ /dev/null @@ -1,534 +0,0 @@ -#include "commonheaders.h" - -int hLangpack = 0; - -BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID) { - g_hInst = hInst; - if (dwReason == DLL_PROCESS_ATTACH) { - INITCOMMONCONTROLSEX icce = { - sizeof(icce), ICC_LISTVIEW_CLASSES | ICC_TAB_CLASSES - }; - InitCommonControlsEx(&icce); - } - return TRUE; -} - -extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_SECUREIM, MIID_LAST}; - -extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) -{ - return &pluginInfoEx; -} - -void AddServiceFunction(LPCSTR serviceName, MIRANDASERVICE serviceFunction) { - - g_hService = (HANDLE*) mir_realloc(g_hService,sizeof(HANDLE)*(iService+1)); - g_hService[iService] = CreateServiceFunction(serviceName, serviceFunction); - iService++; -} - - -void AddProtoServiceFunction(LPCSTR serviceName, MIRANDASERVICE serviceFunction) { - - g_hService = (HANDLE*) mir_realloc(g_hService,sizeof(HANDLE)*(iService+1)); - g_hService[iService] = CreateProtoServiceFunction(szModuleName, serviceName, serviceFunction); - iService++; -} - - -void AddHookFunction(LPCSTR eventName, MIRANDAHOOK hookFunction) { - - g_hHook = (HANDLE*) mir_realloc(g_hHook,sizeof(HANDLE)*(iHook+1)); - g_hHook[iHook] = HookEvent(eventName, hookFunction); - iHook++; -} - - -HANDLE AddMenuItem(LPCSTR name,int pos,HICON hicon,LPCSTR service,int flags=0,WPARAM wParam=0) -{ - CLISTMENUITEM mi = { 0 }; - mi.cbSize=sizeof(mi); - mi.flags=flags | CMIF_HIDDEN; - mi.position=pos; - mi.hIcon=hicon; - mi.pszName= (char*)name; - mi.pszPopupName=(char*)-1; - mi.pszService=(char*)service; - return Menu_AddContactMenuItem(&mi); -} - - -HANDLE AddSubItem(HANDLE rootid,LPCSTR name,int pos,int poppos,LPCSTR service,WPARAM wParam=0) -{ - CLISTMENUITEM mi = { 0 }; - memset(&mi,0,sizeof(mi)); - mi.cbSize=sizeof(mi); - mi.flags=CMIF_CHILDPOPUP | CMIF_HIDDEN; - mi.position=pos; - mi.popupPosition=poppos; - mi.hIcon=NULL; - mi.pszName=(char*)name; - mi.pszPopupName=(char*)rootid; - mi.pszService=(char*)service; - return Menu_AddContactMenuItem(&mi); -} - - -extern "C" __declspec(dllexport) int __cdecl Load(void) -{ - DisableThreadLibraryCalls(g_hInst); - InitializeCriticalSection(&localQueueMutex); - - { - char temp[MAX_PATH]; - GetTempPath(sizeof(temp),temp); - GetLongPathName(temp,TEMP,sizeof(TEMP)); - TEMP_SIZE = (int)strlen(TEMP); - if(TEMP[TEMP_SIZE-1]=='\\') { - TEMP_SIZE--; - TEMP[TEMP_SIZE]='\0'; - } - } - - // get memoryManagerInterface address - //get per-plugin langpack interface - mir_getLP(&pluginInfoEx); - - // check for support TrueColor Icons - BOOL bIsComCtl6 = FALSE; - HMODULE hComCtlDll = LoadLibrary("comctl32.dll"); - if ( hComCtlDll ) { - typedef HRESULT (CALLBACK *PFNDLLGETVERSION)(DLLVERSIONINFO*); - PFNDLLGETVERSION pfnDllGetVersion = (PFNDLLGETVERSION) GetProcAddress(hComCtlDll,"DllGetVersion"); - if ( pfnDllGetVersion ) { - DLLVERSIONINFO dvi; - memset(&dvi,0,sizeof(dvi)); - dvi.cbSize = sizeof(dvi); - HRESULT hRes = (*pfnDllGetVersion)( &dvi ); - if ( SUCCEEDED(hRes) && dvi.dwMajorVersion >= 6 ) { - bIsComCtl6 = TRUE; - } - } - FreeLibrary(hComCtlDll); - } - if (bIsComCtl6) iBmpDepth = ILC_COLOR32 | ILC_MASK; // 32-bit images are supported - else iBmpDepth = ILC_COLOR24 | ILC_MASK; - -// iBmpDepth = ILC_COLOR32 | ILC_MASK; - - char version[512]; - CallService(MS_SYSTEM_GETVERSIONTEXT, sizeof(version), (LPARAM)&version); - bCoreUnicode = strstr(version, "Unicode")!=0; - iCoreVersion = CallService(MS_SYSTEM_GETVERSION,0,0); - - // load crypo++ dll - if ( !loadlib()) { - msgbox1(0,sim107,szModuleName,MB_OK|MB_ICONSTOP); - return 1; - } - - load_rtfconv(); - - // register plugin module - PROTOCOLDESCRIPTOR pd; - memset(&pd,0,sizeof(pd)); - pd.cbSize = sizeof(pd); - pd.szName = (char*)szModuleName; - pd.type = PROTOTYPE_ENCRYPTION; - CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd); - - // hook events - AddHookFunction(ME_SYSTEM_MODULESLOADED, onModulesLoaded); - AddHookFunction(ME_SYSTEM_OKTOEXIT, onSystemOKToExit); - - g_hEvent[0] = CreateHookableEvent(MODULENAME"/Disabled"); - g_hEvent[1] = CreateHookableEvent(MODULENAME"/Established"); - - AddServiceFunction(MODULENAME"/IsContactSecured",Service_IsContactSecured); - AddServiceFunction(MODULENAME"/SIM_EST",Service_CreateIM); - AddServiceFunction(MODULENAME"/SIM_DIS",Service_DisableIM); - AddServiceFunction(MODULENAME"/SIM_ST_DIS",Service_StatusDis); - AddServiceFunction(MODULENAME"/SIM_ST_ENA",Service_StatusEna); - AddServiceFunction(MODULENAME"/SIM_ST_TRY",Service_StatusTry); - AddServiceFunction(MODULENAME"/PGP_SET",Service_PGPsetKey); - AddServiceFunction(MODULENAME"/PGP_DEL",Service_PGPdelKey); - AddServiceFunction(MODULENAME"/GPG_SET",Service_GPGsetKey); - AddServiceFunction(MODULENAME"/GPG_DEL",Service_GPGdelKey); - AddServiceFunction(MODULENAME"/MODE_NAT",Service_ModeNative); - AddServiceFunction(MODULENAME"/MODE_PGP",Service_ModePGP); - AddServiceFunction(MODULENAME"/MODE_GPG",Service_ModeGPG); - AddServiceFunction(MODULENAME"/MODE_RSA",Service_ModeRSAAES); - - return 0; -} - -extern "C" __declspec(dllexport) int __cdecl Unload() { - DeleteCriticalSection(&localQueueMutex); - return 0; -} - - -int __cdecl onModulesLoaded(WPARAM wParam,LPARAM lParam) { - -#if defined(_DEBUG) || defined(NETLIB_LOG) - InitNetlib(); - Sent_NetLog("onModuleLoaded begin"); -#endif - - bMetaContacts = ServiceExists(MS_MC_GETMETACONTACT)!=0; - bPopupExists = ServiceExists(MS_POPUP_ADDPOPUPEX)!=0; - bPopupUnicode = ServiceExists(MS_POPUP_ADDPOPUPW)!=0; - - g_hFolders = FoldersRegisterCustomPath(szModuleName, "Icons", MIRANDA_PATH"\\icons"); - if ( g_hFolders==(HANDLE)CALLSERVICE_NOTFOUND ) g_hFolders = 0; - - InitIcons(); - GetFlags(); - -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("rsa_init"); -#endif - { // RSA/AES - rsa_init(&exp,&imp); - - DBVARIANT dbv; - dbv.type = DBVT_BLOB; - - if ( DBGetContactSetting(0,szModuleName,"rsa_priv",&dbv) == 0 ) { - exp->rsa_set_keypair(CPP_MODE_RSA_4096,dbv.pbVal,dbv.cpbVal); - DBFreeVariant(&dbv); - rsa_4096=1; - } - else - if ( DBGetContactSetting(0,szModuleName,"rsa_priv_4096",&dbv) == 0 ) { - exp->rsa_set_keypair(CPP_MODE_RSA_4096|CPP_MODE_RSA_BER,dbv.pbVal,dbv.cpbVal); - DBFreeVariant(&dbv); - - char priv_key[4096]; int priv_len; - char pub_key[4096]; int pub_len; - - DBCONTACTWRITESETTING cws; - cws.szModule = szModuleName; - cws.value.type = DBVT_BLOB; - - exp->rsa_get_keypair(CPP_MODE_RSA_4096,(PBYTE)&priv_key,&priv_len,(PBYTE)&pub_key,&pub_len); - - cws.szSetting = "rsa_priv"; - cws.value.pbVal = (PBYTE)&priv_key; - cws.value.cpbVal = priv_len; - CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)0, (LPARAM)&cws); - - cws.szSetting = "rsa_pub"; - cws.value.pbVal = (PBYTE)&pub_key; - cws.value.cpbVal = pub_len; - CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)0, (LPARAM)&cws); - - DBDeleteContactSetting(0, szModuleName, "rsa_priv_2048"); - DBDeleteContactSetting(0, szModuleName, "rsa_pub_2048"); -// DBDeleteContactSetting(0, szModuleName, "rsa_priv_4096"); -// DBDeleteContactSetting(0, szModuleName, "rsa_pub_4096"); - - rsa_4096=1; - } - - if ( !rsa_4096 ) { - unsigned int tID; - CloseHandle( (HANDLE) _beginthreadex(NULL, 0, sttGenerateRSA, NULL, 0, &tID)); - } - - exp->rsa_set_timeout( DBGetContactSettingWord(0,szModuleName,"ket",10)); - } - -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("pgp_init"); -#endif - bPGP = DBGetContactSettingByte(0, szModuleName, "pgp", 0); - if(bPGP) { //PGP - bPGPloaded = pgp_init(); - bUseKeyrings = DBGetContactSettingByte(0,szModuleName,"ukr",1); - LPSTR priv = myDBGetStringDecode(0,szModuleName,"pgpPrivKey"); - if(priv) { - bPGPprivkey = true; - if(bPGPloaded) - pgp_set_priv_key(priv); - mir_free(priv); - }// if(priv) - if(bPGPloaded && bUseKeyrings) { - char PubRingPath[MAX_PATH], SecRingPath[MAX_PATH]; - PubRingPath[0]='\0'; SecRingPath[0]='\0'; - if(pgp_get_version()<0x02000000) { // 6xx - bPGPkeyrings = pgp_open_keyrings(PubRingPath,SecRingPath); - } - else { - LPSTR tmp; - tmp = myDBGetString(0,szModuleName,"pgpPubRing"); - if(tmp) { - strncpy(PubRingPath,tmp,sizeof(PubRingPath)); - mir_free(tmp); - } - tmp = myDBGetString(0,szModuleName,"pgpSecRing"); - if(tmp) { - strncpy(SecRingPath,tmp,sizeof(SecRingPath)); - mir_free(tmp); - } - if(PubRingPath[0] && SecRingPath[0]) { - bPGPkeyrings = pgp_open_keyrings(PubRingPath,SecRingPath); - if(bPGPkeyrings) { - DBWriteContactSettingString(0,szModuleName,"pgpPubRing",PubRingPath); - DBWriteContactSettingString(0,szModuleName,"pgpSecRing",SecRingPath); - } - else { - DBDeleteContactSetting(0, szModuleName, "pgpPubRing"); - DBDeleteContactSetting(0, szModuleName, "pgpSecRing"); - } - } - } - }// if(bPGPloaded && bUseKeyrings) - }// if(bPGP) - -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("gpg_init"); -#endif - bGPG = DBGetContactSettingByte(0, szModuleName, "gpg", 0); - if(bGPG) { //GPG - - LPSTR tmp; - - bGPGloaded = gpg_init(); - - char gpgexec[MAX_PATH], gpghome[MAX_PATH]; - gpgexec[0]='\0'; gpghome[0]='\0'; - - tmp = myDBGetString(0,szModuleName,"gpgExec"); - if(tmp) { - strncpy(gpgexec,tmp,sizeof(gpgexec)); - mir_free(tmp); - } - tmp = myDBGetString(0,szModuleName,"gpgHome"); - if(tmp) { - strncpy(gpghome,tmp,sizeof(gpghome)); - mir_free(tmp); - } - - if(DBGetContactSettingByte(0, szModuleName, "gpgLogFlag",0)) { - tmp = myDBGetString(0,szModuleName,"gpgLog"); - if(tmp) { - gpg_set_log(tmp); - mir_free(tmp); - } - } - - if(DBGetContactSettingByte(0, szModuleName, "gpgTmpFlag",0)) { - tmp = myDBGetString(0,szModuleName,"gpgTmp"); - if(tmp) { - gpg_set_tmp(tmp); - mir_free(tmp); - } - } - - bGPGkeyrings = gpg_open_keyrings(gpgexec,gpghome); - if(bGPGkeyrings) { - DBWriteContactSettingString(0,szModuleName,"gpgExec",gpgexec); - DBWriteContactSettingString(0,szModuleName,"gpgHome",gpghome); - } - else { - DBDeleteContactSetting(0, szModuleName, "gpgExec"); - DBDeleteContactSetting(0, szModuleName, "gpgHome"); - } - - bSavePass = DBGetContactSettingByte(0,szModuleName,"gpgSaveFlag",0); - if(bSavePass) { - tmp = myDBGetString(0,szModuleName,"gpgSave"); - if(tmp) { - gpg_set_passphrases(tmp); - mir_free(tmp); - } - } - } - -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("loadContactList"); -#endif - loadContactList(); - - // add new skin sound - SkinAddNewSound("IncomingSecureMessage",LPGEN("Incoming Secure Message"),"Sounds\\iSecureMessage.wav"); - SkinAddNewSound("OutgoingSecureMessage",LPGEN("Outgoing Secure Message"),"Sounds\\oSecureMessage.wav"); - -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("init extra icons"); -#endif - // init extra icons - for(int i=0;i<1+MODE_CNT*IEC_CNT;i++) { - g_IEC[i].cbSize = sizeof(g_IEC[i]); - g_IEC[i].ColumnType = bADV; - g_IEC[i].hImage = (HANDLE)-1; - } - - // build extra imagelist - //onExtraImageListRebuilding(0,0); - -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("hook events"); -#endif - AddHookFunction(ME_CLIST_PREBUILDCONTACTMENU, onRebuildContactMenu); -// g_hMC = HookEvent(ME_MC_SUBCONTACTSCHANGED, onMC); - - if ( ServiceExists(MS_EXTRAICON_REGISTER)) { - g_hCLIcon = ExtraIcon_Register(szModuleName, Translate("SecureIM status"), "sim_cm_est", - onExtraImageListRebuilding, - onExtraImageApplying); - } - else { - AddHookFunction(ME_CLIST_EXTRA_LIST_REBUILD, onExtraImageListRebuilding); - AddHookFunction(ME_CLIST_EXTRA_IMAGE_APPLY, onExtraImageApplying); - } - - // hook init options - AddHookFunction(ME_OPT_INITIALISE, onRegisterOptions); - if(bPopupExists) - AddHookFunction(ME_OPT_INITIALISE, onRegisterPopOptions); - AddHookFunction(ME_PROTO_ACK, onProtoAck); - AddHookFunction(ME_DB_CONTACT_SETTINGCHANGED, onContactSettingChanged); - AddHookFunction(ME_DB_CONTACT_ADDED, onContactAdded); - AddHookFunction(ME_DB_CONTACT_DELETED, onContactDeleted); - - // hook message transport - AddProtoServiceFunction(PSR_MESSAGE, onRecvMsg); - AddProtoServiceFunction(PSS_MESSAGE, (MIRANDASERVICE)onSendMsg); - AddProtoServiceFunction(PSS_MESSAGE"W", (MIRANDASERVICE)onSendMsgW); - AddProtoServiceFunction(PSS_FILE, (MIRANDASERVICE)onSendFile); - -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("create Native/RSA menu"); -#endif - // create a menu item for creating a secure im connection to the user. - g_hMenu[0] = AddMenuItem(sim301,110000,g_hICO[ICO_CM_EST],MODULENAME"/SIM_EST",CMIF_NOTOFFLINE); - g_hMenu[1] = AddMenuItem(sim302,110001,g_hICO[ICO_CM_DIS],MODULENAME"/SIM_DIS",CMIF_NOTOFFLINE); - - if(ServiceExists(MS_CLIST_MENUBUILDSUBGROUP)) { - g_hMenu[2] = AddMenuItem(sim312[0],110002,NULL,NULL,CMIF_ROOTPOPUP); - g_hMenu[3] = AddSubItem(g_hMenu[2],sim232[0],110003,110002,MODULENAME"/SIM_ST_DIS"); - g_hMenu[4] = AddSubItem(g_hMenu[2],sim232[1],110004,110002,MODULENAME"/SIM_ST_ENA"); - g_hMenu[5] = AddSubItem(g_hMenu[2],sim232[2],110005,110002,MODULENAME"/SIM_ST_TRY"); - } - else { - g_hMenu[2] = 0; - g_hMenu[3] = AddMenuItem(sim232[0],110003,NULL,MODULENAME"/SIM_ST_DIS"); - g_hMenu[4] = AddMenuItem(sim232[1],110004,NULL,MODULENAME"/SIM_ST_ENA"); - g_hMenu[5] = AddMenuItem(sim232[2],110005,NULL,MODULENAME"/SIM_ST_TRY"); - } - -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("create PGP/GPG menu"); -#endif - HICON icon; - if ( bPGPloaded ) { - icon=mode2icon(MODE_PGP|SECURED,2); - g_hMenu[6] = AddMenuItem(sim306,110006,icon,MODULENAME"/PGP_SET",0); - icon=mode2icon(MODE_PGP,2); - g_hMenu[7] = AddMenuItem(sim307,110007,icon,MODULENAME"/PGP_DEL",0); - } - - if(bGPGloaded) { - icon=mode2icon(MODE_GPG|SECURED,2); - g_hMenu[8] = AddMenuItem(sim308,110008,icon,MODULENAME"/GPG_SET",0); - icon=mode2icon(MODE_GPG,2); - g_hMenu[9] = AddMenuItem(sim309,110009,icon,MODULENAME"/GPG_DEL",0); - } - -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("create Mode menu"); -#endif - if(ServiceExists(MS_CLIST_MENUBUILDSUBGROUP)) { - g_hMenu[10] = AddMenuItem(sim311[0],110010,NULL,NULL,CMIF_ROOTPOPUP); - g_hMenu[11] = AddSubItem(g_hMenu[10],sim231[0],110011,110010,MODULENAME"/MODE_NAT"); - g_hMenu[12] = AddSubItem(g_hMenu[10],sim231[1],110012,110010,MODULENAME"/MODE_PGP"); - g_hMenu[13] = AddSubItem(g_hMenu[10],sim231[2],110013,110010,MODULENAME"/MODE_GPG"); - g_hMenu[14] = AddSubItem(g_hMenu[10],sim231[3],110014,110010,MODULENAME"/MODE_RSA"); - } - else { - g_hMenu[10] = 0; - g_hMenu[11] = AddMenuItem(sim231[0],110011,NULL,MODULENAME"/MODE_NAT"); - g_hMenu[12] = AddMenuItem(sim231[1],110012,NULL,MODULENAME"/MODE_PGP"); - g_hMenu[13] = AddMenuItem(sim231[2],110013,NULL,MODULENAME"/MODE_GPG"); - g_hMenu[14] = AddMenuItem(sim231[3],110014,NULL,MODULENAME"/MODE_RSA"); - } - - -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("create srmm icons"); -#endif - // add icon to srmm status icons - if(ServiceExists(MS_MSG_ADDICON)) { - - StatusIconData sid; - memset(&sid,0,sizeof(sid)); - sid.cbSize = sizeof(sid); - sid.szModule = (char*)szModuleName; - sid.flags = MBF_DISABLED|MBF_HIDDEN; - // Native - sid.dwId = MODE_NATIVE; - sid.hIcon = mode2icon(MODE_NATIVE|SECURED,3); - sid.hIconDisabled = mode2icon(MODE_NATIVE,3); - sid.szTooltip = Translate("SecureIM [Native]"); - CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid); - // PGP - sid.dwId = MODE_PGP; - sid.hIcon = mode2icon(MODE_PGP|SECURED,3); - sid.hIconDisabled = mode2icon(MODE_PGP,3); - sid.szTooltip = Translate("SecureIM [PGP]"); - CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid); - // GPG - sid.dwId = MODE_GPG; - sid.hIcon = mode2icon(MODE_GPG|SECURED,3); - sid.hIconDisabled = mode2icon(MODE_GPG,3); - sid.szTooltip = Translate("SecureIM [GPG]"); - CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid); - // RSAAES - sid.dwId = MODE_RSAAES; - sid.hIcon = mode2icon(MODE_RSAAES|SECURED,3); - sid.hIconDisabled = mode2icon(MODE_RSAAES,3); - sid.szTooltip = Translate("SecureIM [RSA/AES]"); - CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid); - - // hook the window events so that we can can change the status of the icon - AddHookFunction(ME_MSG_WINDOWEVENT, onWindowEvent); - AddHookFunction(ME_MSG_ICONPRESSED, onIconPressed); - } - -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onModuleLoaded end"); -#endif - return 0; -} - - -int __cdecl onSystemOKToExit(WPARAM wParam,LPARAM lParam) { - - if(bSavePass) { - LPSTR tmp = gpg_get_passphrases(); - DBWriteContactSettingString(0,szModuleName,"gpgSave",tmp); - LocalFree(tmp); - } - else { - DBDeleteContactSetting(0,szModuleName,"gpgSave"); - } - if(bPGPloaded) pgp_done(); - if(bGPGloaded) gpg_done(); - rsa_done(); - while(iHook--) UnhookEvent(g_hHook[iHook]); - mir_free(g_hHook); - while(iService--) DestroyServiceFunction(g_hService[iService]); - mir_free(g_hService); - DestroyHookableEvent(g_hEvent[0]); - DestroyHookableEvent(g_hEvent[1]); - freeContactList(); - free_rtfconv(); -#if defined(_DEBUG) || defined(NETLIB_LOG) - DeinitNetlib(); -#endif - return 0; -} - -// EOF diff --git a/plugins/SecureIM/mmi.cpp b/plugins/SecureIM/mmi.cpp deleted file mode 100644 index 2269d76a51..0000000000 --- a/plugins/SecureIM/mmi.cpp +++ /dev/null @@ -1,155 +0,0 @@ -#include "commonheaders.h" - - -void *operator new(size_t sz) { - return mir_alloc(sz); -} - - -void *operator new[](size_t size) { - return operator new(size); -} - - -void operator delete(void *p) { - mir_free(p); -} - - -void operator delete[](void * p) { - operator delete(p); -} - - -// ANSIzUCS2z + ANSIzUCS2z = ANSIzUCS2z -char *m_wwstrcat(LPCSTR strA, LPCSTR strB) { - int lenA = (int)strlen(strA); - int lenB = (int)strlen(strB); - LPSTR str = (LPSTR)mir_alloc((lenA+lenB+1)*(sizeof(WCHAR)+1)); - memcpy(str, strA, lenA); - memcpy(str+lenA, strB, lenB+1); - memcpy(str+lenA+lenB+1, strA+lenA+1, lenA*sizeof(WCHAR)); - memcpy(str+lenA+lenB+1+lenA*sizeof(WCHAR), strB+lenB+1, (lenB+1)*sizeof(WCHAR)); - return str; -} - - -// ANSIz + ANSIzUCS2z = ANSIzUCS2z -char *m_awstrcat(LPCSTR strA, LPCSTR strB) { - int lenA = (int)strlen(strA); - LPSTR tmpA = (LPSTR)mir_alloc((lenA+1)*(sizeof(WCHAR)+1)); - strcpy(tmpA, strA); - MultiByteToWideChar(CP_ACP, 0, strA, -1, (LPWSTR)(tmpA+lenA+1), (lenA+1)*sizeof(WCHAR)); - LPSTR str = m_wwstrcat(tmpA, strB); - mir_free(tmpA); - return str; -} - - -// ANSIz + ANSIz = ANSIzUCS2z -char *m_aastrcat(LPCSTR strA, LPCSTR strB) { - int lenA = (int)strlen(strA); - int lenB = (int)strlen(strB); - LPSTR str = (LPSTR)mir_alloc((lenA+lenB+1)*(sizeof(WCHAR)+1)); - strcpy(str,strA); - strcat(str,strB); - MultiByteToWideChar(CP_ACP, 0, str, -1, (LPWSTR)(str+lenA+lenB+1), (lenA+lenB+1)*sizeof(WCHAR)); - return str; -} - - -LPSTR m_string = NULL; - -// ANSIz + ANSIz = ANSIz -char *m_ustrcat(LPCSTR strA, LPCSTR strB) { - SAFE_FREE(m_string); - m_string = (LPSTR) mir_alloc(strlen(strA)+strlen(strB)+1); - strcpy(m_string,strA); strcat(m_string,strB); - return m_string; -} - - -LPSTR m_hex = NULL; - -LPSTR to_hex(PBYTE bin, int len) { - SAFE_FREE(m_hex); - m_hex = (LPSTR) mir_alloc(len*3+1); - LPSTR m_ptr = m_hex; - for ( int i=0; iutf8decode(szUtfMsg); - LPSTR szMsg = mir_u2a(wszMsg); - if ( bCoreUnicode ) { - flags |= PREF_UNICODE; - int olen = (int)wcslen((LPWSTR)wszMsg)+1; - int nlen = olen*(sizeof(WCHAR)+1); - szNewMsg = (LPSTR) mir_alloc(nlen); - memcpy(szNewMsg,szMsg,olen); - memcpy(szNewMsg+olen,wszMsg,olen*sizeof(WCHAR)); - mir_free(szMsg); - } - else { - szNewMsg = szMsg; - } - } - else { - flags &= ~PREF_UNICODE; flags |= PREF_UTF; - szNewMsg = (LPSTR) mir_strdup(szUtfMsg); - } - return szNewMsg; -} - - -// ЇаҐ®Ўа §гҐ¬ ⥪бв Ё§ д®а¬ в  ¬Ёа ­¤л ў зЁбвл© UTF8 -LPSTR miranda_to_utf8(LPCSTR szMirMsg, DWORD flags) { - LPSTR szNewMsg; - if(flags & PREF_UTF) { - szNewMsg = (LPSTR) szMirMsg; - } - else - if(flags & PREF_UNICODE) { - szNewMsg = exp->utf8encode((LPCWSTR)(szMirMsg+strlen(szMirMsg)+1)); - } - else { - LPWSTR wszMirMsg = mir_a2u(szMirMsg); - szNewMsg = exp->utf8encode((LPCWSTR)wszMirMsg); - mir_free(wszMirMsg); - } - return mir_strdup(szNewMsg); -} - - -// EOF diff --git a/plugins/SecureIM/mmi.h b/plugins/SecureIM/mmi.h deleted file mode 100644 index 7b3027e232..0000000000 --- a/plugins/SecureIM/mmi.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef __MMI_H__ -#define __MMI_H__ - -#include "commonheaders.h" - -char *m_wwstrcat(LPCSTR,LPCSTR); -char *m_awstrcat(LPCSTR,LPCSTR); -char *m_aastrcat(LPCSTR,LPCSTR); -char *m_ustrcat(LPCSTR,LPCSTR); -LPSTR to_hex(PBYTE,int); - -LPSTR utf8_to_miranda(LPCSTR,DWORD&); -LPSTR miranda_to_utf8(LPCSTR,DWORD); - -void *operator new(size_t sz); -void operator delete(void *p); -void *operator new[](size_t size); -void operator delete[](void * p); - -#define SAFE_INIT(t,p) t p=NULL; -#define SAFE_FREE(p) safe_free((void **)&(p)); -#define SAFE_DELETE(p) safe_delete((void **)&(p)); - -void __fastcall safe_free(void** p); -void __fastcall safe_delete(void** p); - -#endif diff --git a/plugins/SecureIM/options.cpp b/plugins/SecureIM/options.cpp deleted file mode 100644 index d6cc1a70d6..0000000000 --- a/plugins/SecureIM/options.cpp +++ /dev/null @@ -1,1928 +0,0 @@ -#include "commonheaders.h" - -#define PSKSIZE (4096+1) -#define RSASIZE (4096+1) - -BOOL bChangeSortOrder = false; -const char *szAdvancedIcons[] = {"None", "Email", "Protocol", "SMS", "Advanced 1", "Advanced 2", "Web", "Client", "VisMode", "Advanced 6", "Advanced 7", 0}; - - -BOOL hasKey(pUinKey ptr) { - BOOL ret = 0; - if ( ptr->mode==MODE_NATIVE ) { - LPSTR str = myDBGetString(ptr->hContact,szModuleName,"PSK"); - ret = (str!=NULL); SAFE_FREE(str); - } - else - if ( ptr->mode==MODE_RSAAES ) { - DBVARIANT dbv; - dbv.type = DBVT_BLOB; - if ( DBGetContactSetting(ptr->hContact,szModuleName,"rsa_pub",&dbv) == 0 ) { - ret = 1; - DBFreeVariant(&dbv); - } - } - return ret; -} - - -void TC_InsertItem(HWND hwnd, WPARAM wparam, TCITEM *tci) { - if ( bCoreUnicode ) { - LPWSTR tmp = mir_a2u(tci->pszText); - tci->pszText = (LPSTR)TranslateW(tmp); - SNDMSG(hwnd, TCM_INSERTITEMW, wparam, (LPARAM)tci); - mir_free(tmp); - } - else { - tci->pszText = Translate(tci->pszText); - SNDMSG(hwnd, TCM_INSERTITEMA, wparam, (LPARAM)tci); - } -} - - -static void LV_InsertColumn(HWND hwnd, WPARAM wparam, LVCOLUMN *lvc) { - if ( bCoreUnicode ) { - LPWSTR tmp = mir_a2u(lvc->pszText); - lvc->pszText = (LPSTR)TranslateW(tmp); - SNDMSG(hwnd, LVM_INSERTCOLUMNW, wparam, (LPARAM)lvc); - mir_free(tmp); - } - else { - lvc->pszText = Translate(lvc->pszText); - SNDMSG(hwnd, LVM_INSERTCOLUMNA, wparam, (LPARAM)lvc); - } -} - - -int LV_InsertItem(HWND hwnd, LVITEM *lvi) { - return SNDMSG(hwnd, bCoreUnicode ? LVM_INSERTITEMW : LVM_INSERTITEMA, 0, (LPARAM)lvi); -} - - -int LV_InsertItemA(HWND hwnd, LVITEM *lvi) { - if ( bCoreUnicode ) lvi->pszText = (LPSTR) mir_a2u(lvi->pszText); - int ret = LV_InsertItem(hwnd, lvi); - if ( bCoreUnicode ) mir_free(lvi->pszText); - return ret; -} - - -void LV_SetItemText(HWND hwnd, WPARAM wparam, int subitem, LPSTR text) { - LV_ITEM lvi; memset(&lvi,0,sizeof(lvi)); - lvi.iSubItem = subitem; - lvi.pszText = text; - SNDMSG(hwnd, bCoreUnicode ? LVM_SETITEMTEXTW : LVM_SETITEMTEXTA, wparam, (LPARAM)&lvi); -} - - -void LV_SetItemTextA(HWND hwnd, WPARAM wparam, int subitem, LPSTR text) { - if ( bCoreUnicode ) text = (LPSTR) mir_a2u(text); - LV_SetItemText(hwnd, wparam, subitem, text); - if ( bCoreUnicode ) mir_free(text); -} - - -void LV_GetItemTextA(HWND hwnd, WPARAM wparam, int iSubItem, LPSTR text, int cchTextMax) { - LV_ITEM lvi; memset(&lvi,0,sizeof(lvi)); - lvi.iSubItem = iSubItem; - lvi.cchTextMax = cchTextMax; - lvi.pszText = text; - SNDMSG(hwnd, bCoreUnicode ? LVM_GETITEMTEXTW : LVM_GETITEMTEXTA, wparam, (LPARAM)&lvi); - if ( bCoreUnicode ) { - lvi.pszText = mir_u2a((LPWSTR)text); - strcpy(text, lvi.pszText); - mir_free(lvi.pszText); - } -} - -/* - * tabbed options dialog - */ - -INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - - static int iInit = TRUE; - TCITEM tci; - - switch(msg) { - case WM_INITDIALOG: { - RECT rcClient; - GetClientRect(hwnd, &rcClient); - - iInit = TRUE; - tci.mask = TCIF_PARAM|TCIF_TEXT; - - tci.lParam = (LPARAM)CreateDialog(g_hInst,MAKEINTRESOURCE(IDD_TAB_GENERAL),hwnd,DlgProcOptionsGeneral); - tci.pszText = (LPSTR)sim201; - TC_InsertItem(GetDlgItem(hwnd, IDC_OPTIONSTAB), 0, &tci); - MoveWindow((HWND)tci.lParam,5,26,rcClient.right-8,rcClient.bottom-29,1); - - tci.lParam = (LPARAM)CreateDialog(g_hInst,MAKEINTRESOURCE(IDD_TAB_PROTO),hwnd,DlgProcOptionsProto); - tci.pszText = (LPSTR)sim202; - TC_InsertItem(GetDlgItem(hwnd, IDC_OPTIONSTAB), 2, &tci); - MoveWindow((HWND)tci.lParam,5,26,rcClient.right-8,rcClient.bottom-29,1); - ShowWindow((HWND)tci.lParam, SW_HIDE); - - if(bPGP && bPGPloaded) { - tci.lParam = (LPARAM)CreateDialog(g_hInst,MAKEINTRESOURCE(IDD_TAB_PGP),hwnd,DlgProcOptionsPGP); - tci.pszText = (LPSTR)sim214; - TC_InsertItem(GetDlgItem(hwnd, IDC_OPTIONSTAB), 3, &tci); - MoveWindow((HWND)tci.lParam,5,26,rcClient.right-8,rcClient.bottom-29,1); - ShowWindow((HWND)tci.lParam, SW_HIDE); - } - - if(bGPG && bGPGloaded) { - tci.lParam = (LPARAM)CreateDialog(g_hInst,MAKEINTRESOURCE(IDD_TAB_GPG),hwnd,DlgProcOptionsGPG); - tci.pszText = (LPSTR)sim226; - TC_InsertItem(GetDlgItem(hwnd, IDC_OPTIONSTAB), 4, &tci); - MoveWindow((HWND)tci.lParam,5,26,rcClient.right-8,rcClient.bottom-29,1); - ShowWindow((HWND)tci.lParam, SW_HIDE); - } - - // add more tabs here if needed - // activate the final tab - iInit = FALSE; - return TRUE; - } - break; - - case PSM_CHANGED: // used so tabs dont have to call SendMessage(GetParent(GetParent(hwnd)), PSM_CHANGED, 0, 0); - if (!iInit) - SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); - break; - - case WM_COMMAND: { - switch(LOWORD(wParam)) { - case ID_UPDATE_CLIST: { - tci.mask = TCIF_PARAM; - TabCtrl_GetItem(GetDlgItem(hwnd,IDC_OPTIONSTAB),0,&tci); - SendMessage((HWND)tci.lParam,WM_COMMAND,ID_UPDATE_CLIST,0); - } - break; -/* case ID_UPDATE_PROTO: { - tci.mask = TCIF_PARAM; - TabCtrl_GetItem(GetDlgItem(hwnd,IDC_OPTIONSTAB),1,&tci); - SendMessage((HWND)tci.lParam,WM_COMMAND,ID_UPDATE_PROTO,0); - } - break;*/ - case ID_UPDATE_PLIST: { - if ( !bPGP ) break; - tci.mask = TCIF_PARAM; - TabCtrl_GetItem(GetDlgItem(hwnd,IDC_OPTIONSTAB),2,&tci); - SendMessage((HWND)tci.lParam,WM_COMMAND,ID_UPDATE_CLIST,0); - } - break; - case ID_UPDATE_GLIST: { - if ( !bGPG ) break; - tci.mask = TCIF_PARAM; - TabCtrl_GetItem(GetDlgItem(hwnd,IDC_OPTIONSTAB),3,&tci); - SendMessage((HWND)tci.lParam,WM_COMMAND,ID_UPDATE_GLIST,0); - } - break; - } - } - break; - - case WM_NOTIFY: { - switch(((LPNMHDR)lParam)->idFrom) { - case 0: { - switch (((LPNMHDR)lParam)->code) { - case PSN_APPLY: { - tci.mask = TCIF_PARAM; - int cnt = TabCtrl_GetItemCount(GetDlgItem(hwnd,IDC_OPTIONSTAB)); - for (int i=0;icode) { - case TCN_SELCHANGING: { - tci.mask = TCIF_PARAM; - TabCtrl_GetItem(GetDlgItem(hwnd,IDC_OPTIONSTAB),TabCtrl_GetCurSel(GetDlgItem(hwnd,IDC_OPTIONSTAB)),&tci); - ShowWindow((HWND)tci.lParam,SW_HIDE); - } - break; - case TCN_SELCHANGE: { - tci.mask = TCIF_PARAM; - TabCtrl_GetItem(GetDlgItem(hwnd,IDC_OPTIONSTAB),TabCtrl_GetCurSel(GetDlgItem(hwnd,IDC_OPTIONSTAB)),&tci); - ShowWindow((HWND)tci.lParam,SW_SHOW); - } - break; - } - } // case IDC_OPTIONSTAB - break; - } - } // case WM_NOTIFY - break; - } - return FALSE; -} - - -INT_PTR CALLBACK DlgProcOptionsGeneral(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam) { - - static int iInit = TRUE; - static HIMAGELIST hLarge, hSmall; - int i,idx; pUinKey ptr; - - HWND hLV = GetDlgItem(hDlg,IDC_STD_USERLIST); - - switch (wMsg) { - case WM_INITDIALOG: { - - TranslateDialogDefault(hDlg); - -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("DlgProcOptionsGeneral(WN_INITDIALOG)"); -#endif - iInit = TRUE; -// SendMessage(hLV, WM_SETREDRAW, FALSE, 0); - ListView_SetExtendedListViewStyle(hLV, ListView_GetExtendedListViewStyle(hLV) | LVS_EX_FULLROWSELECT); - - hLarge = ImageList_Create(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), iBmpDepth, 1, 1); - hSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), iBmpDepth, 1, 1); -// COLORREF rgbTransparentColor; - for (i = 0; i < ICO_CNT; i++) { -// ImageList_AddMasked(himgl, hbmp, rgbTransparentColor); - ImageList_AddIcon(hSmall, g_hICO[i]); - ImageList_AddIcon(hLarge, g_hICO[i]); - } - - ListView_SetImageList(hLV, hSmall, LVSIL_SMALL); - ListView_SetImageList(hLV, hLarge, LVSIL_NORMAL); - - static const char *szColHdr[] = { sim203, sim204, sim230, sim205, "", sim234, 0 }; - static int iColWidth[] = { 150, 110, 60, 55, 35, 330 }; - LVCOLUMN lvc; - lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; - lvc.fmt = LVCFMT_LEFT; - for (i = 0; szColHdr[i]; i++) { - lvc.iSubItem = i; - lvc.pszText = (LPSTR)szColHdr[i]; - lvc.cx = iColWidth[i]; - LV_InsertColumn(hLV, i, &lvc); - } - for (i = 0; szAdvancedIcons[i]; i++) { - SendMessage(GetDlgItem(hDlg, IDC_ADVICON), CB_ADDSTRING, 0, (LPARAM) Translate(szAdvancedIcons[i])); - } - - RefreshGeneralDlg(hDlg,TRUE); - EnableWindow(hLV, true); -// SendMessage(hLV, WM_SETREDRAW, TRUE, 0); - - iInit = FALSE; - return TRUE; - } // WM_INITDIALOG - break; - - case WM_DESTROY: { - ImageList_Destroy(hSmall); - ImageList_Destroy(hLarge); - } // WM_DESTROY - break; - - case WM_PAINT: { - if (!iInit) - InvalidateRect(hDlg,NULL,FALSE); - } // WM_PAINT - break; - - case WM_COMMAND: { - switch(LOWORD(wParam)) { - case ID_ALWAYS: - case ID_ENABLED: - case ID_DISABLED: { - idx = ListView_GetSelectionMark(hLV); - ptr = (pUinKey) getListViewParam(hLV,idx); - if (ptr) { - ptr->tstatus = LOWORD(wParam)-ID_DISABLED; - setListViewStatus(hLV,idx,ptr->tstatus); - setListViewIcon(hLV,idx,ptr); - } - } - break; - - case ID_SIM_NATIVE: - case ID_SIM_PGP: - case ID_SIM_GPG: - case ID_SIM_RSAAES: - case ID_SIM_RSA: { - idx = ListView_GetSelectionMark(hLV); - ptr = (pUinKey) getListViewParam(hLV,idx); - if (ptr) { - ptr->tmode = LOWORD(wParam)-ID_SIM_NATIVE; - setListViewMode(hLV,idx,ptr->tmode); - setListViewIcon(hLV,idx,ptr); - } - } - break; - - case ID_SETPSK: { - idx = ListView_GetSelectionMark(hLV); - ptr = (pUinKey) getListViewParam(hLV,idx); - if(ptr) { - LPSTR buffer = (LPSTR)alloca(PSKSIZE+1); - getContactName(ptr->hContact, buffer); - int res = DialogBoxParam(g_hInst,MAKEINTRESOURCE(IDD_PSK),NULL,(DLGPROC)DlgProcSetPSK,(LPARAM)buffer); - if(res == IDOK) { - setListViewPSK(hLV,idx,1); - DBWriteContactSettingString(ptr->hContact,szModuleName,"tPSK",buffer); - } - } - } - break; - - case ID_DELPSK: { - idx = ListView_GetSelectionMark(hLV); - ptr = (pUinKey) getListViewParam(hLV,idx); - if(ptr) { - setListViewPSK(hLV,idx,0); - DBDeleteContactSetting(ptr->hContact, szModuleName, "tPSK"); - } - } - break; - - case ID_DELPUBL: { - idx = ListView_GetSelectionMark(hLV); - ptr = (pUinKey) getListViewParam(hLV,idx); - if(ptr) { - setListViewPUB(hLV,idx,0); - } - } - break; - - case ID_EXPPUBL: { - idx = ListView_GetSelectionMark(hLV); - ptr = (pUinKey) getListViewParam(hLV,idx); - if(ptr) { - if ( !ptr->keyLoaded ) { - createRSAcntx(ptr); - loadRSAkey(ptr); - } - if ( ptr->keyLoaded ) { - LPSTR buffer = (LPSTR) alloca(RSASIZE); - exp->rsa_export_pubkey(ptr->cntx,buffer); - if ( !SaveExportRSAKeyDlg(hDlg,buffer,0)) - msgbox(hDlg,sim114,szModuleName,MB_OK|MB_ICONEXCLAMATION); - } - } - return TRUE; - } - break; - - case ID_IMPPUBL: { - idx = ListView_GetSelectionMark(hLV); - ptr = (pUinKey) getListViewParam(hLV,idx); - if(ptr) { - createRSAcntx(ptr); - LPSTR pub = (LPSTR) alloca(RSASIZE); - if ( !LoadImportRSAKeyDlg(hDlg,pub,0)) return TRUE; - if ( exp->rsa_import_pubkey(ptr->cntx,pub)) { - int len; - exp->rsa_get_pubkey(ptr->cntx,(PBYTE)pub,&len); - - DBCONTACTWRITESETTING cws; - cws.szModule = szModuleName; - cws.szSetting = "rsa_pub"; - cws.value.type = DBVT_BLOB; - cws.value.pbVal = (PBYTE)pub; - cws.value.cpbVal = len; - CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)ptr->hContact, (LPARAM)&cws); - - setListViewPUB(hLV,idx,1); - } - else - msgbox(hDlg,sim115,szModuleName,MB_OK|MB_ICONEXCLAMATION); - } - return TRUE; - } - break; - - case ID_UPDATE_CLIST: { -// iInit = TRUE; -// RefreshGeneralDlg(hDlg,FALSE); -// iInit = FALSE; - return TRUE; - } - break; - - case IDC_RESET: { - if (!iInit) - ResetGeneralDlg(hDlg); - } - break; - - case IDC_ADV8: - case IDC_ADV7: - case IDC_ADV6: - case IDC_ADV5: - case IDC_ADV4: - case IDC_ADV3: - case IDC_ADV2: - case IDC_ADV1: - case IDC_ADV0: - case IDC_GPG: - case IDC_PGP: - case IDC_NO_PGP: - case IDC_NOL: - case IDC_AAK: - case IDC_MCM: - case IDC_AIP: - case IDC_SOM: - case IDC_SFT: - case IDC_ASI: - case IDC_MCD: - case IDC_KET: - case IDC_SCM: - case IDC_DGP: - case IDC_OKT: - case IDC_ADVICON: - break; - - default: - return FALSE; - } - if (!iInit) - SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); - } // WM_COMMAND - break; - - case WM_NOTIFY: { - switch(((LPNMHDR)lParam)->idFrom) { - case 0: { - if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) { - iInit = TRUE; - ApplyGeneralSettings(hDlg); - RefreshContactListIcons(); -// SendMessage(GetParent(hDlg),WM_COMMAND,ID_UPDATE_PLIST,0); -// SendMessage(GetParent(hDlg),WM_COMMAND,ID_UPDATE_GLIST,0); - iInit = FALSE; - } - } - break; - - case IDC_STD_USERLIST: { - switch(((LPNMHDR)lParam)->code) { - case NM_DBLCLK: { - if(LPNMLISTVIEW(lParam)->iSubItem == 2) { - idx = LPNMLISTVIEW(lParam)->iItem; - ptr = (pUinKey) getListViewParam(hLV,idx); - if (ptr) { - ptr->tmode++; - if ( !bPGP && ptr->tmode==MODE_PGP ) ptr->tmode++; - if ( !bGPG && ptr->tmode==MODE_GPG ) ptr->tmode++; - if ( ptr->tmode>=MODE_CNT ) ptr->tmode=MODE_NATIVE; - setListViewMode(hLV,idx,ptr->tmode); - setListViewIcon(hLV,idx,ptr); - SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); - } - } - if(LPNMLISTVIEW(lParam)->iSubItem == 3) { - idx = LPNMLISTVIEW(lParam)->iItem; - ptr = (pUinKey) getListViewParam(hLV,idx); - if (ptr) { - ptr->tstatus++; if(ptr->tstatus>(ptr->tmode==MODE_RSAAES?1:2)) ptr->tstatus=0; - setListViewStatus(hLV,idx,ptr->tstatus); - setListViewIcon(hLV,idx,ptr); - SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); - } - } - } break; - case NM_RCLICK: { -// idx = ListView_GetSelectionMark(hLV); - LPNMLISTVIEW lpLV = (LPNMLISTVIEW)lParam; - ptr = (pUinKey) getListViewParam(hLV,lpLV->iItem); - if (ptr) { - POINT p; GetCursorPos(&p); - HMENU hMenu = NULL; - if ( ptr->tmode==MODE_NATIVE || ptr->tmode==MODE_RSAAES ) { - switch( lpLV->iSubItem ) { - case 2: // mode - hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDM_CLIST2)); - break; - case 3: // status - hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE((ptr->tmode==MODE_NATIVE)?IDM_CLIST01:IDM_CLIST11)); - break; - case 4: // PSK/PUB - case 5: // SHA1 - hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE((ptr->tmode==MODE_NATIVE)?IDM_CLIST02:IDM_CLIST12)); - break; - default: // full menu - hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE((ptr->tmode==MODE_NATIVE)?IDM_CLIST0:IDM_CLIST1)); - break; - } - CheckMenuItem(hMenu, ID_DISABLED+ptr->tstatus, MF_CHECKED ); - if ( ptr->tmode==MODE_NATIVE ) { - if ( !hasKey(ptr)) EnableMenuItem(hMenu, ID_DELPSK, MF_GRAYED ); - } - else - if ( ptr->tmode==MODE_RSAAES ) { - if ( !hasKey(ptr)) { - EnableMenuItem(hMenu, ID_EXPPUBL, MF_GRAYED ); - EnableMenuItem(hMenu, ID_DELPUBL, MF_GRAYED ); - } - } - } - if ( !hMenu ) - hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDM_CLIST2)); - TranslateMenu(hMenu); - CheckMenuItem(hMenu, ID_SIM_NATIVE+ptr->tmode, MF_CHECKED ); - if ( !bPGP ) EnableMenuItem(hMenu, ID_SIM_PGP, MF_GRAYED ); - if ( !bGPG ) EnableMenuItem(hMenu, ID_SIM_GPG, MF_GRAYED ); -// CheckMenuItem(hMenu, ID_ENCRYPTION, MF_BYCOMMAND ); - TrackPopupMenu(GetSubMenu(hMenu, 0), TPM_LEFTALIGN | TPM_TOPALIGN, p.x, p.y, 0, hDlg, 0); - DestroyMenu(hMenu); - } - } break; - case LVN_COLUMNCLICK: { - bChangeSortOrder = true; - ListView_Sort(hLV,(LPARAM)(LPNMLISTVIEW(lParam)->iSubItem+0x01)); - bChangeSortOrder = false; - } - } - } - break; - } - } // WM_NOTIFY - break; - } - return FALSE; -} - - -INT_PTR CALLBACK DlgProcOptionsProto(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam) { - - static int iInit = TRUE; - char buf[32]; - int idx; - - HWND hLV = GetDlgItem(hDlg,IDC_PROTO); - - switch (wMsg) { - case WM_INITDIALOG: { - - TranslateDialogDefault(hDlg); - -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("DlgProcOptionsProto(WN_INITDIALOG)"); -#endif - iInit = TRUE; - ListView_SetExtendedListViewStyle(hLV, ListView_GetExtendedListViewStyle(hLV) | LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES); - - LVCOLUMN lvc; - lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; - lvc.fmt = LVCFMT_LEFT; - lvc.pszText = (LPSTR)sim210; - lvc.cx = 150; - LV_InsertColumn(hLV, 0, &lvc); - - RefreshProtoDlg(hDlg); - EnableWindow(hLV, true); - - iInit = FALSE; - return TRUE; - } // WM_INITDIALOG - break; - - case WM_PAINT: { - if (!iInit) - InvalidateRect(hDlg,NULL,FALSE); - } // WM_PAINT - break; - - case WM_COMMAND: { - switch(LOWORD(wParam)) { - case IDC_RSA_COPY: { - char txt[128]; - GetDlgItemText(hDlg, IDC_RSA_SHA, txt, sizeof(txt)); - CopyToClipboard(hDlg,txt); - return TRUE; - } break; - case IDC_RSA_EXP: { - LPSTR pub = (LPSTR) alloca(RSASIZE); - exp->rsa_export_keypair(CPP_MODE_RSA,NULL,pub,NULL); - if ( !SaveExportRSAKeyDlg(hDlg,pub,0)) - msgbox(hDlg,sim114,szModuleName,MB_OK|MB_ICONEXCLAMATION); - return TRUE; - } break; - case IDC_RSA_EXPPRIV: { - LPSTR passphrase = (LPSTR) alloca(RSASIZE); - int res = DialogBoxParam(g_hInst,MAKEINTRESOURCE(IDD_PASSPHRASE),NULL,(DLGPROC)DlgProcSetPassphrase,(LPARAM)passphrase); - if ( res==IDOK ) { - LPSTR priv = (LPSTR) alloca(RSASIZE); - exp->rsa_export_keypair(CPP_MODE_RSA,priv,NULL,passphrase); - if ( !SaveExportRSAKeyDlg(hDlg,priv,1)) - msgbox(hDlg,sim112,szModuleName,MB_OK|MB_ICONEXCLAMATION); - } - return TRUE; - } break; - case IDC_RSA_IMPPRIV: { - LPSTR priv = (LPSTR) alloca(RSASIZE); - if ( !LoadImportRSAKeyDlg(hDlg,priv,1)) return TRUE; - // - LPSTR passphrase = (LPSTR) alloca(RSASIZE); - int res = DialogBoxParam(g_hInst,MAKEINTRESOURCE(IDD_PASSPHRASE),NULL,(DLGPROC)DlgProcSetPassphrase,(LPARAM)passphrase); - if ( res==IDOK ) { - if ( !exp->rsa_import_keypair(CPP_MODE_RSA,priv,passphrase)) { - msgbox(hDlg,sim113,szModuleName,MB_OK|MB_ICONEXCLAMATION); - } - else { - // обновить SHA1 значение - RefreshProtoDlg(hDlg); - } - } - return TRUE; - } break; - case IDC_SPLITON: - case IDC_SPLITOFF: { - if ( HIWORD(wParam) == EN_CHANGE ) { - idx = ListView_GetSelectionMark(hLV); - if ( idx == -1 ) break; - idx = (int) getListViewParam(hLV,idx); - switch(LOWORD(wParam)) { - case IDC_SPLITON: - GetDlgItemText(hDlg,IDC_SPLITON,buf,5); - proto[idx].tsplit_on = atoi(buf); - break; - case IDC_SPLITOFF: - GetDlgItemText(hDlg,IDC_SPLITOFF,buf,5); - proto[idx].tsplit_off = atoi(buf); - break; - } - } - if (!iInit) - SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); - } break; - } - } - break; - - case WM_NOTIFY: { - switch(((LPNMHDR)lParam)->idFrom) { - case 0: { - if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) { - iInit = TRUE; - ApplyProtoSettings(hDlg); - RefreshProtoDlg(hDlg); - RefreshContactListIcons(); - SendMessage(GetParent(hDlg),WM_COMMAND,ID_UPDATE_CLIST,0); -// SendMessage(GetParent(hDlg),WM_COMMAND,ID_UPDATE_PLIST,0); -// SendMessage(GetParent(hDlg),WM_COMMAND,ID_UPDATE_GLIST,0); - iInit = FALSE; - } - } - break; - - case IDC_PROTO: { - if (((LPNMHDR)lParam)->code == (UINT)NM_CLICK) { - idx = (int) getListViewParam(hLV,LPNMLISTVIEW(lParam)->iItem); - if ( idx == -1 ) break; - EnableWindow(GetDlgItem(hDlg,IDC_SPLITON), true); - EnableWindow(GetDlgItem(hDlg,IDC_SPLITOFF), true); - mir_itoa(proto[idx].tsplit_on,buf,10); SetDlgItemText(hDlg,IDC_SPLITON,buf); - mir_itoa(proto[idx].tsplit_off,buf,10); SetDlgItemText(hDlg,IDC_SPLITOFF,buf); - SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); - } - } - break; - } - } // WM_NOTIFY - break; - } - return FALSE; -} - - -static BOOL bPGP9; - -INT_PTR CALLBACK DlgProcOptionsPGP(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam) { - - static int iInit = TRUE; - static HIMAGELIST hLarge, hSmall; - int i; - - HWND hLV = GetDlgItem(hDlg,IDC_PGP_USERLIST); - - switch (wMsg) { - case WM_INITDIALOG: { - - TranslateDialogDefault(hDlg); - -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("DlgProcOptionsPGP(WN_INITDIALOG)"); -#endif - iInit = TRUE; - ListView_SetExtendedListViewStyle(hLV, ListView_GetExtendedListViewStyle(hLV) | LVS_EX_FULLROWSELECT); - - hLarge = ImageList_Create(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), iBmpDepth, 1, 1); - hSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), iBmpDepth, 1, 1); - for (i = ICO_ST_DIS; i <= ICO_ST_TRY; i++) { - ImageList_AddIcon(hSmall, g_hICO[i]); - ImageList_AddIcon(hLarge, g_hICO[i]); - } - - ListView_SetImageList(hLV, hSmall, LVSIL_SMALL); - ListView_SetImageList(hLV, hLarge, LVSIL_NORMAL); - - static const char *szColHdr[] = { sim203, sim204, sim215, 0 }; - static int iColWidth[] = { 160, 150, 80 }; - LVCOLUMN lvc; - lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; - lvc.fmt = LVCFMT_LEFT; - for (i = 0; szColHdr[i]; i++) { - lvc.iSubItem = i; - lvc.pszText = (LPSTR)szColHdr[i]; - lvc.cx = iColWidth[i]; - LV_InsertColumn(hLV, i, &lvc); - } - - RefreshPGPDlg(hDlg,TRUE); -// EnableWindow(hLV, bPGPkeyrings); - - iInit = FALSE; - return TRUE; - } // WM_INITDIALOG - break; - - case WM_DESTROY: { - ImageList_Destroy(hSmall); - ImageList_Destroy(hLarge); - } // WM_DESTROY - break; - - case WM_PAINT: { - if (!iInit) - InvalidateRect(hDlg,NULL,FALSE); - } // WM_PAINT - break; - - case WM_COMMAND: { - switch(LOWORD(wParam)) { - case IDC_SET_KEYRINGS: { - char PubRingPath[MAX_PATH], SecRingPath[MAX_PATH]; - PubRingPath[0]='\0'; SecRingPath[0]='\0'; - bPGPkeyrings = pgp_open_keyrings(PubRingPath,SecRingPath); - if(bPGPkeyrings && PubRingPath[0] && SecRingPath[0]) { - DBWriteContactSettingString(0,szModuleName,"pgpPubRing",PubRingPath); - DBWriteContactSettingString(0,szModuleName,"pgpSecRing",SecRingPath); - } - SetDlgItemText(hDlg, IDC_KEYRING_STATUS, bPGPkeyrings?Translate(sim216):Translate(sim217)); -// EnableWindow(hLV, bPGPkeyrings); -// RefreshPGPDlg(hDlg); - return FALSE; - } - break; - case IDC_NO_KEYRINGS: { - BOOL bNoKR = (SendMessage(GetDlgItem(hDlg, IDC_NO_KEYRINGS),BM_GETCHECK,0L,0L)==BST_CHECKED); - EnableWindow(GetDlgItem(hDlg, IDC_SET_KEYRINGS), !bNoKR); - EnableWindow(GetDlgItem(hDlg, IDC_LOAD_PRIVKEY), bNoKR); - SetDlgItemText(hDlg, IDC_KEYRING_STATUS, bNoKR?Translate(sim225):((bPGP9)?Translate(sim220):(bPGPkeyrings?Translate(sim216):Translate(sim217)))); - } - break; - case IDC_LOAD_PRIVKEY: { - char KeyPath[MAX_PATH]; KeyPath[0]='\0'; - if(ShowSelectKeyDlg(hDlg,KeyPath)) { - char *priv = LoadKeys(KeyPath,true); - if(priv) { - DBWriteContactSettingString(0,szModuleName,"tpgpPrivKey",priv); - mir_free(priv); - } - else { - DBDeleteContactSetting(0,szModuleName,"tpgpPrivKey"); - } - } - } - break; - case ID_UPDATE_PLIST: { - iInit = TRUE; - RefreshPGPDlg(hDlg,FALSE); - iInit = FALSE; - return TRUE; - } - break; - default: - break; - } - if (!iInit) - SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); - } - break; - - case WM_NOTIFY: { - switch(((LPNMHDR)lParam)->idFrom) { - case 0: { - if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) { - iInit = TRUE; - ApplyPGPSettings(hDlg); - RefreshPGPDlg(hDlg,FALSE); -// SendMessage(GetParent(hDlg),WM_COMMAND,ID_UPDATE_CLIST,0); - iInit = FALSE; - } - } - break; - case IDC_PGP_USERLIST: { - switch(((LPNMHDR)lParam)->code) { -/* case NM_RCLICK: { - POINT p; - GetCursorPos(&p); - HMENU hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDM_CLIST)); - CheckMenuItem(hMenu, ID_ENCRYPTION, MF_BYCOMMAND ); - TranslateMenu(hMenu); - TrackPopupMenu(GetSubMenu(hMenu, 0), TPM_LEFTALIGN | TPM_TOPALIGN, p.x, p.y, 0, hDlg, 0); - DestroyMenu(hMenu); - } break;*/ - case LVN_COLUMNCLICK: { - bChangeSortOrder = true; - ListView_Sort(hLV,(LPARAM)(LPNMLISTVIEW(lParam)->iSubItem+0x11)); - bChangeSortOrder = false; - } - } - } - break; - } - } // WM_NOTIFY - break; - } - return FALSE; -} - - -INT_PTR CALLBACK DlgProcOptionsGPG(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam) { - - static int iInit = TRUE; - static HIMAGELIST hLarge, hSmall; - int i, idx; pUinKey ptr; - - HWND hLV = GetDlgItem(hDlg,IDC_GPG_USERLIST); - - switch (wMsg) { - case WM_INITDIALOG: { - - TranslateDialogDefault(hDlg); - -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("DlgProcOptionsGPG(WN_INITDIALOG)"); -#endif - iInit = TRUE; - ListView_SetExtendedListViewStyle(hLV, ListView_GetExtendedListViewStyle(hLV) | LVS_EX_FULLROWSELECT); - - hLarge = ImageList_Create(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), iBmpDepth, 1, 1); - hSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), iBmpDepth, 1, 1); - for (i = ICO_ST_DIS; i <= ICO_ST_TRY; i++) { - ImageList_AddIcon(hSmall, g_hICO[i]); - ImageList_AddIcon(hLarge, g_hICO[i]); - } - - ListView_SetImageList(hLV, hSmall, LVSIL_SMALL); - ListView_SetImageList(hLV, hLarge, LVSIL_NORMAL); - - static const char *szColHdr[] = { sim203, sim204, sim215, sim227, 0 }; - static int iColWidth[] = { 140, 120, 120, 40 }; - LVCOLUMN lvc; - lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; - lvc.fmt = LVCFMT_LEFT; - for (i = 0; szColHdr[i]; i++) { - lvc.iSubItem = i; - lvc.pszText = (LPSTR)szColHdr[i]; - lvc.cx = iColWidth[i]; - LV_InsertColumn(hLV, i, &lvc); - } - - RefreshGPGDlg(hDlg,TRUE); -// EnableWindow(hLV, bPGPkeyrings); - - iInit = FALSE; - return TRUE; - } // WM_INITDIALOG - break; - - case WM_DESTROY: { - ImageList_Destroy(hSmall); - ImageList_Destroy(hLarge); - } // WM_DESTROY - break; - - case WM_PAINT: { - if (!iInit) - InvalidateRect(hDlg,NULL,FALSE); - } // WM_PAINT - break; - - case WM_COMMAND: { - switch(LOWORD(wParam)) { -/* case IDC_LOAD_PRIVKEY: { - char KeyPath[MAX_PATH] = {0}; - if(ShowSelectKeyDlg(hDlg,KeyPath)) { - char *priv = LoadKeys(KeyPath,true); - if(priv) { - DBWriteContactSettingString(0,szModuleName,"tpgpPrivKey",priv); - mir_free(priv); - } - else { - DBDeleteContactSetting(0,szModuleName,"tpgpPrivKey"); - } - } - } - break;*/ - case IDC_BROWSEEXECUTABLE_BTN: { - char gpgexe[256]; - char filter[128]; - OPENFILENAME ofn; - - GetDlgItemText(hDlg, IDC_GPGEXECUTABLE_EDIT, gpgexe, sizeof(gpgexe)); - - char *txtexecutablefiles="Executable Files"; /*lang*/ - char *txtselectexecutable="Select GnuPG Executable"; /*lang*/ - - // filter zusammensetzen - memset(&filter,0,sizeof(filter)); - strcpy(filter, Translate(txtexecutablefiles)); - strcat(filter, " (*.exe)"); - strcpy(filter+strlen(filter)+1, "*.exe"); - - // OPENFILENAME initialisieren - memset(&ofn,0,sizeof(ofn)); - ofn.lStructSize=sizeof(ofn); - ofn.hwndOwner=hDlg; - ofn.lpstrFilter=filter; - ofn.lpstrFile=gpgexe; - ofn.nMaxFile=sizeof(gpgexe); - ofn.lpstrTitle=Translate(txtselectexecutable); - ofn.Flags=OFN_FILEMUSTEXIST|OFN_LONGNAMES|OFN_HIDEREADONLY; - - if (GetOpenFileName(&ofn)) - { - SetDlgItemText(hDlg, IDC_GPGEXECUTABLE_EDIT, ofn.lpstrFile); - } - } - break; - case ID_UPDATE_GLIST: { - iInit = TRUE; - RefreshGPGDlg(hDlg,FALSE); - iInit = FALSE; - return TRUE; - } - break; - default: - break; - } - if (!iInit) - SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); - } - break; - - case WM_NOTIFY: { - switch(((LPNMHDR)lParam)->idFrom) { - case 0: { - if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) { - iInit = TRUE; - ApplyGPGSettings(hDlg); - RefreshGPGDlg(hDlg,FALSE); -// SendMessage(GetParent(hDlg),WM_COMMAND,ID_UPDATE_CLIST,0); - iInit = FALSE; - } - } - break; - case IDC_GPG_USERLIST: { - switch(((LPNMHDR)lParam)->code) { - case NM_DBLCLK: { - if(LPNMLISTVIEW(lParam)->iSubItem == 3) { - idx = LPNMLISTVIEW(lParam)->iItem; - ptr = (pUinKey) getListViewParam(hLV,idx); - if ( !ptr ) break; - ptr->tgpgMode++; ptr->tgpgMode&=1; - LV_SetItemTextA(hLV, LPNMLISTVIEW(lParam)->iItem, LPNMLISTVIEW(lParam)->iSubItem, (ptr->tgpgMode)?Translate(sim228):Translate(sim229)); - SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); - } - } break; -/* case NM_RCLICK: { - POINT p; - GetCursorPos(&p); - HMENU hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDM_CLIST)); - CheckMenuItem(hMenu, ID_ENCRYPTION, MF_BYCOMMAND ); - TranslateMenu(hMenu); - TrackPopupMenu(GetSubMenu(hMenu, 0), TPM_LEFTALIGN | TPM_TOPALIGN, p.x, p.y, 0, hDlg, 0); - DestroyMenu(hMenu); - } break;*/ - case LVN_COLUMNCLICK: { - bChangeSortOrder = true; - ListView_Sort(hLV,(LPARAM)(LPNMLISTVIEW(lParam)->iSubItem+0x21)); - bChangeSortOrder = false; - } - } - } - break; - } - } // WM_NOTIFY - break; - } - return FALSE; -} - - -BOOL CALLBACK DlgProcSetPSK(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) { - static char *buffer; - switch(uMsg) { - case WM_INITDIALOG: { - TranslateDialogDefault(hDlg); - SendDlgItemMessage(hDlg,IDC_EDIT1,EM_LIMITTEXT,PSKSIZE-1,0); - if ( bCoreUnicode ) SetDlgItemTextW(hDlg,IDC_EDIT2,(LPWSTR)lParam); - else SetDlgItemTextA(hDlg,IDC_EDIT2,(LPCSTR)lParam); - buffer = (LPSTR)lParam; - return (TRUE); - } - case WM_COMMAND: { - switch(LOWORD(wParam)) { - case IDOK: { - int len = GetDlgItemTextA(hDlg,IDC_EDIT1,buffer,PSKSIZE); - if(len<8) { - msgbox1(hDlg,sim211,szModuleName,MB_OK|MB_ICONEXCLAMATION); - return TRUE; - } - else { - EndDialog(hDlg,IDOK); - } - } - break; - case IDCANCEL: { - EndDialog(hDlg,IDCANCEL); - } - break; - } - } - break; - default: - return (FALSE); - } - return (TRUE); -} - - -BOOL CALLBACK DlgProcSetPassphrase(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) { - static LPSTR buffer; - switch(uMsg) { - case WM_INITDIALOG: { - TranslateDialogDefault(hDlg); - SendDlgItemMessage(hDlg,IDC_PASSPHRASE,EM_LIMITTEXT,RSASIZE-1,0); - buffer = (LPSTR)lParam; - return (TRUE); - } - case WM_COMMAND: { - switch(LOWORD(wParam)) { - case IDOK: { -// memset(buffer,0,RSASIZE); - GetDlgItemTextA(hDlg,IDC_PASSPHRASE,buffer,RSASIZE); - EndDialog(hDlg,IDOK); - } - break; - case IDCANCEL: { - EndDialog(hDlg,IDCANCEL); - } - break; - } - } - break; - default: - return (FALSE); - } - return (TRUE); -} - - -/////////////////// -// R E F R E S H // -/////////////////// - - -void RefreshGeneralDlg(HWND hDlg, BOOL iInit) { - - char timeout[10]; - UINT data; - -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("RefreshGeneralDlg"); -#endif - // Key Exchange Timeout - data = DBGetContactSettingWord(0, szModuleName, "ket", 10); - mir_itoa(data,timeout,10); - SetDlgItemText(hDlg,IDC_KET,timeout); - - // Offline Key Timeout - data = DBGetContactSettingWord(0, szModuleName, "okt", 2); - mir_itoa(data,timeout,10); - SetDlgItemText(hDlg,IDC_OKT,timeout); - - GetFlags(); - - SendMessage(GetDlgItem(hDlg,IDC_SFT),BM_SETCHECK,(bSFT)?BST_CHECKED:BST_UNCHECKED,0L); - SendMessage(GetDlgItem(hDlg,IDC_SOM),BM_SETCHECK,(bSOM)?BST_CHECKED:BST_UNCHECKED,0L); - SendMessage(GetDlgItem(hDlg,IDC_ASI),BM_SETCHECK,(bASI)?BST_CHECKED:BST_UNCHECKED,0L); - SendMessage(GetDlgItem(hDlg,IDC_MCD),BM_SETCHECK,(bMCD)?BST_CHECKED:BST_UNCHECKED,0L); - SendMessage(GetDlgItem(hDlg,IDC_SCM),BM_SETCHECK,(bSCM)?BST_CHECKED:BST_UNCHECKED,0L); - SendMessage(GetDlgItem(hDlg,IDC_DGP),BM_SETCHECK,(bDGP)?BST_CHECKED:BST_UNCHECKED,0L); - SendMessage(GetDlgItem(hDlg,IDC_AIP),BM_SETCHECK,(bAIP)?BST_CHECKED:BST_UNCHECKED,0L); - SendMessage(GetDlgItem(hDlg,IDC_NOL),BM_SETCHECK,(bNOL)?BST_CHECKED:BST_UNCHECKED,0L); - SendMessage(GetDlgItem(hDlg,IDC_AAK),BM_SETCHECK,(bAAK)?BST_CHECKED:BST_UNCHECKED,0L); - SendMessage(GetDlgItem(hDlg,IDC_MCM),BM_SETCHECK,(bMCM)?BST_CHECKED:BST_UNCHECKED,0L); - - // Advanced - SendMessage(GetDlgItem(hDlg, IDC_ADVICON), CB_SETCURSEL, bADV, 0); - if ( g_hCLIcon ) { - EnableWindow(GetDlgItem(hDlg, IDC_ADVICON), false); - } - - // Select {OFF,PGP,GPG} - SendMessage(GetDlgItem(hDlg,IDC_PGP),BM_SETCHECK,bPGP?BST_CHECKED:BST_UNCHECKED,0L); - SendMessage(GetDlgItem(hDlg,IDC_GPG),BM_SETCHECK,bGPG?BST_CHECKED:BST_UNCHECKED,0L); - - // rebuild list of contacts - HWND hLV = GetDlgItem(hDlg,IDC_STD_USERLIST); - ListView_DeleteAllItems(hLV); - - LVITEM lvi; memset(&lvi,0,sizeof(lvi)); - lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; - - HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - char tmp[NAMSIZE]; - - while (hContact) { - - pUinKey ptr = getUinKey(hContact); - if ( ptr && isSecureProtocol(hContact) /*&& !getMetaContact(hContact)*/ && !isChatRoom(hContact)) { - - if ( iInit ) { - ptr->tmode = ptr->mode; - ptr->tstatus = ptr->status; - } - - lvi.iItem++; - lvi.iImage = ptr->tstatus; - lvi.lParam = (LPARAM)ptr; - - getContactName(hContact, tmp); - lvi.pszText = (LPSTR)&tmp; - int itemNum = LV_InsertItem(hLV, &lvi); - - getContactUin(hContact, tmp); - LV_SetItemText(hLV, itemNum, 1, tmp); - - setListViewMode(hLV, itemNum, ptr->tmode); - setListViewStatus(hLV, itemNum, ptr->tstatus); - if ( ptr->mode==MODE_NATIVE ) setListViewPSK(hLV, itemNum, hasKey(ptr)); - else setListViewPUB(hLV, itemNum, hasKey(ptr)); - setListViewIcon(hLV, itemNum, ptr); - } - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); - } - ListView_Sort(hLV,(LPARAM)0); -} - - -void RefreshProtoDlg(HWND hDlg) { - - int i; - -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("RefreshProtoDlg"); -#endif - HWND hLV = GetDlgItem(hDlg,IDC_PROTO); - ListView_DeleteAllItems(hLV); - - LVITEM lvi; memset(&lvi,0,sizeof(lvi)); - lvi.mask = LVIF_TEXT | LVIF_PARAM; - - for(i=0;irsa_get_keyhash(CPP_MODE_RSA,NULL,NULL,(PBYTE)&sha,&len); - LPSTR txt = mir_strdup(to_hex(sha,len)); - SetDlgItemText(hDlg, IDC_RSA_SHA, txt); - mir_free(txt); -} - - -void RefreshPGPDlg(HWND hDlg, BOOL iInit) { - - int ver = pgp_get_version(); - bPGP9 = (ver>=0x03050000); - -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("RefreshPGPDlg"); -#endif - EnableWindow(GetDlgItem(hDlg, IDC_SET_KEYRINGS), bUseKeyrings && !bPGP9); - EnableWindow(GetDlgItem(hDlg, IDC_LOAD_PRIVKEY), !bUseKeyrings); - SetDlgItemText(hDlg, IDC_PGP_PRIVKEY, bPGPprivkey?Translate(sim222):Translate(sim223)); - - if(bPGPloaded && ver) { - char pgpVerStr[64]; - sprintf(pgpVerStr, Translate(sim218), ver >> 24, (ver >> 16) & 255, (ver >> 8) & 255); - SetDlgItemText(hDlg, IDC_PGP_SDK, pgpVerStr); - } - else { - SetDlgItemText(hDlg, IDC_PGP_SDK, Translate(sim219)); - } - SetDlgItemText(hDlg, IDC_KEYRING_STATUS, !bUseKeyrings?Translate(sim225):((bPGP9)?Translate(sim220):(bPGPkeyrings?Translate(sim216):Translate(sim217)))); - - // Disable keyrings use - SendMessage(GetDlgItem(hDlg,IDC_NO_KEYRINGS),BM_SETCHECK,(bUseKeyrings)?BST_UNCHECKED:BST_CHECKED,0L); - - // rebuild list of contacts - HWND hLV = GetDlgItem(hDlg,IDC_PGP_USERLIST); - ListView_DeleteAllItems(hLV); - - LVITEM lvi; memset(&lvi,0,sizeof(lvi)); - lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; - - HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - char tmp[NAMSIZE]; - - while (hContact) { - - pUinKey ptr = getUinKey(hContact); - if (ptr && ptr->mode==MODE_PGP && isSecureProtocol(hContact) /*&& !getMetaContact(hContact)*/ && !isChatRoom(hContact)) { - - LPSTR szKeyID = myDBGetString(hContact,szModuleName,"pgp_abbr"); - - lvi.iItem++; - lvi.iImage = (szKeyID!=0); - lvi.lParam = (LPARAM)ptr; - - getContactName(hContact, tmp); - lvi.pszText = (LPSTR)&tmp; - int itemNum = LV_InsertItem(hLV, &lvi); - - getContactUin(hContact, tmp); - LV_SetItemText(hLV, itemNum, 1, tmp); - - LV_SetItemTextA(hLV, itemNum, 2, (szKeyID)?szKeyID:Translate(sim221)); - SAFE_FREE(szKeyID); - } - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); - } - ListView_Sort(hLV,(LPARAM)0x10); -} - - -void RefreshGPGDlg(HWND hDlg, BOOL iInit) { - - LPSTR path; - -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("RefreshGPGDlg"); -#endif - path = myDBGetString(0,szModuleName,"gpgExec"); - if(path) { - SetDlgItemText(hDlg, IDC_GPGEXECUTABLE_EDIT, path); - mir_free(path); - } - path = myDBGetString(0,szModuleName,"gpgHome"); - if(path) { - SetDlgItemText(hDlg, IDC_GPGHOME_EDIT, path); - mir_free(path); - } - BOOL bGPGLogFlag = DBGetContactSettingByte(0, szModuleName, "gpgLogFlag",0); - SendMessage(GetDlgItem(hDlg,IDC_LOGGINGON_CBOX),BM_SETCHECK,(bGPGLogFlag)?BST_CHECKED:BST_UNCHECKED,0L); - path = myDBGetString(0,szModuleName,"gpgLog"); - if(path) { - SetDlgItemText(hDlg, IDC_GPGLOGFILE_EDIT, path); - mir_free(path); - } - SendMessage(GetDlgItem(hDlg,IDC_SAVEPASS_CBOX),BM_SETCHECK,(bSavePass)?BST_CHECKED:BST_UNCHECKED,0L); - BOOL bGPGTmpFlag = DBGetContactSettingByte(0, szModuleName, "gpgTmpFlag",0); - SendMessage(GetDlgItem(hDlg,IDC_TMPPATHON_CBOX),BM_SETCHECK,(bGPGTmpFlag)?BST_CHECKED:BST_UNCHECKED,0L); - path = myDBGetString(0,szModuleName,"gpgTmp"); - if(path) { - SetDlgItemText(hDlg, IDC_GPGTMPPATH_EDIT, path); - mir_free(path); - } - - // rebuild list of contacts - HWND hLV = GetDlgItem(hDlg,IDC_GPG_USERLIST); - ListView_DeleteAllItems(hLV); - - LVITEM lvi; memset(&lvi,0,sizeof(lvi)); - lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; - - HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - char tmp[NAMSIZE]; - - while (hContact) { - - pUinKey ptr = getUinKey(hContact); - if (ptr && ptr->mode==MODE_GPG && isSecureProtocol(hContact) /*&& !getMetaContact(hContact)*/ && !isChatRoom(hContact)) { - - if ( iInit ) { - ptr->tgpgMode = ptr->gpgMode; - } - - LPSTR szKeyID = myDBGetString(hContact,szModuleName,"gpg"); - - lvi.iItem++; - lvi.iImage = (szKeyID!=0); - lvi.lParam = (LPARAM)ptr; - - getContactName(hContact, tmp); - lvi.pszText = (LPSTR)&tmp; - int itemNum = LV_InsertItem(hLV, &lvi); - - getContactUin(hContact, tmp); - LV_SetItemText(hLV, itemNum, 1, tmp); - - LV_SetItemTextA(hLV, itemNum, 2, (szKeyID)?szKeyID:Translate(sim221)); - LV_SetItemTextA(hLV, itemNum, 3, (ptr->tgpgMode)?Translate(sim228):Translate(sim229)); - SAFE_FREE(szKeyID); - } - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); - } - ListView_Sort(hLV,(LPARAM)0x20); -} - - -/////////////// -// R E S E T // -/////////////// - - -void ResetGeneralDlg(HWND hDlg) { - - SetDlgItemText(hDlg,IDC_KET,"10"); - SetDlgItemText(hDlg,IDC_OKT,"2"); - - SendMessage(GetDlgItem(hDlg,IDC_SFT),BM_SETCHECK,BST_UNCHECKED,0L); - SendMessage(GetDlgItem(hDlg,IDC_SOM),BM_SETCHECK,BST_UNCHECKED,0L); - SendMessage(GetDlgItem(hDlg,IDC_ASI),BM_SETCHECK,BST_UNCHECKED,0L); - SendMessage(GetDlgItem(hDlg,IDC_MCD),BM_SETCHECK,BST_UNCHECKED,0L); - SendMessage(GetDlgItem(hDlg,IDC_SCM),BM_SETCHECK,BST_UNCHECKED,0L); - SendMessage(GetDlgItem(hDlg,IDC_DGP),BM_SETCHECK,BST_UNCHECKED,0L); - SendMessage(GetDlgItem(hDlg,IDC_AIP),BM_SETCHECK,BST_UNCHECKED,0L); - SendMessage(GetDlgItem(hDlg,IDC_MCM),BM_SETCHECK,BST_UNCHECKED,0L); - -// for(int i=0;itmode=MODE_NATIVE; - ptr->tstatus=STATUS_ENABLED; - - lvi.iItem++; - lvi.iImage = ptr->tstatus; - lvi.lParam = (LPARAM)ptr; - - getContactName(hContact, tmp); - lvi.pszText = (LPSTR)&tmp; - int itemNum = LV_InsertItem(hLV, &lvi); - - getContactUin(hContact, tmp); - LV_SetItemText(hLV, itemNum, 1, tmp); - - setListViewMode(hLV, itemNum, ptr->tmode); - setListViewStatus(hLV, itemNum, ptr->tstatus); - if ( ptr->mode==MODE_NATIVE ) setListViewPSK(hLV, itemNum, 0); - else setListViewPUB(hLV, itemNum, 0); - setListViewIcon(hLV, itemNum, ptr); - } - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); - } -} - - -void ResetProtoDlg(HWND hDlg) { -} - - -/////////////// -// A P P L Y // -/////////////// - - -void ApplyGeneralSettings(HWND hDlg) { - - char timeout[5]; - int tmp,i; - - // Key Exchange Timeout - GetDlgItemText(hDlg,IDC_KET,timeout,5); - tmp = atoi(timeout); if(tmp > 65535) tmp = 65535; - DBWriteContactSettingWord(0,szModuleName,"ket",tmp); - exp->rsa_set_timeout( DBGetContactSettingWord(0,szModuleName,"ket",10)); - mir_itoa(tmp,timeout,10); - SetDlgItemText(hDlg,IDC_KET,timeout); - - // Offline Key Timeout - GetDlgItemText(hDlg,IDC_OKT,timeout,5); - tmp = atoi(timeout); if(tmp > 65535) tmp = 65535; - DBWriteContactSettingWord(0,szModuleName,"okt",tmp); - mir_itoa(tmp,timeout,10); - SetDlgItemText(hDlg,IDC_OKT,timeout); - - bSFT = (SendMessage(GetDlgItem(hDlg, IDC_SFT),BM_GETCHECK,0L,0L)==BST_CHECKED); - bSOM = (SendMessage(GetDlgItem(hDlg, IDC_SOM),BM_GETCHECK,0L,0L)==BST_CHECKED); - bASI = (SendMessage(GetDlgItem(hDlg, IDC_ASI),BM_GETCHECK,0L,0L)==BST_CHECKED); - bMCD = (SendMessage(GetDlgItem(hDlg, IDC_MCD),BM_GETCHECK,0L,0L)==BST_CHECKED); - bSCM = (SendMessage(GetDlgItem(hDlg, IDC_SCM),BM_GETCHECK,0L,0L)==BST_CHECKED); - bDGP = (SendMessage(GetDlgItem(hDlg, IDC_DGP),BM_GETCHECK,0L,0L)==BST_CHECKED); - bAIP = (SendMessage(GetDlgItem(hDlg, IDC_AIP),BM_GETCHECK,0L,0L)==BST_CHECKED); - bNOL = (SendMessage(GetDlgItem(hDlg, IDC_NOL),BM_GETCHECK,0L,0L)==BST_CHECKED); - bAAK = (SendMessage(GetDlgItem(hDlg, IDC_AAK),BM_GETCHECK,0L,0L)==BST_CHECKED); - bMCM = (SendMessage(GetDlgItem(hDlg, IDC_MCM),BM_GETCHECK,0L,0L)==BST_CHECKED); - bADV = (BYTE)SendMessage(GetDlgItem(hDlg, IDC_ADVICON), CB_GETCURSEL, 0, 0); - - SetFlags(); - - // PGP &| GPG flags - { - tmp = 0; - i = SendMessage(GetDlgItem(hDlg, IDC_PGP),BM_GETCHECK,0L,0L)==BST_CHECKED; - if(i!=bPGP) { - bPGP = i; tmp++; - DBWriteContactSettingByte(0, szModuleName, "pgp", bPGP); - } - i = SendMessage(GetDlgItem(hDlg, IDC_GPG),BM_GETCHECK,0L,0L)==BST_CHECKED; - if(i!=bGPG) { - bGPG = i; tmp++; - DBWriteContactSettingByte(0, szModuleName, "gpg", bGPG); - } - if(tmp) msgbox1(hDlg, sim224, szModuleName, MB_OK|MB_ICONINFORMATION); - } - - HWND hLV = GetDlgItem(hDlg,IDC_STD_USERLIST); - i = ListView_GetNextItem(hLV,(UINT)-1,LVNI_ALL); - while(i!=-1) { - pUinKey ptr = (pUinKey)getListViewParam(hLV,i); - if ( !ptr ) continue; - if ( ptr->mode!=ptr->tmode ) { - ptr->mode = ptr->tmode; - DBWriteContactSettingByte(ptr->hContact, szModuleName, "mode", ptr->mode); - } - if ( ptr->status!=ptr->tstatus ) { - ptr->status = ptr->tstatus; - if(ptr->status==STATUS_ENABLED) DBDeleteContactSetting(ptr->hContact, szModuleName, "StatusID"); - else DBWriteContactSettingByte(ptr->hContact, szModuleName, "StatusID", ptr->status); - } - if ( ptr->mode==MODE_NATIVE ) { - if ( getListViewPSK(hLV,i)) { - LPSTR tmp = myDBGetString(ptr->hContact,szModuleName,"tPSK"); - DBWriteContactSettingString(ptr->hContact, szModuleName, "PSK", tmp); - mir_free(tmp); - } - else { - DBDeleteContactSetting(ptr->hContact, szModuleName, "PSK"); - } - DBDeleteContactSetting(ptr->hContact, szModuleName, "tPSK"); - } - else - if ( ptr->mode==MODE_RSAAES ) { - if ( !getListViewPUB(hLV,i)) { - DBDeleteContactSetting(ptr->hContact, szModuleName, "rsa_pub"); - } - } - i = ListView_GetNextItem(hLV,i,LVNI_ALL); - } -} - - -void ApplyProtoSettings(HWND hDlg) { - - LPSTR szNames = (LPSTR) alloca(2048); *szNames = '\0'; - - HWND hLV = GetDlgItem(hDlg,IDC_PROTO); - int i = ListView_GetNextItem(hLV,(UINT)-1,LVNI_ALL); - while(i!=-1) { - int j = getListViewProto(hLV,i); - proto[j].inspecting = ListView_GetCheckState(hLV,i); - char tmp[128]; - sprintf(tmp,"%s:%d:%d:%d;",proto[j].name,proto[j].inspecting,proto[j].tsplit_on,proto[j].tsplit_off); - strcat(szNames,tmp); - proto[j].split_on = proto[j].tsplit_on; - proto[j].split_off = proto[j].tsplit_off; - i = ListView_GetNextItem(hLV,i,LVNI_ALL); - } - - DBWriteContactSettingString(0,szModuleName,"protos",szNames); -} - - -void ApplyPGPSettings(HWND hDlg) { - - bUseKeyrings = !(SendMessage(GetDlgItem(hDlg, IDC_NO_KEYRINGS),BM_GETCHECK,0L,0L)==BST_CHECKED); - DBWriteContactSettingByte(0,szModuleName,"ukr",bUseKeyrings); - - char *priv = myDBGetString(0,szModuleName,"tpgpPrivKey"); - if(priv) { - bPGPprivkey = true; - pgp_set_priv_key(priv); - myDBWriteStringEncode(0,szModuleName,"pgpPrivKey",priv); - mir_free(priv); - DBDeleteContactSetting(0,szModuleName,"tpgpPrivKey"); - } -} - - -void ApplyGPGSettings(HWND hDlg) { - - char tmp[256]; - - GetDlgItemText(hDlg, IDC_GPGEXECUTABLE_EDIT, tmp, sizeof(tmp)); - DBWriteContactSettingString(0,szModuleName,"gpgExec",tmp); - GetDlgItemText(hDlg, IDC_GPGHOME_EDIT, tmp, sizeof(tmp)); - DBWriteContactSettingString(0,szModuleName,"gpgHome",tmp); - - bSavePass = (SendMessage(GetDlgItem(hDlg, IDC_SAVEPASS_CBOX),BM_GETCHECK,0L,0L)==BST_CHECKED); - DBWriteContactSettingByte(0,szModuleName,"gpgSaveFlag",bSavePass); - - BOOL bgpgLogFlag = (SendMessage(GetDlgItem(hDlg, IDC_LOGGINGON_CBOX),BM_GETCHECK,0L,0L)==BST_CHECKED); - DBWriteContactSettingByte(0,szModuleName,"gpgLogFlag",bgpgLogFlag); - GetDlgItemText(hDlg, IDC_GPGLOGFILE_EDIT, tmp, sizeof(tmp)); - DBWriteContactSettingString(0,szModuleName,"gpgLog",tmp); - if(bgpgLogFlag) gpg_set_log(tmp); - else gpg_set_log(0); - - BOOL bgpgTmpFlag = (SendMessage(GetDlgItem(hDlg, IDC_TMPPATHON_CBOX),BM_GETCHECK,0L,0L)==BST_CHECKED); - DBWriteContactSettingByte(0,szModuleName,"gpgTmpFlag",bgpgTmpFlag); - GetDlgItemText(hDlg, IDC_GPGTMPPATH_EDIT, tmp, sizeof(tmp)); - DBWriteContactSettingString(0,szModuleName,"gpgTmp",tmp); - if(bgpgTmpFlag) gpg_set_tmp(tmp); - else gpg_set_tmp(0); - - HWND hLV = GetDlgItem(hDlg,IDC_GPG_USERLIST); - int i = ListView_GetNextItem(hLV,(UINT)-1,LVNI_ALL); - while(i!=-1) { - pUinKey ptr = (pUinKey)getListViewParam(hLV,i); - if ( !ptr ) continue; - if ( ptr->gpgMode != ptr->tgpgMode ) { - ptr->gpgMode = ptr->tgpgMode; - if ( ptr->gpgMode ) DBWriteContactSettingByte(ptr->hContact,szModuleName,"gpgANSI",1); - else DBDeleteContactSetting(ptr->hContact,szModuleName,"gpgANSI"); - } - - i = ListView_GetNextItem(hLV,i,LVNI_ALL); - } -} - - -/////////////// -// O T H E R // -/////////////// - - -LPARAM getListViewParam(HWND hLV, UINT iItem) { - - LVITEM lvi; memset(&lvi,0,sizeof(lvi)); - lvi.iItem = iItem; - lvi.mask = LVIF_PARAM; - ListView_GetItem(hLV, &lvi); - return lvi.lParam; -} - - -void setListViewIcon(HWND hLV, UINT iItem, pUinKey ptr) { - - LVITEM lvi; memset(&lvi,0,sizeof(lvi)); - lvi.iItem = iItem; - switch(ptr->tmode) { - case MODE_NATIVE: - case MODE_RSAAES: - lvi.iImage = ICO_ST_DIS+ptr->tstatus; - break; - case MODE_PGP: - lvi.iImage = ICO_OV_PGP; - break; - case MODE_GPG: - lvi.iImage = ICO_OV_GPG; - break; - } - lvi.mask = LVIF_IMAGE; - ListView_SetItem(hLV, &lvi); -} - - -void setListViewMode(HWND hLV, UINT iItem, UINT iMode) { - - char tmp[256]; - strncpy(tmp, Translate(sim231[iMode]), sizeof(tmp)); - LV_SetItemTextA(hLV, iItem, 2, tmp); -} - - -void setListViewStatus(HWND hLV, UINT iItem, UINT iStatus) { - - char tmp[128]; - strncpy(tmp, Translate(sim232[iStatus]), sizeof(tmp)); - LV_SetItemTextA(hLV, iItem, 3, tmp); -} - - -UINT getListViewPSK(HWND hLV, UINT iItem) { - - char str[128]; - LV_GetItemTextA(hLV, iItem, 4, str, sizeof(str)); - return strncmp(str, Translate(sim206), sizeof(str))==0; -} - - -void setListViewPSK(HWND hLV, UINT iItem, UINT iStatus) { - - char str[128]; - strncpy(str, (iStatus)?Translate(sim206):"-", sizeof(str)); - LV_SetItemTextA(hLV, iItem, 4, str); -} - - -UINT getListViewPUB(HWND hLV, UINT iItem) { - - char str[128]; - LV_GetItemTextA(hLV, iItem, 4, str, sizeof(str)); - return strncmp(str, Translate(sim233), sizeof(str))==0; -} - - -void setListViewPUB(HWND hLV, UINT iItem, UINT iStatus) { - - char str[128]; - strncpy(str, (iStatus)?Translate(sim233):"-", sizeof(str)); - LV_SetItemTextA(hLV, iItem, 4, str); - - LPSTR sha = NULL; - if ( iStatus ) { - DBVARIANT dbv; - dbv.type = DBVT_BLOB; - pUinKey ptr = (pUinKey) getListViewParam(hLV, iItem); - if ( DBGetContactSetting(ptr->hContact,szModuleName,"rsa_pub",&dbv) == 0 ) { - int len; - exp->rsa_get_hash((PBYTE)dbv.pbVal,dbv.cpbVal,(PBYTE)str,&len); - sha = mir_strdup(to_hex((PBYTE)str,len)); - DBFreeVariant(&dbv); - } - } - if ( sha ) { - LV_SetItemTextA(hLV, iItem, 5, sha); - mir_free(sha); - } - else LV_SetItemTextA(hLV, iItem, 5, ""); -} - - -int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) { - char t1[NAMSIZE], t2[NAMSIZE]; - int s,d,m=1; - DBVARIANT dbv1,dbv2; - - if(lParamSort&0x100) { - lParamSort&=0xFF; - m=-1; - } - - switch(lParamSort){ - case 0x01: - case 0x11: - case 0x21: { - getContactNameA(pUinKey(lParam1)->hContact, t1); - getContactNameA(pUinKey(lParam2)->hContact, t2); - return strncmp(t1,t2,NAMSIZE)*m; - } break; - case 0x02: - case 0x12: - case 0x22: { - getContactUinA(pUinKey(lParam1)->hContact, t1); - getContactUinA(pUinKey(lParam2)->hContact, t2); - return strncmp(t1,t2,NAMSIZE)*m; - } break; - case 0x03: { - s = pUinKey(lParam1)->tmode; - d = pUinKey(lParam2)->tmode; - return (s-d)*m; - } break; - case 0x13: { - DBGetContactSetting(pUinKey(lParam1)->hContact,szModuleName,"pgp_abbr",&dbv1); - DBGetContactSetting(pUinKey(lParam2)->hContact,szModuleName,"pgp_abbr",&dbv2); - s=(dbv1.type==DBVT_ASCIIZ); - d=(dbv2.type==DBVT_ASCIIZ); - if(s && d) { - s=strcmp(dbv1.pszVal,dbv2.pszVal); - d=0; - } - DBFreeVariant(&dbv1); - DBFreeVariant(&dbv2); - return (s-d)*m; - } break; - case 0x23: { - DBGetContactSetting(pUinKey(lParam1)->hContact,szModuleName,"gpg",&dbv1); - DBGetContactSetting(pUinKey(lParam2)->hContact,szModuleName,"gpg",&dbv2); - s=(dbv1.type==DBVT_ASCIIZ); - d=(dbv2.type==DBVT_ASCIIZ); - if(s && d) { - s=strcmp(dbv1.pszVal,dbv2.pszVal); - d=0; - } - DBFreeVariant(&dbv1); - DBFreeVariant(&dbv2); - return (s-d)*m; - } break; - case 0x04: { - s = pUinKey(lParam1)->tstatus; - d = pUinKey(lParam2)->tstatus; - return (s-d)*m; - } break; - case 0x05: { - DBGetContactSetting(pUinKey(lParam1)->hContact,szModuleName,"PSK",&dbv1); - s=(dbv1.type==DBVT_ASCIIZ); - DBFreeVariant(&dbv1); - DBGetContactSetting(pUinKey(lParam2)->hContact,szModuleName,"PSK",&dbv2); - d=(dbv2.type==DBVT_ASCIIZ); - DBFreeVariant(&dbv2); - return (s-d)*m; - } break; - } - return 0; -} - - -void ListView_Sort(HWND hLV, LPARAM lParamSort) { - char t[32]; - - // restore sort column - sprintf(t,"os%02x",(UINT)lParamSort&0xF0); - if ((lParamSort&0x0F)==0) { - lParamSort=(int)DBGetContactSettingByte(0, szModuleName, t, lParamSort+1); - } - DBWriteContactSettingByte(0, szModuleName, t, (BYTE)lParamSort); - - // restore sort order - sprintf(t,"os%02x",(UINT)lParamSort); - int m=DBGetContactSettingByte(0, szModuleName, t, 0); - if(bChangeSortOrder){ m=!m; DBWriteContactSettingByte(0, szModuleName, t, m); } - - ListView_SortItems(hLV,&CompareFunc,lParamSort|(m<<8)); -} - - -BOOL ShowSelectKeyDlg(HWND hParent, LPSTR KeyPath) -{ - OPENFILENAME ofn; memset(&ofn, 0, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = hParent; - ofn.nMaxFile = MAX_PATH; - ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_NONETWORKBUTTON; - - ofn.lpstrFile = KeyPath; - ofn.lpstrFilter = "ASC files\0*.asc\0All files (*.*)\0*.*\0"; - ofn.lpstrTitle = "Open Key File"; - if (!GetOpenFileName(&ofn)) return FALSE; - - return TRUE; -} - - -LPCSTR priv_beg = "-----BEGIN PGP PRIVATE KEY BLOCK-----"; -LPCSTR priv_end = "-----END PGP PRIVATE KEY BLOCK-----"; -LPCSTR publ_beg = "-----BEGIN PGP PUBLIC KEY BLOCK-----"; -LPCSTR publ_end = "-----END PGP PUBLIC KEY BLOCK-----"; - -LPSTR LoadKeys(LPCSTR file,BOOL priv) { - FILE *f=fopen(file,"r"); - if (!f) return NULL; - - fseek(f,0,SEEK_END); - int flen = ftell(f); - fseek(f,0,SEEK_SET); - - LPCSTR beg,end; - if(priv) { - beg = priv_beg; - end = priv_end; - } - else { - beg = publ_beg; - end = publ_end; - } - - LPSTR keys = (LPSTR)mir_alloc(flen+1); - int i=0; BOOL b=false; - while(fgets(keys+i,128,f)) { - if (!b && strncmp(keys+i,beg,strlen(beg))==0) { - b=true; - } - else - if(b && strncmp(keys+i,end,strlen(end))==0) { - i+=(int)strlen(keys+i); - b=false; - } - if(b) { - i+=(int)strlen(keys+i); - } - } - *(keys+i)='\0'; -/* while(flen) { - int block = (flen>32768)?32768:flen; - fread(keys+i,block,1,f); - i+=block; - flen-=block; - }*/ - fclose(f); - return keys; -} - - -BOOL SaveExportRSAKeyDlg(HWND hParent, LPSTR key, BOOL priv) -{ - char szFile[MAX_PATH] = "rsa_pub.asc"; - if ( priv ) strcpy(szFile,"rsa_priv.asc"); - - OPENFILENAME ofn; memset(&ofn, 0, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = hParent; - ofn.nMaxFile = MAX_PATH; - ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_NONETWORKBUTTON; - ofn.lpstrFile = szFile; - ofn.lpstrFilter = "ASC files\0*.asc\0All files (*.*)\0*.*\0"; - ofn.lpstrTitle = (priv)?"Save Private Key File":"Save Public Key File"; - if (!GetSaveFileName(&ofn)) return FALSE; - - FILE *f=fopen(szFile,"wb"); - if ( !f ) return FALSE; - fwrite(key,strlen(key),1,f); - fclose(f); - - return TRUE; -} - - -BOOL LoadImportRSAKeyDlg(HWND hParent, LPSTR key, BOOL priv) -{ - char szFile[MAX_PATH] = "rsa_pub.asc"; - if ( priv ) strcpy(szFile,"rsa_priv.asc"); - - OPENFILENAME ofn; memset(&ofn, 0, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = hParent; - ofn.nMaxFile = MAX_PATH; - ofn.Flags = OFN_EXPLORER | OFN_CREATEPROMPT | OFN_OVERWRITEPROMPT | OFN_NOREADONLYRETURN; - ofn.lpstrFile = szFile; - ofn.lpstrFilter = "ASC files\0*.asc\0All files (*.*)\0*.*\0"; - ofn.lpstrTitle = (priv)?"Load Private Key File":"Load Public Key File"; - if (!GetOpenFileName(&ofn)) return FALSE; - - FILE *f=fopen(szFile,"rb"); - if ( !f ) return FALSE; - - fseek(f,0,SEEK_END); - int flen = ftell(f); if(flen>RSASIZE) { fclose(f); return FALSE; } - fseek(f,0,SEEK_SET); - - fread(key,flen,1,f); - fclose(f); - - return TRUE; -} - - -int onRegisterOptions(WPARAM wParam, LPARAM) -{ - OPTIONSDIALOGPAGE odp = { 0 }; - odp.cbSize = sizeof(odp); - odp.hInstance = g_hInst; - odp.pszTemplate = MAKEINTRESOURCE(IDD_OPTIONSTAB); - odp.pszTitle = (char*)szModuleName; - odp.pszGroup = LPGEN("Services"); - odp.pfnDlgProc = OptionsDlgProc; - Options_AddPage(wParam, &odp); - return 0; -} - -// EOF diff --git a/plugins/SecureIM/options.h b/plugins/SecureIM/options.h deleted file mode 100644 index c87a0de34d..0000000000 --- a/plugins/SecureIM/options.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef __OPTIONS_H__ -#define __OPTIONS_H__ - -INT_PTR CALLBACK OptionsDlgProc(HWND,UINT,WPARAM,LPARAM); -INT_PTR CALLBACK DlgProcOptionsGeneral(HWND,UINT,WPARAM,LPARAM); -INT_PTR CALLBACK DlgProcOptionsProto(HWND,UINT,WPARAM,LPARAM); -INT_PTR CALLBACK DlgProcOptionsPGP(HWND,UINT,WPARAM,LPARAM); -INT_PTR CALLBACK DlgProcOptionsGPG(HWND,UINT,WPARAM,LPARAM); -BOOL CALLBACK DlgProcSetPSK(HWND,UINT,WPARAM,LPARAM); -BOOL CALLBACK DlgProcSetPassphrase(HWND,UINT,WPARAM,LPARAM); -void ApplyGeneralSettings(HWND); -void ApplyProtoSettings(HWND); -void ApplyPGPSettings(HWND); -void ApplyGPGSettings(HWND); -void RefreshGeneralDlg(HWND,BOOL); -void RefreshProtoDlg(HWND); -void RefreshPGPDlg(HWND,BOOL); -void RefreshGPGDlg(HWND,BOOL); -void ResetGeneralDlg(HWND); -void ResetProtoDlg(HWND); -LPARAM getListViewParam(HWND,UINT); -void setListViewIcon(HWND,UINT,pUinKey); -void setListViewMode(HWND,UINT,UINT); -void setListViewStatus(HWND,UINT,UINT); -UINT getListViewPSK(HWND,UINT); -void setListViewPSK(HWND,UINT,UINT); -UINT getListViewPUB(HWND,UINT); -void setListViewPUB(HWND,UINT,UINT); -int onRegisterOptions(WPARAM,LPARAM); -int CALLBACK CompareFunc(LPARAM,LPARAM,LPARAM); -void ListView_Sort(HWND,LPARAM); -BOOL ShowSelectKeyDlg(HWND,LPSTR); -LPSTR LoadKeys(LPCSTR,BOOL); -BOOL SaveExportRSAKeyDlg(HWND,LPSTR,BOOL); -BOOL LoadImportRSAKeyDlg(HWND,LPSTR,BOOL); - -#define getListViewContact(h,i) (HANDLE)getListViewParam(h,i) -#define getListViewProto(h,i) (int)getListViewParam(h,i) - -#endif diff --git a/plugins/SecureIM/popupOptions.cpp b/plugins/SecureIM/popupOptions.cpp deleted file mode 100644 index 6e08cd81fc..0000000000 --- a/plugins/SecureIM/popupOptions.cpp +++ /dev/null @@ -1,239 +0,0 @@ -#include "commonheaders.h" - - -INT_PTR CALLBACK PopOptionsDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam) { - - char getTimeout[5]; - - HWND hec = GetDlgItem(hDlg, IDC_EC); - HWND hdc = GetDlgItem(hDlg, IDC_DC); - HWND hks = GetDlgItem(hDlg, IDC_KS); - HWND hkr = GetDlgItem(hDlg, IDC_KR); - HWND hss = GetDlgItem(hDlg, IDC_SS); - HWND hsr = GetDlgItem(hDlg, IDC_SR); - - switch (wMsg) { - case WM_COMMAND: { - - if (HIWORD(wParam) == CPN_COLOURCHANGED) { - //It's a colour picker change. LOWORD(wParam) is the control id. - DWORD color = SendDlgItemMessage(hDlg,LOWORD(wParam),CPM_GETCOLOUR,0,0); - - switch(LOWORD(wParam)) { - case IDC_BACKKEY: - DBWriteContactSettingDword(0, szModuleName, "colorKeyb", color); - break; - case IDC_TEXTKEY: - DBWriteContactSettingDword(0, szModuleName, "colorKeyt", color); - break; - case IDC_BACKSEC: - DBWriteContactSettingDword(0, szModuleName, "colorSecb", color); - break; - case IDC_TEXTSEC: - DBWriteContactSettingDword(0, szModuleName, "colorSect", color); - break; - case IDC_BACKSR: - DBWriteContactSettingDword(0, szModuleName, "colorSRb", color); - break; - case IDC_TEXTSR: - DBWriteContactSettingDword(0, szModuleName, "colorSRt", color); - break; - } - return TRUE; - } - - switch (LOWORD(wParam)) { - case IDC_PREV: { - //preview popups... - showPopUp("Key Popup",NULL,g_hPOP[POP_PU_PRC],0); - showPopUp("Secure Popup",NULL,g_hPOP[POP_PU_EST],1); - showPopUp("Message Popup",NULL,g_hPOP[POP_PU_MSR],2); - } - break; - case IDC_EC: { - //set ec checkbox value - DBWriteContactSettingByte(0, szModuleName, "ec", (BYTE)(SendMessage(hec,BM_GETCHECK,0L,0L)==BST_CHECKED)); - } - break; - case IDC_DC: { - //set dc checkbox value - DBWriteContactSettingByte(0, szModuleName, "dc", (BYTE)(SendMessage(hdc,BM_GETCHECK,0L,0L)==BST_CHECKED)); - } - break; - case IDC_SS: { - //set ss checkbox value - DBWriteContactSettingByte(0, szModuleName, "ss", (BYTE)(SendMessage(hss,BM_GETCHECK,0L,0L)==BST_CHECKED)); - } - break; - case IDC_SR: { - //set sr checkbox value - DBWriteContactSettingByte(0, szModuleName, "sr", (BYTE)(SendMessage(hsr,BM_GETCHECK,0L,0L)==BST_CHECKED)); - } - break; - case IDC_KS: { - //set indicator checkbox value - DBWriteContactSettingByte(0, szModuleName, "ks", (BYTE)(SendMessage(hks,BM_GETCHECK,0L,0L)==BST_CHECKED)); - } - break; - case IDC_KR: { - //set indicator checkbox value - DBWriteContactSettingByte(0, szModuleName, "kr", (BYTE)(SendMessage(hkr,BM_GETCHECK,0L,0L)==BST_CHECKED)); - } - break; - case IDC_TIMEKEY: { - //set timeout value - GetDlgItemText(hDlg,IDC_TIMEKEY,getTimeout,sizeof(getTimeout)); - mir_itoa(atoi(getTimeout),getTimeout,10); - DBWriteContactSettingString(0, szModuleName, "timeoutKey", getTimeout); - } - break; - case IDC_TIMESEC: { - //set timeout value - GetDlgItemText(hDlg,IDC_TIMESEC,getTimeout,sizeof(getTimeout)); - mir_itoa(atoi(getTimeout),getTimeout,10); - DBWriteContactSettingString(0, szModuleName, "timeoutSec", getTimeout); - } - break; - case IDC_TIMESR: { - //set timeout value - GetDlgItemText(hDlg,IDC_TIMESR,getTimeout,sizeof(getTimeout)); - mir_itoa(atoi(getTimeout),getTimeout,10); - DBWriteContactSettingString(0, szModuleName, "timeoutSR", getTimeout); - } - break; - } //switch - - RefreshPopupOptionsDlg(hec,hdc,hss,hsr,hks,hkr); - break; - } - - case WM_DESTROY: - break; - - case WM_INITDIALOG: { - TranslateDialogDefault(hDlg); - RefreshPopupOptionsDlg(hec,hdc,hss,hsr,hks,hkr); - - DBVARIANT dbv; - char *timeout; - - //set timeout value for Key - if (DBGetContactSetting(0, szModuleName, "timeoutKey", &dbv) == 0) timeout=dbv.pszVal; - else timeout="0"; - SetDlgItemText(hDlg, IDC_TIMEKEY, timeout); - DBFreeVariant(&dbv); - - //set timeout value for SEC - if (DBGetContactSetting(0, szModuleName, "timeoutSec", &dbv) == 0) timeout=dbv.pszVal; - else timeout="0"; - SetDlgItemText(hDlg, IDC_TIMESEC, timeout); - DBFreeVariant(&dbv); - - //set timeout value for SR - if (DBGetContactSetting(0, szModuleName, "timeoutSR", &dbv) == 0) timeout=dbv.pszVal; - else timeout="0"; - SetDlgItemText(hDlg, IDC_TIMESR, timeout); - DBFreeVariant(&dbv); - - //key color - SendDlgItemMessage(hDlg,IDC_BACKKEY,CPM_SETCOLOUR,0,DBGetContactSettingDword(0, szModuleName, "colorKeyb", RGB(230,230,255))); - SendDlgItemMessage(hDlg,IDC_TEXTKEY,CPM_SETCOLOUR,0,DBGetContactSettingDword(0, szModuleName, "colorKeyt", RGB(0,0,0))); - - //Session color - SendDlgItemMessage(hDlg,IDC_BACKSEC,CPM_SETCOLOUR,0,DBGetContactSettingDword(0, szModuleName, "colorSecb", RGB(255,255,200))); - SendDlgItemMessage(hDlg,IDC_TEXTSEC,CPM_SETCOLOUR,0,DBGetContactSettingDword(0, szModuleName, "colorSect", RGB(0,0,0))); - - //SR color - SendDlgItemMessage(hDlg,IDC_BACKSR,CPM_SETCOLOUR,0,DBGetContactSettingDword(0, szModuleName, "colorSRb", RGB(200,255,200))); - SendDlgItemMessage(hDlg,IDC_TEXTSR,CPM_SETCOLOUR,0,DBGetContactSettingDword(0, szModuleName, "colorSRt", RGB(0,0,0))); - - break; - } - - case WM_NOTIFY: { - break; - } - default: - return FALSE; - } - return TRUE; -} - - -void RefreshPopupOptionsDlg(HWND hec,HWND hdc,HWND hss,HWND hsr,HWND hks,HWND hkr) { - - DBVARIANT dbv; - int indic; - - // ec checkbox - if (DBGetContactSetting(0, szModuleName, "ec", &dbv) == 0) - {indic=dbv.bVal; - } - else indic=1; - - if(indic==1)SendMessage(hec,BM_SETCHECK,BST_CHECKED,0L); - else SendMessage(hec,BM_SETCHECK,BST_UNCHECKED,0L); - - // dc checkbox - if (DBGetContactSetting(0, szModuleName, "dc", &dbv) == 0) - {indic=dbv.bVal; - } - else indic=1; - - if(indic==1)SendMessage(hdc,BM_SETCHECK,BST_CHECKED,0L); - else SendMessage(hdc,BM_SETCHECK,BST_UNCHECKED,0L); - - // ks checkbox - if (DBGetContactSetting(0, szModuleName, "ks", &dbv) == 0) - {indic=dbv.bVal; - } - else indic=1; - - if(indic==1)SendMessage(hks,BM_SETCHECK,BST_CHECKED,0L); - else SendMessage(hks,BM_SETCHECK,BST_UNCHECKED,0L); - - // kr checkbox - if (DBGetContactSetting(0, szModuleName, "kr", &dbv) == 0) - {indic=dbv.bVal; - } - else indic=1; - - if(indic==1)SendMessage(hkr,BM_SETCHECK,BST_CHECKED,0L); - else SendMessage(hkr,BM_SETCHECK,BST_UNCHECKED,0L); - - //ss checkbox - if (DBGetContactSetting(0, szModuleName, "ss", &dbv) == 0) - {indic=dbv.bVal; - } - else indic=0; - - if(indic==1)SendMessage(hss,BM_SETCHECK,BST_CHECKED,0L); - else SendMessage(hss,BM_SETCHECK,BST_UNCHECKED,0L); - - //sr checkbox - if (DBGetContactSetting(0, szModuleName, "sr", &dbv) == 0) - {indic=dbv.bVal; - } - else indic=0; - - if(indic==1)SendMessage(hsr,BM_SETCHECK,BST_CHECKED,0L); - else SendMessage(hsr,BM_SETCHECK,BST_UNCHECKED,0L); - - DBFreeVariant(&dbv); -} - - -int onRegisterPopOptions(WPARAM wParam, LPARAM) -{ - OPTIONSDIALOGPAGE odp = {0}; - odp.cbSize = sizeof(odp); - odp.hInstance = g_hInst; - odp.pszTemplate = MAKEINTRESOURCE(IDD_POPUP); - odp.pszTitle = (char*)szModuleName; - odp.pszGroup = LPGEN("Popups"); - odp.pfnDlgProc = PopOptionsDlgProc; - Options_AddPage(wParam, &odp); - return 0; -} - -// EOF diff --git a/plugins/SecureIM/popupOptions.h b/plugins/SecureIM/popupOptions.h deleted file mode 100644 index 22d3453adc..0000000000 --- a/plugins/SecureIM/popupOptions.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __POPUP_OPTIONS__ -#define __POPUP_OPTIONS__ - -INT_PTR CALLBACK PopOptionsDlgProc(HWND,UINT,WPARAM,LPARAM); -void RefreshPopupOptionsDlg(HWND,HWND,HWND,HWND,HWND,HWND); -int onRegisterPopOptions(WPARAM,LPARAM); - -#endif diff --git a/plugins/SecureIM/res/cl_dis.ico b/plugins/SecureIM/res/cl_dis.ico new file mode 100644 index 0000000000..53209bc652 Binary files /dev/null and b/plugins/SecureIM/res/cl_dis.ico differ diff --git a/plugins/SecureIM/res/cl_est.ico b/plugins/SecureIM/res/cl_est.ico new file mode 100644 index 0000000000..8b42e2cb44 Binary files /dev/null and b/plugins/SecureIM/res/cl_est.ico differ diff --git a/plugins/SecureIM/res/cm_dis.ico b/plugins/SecureIM/res/cm_dis.ico new file mode 100644 index 0000000000..53209bc652 Binary files /dev/null and b/plugins/SecureIM/res/cm_dis.ico differ diff --git a/plugins/SecureIM/res/cm_est.ico b/plugins/SecureIM/res/cm_est.ico new file mode 100644 index 0000000000..dd6f805868 Binary files /dev/null and b/plugins/SecureIM/res/cm_est.ico differ diff --git a/plugins/SecureIM/res/mw_dis.ico b/plugins/SecureIM/res/mw_dis.ico new file mode 100644 index 0000000000..53209bc652 Binary files /dev/null and b/plugins/SecureIM/res/mw_dis.ico differ diff --git a/plugins/SecureIM/res/mw_est.ico b/plugins/SecureIM/res/mw_est.ico new file mode 100644 index 0000000000..8b42e2cb44 Binary files /dev/null and b/plugins/SecureIM/res/mw_est.ico differ diff --git a/plugins/SecureIM/res/ov_gpg.ico b/plugins/SecureIM/res/ov_gpg.ico new file mode 100644 index 0000000000..d823cf83b6 Binary files /dev/null and b/plugins/SecureIM/res/ov_gpg.ico differ diff --git a/plugins/SecureIM/res/ov_nat.ico b/plugins/SecureIM/res/ov_nat.ico new file mode 100644 index 0000000000..37000bd69b Binary files /dev/null and b/plugins/SecureIM/res/ov_nat.ico differ diff --git a/plugins/SecureIM/res/ov_pgp.ico b/plugins/SecureIM/res/ov_pgp.ico new file mode 100644 index 0000000000..c365c48cde Binary files /dev/null and b/plugins/SecureIM/res/ov_pgp.ico differ diff --git a/plugins/SecureIM/res/ov_rsa.ico b/plugins/SecureIM/res/ov_rsa.ico new file mode 100644 index 0000000000..a659463475 Binary files /dev/null and b/plugins/SecureIM/res/ov_rsa.ico differ diff --git a/plugins/SecureIM/res/pu_dis.ico b/plugins/SecureIM/res/pu_dis.ico new file mode 100644 index 0000000000..53209bc652 Binary files /dev/null and b/plugins/SecureIM/res/pu_dis.ico differ diff --git a/plugins/SecureIM/res/pu_est.ico b/plugins/SecureIM/res/pu_est.ico new file mode 100644 index 0000000000..8b42e2cb44 Binary files /dev/null and b/plugins/SecureIM/res/pu_est.ico differ diff --git a/plugins/SecureIM/res/pu_msg.ico b/plugins/SecureIM/res/pu_msg.ico new file mode 100644 index 0000000000..5964ead2e1 Binary files /dev/null and b/plugins/SecureIM/res/pu_msg.ico differ diff --git a/plugins/SecureIM/res/pu_prc.ico b/plugins/SecureIM/res/pu_prc.ico new file mode 100644 index 0000000000..822c55aeb7 Binary files /dev/null and b/plugins/SecureIM/res/pu_prc.ico differ diff --git a/plugins/SecureIM/res/resource.rc b/plugins/SecureIM/res/resource.rc new file mode 100644 index 0000000000..9ff15ed681 --- /dev/null +++ b/plugins/SecureIM/res/resource.rc @@ -0,0 +1,331 @@ +// Microsoft Visual C++ generated resource script. +// +#include "..\src\resource.h" +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#define APSTUDIO_HIDDEN_SYMBOLS +#include "windows.h" +#undef APSTUDIO_HIDDEN_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Russian resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) +#ifdef _WIN32 +LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT +#pragma code_page(1251) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_OPTIONSTAB DIALOGEX 0, 0, 312, 247 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + CONTROL "",IDC_OPTIONSTAB,"SysTabControl32",0x0,1,1,310,245,WS_EX_ACCEPTFILES +END + +IDD_TAB_GENERAL DIALOGEX 0, 0, 303, 226 +STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_VISIBLE +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + GROUPBOX "User List",IDC_STATIC,3,0,296,140 + CONTROL "",IDC_STD_USERLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,9,288,126,WS_EX_STATICEDGE + CONTROL "Enable Secure Offline messages",IDC_SOM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,142,145,10 + CONTROL "Enable Secure File Transfer",IDC_SFT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,152,145,10 + CONTROL "Always show status icons in contact list",IDC_ASI, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,162,145,10 + CONTROL "Context Menu only for ""Miranda"" clients",IDC_MCD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,172,145,10 + CONTROL "Status in Context Menu",IDC_SCM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,182,145,10 + CONTROL "Disable encryption for game plugins",IDC_DGP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,192,145,10 + CONTROL "Always secured if possible",IDC_AIP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,202,145,10 + CONTROL "Not secured for NotOnList",IDC_NOL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,212,145,10 + CONTROL "Auto accept RSA key (NOT SECURED)",IDC_AAK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,156,142,145,10 + CONTROL "Mode in Context Menu",IDC_MCM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,156,152,145,10 + GROUPBOX "",IDC_STATIC,156,158,144,19 + COMBOBOX IDC_ADVICON,160,163,135,81,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP,WS_EX_CLIENTEDGE + GROUPBOX "",IDC_STATIC,156,175,144,32 + RTEXT "Key Exchange Timeout :",IDC_STATIC,160,182,80,8 + EDITTEXT IDC_KET,241,180,30,12,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "sec",IDC_STATIC,275,182,18,8 + RTEXT "Offline Key Timeout :",IDC_STATIC,160,194,80,8 + EDITTEXT IDC_OKT,241,192,30,12,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "days",IDC_STATIC,275,194,18,8 + GROUPBOX "",IDC_STATIC,156,204,93,19 + CONTROL "PGP",IDC_PGP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,172,211,34,10 + CONTROL "GPG",IDC_GPG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,210,211,34,10 + PUSHBUTTON "Reset All",IDC_RESET,253,210,46,12 +END + +IDD_TAB_PROTO DIALOGEX 0, 0, 303, 226 +STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + GROUPBOX "Protocols",IDC_STATIC,14,12,129,137 + CONTROL "",IDC_PROTO,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,25,23,107,120,WS_EX_STATICEDGE + GROUPBOX "Split Messages",IDC_STATIC,154,12,136,28 + EDITTEXT IDC_SPLITON,190,23,26,12,ES_AUTOHSCROLL + LTEXT "Online:",IDC_STATIC,160,24,23,10 + EDITTEXT IDC_SPLITOFF,258,23,26,12,ES_AUTOHSCROLL + LTEXT "Offline:",IDC_STATIC,228,24,23,10 + GROUPBOX "RSA Key",IDC_STATIC,14,157,274,56 + LTEXT "SHA1:",IDC_STATIC,23,171,34,10 + CTEXT "",IDC_RSA_SHA,58,169,220,12,SS_CENTERIMAGE | SS_SUNKEN + GROUPBOX "Public",IDC_STATIC,21,184,123,25 + PUSHBUTTON "&Copy SHA1",IDC_RSA_COPY,27,193,54,12 + PUSHBUTTON "E&xport",IDC_RSA_EXP,87,193,54,12 + GROUPBOX "Private",IDC_STATIC,157,184,123,25 + PUSHBUTTON "&Export",IDC_RSA_EXPPRIV,164,193,54,12 + PUSHBUTTON "&Import",IDC_RSA_IMPPRIV,221,193,54,12 +END + +/* +IDD_TAB_MESSAGES DIALOGEX 0, 0, 303, 226 +STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + GROUPBOX "Protocols",IDC_STATIC,82,25,129,168 + EDITTEXT IDC_STATIC,221,71,69,77,ES_MULTILINE | ES_AUTOVSCROLL | + ES_AUTOHSCROLL | ES_WANTRETURN +END +*/ +IDD_TAB_PGP DIALOGEX 0, 0, 303, 226 +STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + GROUPBOX "",IDC_STATIC,5,5,292,30 + CTEXT "",IDC_PGP_SDK,13,15,101,15,SS_CENTERIMAGE | SS_SUNKEN + CTEXT "",IDC_KEYRING_STATUS,122,15,96,15,SS_CENTERIMAGE | SS_SUNKEN + PUSHBUTTON "Set &keyrings...",IDC_SET_KEYRINGS,225,15,65,15 + CONTROL "",IDC_PGP_USERLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | WS_BORDER | WS_TABSTOP,5,40,292,150 + GROUPBOX "",IDC_STATIC,5,190,292,30 + CTEXT "",IDC_PGP_PRIVKEY,13,200,106,15,SS_CENTERIMAGE | SS_SUNKEN + CTEXT "",IDC_STATIC,126,200,92,15,SS_CENTERIMAGE | SS_SUNKEN + CONTROL "Disable keyrings use",IDC_NO_KEYRINGS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,133,201,79,13 + PUSHBUTTON "Load &Private key",IDC_LOAD_PRIVKEY,225,200,65,15 +END + +IDD_TAB_GPG DIALOG DISCARDABLE 0, 0, 303, 226 +STYLE DS_FIXEDSYS | DS_CONTROL | WS_CHILD +FONT 8, "MS Shell Dlg" +BEGIN + GROUPBOX "Basic",IDC_STATIC,0,0,302,52 + LTEXT "Executable:",IDC_STATIC,5,11,58,8 + EDITTEXT IDC_GPGEXECUTABLE_EDIT,65,8,216,12,ES_AUTOHSCROLL + PUSHBUTTON "...",IDC_BROWSEEXECUTABLE_BTN,281,8,14,12 + LTEXT "Home Directory:",IDC_STATIC,5,24,58,8 + EDITTEXT IDC_GPGHOME_EDIT,65,22,232,12,ES_AUTOHSCROLL + CONTROL "Temp Dir:",IDC_TMPPATHON_CBOX,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,8,37,46,10 + EDITTEXT IDC_GPGTMPPATH_EDIT,65,36,232,12,ES_AUTOHSCROLL + GROUPBOX "Key Assignment",IDC_STATIC,0,53,302,142 + CONTROL "",IDC_GPG_USERLIST,"SysListView32",LVS_REPORT | + LVS_SINGLESEL | WS_BORDER | WS_TABSTOP,4,63,294,128 + GROUPBOX "Debug",IDC_STATIC,0,196,302,28 + CONTROL "Log to File",IDC_LOGGINGON_CBOX,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,5,208,46,10 + EDITTEXT IDC_GPGLOGFILE_EDIT,56,207,187,12,ES_AUTOHSCROLL + CONTROL "Save Pass",IDC_SAVEPASS_CBOX,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,249,208,48,10 +END + + +IDD_POPUP DIALOGEX 0, 0, 303, 226 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + CONTROL "",IDC_BACKKEY,"ColourPicker",WS_TABSTOP,14,36,28,14 + CONTROL "",IDC_TEXTKEY,"ColourPicker",WS_TABSTOP,50,36,28,14 + CTEXT "Back",IDC_STATIC,14,23,28,8 + CTEXT "Text",IDC_STATIC,50,23,28,8 + LTEXT "Key agreement colors",IDC_STATIC,82,42,105,8 + CONTROL "",IDC_BACKSEC,"ColourPicker",WS_TABSTOP,14,57,28,14 + CONTROL "",IDC_TEXTSEC,"ColourPicker",WS_TABSTOP,50,57,28,14 + LTEXT "Secure connection colors",IDC_STATIC,82,63,105,8 + CONTROL "",IDC_BACKSR,"ColourPicker",WS_TABSTOP,14,79,28,14 + CONTROL "",IDC_TEXTSR,"ColourPicker",WS_TABSTOP,50,79,28,14 + LTEXT "Send/Receive encrypted colors",IDC_STATIC,82,84,104,8 + GROUPBOX "SecureIM PopUp Colors",IDC_STATIC,7,7,181,122 + PUSHBUTTON "Preview",IDC_PREV,15,107,57,16 + GROUPBOX "Events",IDC_STATIC,7,132,248,88 + GROUPBOX "PopUp Timeout",IDC_STATIC,196,7,59,122 + EDITTEXT IDC_TIMEKEY,210,37,31,14,ES_AUTOHSCROLL + EDITTEXT IDC_TIMESEC,210,59,31,14,ES_AUTOHSCROLL + EDITTEXT IDC_TIMESR,210,81,31,14,ES_AUTOHSCROLL + CTEXT "Time in Seconds",IDC_STATIC,200,23,54,8 + CTEXT "0 = Default PopUp Timeout Value",IDC_STATIC,200,101,49,24 + CONTROL "Show a popup on established connection",IDC_EC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,144,168,10 + CONTROL "Show a popup on disabled connection",IDC_DC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,156,168,10 + CONTROL "Show a popup on key send",IDC_KS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,168,168,10 + CONTROL "Show a popup on key received",IDC_KR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,180,168,10 + CONTROL "Show a popup on each secure send",IDC_SS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,192,168,10 + CONTROL "Show a popup on each secure receive",IDC_SR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,204,168,10 +END + + +IDD_PSK DIALOGEX 0, 0, 166, 73 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Please type in your password" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + LTEXT "Username:",IDC_STATIC,7,16,36,8 + EDITTEXT IDC_EDIT2,46,14,113,13,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + LTEXT "Password:",IDC_STATIC,7,36,34,8 + EDITTEXT IDC_EDIT1,46,33,113,13,ES_PASSWORD | ES_AUTOHSCROLL + DEFPUSHBUTTON "OK",IDOK,126,54,33,12 + PUSHBUTTON "Cancel",IDCANCEL,92,54,33,12 +END + + +IDD_PASSPHRASE DIALOGEX 0, 0, 238, 46 +STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "SecureIM plugin Passphrase of private key" +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +BEGIN + LTEXT "Enter passphrase for the secret key:",IDC_STATIC,8,8,168,8 + EDITTEXT IDC_PASSPHRASE,6,24,168,12,ES_PASSWORD | ES_AUTOHSCROLL + DEFPUSHBUTTON "Ok",IDOK,181,7,50,14 + PUSHBUTTON "Cancel",IDCANCEL,181,24,50,14 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDM_CLIST0 MENU +BEGIN + POPUP "" + BEGIN + POPUP "Mode" + BEGIN + MENUITEM "Native SecureIM", ID_SIM_NATIVE + MENUITEM "PGP SecureIM", ID_SIM_PGP + MENUITEM "GPG SecureIM", ID_SIM_GPG + MENUITEM "RSA/AES SecureIM", ID_SIM_RSAAES +// MENUITEM "RSA SecureIM", ID_SIM_RSA + END + POPUP "Status" + BEGIN + MENUITEM "Always Try to Establish Secure IM", ID_ALWAYS + MENUITEM "Secure IM Enabled", ID_ENABLED + MENUITEM "Secure IM Disabled", ID_DISABLED + END + POPUP "Pre-shared key" + BEGIN + MENUITEM "Set key", ID_SETPSK + MENUITEM "Delete key", ID_DELPSK + END + END +END + + +IDM_CLIST01 MENU +BEGIN + POPUP "" + BEGIN + MENUITEM "Always Try to Establish Secure IM", ID_ALWAYS + MENUITEM "Secure IM Enabled", ID_ENABLED + MENUITEM "Secure IM Disabled", ID_DISABLED + END +END + + +IDM_CLIST02 MENU +BEGIN + POPUP "" + BEGIN + MENUITEM "Set pre-shared key", ID_SETPSK + MENUITEM "Delete pre-shared key", ID_DELPSK + END +END + + +IDM_CLIST1 MENU +BEGIN + POPUP "" + BEGIN + POPUP "Mode" + BEGIN + MENUITEM "Native SecureIM", ID_SIM_NATIVE + MENUITEM "PGP SecureIM", ID_SIM_PGP + MENUITEM "GPG SecureIM", ID_SIM_GPG + MENUITEM "RSA/AES SecureIM", ID_SIM_RSAAES +// MENUITEM "RSA SecureIM", ID_SIM_RSA + END + POPUP "Status" + BEGIN + MENUITEM "Secure IM Enabled", ID_ENABLED + MENUITEM "Secure IM Disabled", ID_DISABLED + END + POPUP "Public key" + BEGIN + MENUITEM "Export key", ID_EXPPUBL + MENUITEM "Import key", ID_IMPPUBL + MENUITEM "Delete key", ID_DELPUBL + END + END +END + + +IDM_CLIST11 MENU +BEGIN + POPUP "" + BEGIN + MENUITEM "Secure IM Enabled", ID_ENABLED + MENUITEM "Secure IM Disabled", ID_DISABLED + END +END + + +IDM_CLIST12 MENU +BEGIN + POPUP "" + BEGIN + MENUITEM "Export public key", ID_EXPPUBL + MENUITEM "Import public key", ID_IMPPUBL + MENUITEM "Delete public key", ID_DELPUBL + END +END + + +IDM_CLIST2 MENU +BEGIN + POPUP "" + BEGIN + MENUITEM "Native SecureIM", ID_SIM_NATIVE + MENUITEM "PGP SecureIM", ID_SIM_PGP + MENUITEM "GPG SecureIM", ID_SIM_GPG + MENUITEM "RSA/AES SecureIM", ID_SIM_RSAAES +// MENUITEM "RSA SecureIM", ID_SIM_RSA + END +END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "..\\src\\resource.h\0" + "afxres.h\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // Russian resources +///////////////////////////////////////////////////////////////////////////// diff --git a/plugins/SecureIM/res/resource_icons.rc b/plugins/SecureIM/res/resource_icons.rc new file mode 100644 index 0000000000..8f9e8edf85 --- /dev/null +++ b/plugins/SecureIM/res/resource_icons.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "..\src\resource.h" +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#define APSTUDIO_HIDDEN_SYMBOLS +#include "windows.h" +#undef APSTUDIO_HIDDEN_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Russian 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_CL_DIS ICON "cl_dis.ico" +IDI_CL_EST ICON "cl_est.ico" +IDI_CM_DIS ICON "cm_dis.ico" +IDI_CM_EST ICON "cm_est.ico" +IDI_MW_DIS ICON "mw_dis.ico" +IDI_MW_EST ICON "mw_est.ico" +IDI_PU_DIS ICON "pu_dis.ico" +IDI_PU_EST ICON "pu_est.ico" +IDI_PU_PRC ICON "pu_prc.ico" +IDI_PU_MSG ICON "pu_msg.ico" +IDI_ST_DIS ICON "st_dis.ico" +IDI_ST_ENA ICON "st_ena.ico" +IDI_ST_TRY ICON "st_try.ico" +IDI_OV_NAT ICON "ov_nat.ico" +IDI_OV_PGP ICON "ov_pgp.ico" +IDI_OV_GPG ICON "ov_gpg.ico" +IDI_OV_RSA ICON "ov_rsa.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "..\\src\\resource.h\0" + "afxres.h\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // Russian resources +///////////////////////////////////////////////////////////////////////////// diff --git a/plugins/SecureIM/res/st_dis.ico b/plugins/SecureIM/res/st_dis.ico new file mode 100644 index 0000000000..16c5bcfa90 Binary files /dev/null and b/plugins/SecureIM/res/st_dis.ico differ diff --git a/plugins/SecureIM/res/st_ena.ico b/plugins/SecureIM/res/st_ena.ico new file mode 100644 index 0000000000..fa67cbd015 Binary files /dev/null and b/plugins/SecureIM/res/st_ena.ico differ diff --git a/plugins/SecureIM/res/st_try.ico b/plugins/SecureIM/res/st_try.ico new file mode 100644 index 0000000000..9f4c6855aa Binary files /dev/null and b/plugins/SecureIM/res/st_try.ico differ diff --git a/plugins/SecureIM/res/version.rc b/plugins/SecureIM/res/version.rc new file mode 100644 index 0000000000..1dbe2d8238 --- /dev/null +++ b/plugins/SecureIM/res/version.rc @@ -0,0 +1,45 @@ +#ifdef APSTUDIO_INVOKED +#error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + +#include "..\src\version.h" + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION __FILEVERSION_STRING + PRODUCTVERSION __FILEVERSION_STRING + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "Comments", "Licensed under the terms of the GNU General Public License" + VALUE "FileDescription", "SecureIM plugin for Miranda IM" + VALUE "FileVersion", __VERSION_STRING + VALUE "InternalName", "SecureIM" + VALUE "LegalCopyright", "Copyright й 2003 Johell, й 2005-09 Baloo" + VALUE "OriginalFilename", "secureim.dll" + VALUE "ProductName", "SecureIM plugin" + VALUE "ProductVersion", __VERSION_STRING + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END + + diff --git a/plugins/SecureIM/res/version_icons.rc b/plugins/SecureIM/res/version_icons.rc new file mode 100644 index 0000000000..194ee4bc79 --- /dev/null +++ b/plugins/SecureIM/res/version_icons.rc @@ -0,0 +1,44 @@ +#ifdef APSTUDIO_INVOKED +#error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + +#include "..\src\version.h" + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION __FILEVERSION_STRING + PRODUCTVERSION __FILEVERSION_STRING + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "FileDescription", "Iconpack for SecureIM plugin of Miranda IM" + VALUE "FileVersion", __VERSION_STRING + VALUE "InternalName", "SecureIM_icons" + VALUE "LegalCopyright", "Copyright й 2006-09 Baloo" + VALUE "OriginalFilename", "SecureIM_icons.dll" + VALUE "ProductName", "Iconpack for SecureIM plugin" + VALUE "ProductVersion", __VERSION_STRING + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END + + diff --git a/plugins/SecureIM/resource.h b/plugins/SecureIM/resource.h deleted file mode 100644 index f8a753773d..0000000000 --- a/plugins/SecureIM/resource.h +++ /dev/null @@ -1,160 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by resource.rc -// -#define ID_FIRSTICON 1 -#define IDI_CL_DIS 1 -#define IDI_CL_EST 2 -#define IDI_CM_DIS 3 -#define IDI_CM_EST 4 -#define IDI_MW_DIS 5 -#define IDI_MW_EST 6 -#define IDI_PU_DIS 7 -#define IDI_PU_EST 8 -#define IDI_PU_PRC 9 -#define IDI_PU_MSG 10 -#define IDI_ST_DIS 11 -#define IDI_ST_ENA 12 -#define IDI_ST_TRY 13 -#define IDI_OV_NAT 14 -#define IDI_OV_PGP 15 -#define IDI_OV_GPG 16 -#define IDI_OV_RSA 17 -#define ID_LASTICON 17 - -#define ID_DISABLED 111 -#define ID_ENABLED 112 -#define ID_ALWAYS 113 -#define ID_SETPSK 114 -#define ID_DELPSK 115 -#define ID_UPDATE_CLIST 116 -#define ID_UPDATE_PROTO 117 -#define ID_UPDATE_PLIST 118 -#define ID_UPDATE_GLIST 119 -#define ID_GETPUBL 120 -#define ID_DELPUBL 121 -#define ID_EXPPUBL 122 -#define ID_IMPPUBL 123 - -#define ID_SIM_NATIVE 130 -#define ID_SIM_PGP 131 -#define ID_SIM_GPG 132 -#define ID_SIM_RSAAES 133 -#define ID_SIM_RSA 134 - -#define IDM_CLIST0 150 -#define IDM_CLIST1 151 -#define IDM_CLIST2 152 -#define IDM_CLIST01 153 -#define IDM_CLIST02 154 -#define IDM_CLIST11 155 -#define IDM_CLIST12 156 - -#define IDD_OPTIONSTAB 501 -#define IDD_TAB_GENERAL 502 -#define IDD_TAB_PROTO 503 -#define IDD_TAB_PGP 504 -#define IDD_TAB_GPG 505 -#define IDD_TAB_MESSAGES 506 -#define IDD_POPUP 507 -#define IDD_PSK 508 -#define IDD_PASSPHRASE 509 - -#define IDC_STD_USERLIST 1001 -#define IDC_TIMEOUT 1002 -#define IDC_BACKKEY 1003 -#define IDC_TEXTKEY 1004 -#define IDC_PREV 1005 -#define IDC_BACKSEC 1006 -#define IDC_TEXTSEC 1007 -#define IDC_RESET 1008 -#define IDC_ALWAYSICON 1009 -#define IDC_EC 1010 -#define IDC_DC 1011 -#define IDC_KS 1012 -#define IDC_KR 1013 -#define IDC_SS 1014 -#define IDC_SR 1015 -#define IDC_BACKSR 1016 -#define IDC_BACKKEY6 1017 -#define IDC_TEXTSR 1018 -#define IDC_TIMEKEY 1019 -#define IDC_TIMESEC 1020 -#define IDC_TIMESR 1021 -#define IDC_PVALUES 1022 -#define IDC_ADD 1023 -#define IDC_DELETE 1024 -#define IDC_SFT 1025 -#define IDC_ASI 1026 -#define IDC_SOM 1027 -#define IDC_ADV0 1028 -#define IDC_ADV1 1029 -#define IDC_ADV2 1030 -#define IDC_ADV3 1031 -#define IDC_ADV4 1032 -#define IDC_ADV5 1033 -#define IDC_ADV6 1034 -#define IDC_ADV7 1035 -#define IDC_ADV8 1036 -#define IDC_MCD 1037 -#define IDC_KET 1038 -#define IDC_OPTIONSTAB 1039 -#define IDC_PROTO 1040 -#define IDC_EDIT1 1041 -#define IDC_EDIT2 1042 -#define IDC_SCM 1043 -#define IDC_DGP 1044 -#define IDC_OKT 1045 -#define IDC_AIP 1046 -#define IDC_ADVICON 1047 -#define IDC_SPLITON 1048 -#define IDC_SPLITOFF 1049 -#define IDC_RSA_SHA 1050 -#define IDC_NOL 1051 -#define IDC_AAK 1052 -#define IDC_MCM 1053 -#define IDC_RSA_COPY 1054 -#define IDC_RSA_EXP 1055 -#define IDC_RSA_EXPPRIV 1056 -#define IDC_RSA_IMPPRIV 1057 -#define IDC_PASSPHRASE 1058 - -#define IDC_NO_PGP 1100 -#define IDC_PGP 1101 -#define IDC_GPG 1102 - -#define IDC_PGP_SDK 1200 -#define IDC_PGP_USERLIST 1201 -#define IDC_SET_KEYRINGS 1202 -#define IDC_KEYRING_STATUS 1203 -#define IDC_PGP_PRIVKEY 1204 -#define IDC_LOAD_PRIVKEY 1205 -#define IDC_NO_KEYRINGS 1206 - -#define IDC_GPGEXECUTABLE_EDIT 1300 -#define IDC_BROWSEEXECUTABLE_BTN 1301 -#define IDC_GPGHOME_EDIT 1302 -#define IDC_SECRETKEY_DDOWN 1303 -#define IDC_SECRETREFRESH_BTN 1304 -#define IDC_GPG_USERLIST 1305 -#define IDC_PUBLICKEY_DDOWN 1306 -#define IDC_PUBLICREFRESH_BTN 1307 -#define IDC_LOGGINGON_CBOX 1308 -#define IDC_GPGLOGFILE_EDIT 1309 -#define IDC_SAVEPASS_CBOX 1310 -#define IDC_TMPPATHON_CBOX 1311 -#define IDC_GPGTMPPATH_EDIT 1312 - -#define IDC_STATIC -1 -#define ID_ENCRYPTION 40001 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 119 -#define _APS_NEXT_COMMAND_VALUE 40002 -#define _APS_NEXT_CONTROL_VALUE 1400 -#define _APS_NEXT_SYMED_VALUE 119 -#endif -#endif diff --git a/plugins/SecureIM/resource.rc b/plugins/SecureIM/resource.rc deleted file mode 100644 index 929f4a413f..0000000000 --- a/plugins/SecureIM/resource.rc +++ /dev/null @@ -1,334 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#define APSTUDIO_HIDDEN_SYMBOLS -#include "windows.h" -#undef APSTUDIO_HIDDEN_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Russian resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) -#ifdef _WIN32 -LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT -#pragma code_page(1251) -#endif //_WIN32 - -#include "version.rc" - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_OPTIONSTAB DIALOGEX 0, 0, 312, 247 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - CONTROL "",IDC_OPTIONSTAB,"SysTabControl32",0x0,1,1,310,245,WS_EX_ACCEPTFILES -END - -IDD_TAB_GENERAL DIALOGEX 0, 0, 303, 226 -STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_VISIBLE -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - GROUPBOX "User List",IDC_STATIC,3,0,296,140 - CONTROL "",IDC_STD_USERLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,9,288,126,WS_EX_STATICEDGE - CONTROL "Enable Secure Offline messages",IDC_SOM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,142,145,10 - CONTROL "Enable Secure File Transfer",IDC_SFT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,152,145,10 - CONTROL "Always show status icons in contact list",IDC_ASI, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,162,145,10 - CONTROL "Context Menu only for ""Miranda"" clients",IDC_MCD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,172,145,10 - CONTROL "Status in Context Menu",IDC_SCM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,182,145,10 - CONTROL "Disable encryption for game plugins",IDC_DGP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,192,145,10 - CONTROL "Always secured if possible",IDC_AIP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,202,145,10 - CONTROL "Not secured for NotOnList",IDC_NOL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,212,145,10 - CONTROL "Auto accept RSA key (NOT SECURED)",IDC_AAK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,156,142,145,10 - CONTROL "Mode in Context Menu",IDC_MCM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,156,152,145,10 - GROUPBOX "",IDC_STATIC,156,158,144,19 - COMBOBOX IDC_ADVICON,160,163,135,81,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP,WS_EX_CLIENTEDGE - GROUPBOX "",IDC_STATIC,156,175,144,32 - RTEXT "Key Exchange Timeout :",IDC_STATIC,160,182,80,8 - EDITTEXT IDC_KET,241,180,30,12,ES_AUTOHSCROLL | ES_NUMBER - LTEXT "sec",IDC_STATIC,275,182,18,8 - RTEXT "Offline Key Timeout :",IDC_STATIC,160,194,80,8 - EDITTEXT IDC_OKT,241,192,30,12,ES_AUTOHSCROLL | ES_NUMBER - LTEXT "days",IDC_STATIC,275,194,18,8 - GROUPBOX "",IDC_STATIC,156,204,93,19 - CONTROL "PGP",IDC_PGP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,172,211,34,10 - CONTROL "GPG",IDC_GPG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,210,211,34,10 - PUSHBUTTON "Reset All",IDC_RESET,253,210,46,12 -END - -IDD_TAB_PROTO DIALOGEX 0, 0, 303, 226 -STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - GROUPBOX "Protocols",IDC_STATIC,14,12,129,137 - CONTROL "",IDC_PROTO,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,25,23,107,120,WS_EX_STATICEDGE - GROUPBOX "Split Messages",IDC_STATIC,154,12,136,28 - EDITTEXT IDC_SPLITON,190,23,26,12,ES_AUTOHSCROLL - LTEXT "Online:",IDC_STATIC,160,24,23,10 - EDITTEXT IDC_SPLITOFF,258,23,26,12,ES_AUTOHSCROLL - LTEXT "Offline:",IDC_STATIC,228,24,23,10 - GROUPBOX "RSA Key",IDC_STATIC,14,157,274,56 - LTEXT "SHA1:",IDC_STATIC,23,171,34,10 - CTEXT "",IDC_RSA_SHA,58,169,220,12,SS_CENTERIMAGE | SS_SUNKEN - GROUPBOX "Public",IDC_STATIC,21,184,123,25 - PUSHBUTTON "&Copy SHA1",IDC_RSA_COPY,27,193,54,12 - PUSHBUTTON "E&xport",IDC_RSA_EXP,87,193,54,12 - GROUPBOX "Private",IDC_STATIC,157,184,123,25 - PUSHBUTTON "&Export",IDC_RSA_EXPPRIV,164,193,54,12 - PUSHBUTTON "&Import",IDC_RSA_IMPPRIV,221,193,54,12 -END - -/* -IDD_TAB_MESSAGES DIALOGEX 0, 0, 303, 226 -STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - GROUPBOX "Protocols",IDC_STATIC,82,25,129,168 - EDITTEXT IDC_STATIC,221,71,69,77,ES_MULTILINE | ES_AUTOVSCROLL | - ES_AUTOHSCROLL | ES_WANTRETURN -END -*/ -IDD_TAB_PGP DIALOGEX 0, 0, 303, 226 -STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - GROUPBOX "",IDC_STATIC,5,5,292,30 - CTEXT "",IDC_PGP_SDK,13,15,101,15,SS_CENTERIMAGE | SS_SUNKEN - CTEXT "",IDC_KEYRING_STATUS,122,15,96,15,SS_CENTERIMAGE | SS_SUNKEN - PUSHBUTTON "Set &keyrings...",IDC_SET_KEYRINGS,225,15,65,15 - CONTROL "",IDC_PGP_USERLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | WS_BORDER | WS_TABSTOP,5,40,292,150 - GROUPBOX "",IDC_STATIC,5,190,292,30 - CTEXT "",IDC_PGP_PRIVKEY,13,200,106,15,SS_CENTERIMAGE | SS_SUNKEN - CTEXT "",IDC_STATIC,126,200,92,15,SS_CENTERIMAGE | SS_SUNKEN - CONTROL "Disable keyrings use",IDC_NO_KEYRINGS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,133,201,79,13 - PUSHBUTTON "Load &Private key",IDC_LOAD_PRIVKEY,225,200,65,15 -END - -IDD_TAB_GPG DIALOG DISCARDABLE 0, 0, 303, 226 -STYLE DS_FIXEDSYS | DS_CONTROL | WS_CHILD -FONT 8, "MS Shell Dlg" -BEGIN - GROUPBOX "Basic",IDC_STATIC,0,0,302,52 - LTEXT "Executable:",IDC_STATIC,5,11,58,8 - EDITTEXT IDC_GPGEXECUTABLE_EDIT,65,8,216,12,ES_AUTOHSCROLL - PUSHBUTTON "...",IDC_BROWSEEXECUTABLE_BTN,281,8,14,12 - LTEXT "Home Directory:",IDC_STATIC,5,24,58,8 - EDITTEXT IDC_GPGHOME_EDIT,65,22,232,12,ES_AUTOHSCROLL - CONTROL "Temp Dir:",IDC_TMPPATHON_CBOX,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,8,37,46,10 - EDITTEXT IDC_GPGTMPPATH_EDIT,65,36,232,12,ES_AUTOHSCROLL - GROUPBOX "Key Assignment",IDC_STATIC,0,53,302,142 - CONTROL "",IDC_GPG_USERLIST,"SysListView32",LVS_REPORT | - LVS_SINGLESEL | WS_BORDER | WS_TABSTOP,4,63,294,128 - GROUPBOX "Debug",IDC_STATIC,0,196,302,28 - CONTROL "Log to File",IDC_LOGGINGON_CBOX,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,5,208,46,10 - EDITTEXT IDC_GPGLOGFILE_EDIT,56,207,187,12,ES_AUTOHSCROLL - CONTROL "Save Pass",IDC_SAVEPASS_CBOX,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,249,208,48,10 -END - - -IDD_POPUP DIALOGEX 0, 0, 303, 226 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - CONTROL "",IDC_BACKKEY,"ColourPicker",WS_TABSTOP,14,36,28,14 - CONTROL "",IDC_TEXTKEY,"ColourPicker",WS_TABSTOP,50,36,28,14 - CTEXT "Back",IDC_STATIC,14,23,28,8 - CTEXT "Text",IDC_STATIC,50,23,28,8 - LTEXT "Key agreement colors",IDC_STATIC,82,42,105,8 - CONTROL "",IDC_BACKSEC,"ColourPicker",WS_TABSTOP,14,57,28,14 - CONTROL "",IDC_TEXTSEC,"ColourPicker",WS_TABSTOP,50,57,28,14 - LTEXT "Secure connection colors",IDC_STATIC,82,63,105,8 - CONTROL "",IDC_BACKSR,"ColourPicker",WS_TABSTOP,14,79,28,14 - CONTROL "",IDC_TEXTSR,"ColourPicker",WS_TABSTOP,50,79,28,14 - LTEXT "Send/Receive encrypted colors",IDC_STATIC,82,84,104,8 - GROUPBOX "SecureIM PopUp Colors",IDC_STATIC,7,7,181,122 - PUSHBUTTON "Preview",IDC_PREV,15,107,57,16 - GROUPBOX "Events",IDC_STATIC,7,132,248,88 - GROUPBOX "PopUp Timeout",IDC_STATIC,196,7,59,122 - EDITTEXT IDC_TIMEKEY,210,37,31,14,ES_AUTOHSCROLL - EDITTEXT IDC_TIMESEC,210,59,31,14,ES_AUTOHSCROLL - EDITTEXT IDC_TIMESR,210,81,31,14,ES_AUTOHSCROLL - CTEXT "Time in Seconds",IDC_STATIC,200,23,54,8 - CTEXT "0 = Default PopUp Timeout Value",IDC_STATIC,200,101,49,24 - CONTROL "Show a popup on established connection",IDC_EC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,144,168,10 - CONTROL "Show a popup on disabled connection",IDC_DC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,156,168,10 - CONTROL "Show a popup on key send",IDC_KS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,168,168,10 - CONTROL "Show a popup on key received",IDC_KR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,180,168,10 - CONTROL "Show a popup on each secure send",IDC_SS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,192,168,10 - CONTROL "Show a popup on each secure receive",IDC_SR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,204,168,10 -END - - -IDD_PSK DIALOGEX 0, 0, 166, 73 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Please type in your password" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - LTEXT "Username:",IDC_STATIC,7,16,36,8 - EDITTEXT IDC_EDIT2,46,14,113,13,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED - LTEXT "Password:",IDC_STATIC,7,36,34,8 - EDITTEXT IDC_EDIT1,46,33,113,13,ES_PASSWORD | ES_AUTOHSCROLL - DEFPUSHBUTTON "OK",IDOK,126,54,33,12 - PUSHBUTTON "Cancel",IDCANCEL,92,54,33,12 -END - - -IDD_PASSPHRASE DIALOGEX 0, 0, 238, 46 -STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "SecureIM plugin Passphrase of private key" -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - LTEXT "Enter passphrase for the secret key:",IDC_STATIC,8,8,168,8 - EDITTEXT IDC_PASSPHRASE,6,24,168,12,ES_PASSWORD | ES_AUTOHSCROLL - DEFPUSHBUTTON "Ok",IDOK,181,7,50,14 - PUSHBUTTON "Cancel",IDCANCEL,181,24,50,14 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDM_CLIST0 MENU -BEGIN - POPUP "" - BEGIN - POPUP "Mode" - BEGIN - MENUITEM "Native SecureIM", ID_SIM_NATIVE - MENUITEM "PGP SecureIM", ID_SIM_PGP - MENUITEM "GPG SecureIM", ID_SIM_GPG - MENUITEM "RSA/AES SecureIM", ID_SIM_RSAAES -// MENUITEM "RSA SecureIM", ID_SIM_RSA - END - POPUP "Status" - BEGIN - MENUITEM "Always Try to Establish Secure IM", ID_ALWAYS - MENUITEM "Secure IM Enabled", ID_ENABLED - MENUITEM "Secure IM Disabled", ID_DISABLED - END - POPUP "Pre-shared key" - BEGIN - MENUITEM "Set key", ID_SETPSK - MENUITEM "Delete key", ID_DELPSK - END - END -END - - -IDM_CLIST01 MENU -BEGIN - POPUP "" - BEGIN - MENUITEM "Always Try to Establish Secure IM", ID_ALWAYS - MENUITEM "Secure IM Enabled", ID_ENABLED - MENUITEM "Secure IM Disabled", ID_DISABLED - END -END - - -IDM_CLIST02 MENU -BEGIN - POPUP "" - BEGIN - MENUITEM "Set pre-shared key", ID_SETPSK - MENUITEM "Delete pre-shared key", ID_DELPSK - END -END - - -IDM_CLIST1 MENU -BEGIN - POPUP "" - BEGIN - POPUP "Mode" - BEGIN - MENUITEM "Native SecureIM", ID_SIM_NATIVE - MENUITEM "PGP SecureIM", ID_SIM_PGP - MENUITEM "GPG SecureIM", ID_SIM_GPG - MENUITEM "RSA/AES SecureIM", ID_SIM_RSAAES -// MENUITEM "RSA SecureIM", ID_SIM_RSA - END - POPUP "Status" - BEGIN - MENUITEM "Secure IM Enabled", ID_ENABLED - MENUITEM "Secure IM Disabled", ID_DISABLED - END - POPUP "Public key" - BEGIN - MENUITEM "Export key", ID_EXPPUBL - MENUITEM "Import key", ID_IMPPUBL - MENUITEM "Delete key", ID_DELPUBL - END - END -END - - -IDM_CLIST11 MENU -BEGIN - POPUP "" - BEGIN - MENUITEM "Secure IM Enabled", ID_ENABLED - MENUITEM "Secure IM Disabled", ID_DISABLED - END -END - - -IDM_CLIST12 MENU -BEGIN - POPUP "" - BEGIN - MENUITEM "Export public key", ID_EXPPUBL - MENUITEM "Import public key", ID_IMPPUBL - MENUITEM "Delete public key", ID_DELPUBL - END -END - - -IDM_CLIST2 MENU -BEGIN - POPUP "" - BEGIN - MENUITEM "Native SecureIM", ID_SIM_NATIVE - MENUITEM "PGP SecureIM", ID_SIM_PGP - MENUITEM "GPG SecureIM", ID_SIM_GPG - MENUITEM "RSA/AES SecureIM", ID_SIM_RSAAES -// MENUITEM "RSA SecureIM", ID_SIM_RSA - END -END - - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" - "afxres.h\0" - "version.rc\0" -END - -#endif // APSTUDIO_INVOKED - -#endif // Russian resources -///////////////////////////////////////////////////////////////////////////// diff --git a/plugins/SecureIM/resource_icons.rc b/plugins/SecureIM/resource_icons.rc deleted file mode 100644 index db48cece57..0000000000 --- a/plugins/SecureIM/resource_icons.rc +++ /dev/null @@ -1,66 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#define APSTUDIO_HIDDEN_SYMBOLS -#include "windows.h" -#undef APSTUDIO_HIDDEN_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Russian resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) -LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT -#pragma code_page(1251) - -#include "version_icons.rc" - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_CL_DIS ICON "icons\\cl_dis.ico" -IDI_CL_EST ICON "icons\\cl_est.ico" -IDI_CM_DIS ICON "icons\\cm_dis.ico" -IDI_CM_EST ICON "icons\\cm_est.ico" -IDI_MW_DIS ICON "icons\\mw_dis.ico" -IDI_MW_EST ICON "icons\\mw_est.ico" -IDI_PU_DIS ICON "icons\\pu_dis.ico" -IDI_PU_EST ICON "icons\\pu_est.ico" -IDI_PU_PRC ICON "icons\\pu_prc.ico" -IDI_PU_MSG ICON "icons\\pu_msg.ico" -IDI_ST_DIS ICON "icons\\st_dis.ico" -IDI_ST_ENA ICON "icons\\st_ena.ico" -IDI_ST_TRY ICON "icons\\st_try.ico" -IDI_OV_NAT ICON "icons\\ov_nat.ico" -IDI_OV_PGP ICON "icons\\ov_pgp.ico" -IDI_OV_GPG ICON "icons\\ov_gpg.ico" -IDI_OV_RSA ICON "icons\\ov_rsa.ico" - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" - "afxres.h\0" - "version.rc\0" -END - -#endif // APSTUDIO_INVOKED - -#endif // Russian resources -///////////////////////////////////////////////////////////////////////////// diff --git a/plugins/SecureIM/rtfconv.cpp b/plugins/SecureIM/rtfconv.cpp deleted file mode 100644 index 994f541373..0000000000 --- a/plugins/SecureIM/rtfconv.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "commonheaders.h" - - -HINSTANCE hRtfconv = NULL; -RTFCONVSTRING pRtfconvString = NULL; - - -BOOL load_rtfconv () { - - hRtfconv = LoadLibrary( "rtfconv.dll" ) ; - if ( hRtfconv == NULL ) { - hRtfconv = LoadLibrary( "plugins\\rtfconv.dll" ) ; - if ( hRtfconv == NULL ) - return FALSE; - } - - pRtfconvString = (RTFCONVSTRING) GetProcAddress( hRtfconv, "RtfconvString" ) ; - if ( pRtfconvString == NULL ) { - FreeLibrary( hRtfconv ) ; - return FALSE; - } - - return TRUE; -} - -void free_rtfconv () { - - if ( hRtfconv ) - FreeLibrary( hRtfconv ) ; - pRtfconvString = NULL; - hRtfconv = NULL; -} - - -void rtfconvA(LPCSTR rtf, LPWSTR plain) { - - pRtfconvString( rtf, plain, 0, 1200, CONVMODE_USE_SYSTEM_TABLE, (strlen(rtf)+1)*sizeof(WCHAR)); -} - - -void rtfconvW(LPCWSTR rtf, LPWSTR plain) { - - pRtfconvString( rtf, plain, 0, 1200, CONVMODE_USE_SYSTEM_TABLE, (wcslen(rtf)+1)*sizeof(WCHAR)); -} - -// EOF diff --git a/plugins/SecureIM/rtfconv.h b/plugins/SecureIM/rtfconv.h deleted file mode 100644 index 2a3e75089b..0000000000 --- a/plugins/SecureIM/rtfconv.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef __RTFCONV_H__ -#define __RTFCONV_H__ - -#include - -#ifndef _INTPTR_T_DEFINED -#define intptr_t int -#endif - -#define CONVMODE_USE_SYSTEM_TABLE 0x800000 /* Use OS's table only */ - -typedef intptr_t (WINAPI *RTFCONVSTRING) ( const void *pSrcBuffer, void *pDstBuffer, - int nSrcCodePage, int nDstCodePage, unsigned long dwFlags, - size_t nMaxLen ); - -extern RTFCONVSTRING pRtfconvString; - -BOOL load_rtfconv (); -void free_rtfconv (); -void rtfconvA(LPCSTR rtf, LPWSTR plain); -void rtfconvW(LPCWSTR rtf, LPWSTR plain); - -#endif diff --git a/plugins/SecureIM/secureim-translation.txt b/plugins/SecureIM/secureim-translation.txt deleted file mode 100644 index 1242476fc9..0000000000 --- a/plugins/SecureIM/secureim-translation.txt +++ /dev/null @@ -1,106 +0,0 @@ -; Common strings that belong to many files -;[] - -; ../../plugins/SecureIM/main.cpp -;[Incoming Secure Message] -;[Outgoing Secure Message] -;[SecureIM [GPG]] -;[SecureIM [Native]] -;[SecureIM [PGP]] -;[SecureIM [RSA/AES]] -;[SecureIM status] - -; ../../plugins/SecureIM/options.cpp -;[Services] - -; ../../plugins/SecureIM/popupOptions.cpp -;[Popups] - -; ../../plugins/SecureIM/resource.rc -;[&Copy SHA1] -;[&Export] -;[&Import] -;[0 = Default PopUp Timeout Value] -;[Always Try to Establish Secure IM] -;[Always secured if possible] -;[Always show status icons in contact list] -;[Auto accept RSA key (NOT SECURED)] -;[Back] -;[Basic] -;[Cancel] -;[Context Menu only for \"Miranda\" clients] -;[Debug] -;[Delete key] -;[Delete pre-shared key] -;[Delete public key] -;[Disable encryption for game plugins] -;[Disable keyrings use] -;[E&xport] -;[Enable Secure File Transfer] -;[Enable Secure Offline messages] -;[Enter passphrase for the secret key:] -;[Events] -;[Executable:] -;[Export key] -;[Export public key] -;[GPG] -;[GPG SecureIM] -;[Home Directory:] -;[Import key] -;[Import public key] -;[Key Assignment] -;[Key Exchange Timeout :] -;[Key agreement colors] -;[Load &Private key] -;[Log to File] -;[Mode] -;[Mode in Context Menu] -;[Native SecureIM] -;[Not secured for NotOnList] -;[OK] -;[Offline Key Timeout :] -;[Offline:] -;[Ok] -;[Online:] -;[PGP] -;[PGP SecureIM] -;[Password:] -;[Please type in your password] -;[PopUp Timeout] -;[Pre-shared key] -;[Preview] -;[Private] -;[Protocols] -;[Public] -;[Public key] -;[RSA Key] -;[RSA SecureIM] -;[RSA/AES SecureIM] -;[Reset All] -;[SHA1:] -;[Save Pass] -;[Secure IM Disabled] -;[Secure IM Enabled] -;[Secure connection colors] -;[SecureIM PopUp Colors] -;[SecureIM plugin Passphrase of private key] -;[Send/Receive encrypted colors] -;[Set &keyrings...] -;[Set key] -;[Set pre-shared key] -;[Show a popup on disabled connection] -;[Show a popup on each secure receive] -;[Show a popup on each secure send] -;[Show a popup on established connection] -;[Show a popup on key received] -;[Show a popup on key send] -;[Split Messages] -;[Status] -;[Status in Context Menu] -;[Temp Dir:] -;[Text] -;[Time in Seconds] -;[User List] -;[Username:] -;[days] -;[sec] diff --git a/plugins/SecureIM/secureim.h b/plugins/SecureIM/secureim.h deleted file mode 100644 index a307d1e5a2..0000000000 --- a/plugins/SecureIM/secureim.h +++ /dev/null @@ -1,172 +0,0 @@ -#ifndef __SECURE_IM__ -#define __SECURE_IM__ - -#include "resource.h" - -// режимы шифрования SecureIM -#define MODE_NATIVE 0 -#define MODE_PGP 1 -#define MODE_GPG 2 -#define MODE_RSAAES 3 -#define MODE_CNT (3+1) -#define MODE_RSA 4 - -#define SECURED 0x10 - -// статусы для Native и RSA/AES режимов -#define STATUS_DISABLED 0 -#define STATUS_ENABLED 1 -#define STATUS_ALWAYSTRY 2 - -#define SiG_KEYR 0 -#define SiG_KEY3 SiG_KEYR -#define SiG_KEY4 SiG_KEYR -#define SiG_ENON 1 -#define SiG_ENOF 2 -#define SiG_RSND 3 -#define SiG_INIT 4 -#define SiG_DEIN 5 -#define SiG_DISA 6 -#define SiG_FAKE 7 -#define SiG_KEYA 8 -#define SiG_KEYB 9 -#define SiG_PART 10 -#define SiG_SECU 11 -#define SiG_SECP 12 -#define SiG_PGPM 13 -#define SiG_NONE -1 -#define SiG_GAME -2 - -struct SIG { - char *sig; - BYTE len; - char key; -}; - -const SIG signs[] = { - {"----Key3@hell----", 17, SiG_KEYR}, - {"----Key4@hell----", 17, SiG_KEYR}, - {"----Secured@hell----", 20, SiG_ENON}, - {"----Offline@hell----", 20, SiG_ENOF}, - {"----Resend@hell----", 19, SiG_RSND}, - {"----INIT@HELL----", 17, SiG_INIT}, - {"----DEINIT@HELL----", 19, SiG_DEIN}, - {"----DISABLED@HELL----", 21, SiG_DISA}, - {"----FAKE@HELL----", 17, SiG_FAKE}, - {"----KeyA@hell----", 17, SiG_KEYA}, - {"----KeyB@hell----", 17, SiG_KEYB}, - {"----Part@hell----", 17, SiG_PART}, - {"[SECURE]", 8, SiG_SECU}, - {"[$ECURE]", 8, SiG_SECP}, - {"-----BEGIN PGP MESSAGE-----", 27, SiG_PGPM}, - {"@@BattleShip", 12, SiG_GAME}, - {"GoMoku 0.0.2.2:", 15, SiG_GAME}, - {"@@GoMoku", 8, SiG_GAME}, - {"pbiChess:", 9, SiG_GAME}, - {"pbiReverse:", 11, SiG_GAME}, - {"pbiCorners:", 11, SiG_GAME}, - {"pbiCheckersInt:", 15, SiG_GAME}, - {"pbiCheckersRus:", 15, SiG_GAME}, - {"pbiCheckersPool:", 16, SiG_GAME}, - {0} -}; - -#define SIG_KEY3 signs[ 0].sig -#define SIG_KEY4 signs[ 1].sig -#define SIG_ENON signs[ 2].sig -#define SIG_ENOF signs[ 3].sig -#define SIG_RSND signs[ 4].sig -#define SIG_INIT signs[ 5].sig -#define SIG_DEIN signs[ 6].sig -#define SIG_DISA signs[ 7].sig -#define SIG_FAKE signs[ 8].sig -#define SIG_KEYA signs[ 9].sig -#define SIG_KEYB signs[10].sig -#define SIG_PART signs[11].sig -#define SIG_SECU signs[12].sig -#define SIG_SECP signs[13].sig - -#define LEN_KEY3 signs[ 0].len -#define LEN_KEY4 signs[ 1].len -#define LEN_ENON signs[ 2].len -#define LEN_ENOF signs[ 3].len -#define LEN_RSND signs[ 4].len -#define LEN_INIT signs[ 5].len -#define LEN_DEIN signs[ 6].len -#define LEN_DISA signs[ 7].len -#define LEN_FAKE signs[ 8].len -#define LEN_KEYA signs[ 9].len -#define LEN_KEYB signs[10].len -#define LEN_PART signs[11].len -#define LEN_SECU signs[12].len -#define LEN_SECP signs[13].len - -#define TBL_IEC 0x01 -#define TBL_ICO 0x02 -#define TBL_POP 0x03 - -#define IEC_CL_DIS 0x00 -#define IEC_CL_EST 0x01 -#define IEC_CNT (0x01+1) - -#define ICO_CM_DIS 0x00 -#define ICO_CM_EST 0x01 -#define ICO_MW_DIS 0x02 -#define ICO_MW_EST 0x03 -#define ICO_ST_DIS 0x04 -#define ICO_ST_ENA 0x05 -#define ICO_ST_TRY 0x06 -#define ICO_OV_NAT 0x07 -#define ICO_OV_PGP 0x08 -#define ICO_OV_GPG 0x09 -#define ICO_OV_RSA 0x0A -#define ICO_CNT (0x0A+1) - -#define POP_PU_DIS 0x00 -#define POP_PU_EST 0x01 -#define POP_PU_PRC 0x02 -#define POP_PU_MSR 0x03 -#define POP_PU_MSS 0x04 -#define POP_CNT (0x04+1) - -#define ADV_CNT 8 -#define ALL_CNT (IEC_CNT+ICO_CNT+POP_CNT) - -struct ICONS { - UINT key; // Resource ID - BYTE tbl; // Table NUM - BYTE idx; // Table IDX - char *section; - char *name; - char *text; -}; - -const ICONS icons[] = { - // Contact List - {IDI_CL_DIS, TBL_IEC, IEC_CL_DIS, MODULENAME"/Contact List", "sim_cl_dis", "Connection Disabled"}, - {IDI_CL_EST, TBL_IEC, IEC_CL_EST, MODULENAME"/Contact List", "sim_cl_est", "Connection Established"}, - // Contact Menu - {IDI_CM_DIS, TBL_ICO, ICO_CM_DIS, MODULENAME"/Contact Menu", "sim_cm_dis", "Disable Secure Connection"}, - {IDI_CM_EST, TBL_ICO, ICO_CM_EST, MODULENAME"/Contact Menu", "sim_cm_est", "Establishe Secure Connection"}, - // Message Window - {IDI_MW_DIS, TBL_ICO, ICO_MW_DIS, MODULENAME"/Message Window", "sim_mw_dis", "Connection Disabled"}, - {IDI_MW_EST, TBL_ICO, ICO_MW_EST, MODULENAME"/Message Window", "sim_mw_est", "Connection Established"}, - // popup's - {IDI_PU_DIS, TBL_POP, POP_PU_DIS, MODULENAME"/Popups", "sim_pu_dis", "Secure Connection Disabled"}, - {IDI_PU_EST, TBL_POP, POP_PU_EST, MODULENAME"/Popups", "sim_pu_est", "Secure Connection Established"}, - {IDI_PU_PRC, TBL_POP, POP_PU_PRC, MODULENAME"/Popups", "sim_pu_prc", "Secure Connection In Process"}, - {IDI_PU_MSG, TBL_POP, POP_PU_MSR, MODULENAME"/Popups", "sim_pu_msr", "Recv Secured Message"}, - {IDI_PU_MSG, TBL_POP, POP_PU_MSS, MODULENAME"/Popups", "sim_pu_mss", "Sent Secured Message"}, - // statuses - {IDI_ST_DIS, TBL_ICO, ICO_ST_DIS, MODULENAME"/Menu State", "sim_st_dis", "Disabled"}, - {IDI_ST_ENA, TBL_ICO, ICO_ST_ENA, MODULENAME"/Menu State", "sim_st_ena", "Enabled"}, - {IDI_ST_TRY, TBL_ICO, ICO_ST_TRY, MODULENAME"/Menu State", "sim_st_try", "Always Try"}, - // overlay - {IDI_OV_NAT, TBL_ICO, ICO_OV_NAT, MODULENAME"/Overlays", "sim_ov_nat", "Native mode"}, - {IDI_OV_PGP, TBL_ICO, ICO_OV_PGP, MODULENAME"/Overlays", "sim_ov_pgp", "PGP mode"}, - {IDI_OV_GPG, TBL_ICO, ICO_OV_GPG, MODULENAME"/Overlays", "sim_ov_gpg", "GPG mode"}, - {IDI_OV_RSA, TBL_ICO, ICO_OV_RSA, MODULENAME"/Overlays", "sim_ov_rsa", "RSA/AES mode"}, - {0} -}; - -#endif diff --git a/plugins/SecureIM/secureim.msp b/plugins/SecureIM/secureim.msp deleted file mode 100644 index 3d02d076d0..0000000000 --- a/plugins/SecureIM/secureim.msp +++ /dev/null @@ -1,136 +0,0 @@ -[Project] -name=secureim -type=2 -defaultConfig=1 - - -[Debug] -// compiler -workingDirectory= -arguments= -intermediateFilesDirectory=Debug -outputFilesDirectory=Debug -compilerPreprocessor=BUILDING_DLL -extraCompilerOptions= -compilerIncludeDirectory=\mingw\local\include,\mingw\local\include\libotr,\source\include -noWarning=0 -defaultWarning=0 -allWarning=1 -extraWarning=0 -isoWarning=0 -warningsAsErrors=0 -debugType=1 -debugLevel=3 -exceptionEnabled=0 -runtimeTypeEnabled=0 -optimizeLevel=0 - -// linker -libraryPath= -outputFilename=Debug\secureim.dll -libraries=comctl32,comdlg32,msimg32,gdi32 -extraLinkerOptions=-shared -ignoreStartupFile=0 -ignoreDefaultLibs=0 -stripExecutableFile=0 - -// archive -extraArchiveOptions= - -//resource -resourcePreprocessor= -resourceIncludeDirectory= -extraResourceOptions= - -[Release] -// compiler -workingDirectory= -arguments= -intermediateFilesDirectory=Release -outputFilesDirectory=Release -compilerPreprocessor=BUILDING_DLL -extraCompilerOptions= -compilerIncludeDirectory=\mingw\local\include,\mingw\local\include\libotr,\source\include -noWarning=0 -defaultWarning=0 -allWarning=1 -extraWarning=0 -isoWarning=0 -warningAsErrors=0 -debugType=0 -debugLevel=1 -exceptionEnabled=0 -runtimeTypeEnabled=0 -optimizeLevel=4 - -// linker -libraryPath= -outputFilename=Release\secureim.dll -libraries=comctl32,comdlg32,msimg32,gdi32 -extraLinkerOptions=-shared -ignoreStartupFile=0 -ignoreDefaultLibs=0 -stripExecutableFile=1 - -// archive -extraArchiveOptions= - -//resource -resourcePreprocessor= -resourceIncludeDirectory= -extraResourceOptions= - -[Source] -1=commonheaders.cpp -2=crypt_check.cpp -3=crypt_dll.cpp -4=crypt_lists.cpp -5=crypt_misc.cpp -6=crypt_popups.cpp -7=gettime.cpp -8=language.cpp -9=loadicons.cpp -10=loadlib.cpp -11=main.cpp -12=mmi.cpp -13=options.cpp -14=popupOptions.cpp -15=rtfconv.cpp -16=crypt_metacontacts.cpp -17=crypt_icons.cpp -18=images.cpp -19=dbevent.cpp -20=svcs_clist.cpp -21=svcs_menu.cpp -22=svcs_srmm.cpp -23=svcs_rsa.cpp -24=svcs_proto.cpp -25=splitmsg.cpp -[Header] -1=commonheaders.h -2=crypt.h -3=cryptopp.h -4=forkthread.h -5=gettime.h -6=language.h -7=loadicons.h -8=loadlib.h -9=mmi.h -10=options.h -11=popupOptions.h -12=resource.h -13=rtfconv.h -14=secureim.h -15=version.h -16=dbevent.h -17=images.h -18=svcs_clist.h -19=svcs_menu.h -20=svcs_proto.h -21=svcs_rsa.h -22=svcs_srmm.h -23=splitmsg.h -[Resource] -1=resource.rc -[Other] -[History] diff --git a/plugins/SecureIM/secureim_10.vcxproj b/plugins/SecureIM/secureim_10.vcxproj index 9e6ced746a..d413c80bdc 100644 --- a/plugins/SecureIM/secureim_10.vcxproj +++ b/plugins/SecureIM/secureim_10.vcxproj @@ -73,7 +73,7 @@ Disabled ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) MultiThreadedDebugDLL true Use @@ -99,7 +99,7 @@ Disabled ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN64;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + WIN64;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) MultiThreadedDebugDLL true Use @@ -126,7 +126,7 @@ Size true ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true false true @@ -156,7 +156,7 @@ Size true ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN64;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + WIN64;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true false true @@ -181,60 +181,61 @@ - + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - + Create - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/SecureIM/secureim_10.vcxproj.filters b/plugins/SecureIM/secureim_10.vcxproj.filters index 3a30f21882..737f043152 100644 --- a/plugins/SecureIM/secureim_10.vcxproj.filters +++ b/plugins/SecureIM/secureim_10.vcxproj.filters @@ -15,152 +15,155 @@ - + + Resource Files + + Resource Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files diff --git a/plugins/SecureIM/secureim_icons_10.vcxproj b/plugins/SecureIM/secureim_icons_10.vcxproj index be629d525d..aff7599b79 100644 --- a/plugins/SecureIM/secureim_icons_10.vcxproj +++ b/plugins/SecureIM/secureim_icons_10.vcxproj @@ -122,7 +122,8 @@ - + + diff --git a/plugins/SecureIM/secureim_icons_10.vcxproj.filters b/plugins/SecureIM/secureim_icons_10.vcxproj.filters index c5b09773a5..62b3db57fd 100644 --- a/plugins/SecureIM/secureim_icons_10.vcxproj.filters +++ b/plugins/SecureIM/secureim_icons_10.vcxproj.filters @@ -1,21 +1,16 @@ п»ї - - {309a0365-ebce-450d-8b06-98d3d2d5e2ba} - cpp;c;cxx;rc;def;r;odl;idl;hpj;bat - {d6176538-1c22-41e7-b82c-e4c9344fd47f} ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - {abff76b4-ff7b-41c3-bfd2-40efdda4e3d5} - h;hpp;hxx;hm;inl - - + + Resource Files + + Resource Files diff --git a/plugins/SecureIM/splitmsg.cpp b/plugins/SecureIM/splitmsg.cpp deleted file mode 100644 index ca4f0635cf..0000000000 --- a/plugins/SecureIM/splitmsg.cpp +++ /dev/null @@ -1,124 +0,0 @@ -#include "commonheaders.h" - - -// разбивает сообщение szMsg на части длиной iLen, возвращает строку вида PARTzPARTzz -LPSTR splitMsg(LPSTR szMsg, int iLen) { - -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("split: msg: -----\n%s\n-----\n",szMsg); -#endif - int len = (int)strlen(szMsg); - LPSTR out = (LPSTR) mir_alloc(len*2); - LPSTR buf = out; - - WORD msg_id = DBGetContactSettingWord(0, szModuleName, "msgid", 0) + 1; - DBWriteContactSettingWord(0, szModuleName, "msgid", msg_id); - - int part_all = (len+iLen-1)/iLen; - for(int part_num=0; part_numiLen)?iLen:len; - mir_snprintf(buf,32,"%s%04X%02X%02X",SIG_SECP,msg_id,part_num,part_all); - memcpy(buf+LEN_SECP+8,szMsg,sz); - *(buf+LEN_SECP+8+sz) = '\0'; -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("split: part: %s",buf); -#endif - buf += LEN_SECP+8+sz+1; - szMsg += sz; - len -= sz; - } - *buf = '\0'; - return out; -} - - -// собираем сообщение из частей, части храним в структуре у контакта -LPSTR combineMessage(pUinKey ptr, LPSTR szMsg) { - -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("combine: part: %s",szMsg); -#endif - int msg_id,part_num,part_all; - sscanf(szMsg,"%4X%2X%2X",&msg_id,&part_num,&part_all); - // - pPM ppm = NULL, pm = ptr->msgPart; - if ( !ptr->msgPart ) { - pm = ptr->msgPart = new partitionMessage; - memset(pm,0,sizeof(partitionMessage)); - pm->id = msg_id; - pm->message = new LPSTR[part_all]; - memset(pm->message,0,sizeof(LPSTR)*part_all); - } - else - while(pm) { - if ( pm->id == msg_id ) break; - ppm = pm; pm = pm->nextMessage; - } - if (!pm) { // nothing to found - pm = ppm->nextMessage = new partitionMessage; - memset(pm,0,sizeof(partitionMessage)); - pm->id = msg_id; - pm->message = new LPSTR[part_all]; - memset(pm->message,0,sizeof(LPSTR)*part_all); - } - pm->message[part_num] = new char[strlen(szMsg)]; - strcpy(pm->message[part_num],szMsg+8); -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("combine: save part: %s",pm->message[part_num]); -#endif - int len=0,i; - for ( i=0; imessage[i]==NULL) break; - len+=(int)strlen(pm->message[i]); - } - if ( i==part_all ) { // combine message - SAFE_FREE(ptr->tmp); - ptr->tmp = (LPSTR) mir_alloc(len+1); *(ptr->tmp)='\0'; - for ( i=0; itmp,pm->message[i]); - delete pm->message[i]; - } - delete pm->message; - if(ppm) ppm->nextMessage = pm->nextMessage; - else ptr->msgPart = pm->nextMessage; - delete pm; -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("combine: all parts: -----\n%s\n-----\n", ptr->tmp); -#endif - // собрали одно сообщение - return ptr->tmp; - } -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("combine: not all parts"); -#endif - // еще не собрали - return NULL; -} - - -// отправляет сообщение, если надо то разбивает на части -int splitMessageSend(pUinKey ptr, LPSTR szMsg) { - - int ret; - int len = (int)strlen(szMsg); - int par = (getContactStatus(ptr->hContact)==ID_STATUS_OFFLINE)?ptr->proto->split_off:ptr->proto->split_on; - if ( par && len>par ) { - LPSTR msg = splitMsg(szMsg,par); - LPSTR buf = msg; - while( *buf ) { - len = (int)strlen(buf); - LPSTR tmp = mir_strdup(buf); - ret = CallContactService(ptr->hContact,PSS_MESSAGE,(WPARAM)PREF_METANODB,(LPARAM)tmp); - mir_free(tmp); - buf += len+1; - } - SAFE_FREE(msg); - } - else { - ret = CallContactService(ptr->hContact,PSS_MESSAGE,(WPARAM)PREF_METANODB,(LPARAM)szMsg); - } - return ret; -} - - -// EOF diff --git a/plugins/SecureIM/splitmsg.h b/plugins/SecureIM/splitmsg.h deleted file mode 100644 index 9f55c2784e..0000000000 --- a/plugins/SecureIM/splitmsg.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef __SPLITMSG_H__ -#define __SPLITMSG_H__ - -#include - -LPSTR combineMessage(pUinKey,LPSTR); -int splitMessageSend(pUinKey,LPSTR); - -#endif diff --git a/plugins/SecureIM/src/commonheaders.cpp b/plugins/SecureIM/src/commonheaders.cpp new file mode 100644 index 0000000000..3697abea6e --- /dev/null +++ b/plugins/SecureIM/src/commonheaders.cpp @@ -0,0 +1,197 @@ +#include "commonheaders.h" + +HINSTANCE g_hInst, g_hIconInst; + +LPCSTR szModuleName = MODULENAME; +LPCSTR szVersionStr = MODULENAME" DLL ("__VERSION_STRING")"; +char TEMP[MAX_PATH]; +int TEMP_SIZE = 0; + +HANDLE g_hEvent[2], g_hMenu[15], g_hCLIcon=0, g_hFolders=0; +HANDLE *g_hService=NULL; +HANDLE *g_hHook=NULL; +int iService=0; +int iHook=0; + +HICON g_hICO[ICO_CNT], g_hPOP[POP_CNT], g_hIEC[1+IEC_CNT*MODE_CNT] = {0}; +IconExtraColumn g_IEC[1+IEC_CNT*MODE_CNT]; + +int iBmpDepth; +BOOL bCoreUnicode = false, bMetaContacts = false, bPopupExists = false, bPopupUnicode = false; +BOOL bPGPloaded = false, bPGPkeyrings = false, bUseKeyrings = false, bPGPprivkey = false; +BOOL bGPGloaded = false, bGPGkeyrings = false, bSavePass = false; +BOOL bSFT, bSOM, bASI, bMCD, bSCM, bDGP, bAIP, bNOL, bAAK, bMCM; +BYTE bADV, bPGP, bGPG; +DWORD iCoreVersion = 0; +CRITICAL_SECTION localQueueMutex; + +PLUGININFOEX pluginInfoEx = { + sizeof(PLUGININFOEX), + MODULENAME, + __VERSION_DWORD, + MODULENAME" plugin for Miranda IM ("__DATE__")", + "Johell, Ghost, Nightwish, __alex, Baloo", + "Johell@ifrance.com, baloo@bk.ru", + "© 2003 Johell, © 2005-09 Baloo", + "http://nightly.miranda.im/", + 0, + MIID_SECUREIM +}; + +LPSTR myDBGetString(HANDLE hContact,const char *szModule,const char *szSetting) { + char *val=NULL; + DBVARIANT dbv; + dbv.type = DBVT_ASCIIZ; + DBGetContactSetting(hContact,szModule,szSetting,&dbv); + if ( dbv.pszVal && (dbv.type==DBVT_ASCIIZ || dbv.type==DBVT_UTF8 || dbv.type==DBVT_WCHAR)) + val = mir_strdup(dbv.pszVal); + DBFreeVariant(&dbv); + return val; +} + + +LPSTR myDBGetStringDecode(HANDLE hContact,const char *szModule,const char *szSetting) { + char *val = myDBGetString(hContact,szModule,szSetting); + if (!val) return NULL; + size_t len = strlen(val)+64; + char *buf = (LPSTR)mir_alloc(len); + strncpy(buf,val,len); mir_free(val); + CallService(MS_DB_CRYPT_DECODESTRING,(WPARAM)len,(LPARAM)buf); + return buf; +} + + +int myDBWriteStringEncode(HANDLE hContact,const char *szModule,const char *szSetting,const char *val) { + int len = (int)strlen(val)+64; + char *buf = (LPSTR)alloca(len); + strncpy(buf,val,len); + CallService(MS_DB_CRYPT_ENCODESTRING,(WPARAM)len,(LPARAM)buf); + int ret = DBWriteContactSettingString(hContact,szModule,szSetting,buf); + return ret; +} + +void GetFlags() { + bSFT = DBGetContactSettingByte(0,szModuleName,"sft",0); + bSOM = DBGetContactSettingByte(0,szModuleName,"som",0); + bASI = DBGetContactSettingByte(0,szModuleName,"asi",0); + bMCD = DBGetContactSettingByte(0,szModuleName,"mcd",0); + bSCM = DBGetContactSettingByte(0,szModuleName,"scm",0); + bDGP = DBGetContactSettingByte(0,szModuleName,"dgp",0); + bAIP = DBGetContactSettingByte(0,szModuleName,"aip",0); + bADV = DBGetContactSettingByte(0,szModuleName,"adv",0); + bNOL = DBGetContactSettingByte(0,szModuleName,"nol",0); + bAAK = DBGetContactSettingByte(0,szModuleName,"aak",0); + bMCM = DBGetContactSettingByte(0,szModuleName,"mcm",0); +} + + +void SetFlags() { + DBWriteContactSettingByte(0,szModuleName,"sft",bSFT); + DBWriteContactSettingByte(0,szModuleName,"som",bSOM); + DBWriteContactSettingByte(0,szModuleName,"asi",bASI); + DBWriteContactSettingByte(0,szModuleName,"mcd",bMCD); + DBWriteContactSettingByte(0,szModuleName,"scm",bSCM); + DBWriteContactSettingByte(0,szModuleName,"dgp",bDGP); + DBWriteContactSettingByte(0,szModuleName,"aip",bAIP); + DBWriteContactSettingByte(0,szModuleName,"adv",bADV); + DBWriteContactSettingByte(0,szModuleName,"nol",bNOL); + DBWriteContactSettingByte(0,szModuleName,"aak",bAAK); + DBWriteContactSettingByte(0,szModuleName,"mcm",bMCM); +} + +struct A2U { + LPSTR a; + LPSTR u; +}; +typedef A2U* pA2U; + +pA2U pa2u; +int ca2u=0; + +LPSTR TranslateU( LPCSTR lpText ) { + int i; + for(i=0;iutf8encode(lpwTran)); + } + else { + LPSTR lpTran = Translate(lpText); + LPWSTR lpwTran = mir_a2u(lpTran); + lpTran = exp->utf8encode(lpwTran); + mir_free(lpwTran); + pa2u[i].u = mir_strdup(lpTran); + } + return pa2u[i].u; +} + +int msgbox( HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType) { + if ( bCoreUnicode ) { + LPWSTR lpwText = mir_a2u(lpText); + LPWSTR lpwCaption = mir_a2u(lpCaption); + int r = MessageBoxW(hWnd,TranslateW(lpwText),TranslateW(lpwCaption),uType); + mir_free(lpwCaption); + mir_free(lpwText); + return r; + } + return MessageBoxA(hWnd,Translate(lpText),Translate(lpCaption),uType); +} + +void CopyToClipboard(HWND hwnd,LPSTR msg) +{ + HGLOBAL hglbCopy; + LPSTR lpstrCopy; + + hglbCopy = GlobalAlloc(GMEM_MOVEABLE, lstrlenA(msg)+1); + lpstrCopy = (LPSTR)GlobalLock(hglbCopy); + lstrcpyA(lpstrCopy, msg); + GlobalUnlock(hglbCopy); + + OpenClipboard(NULL); + EmptyClipboard(); + SetClipboardData(CF_TEXT, hglbCopy); + CloseClipboard(); +} + +#if defined(_DEBUG) || defined(NETLIB_LOG) +HANDLE hNetlibUser; + +void InitNetlib() { + NETLIBUSER nl_user; + memset(&nl_user,0,sizeof(nl_user)); + nl_user.cbSize = sizeof(nl_user); + nl_user.szSettingsModule = (LPSTR)szModuleName; + nl_user.szDescriptiveName = (LPSTR)szModuleName; + nl_user.flags = NUF_NOOPTIONS; + + hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nl_user); +} + +void DeinitNetlib() { + if(hNetlibUser) + CallService(MS_NETLIB_CLOSEHANDLE, (WPARAM)hNetlibUser, 0); +} + +int Sent_NetLog(const char *fmt,...) +{ + va_list va; + char szText[1024]; + + va_start(va,fmt); + mir_vsnprintf(szText,sizeof(szText),fmt,va); + va_end(va); + return CallService(MS_NETLIB_LOG,(WPARAM)hNetlibUser,(LPARAM)szText); +} +#endif + + +// EOF diff --git a/plugins/SecureIM/src/commonheaders.h b/plugins/SecureIM/src/commonheaders.h new file mode 100644 index 0000000000..c848d43484 --- /dev/null +++ b/plugins/SecureIM/src/commonheaders.h @@ -0,0 +1,192 @@ +// Windows API + +#define WIN32_LEAN_AND_MEAN +#define NETLIB_LOG + +#ifdef _MSC_VER +#pragma once +#define _CRT_SECURE_NO_WARNINGS +// _MSC_VER: 1200=6.0 1300=7.0(2003) 1400=8.0(2005) 1500=9.0(2008) +#if _MSC_VER >= 1300 +// MSVC 7.0 and above +#define mir_itoa _itoa +#define mir_unlink _unlink +#else +// MSVC 6.0 and below +#ifndef _DEBUG +#pragma optimize("gsy", on) +#endif +#endif +#endif + +#ifndef mir_itoa +#define mir_itoa itoa +#endif + +#ifndef mir_unlink +#define mir_unlink unlink +#endif + +#ifndef WINVER +#define WINVER 0x0501 +#endif + +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0501 +#endif + +#ifndef _WIN32_IE +#define _WIN32_IE 0x0501 +#endif + +#ifndef M_SIM_COMMONHEADERS_H +#define M_SIM_COMMONHEADERS_H + +#define MIRANDA_VER 0x0A00 +#include + +// Windows API +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MODULENAME "SecureIM" + +#ifndef ListView_SetCheckState +#define ListView_SetCheckState(hwndLV, i, fCheck) \ + ListView_SetItemState(hwndLV, i, INDEXTOSTATEIMAGEMASK((fCheck)?2:1), LVIS_STATEIMAGEMASK) +#endif + +#ifndef SIZEOF +#define SIZEOF(X) (sizeof(X)/sizeof(X[0])) +#endif + +#ifndef M_API_H__ +#define M_API_H__ + +// Miranda API +#include "newpluginapi.h" +#include "m_stdhdr.h" +#include "m_system.h" +#include "m_database.h" +#include "m_protomod.h" +#include "m_protosvc.h" +#include "m_langpack.h" +#include "m_options.h" +#include "m_clist.h" +#include "m_clc.h" +#include "m_clui.h" +#include "m_cluiframes.h" +#include "m_utils.h" +#include "m_skin.h" +#include "m_popup.h" +#include "m_genmenu.h" +#include "m_icolib.h" +#include "m_message.h" +#include "m_netlib.h" +#include "m_metacontacts.h" +#include "m_extraicons.h" +#include "m_folders.h" + +#endif + +// my libs +#include "secureim.h" +#include "version.h" +#include "resource.h" +#include "language.h" +#include "loadlib.h" +#include "mmi.h" +#include "crypt.h" +#include "gettime.h" +#include "language.h" +#include "options.h" +#include "popupoptions.h" +#include "loadicons.h" +#include "rtfconv.h" +#include "cryptopp.h" +#include "images.h" +#include "dbevent.h" +#include "splitmsg.h" +#include "svcs_proto.h" +#include "svcs_clist.h" +#include "svcs_menu.h" +#include "svcs_srmm.h" +#include "svcs_rsa.h" + +extern LPCSTR szModuleName; +extern LPCSTR szVersionStr; +extern char TEMP[MAX_PATH]; +extern int TEMP_SIZE; + +// shared vars +extern HINSTANCE g_hInst, g_hIconInst; +extern PLUGININFOEX pluginInfoEx; + +#define MIID_SECUREIM {0x1B2A39E5, 0xE2F6, 0x494D, { 0x95, 0x8D, 0x18, 0x08, 0xFD, 0x11, 0x0D, 0xD5 }} //1B2A39E5-E2F6-494D-958D-1808FD110DD5 + +#define PREF_METANODB 0x2000 //!< Flag to indicate message should not be added to db by filter when sending +#define PREF_SIMNOMETA 0x4000 //!< Flag to indicate message should not be inspected by filter on metacontact + +extern HANDLE g_hEvent[2], g_hMenu[15], g_hCLIcon, g_hFolders; +extern HANDLE *g_hService; +extern HANDLE *g_hHook; +extern int iService, iHook; +extern HICON g_hICO[ICO_CNT], g_hIEC[1+IEC_CNT*MODE_CNT], g_hPOP[POP_CNT]; +extern IconExtraColumn g_IEC[1+IEC_CNT*MODE_CNT]; +extern int iBmpDepth; +extern BOOL bCoreUnicode, bMetaContacts, bPopupExists, bPopupUnicode; +extern BOOL bPGPloaded, bPGPkeyrings, bUseKeyrings, bPGPprivkey; +extern BOOL bGPGloaded, bGPGkeyrings, bSavePass; +extern BOOL bSFT, bSOM, bASI, bMCD, bSCM, bDGP, bAIP, bNOL, bAAK, bMCM; +extern BYTE bADV, bPGP, bGPG; +extern DWORD iCoreVersion; +extern CRITICAL_SECTION localQueueMutex; + +int onModulesLoaded(WPARAM,LPARAM); +int onSystemOKToExit(WPARAM,LPARAM); + +void AddServiceFunction(LPCSTR,MIRANDASERVICE); +void AddProtoServiceFunction(LPCSTR,MIRANDASERVICE); +void AddHookFunction(LPCSTR,MIRANDAHOOK); + +LPSTR myDBGetString(HANDLE,const char *,const char *); +LPSTR myDBGetStringDecode(HANDLE,const char *,const char *); +int myDBWriteStringEncode(HANDLE,const char *,const char *,const char *); + +#if defined(_DEBUG) || defined(NETLIB_LOG) +extern HANDLE hNetlibUser; +void InitNetlib(); +void DeinitNetlib(); +int Sent_NetLog(const char *,...); +#endif +/* +int DBWriteString(HANDLE,const char *,const char *,const char *); +int DBGetByte(HANDLE,const char *,const char *,int); +int DBWriteByte(HANDLE,const char *,const char *,BYTE); +int DBGetWord(HANDLE,const char *,const char *,int); +int DBWriteWord(HANDLE,const char *,const char *,WORD); +*/ +void GetFlags(); +void SetFlags(); +/* +LPSTR u2a( LPCWSTR src ); +LPWSTR a2u( LPCSTR src ); +*/ +LPSTR TranslateU( LPCSTR lpText ); +int msgbox( HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType ); +void CopyToClipboard(HWND hwnd,LPSTR msg); +#define msgbox0(a,b,c,d) msgbox(a,b,c,d) +#define msgbox1(a,b,c,d) msgbox(a,b,c,d) + +#endif + +// EOF diff --git a/plugins/SecureIM/src/crypt.h b/plugins/SecureIM/src/crypt.h new file mode 100644 index 0000000000..e626570f9e --- /dev/null +++ b/plugins/SecureIM/src/crypt.h @@ -0,0 +1,183 @@ +#ifndef __CRYPT_H__ +#define __CRYPT_H__ + +#include "secureim.h" +#include "cryptopp.h" +#include "gettime.h" + +#define KEYSIZE 256 +#define NAMSIZE 512 +#define DEFMSGS 4096 + +#define KEY_A_SIG 0x000000 +#define KEY_B_SIG 0x010000 + +// struct to store all supported protocols +struct SupPro { + LPSTR name; + BOOL inspecting; + int split_on,tsplit_on; + int split_off,tsplit_off; +}; +typedef SupPro *pSupPro; + +// struct to store wainting messages +struct waitingMessage { + LPSTR Message; + WPARAM wParam; + waitingMessage *nextMessage; +}; +typedef waitingMessage* pWM; + +struct partitionMessage { + int id; + LPSTR *message; // array of message parts + partitionMessage *nextMessage; +}; +typedef partitionMessage* pPM; + +#define HEADER 0xABCD1234 +#define FOOTER 0x9876FEDC +#define EMPTYH 0xF1E2D3C4 + +// memory struct for keys +struct UinKey { + u_int header; // HEADER + HANDLE hContact; // handle of contact + pSupPro proto; // proto struct + BYTE mode,tmode; // mode: Native,PGP,GPG,RSA/AES,RSA [0..4] + BYTE status,tstatus; // status: Disabled,Enabled,AlwaysTry [0..2] for Native mode + LPSTR msgSplitted; // message to combine + pPM msgPart; // parts of message + pWM msgQueue; // last messages not sended or to resend; + BOOL sendQueue; // идет отсылка очереди - не обрабатываются сообщения + BOOL offlineKey; + char waitForExchange; // 0 - сбросить очередь + // 1 - ожидаем + // 2 - дослать с шифрованием + // 3 - дослать без шифрования с вопросом + BOOL decoded; // false on decode error + short features; + HANDLE cntx; // crypto context + BYTE keyLoaded; // ( 1-PGP, 2-GPG ) | 1-RSA + BYTE gpgMode,tgpgMode; // 0-UTF8, 1-ANSI + char *lastFileRecv; + char *lastFileSend; + char **fileSend; + BOOL finFileRecv; + BOOL finFileSend; + LPSTR tmp; // tmp text string + u_int footer; // FOOTER +}; +typedef UinKey* pUinKey; + +struct TFakeAckParams { + inline TFakeAckParams( HANDLE p1, HANDLE p2, LONG p3, LPCSTR p4 ) : + hEvent( p1 ), + hContact( p2 ), + id( p3 ), + msg( p4 ) + {} + + HANDLE hEvent; + HANDLE hContact; + LONG id; + LPCSTR msg; +}; + +struct TWaitForExchange { + inline TWaitForExchange( HANDLE p1, HANDLE p2 ) : + hEvent( p1 ), + hContact( p2 ) + {} + + HANDLE hEvent; + HANDLE hContact; +}; + +extern char szUIN[NAMSIZE]; +extern char szName[NAMSIZE]; +extern pSupPro proto; +extern pUinKey clist; +extern int proto_cnt; +extern int clist_cnt; + +// crypt_lists.cpp +void loadContactList(); +void freeContactList(); +pUinKey addContact(HANDLE); +void delContact(HANDLE); +pSupPro getSupPro(HANDLE); +pUinKey getUinKey(HANDLE); +pUinKey getUinCtx(HANDLE); +void addMsg2Queue(pUinKey,WPARAM,LPSTR); + +void getContactName(HANDLE hContact, LPSTR szName); +void getContactNameA(HANDLE hContact, LPSTR szName); +void getContactUin(HANDLE hContact, LPSTR szUIN); +void getContactUinA(HANDLE hContact, LPSTR szUIN); + +// crypt_check.cpp +int getContactStatus(HANDLE); + +BOOL isSecureProtocol(HANDLE); +BYTE isContactSecured(HANDLE); +BOOL isClientMiranda(pUinKey ptr, BOOL emptyMirverAsMiranda=FALSE); +BOOL isClientMiranda(HANDLE hContact, BOOL emptyMirverAsMiranda=FALSE); +BOOL isProtoSmallPackets(HANDLE); +BOOL isContactInvisible(HANDLE); +BOOL isNotOnList(HANDLE); +BOOL isContactNewPG(HANDLE); +BOOL isContactPGP(HANDLE); +BOOL isContactGPG(HANDLE); +BOOL isContactRSAAES(HANDLE); +BOOL isContactRSA(HANDLE); +BOOL isChatRoom(HANDLE); +BOOL isFileExist(LPCSTR); +BOOL isSecureIM(pUinKey ptr, BOOL emptyMirverAsSecureIM=FALSE); +BOOL isSecureIM(HANDLE hContact, BOOL emptyMirverAsSecureIM=FALSE); + +// crypt_icons.cpp +HICON mode2icon(int,int); +HICON mode2icon2(int,int); // создает КОПИЮ иконки, которую надо разрушить +IconExtraColumn mode2iec(int); +void RefreshContactListIcons(void); +void ShowStatusIcon(HANDLE,UINT); +void ShowStatusIcon(HANDLE); +void ShowStatusIconNotify(HANDLE); + +// crypt_popups.cpp +//static int CALLBACK PopupDlgProc(HWND,UINT,WPARAM,LPARAM); +void showPopUp(LPCSTR,HANDLE,HICON,UINT); +void showPopUpEC(HANDLE); +void showPopUpDCmsg(HANDLE,LPCSTR); +void showPopUpDC(HANDLE); +void showPopUpKS(HANDLE); +void showPopUpKRmsg(HANDLE,LPCSTR); +void showPopUpKR(HANDLE); +void showPopUpSM(HANDLE); +void showPopUpRM(HANDLE); + +// crypt_meta.cpp +BOOL isProtoMetaContacts(HANDLE); +BOOL isDefaultSubContact(HANDLE); +HANDLE getMetaContact(HANDLE); +HANDLE getMostOnline(HANDLE); +void DeinitMetaContact(HANDLE); + +// crypt_dll.cpp +LPSTR InitKeyA(pUinKey,int); +int InitKeyB(pUinKey,LPCSTR); +void InitKeyX(pUinKey,BYTE*); +BOOL CalculateKeyX(pUinKey,HANDLE); +LPSTR encodeMsg(pUinKey,LPARAM); +LPSTR decodeMsg(pUinKey,LPARAM,LPSTR); +BOOL LoadKeyPGP(pUinKey); +BOOL LoadKeyGPG(pUinKey); + +// crypt_misc.cpp +unsigned __stdcall sttFakeAck(LPVOID); +unsigned __stdcall sttWaitForExchange(LPVOID); +void waitForExchange(pUinKey ptr, int flag = 1); + +#endif diff --git a/plugins/SecureIM/src/crypt_check.cpp b/plugins/SecureIM/src/crypt_check.cpp new file mode 100644 index 0000000000..3a4a0e0c30 --- /dev/null +++ b/plugins/SecureIM/src/crypt_check.cpp @@ -0,0 +1,267 @@ +#include "commonheaders.h" + + +int getContactStatus(HANDLE hContact) { + + pSupPro ptr = getSupPro(hContact); + if (ptr) + return DBGetContactSettingWord(hContact, ptr->name, "Status", ID_STATUS_OFFLINE); + + return -1; +} + + +BOOL isSecureProtocol(HANDLE hContact) { + + pSupPro ptr = getSupPro(hContact); + if (!ptr) return false; + + return ptr->inspecting; +} + + +BYTE isContactSecured(HANDLE hContact) { + // нужна проверка на Offline и в этом случае другие статусы + if (!clist_cnt) return 0; + + BYTE r=0; + if ( isProtoMetaContacts(hContact)) + hContact = getMostOnline(hContact); // возьмем тот, через который пойдет сообщение + + for(int j=0;jinspecting ) break; + DBVARIANT dbv; + r=clist[j].mode; + switch(r) { + case MODE_NATIVE: + if(cpp_keyx(clist[j].cntx)!=0) r|=SECURED; + break; + case MODE_PGP: + DBGetContactSetting(hContact,szModuleName,"pgp",&dbv); + if ( dbv.type!=0 ) r|=SECURED; + DBFreeVariant(&dbv); + break; + case MODE_GPG: + DBGetContactSetting(hContact,szModuleName,"gpg",&dbv); + if ( dbv.type!=0 ) r|=SECURED; + DBFreeVariant(&dbv); + break; + case MODE_RSAAES: + if(exp->rsa_get_state(clist[j].cntx)==7) r|=SECURED; + break; + case MODE_RSA: + if(clist[j].cntx) r|=SECURED; + break; + } + break; + } + } + return r; // (mode&SECURED) - проверка на EST/DIS +} + + +BOOL isClientMiranda(pUinKey ptr, BOOL emptyMirverAsMiranda) { + + if ( !bMCD ) return true; + if ( !ptr->proto->inspecting ) return false; + + BOOL isMiranda = true; + LPSTR mirver = myDBGetString(ptr->hContact,ptr->proto->name,"MirVer"); + if ( mirver ) { + isMiranda = (emptyMirverAsMiranda && !*mirver) || (strstr(mirver,"Miranda")!=NULL); + mir_free(mirver); + } + return isMiranda; +} + + +BOOL isClientMiranda(HANDLE hContact, BOOL emptyMirverAsMiranda) { + + if ( !bMCD ) return true; + if ( !clist_cnt ) return false; + + for(int j=0;jinspecting ) break; + return strstr(clist[j].proto->name,"IRC")!=NULL || + strstr(clist[j].proto->name,"WinPopup")!=NULL || + strstr(clist[j].proto->name,"VyChat")!=NULL; + } + } + return false; +} + + +BOOL isContactInvisible(HANDLE hContact) { + + if ( !DBGetContactSettingByte(hContact,"CList","Hidden",0)) { + if ( !clist_cnt ) return false; + for(int j=0;jinspecting ) return false; + if ( clist[j].waitForExchange ) return false; + switch( (int)DBGetContactSettingWord(hContact,clist[j].proto->name,"ApparentMode",0)) { + case 0: + return (CallProtoService(clist[j].proto->name,PS_GETSTATUS,0,0)==ID_STATUS_INVISIBLE); + case ID_STATUS_ONLINE: + return false; + case ID_STATUS_OFFLINE: + return true; + } //switch + break; + } + }// for + } + return true; +} + + +BOOL isNotOnList(HANDLE hContact) { + return DBGetContactSettingByte(hContact, "CList", "NotOnList", 0); +} + + +BOOL isContactNewPG(HANDLE hContact) { + + if (!clist_cnt) return false; + for(int j=0;jinspecting ) break; + if ( !clist[j].cntx ) break; + return (clist[j].features & CPP_FEATURES_NEWPG) != 0; + } + } + return false; +} + + +BOOL isContactPGP(HANDLE hContact) { + + if (!bPGPloaded || (!bPGPkeyrings && !bPGPprivkey)) return false; + if (!clist_cnt) return false; + for(int j=0;jinspecting ) break; + if ( clist[j].mode!=MODE_PGP ) break; + DBVARIANT dbv; + DBGetContactSetting(hContact,szModuleName,"pgp",&dbv); + BOOL r=(dbv.type!=0); + DBFreeVariant(&dbv); + return r; + } + } + return false; +} + + +BOOL isContactGPG(HANDLE hContact) { + + if (!bGPGloaded || !bGPGkeyrings) return false; + if (!clist_cnt) return false; + for(int j=0;jinspecting ) break; + if ( clist[j].mode!=MODE_GPG ) break; + DBVARIANT dbv; + DBGetContactSetting(hContact,szModuleName,"gpg",&dbv); + BOOL r=(dbv.type!=0); + DBFreeVariant(&dbv); + return r; + } + } + return false; +} + + +BOOL isContactRSAAES(HANDLE hContact) { + + if (!clist_cnt) return false; + for(int j=0;jinspecting ) break; + if ( clist[j].mode!=MODE_RSAAES ) break; + return true; + } + } + return false; +} + + +BOOL isContactRSA(HANDLE hContact) { + + if (!clist_cnt) return false; + for(int j=0;jinspecting ) break; + if ( clist[j].mode!=MODE_RSA ) break; + return true; + } + } + return false; +} + + +BOOL isChatRoom(HANDLE hContact) { + + if (!clist_cnt) return false; + for(int j=0;jinspecting ) break; + return (DBGetContactSettingByte(hContact,clist[j].proto->name,"ChatRoom",0)!=0); + } + } + return false; +} + + +BOOL isFileExist(LPCSTR filename) { + return (GetFileAttributes(filename)!=(UINT)-1); +} + + +BOOL isSecureIM(pUinKey ptr, BOOL emptyMirverAsSecureIM) { + + if ( !bAIP ) return false; + if ( !ptr->proto->inspecting ) return false; + + BOOL isSecureIM = false; + if ( bNOL && DBGetContactSettingByte(ptr->hContact,"CList","NotOnList",0)) { + return false; + } + LPSTR mirver = myDBGetString(ptr->hContact,ptr->proto->name,"MirVer"); + if ( mirver ) { + isSecureIM = (emptyMirverAsSecureIM && !*mirver) || (strstr(mirver,"SecureIM")!=NULL) || (strstr(mirver,"secureim")!=NULL); + mir_free(mirver); + } + return isSecureIM; +} + + +BOOL isSecureIM(HANDLE hContact, BOOL emptyMirverAsSecureIM) { + + if ( !bAIP ) return false; + if ( !clist_cnt ) return false; + + for(int j=0;jcntx ) + ptr->cntx = cpp_create_context(isProtoSmallPackets(ptr->hContact)?CPP_MODE_BASE64:0); + + char *tmp = myDBGetString(ptr->hContact,szModuleName,"PSK"); + if(tmp) { + cpp_init_keyp(ptr->cntx,tmp); // make pre-shared key from password + mir_free(tmp); + } + + LPSTR pub_text = cpp_init_keya(ptr->cntx,features); // calculate public and private key & fill KeyA + + LPSTR keysig; + if(features&CPP_FEATURES_NEWPG) { + if(features&KEY_B_SIG) + keysig = (LPSTR)SIG_KEYB; + else + keysig = (LPSTR)SIG_KEYA; + } + else + if(isProtoSmallPackets(ptr->hContact)) + keysig = (LPSTR)SIG_KEY4; + else + keysig = (LPSTR)SIG_KEY3; + + int slen = (int)strlen(keysig); + int tlen = (int)strlen(pub_text); + + LPSTR keyToSend = (LPSTR) mir_alloc(slen+tlen+1); + + memcpy(keyToSend,keysig,slen); + memcpy(keyToSend+slen,pub_text,tlen+1); + + return keyToSend; +} + +// store KeyB into context +int InitKeyB(pUinKey ptr,LPCSTR key) { +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("InitKeyB: %s", key); +#endif + if (!ptr->cntx) + ptr->cntx = cpp_create_context(isProtoSmallPackets(ptr->hContact)?CPP_MODE_BASE64:0); + + if (!cpp_keyp(ptr->cntx)) { + char *tmp = myDBGetString(ptr->hContact,szModuleName,"PSK"); + if(tmp) { + cpp_init_keyp(ptr->cntx,tmp); // make pre-shared key from password + mir_free(tmp); + } + } + + cpp_init_keyb(ptr->cntx,key); + ptr->features = cpp_get_features(ptr->cntx); + + return cpp_get_error(ptr->cntx); +} + + +// store KeyX into context +void InitKeyX(pUinKey ptr,BYTE *key) { + + if (!ptr->cntx) + ptr->cntx = cpp_create_context(isProtoSmallPackets(ptr->hContact)?CPP_MODE_BASE64:0); + + cpp_set_keyx(ptr->cntx,key); +} + + +// calculate secret key +BOOL CalculateKeyX(pUinKey ptr,HANDLE hContact) { + + int agr = cpp_calc_keyx(ptr->cntx); + if ( agr ) { + // do this only if key exchanged is ok + // we use a 192bit key + int keysize = cpp_size_keyx(); + PBYTE buffer = (PBYTE) alloca(keysize); // buffer for hash + + // store key + cpp_get_keyx(ptr->cntx,buffer); + + DBCONTACTWRITESETTING cws; + cws.szModule = szModuleName; + + // store key in database + cws.szSetting = "offlineKey"; + cws.value.type = DBVT_BLOB; + cws.value.cpbVal = keysize; + cws.value.pbVal = buffer; + CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)hContact, (LPARAM)&cws); + + // store timeout of key in database (2 days) + cws.szSetting = "offlineKeyTimeout"; + cws.value.type = DBVT_DWORD; + cws.value.dVal = gettime()+(60*60*24*DBGetContactSettingWord(0,szModuleName,"okt",2)); + CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)hContact, (LPARAM)&cws); + + // key exchange is finished + showPopUpEC(ptr->hContact); + } + else { + // agree value problem + showPopUp(sim002,hContact,g_hPOP[POP_PU_DIS],0); + } + return agr!=0; +} + + +// encrypt message +LPSTR encrypt(pUinKey ptr, LPCSTR szEncMsg) { + + LPSTR szSig = (LPSTR) (ptr->offlineKey?SIG_ENOF:SIG_ENON); + + int slen = (int)strlen(szSig); + int clen = (int)strlen(szEncMsg); + + LPSTR szMsg = (LPSTR) mir_alloc(clen+slen+1); + memcpy(szMsg, szSig, slen); + memcpy(szMsg+slen, szEncMsg, clen+1); + + return szMsg; +} + + +// encode message +LPSTR encodeMsg(pUinKey ptr, LPARAM lParam) { + + CCSDATA *pccsd = (CCSDATA *)lParam; + LPSTR szNewMsg = NULL; + LPSTR szOldMsg = (LPSTR) pccsd->lParam; + + if ( pccsd->wParam & PREF_UTF ) + szNewMsg = encrypt(ptr,cpp_encodeU(ptr->cntx,szOldMsg)); + else + if ( pccsd->wParam & PREF_UNICODE ) + szNewMsg = encrypt(ptr,cpp_encodeW(ptr->cntx,(LPWSTR)(szOldMsg+strlen(szOldMsg)+1))); + else + szNewMsg = encrypt(ptr,cpp_encodeA(ptr->cntx,szOldMsg)); + +// pccsd->wParam &= ~(PREF_UNICODE|PREF_UTF); + pccsd->wParam &= ~PREF_UNICODE; + + return szNewMsg; +} + + +// decode message +LPSTR decodeMsg(pUinKey ptr, LPARAM lParam, LPSTR szEncMsg) { + + CCSDATA *pccsd = (CCSDATA *)lParam; + PROTORECVEVENT *ppre = (PROTORECVEVENT *)pccsd->lParam; + + LPSTR szNewMsg = NULL; + LPSTR szOldMsg = (ppre->flags&PREF_UTF)?cpp_decodeU(ptr->cntx,szEncMsg):cpp_decode(ptr->cntx,szEncMsg); + + if(szOldMsg == NULL) { + ptr->decoded=false; + switch(cpp_get_error(ptr->cntx)) { + case CPP_ERROR_BAD_LEN: + szNewMsg = mir_strdup(Translate(sim102)); + break; + case CPP_ERROR_BAD_CRC: + szNewMsg = mir_strdup(Translate(sim103)); + break; + default: { + ptr->decoded=true; + szNewMsg = mir_strdup(Translate(sim101)); + } + break; + } + ppre->flags &= ~(PREF_UNICODE|PREF_UTF); + pccsd->wParam &= ~(PREF_UNICODE|PREF_UTF); + } + else { + ptr->decoded=true; + if ( ppre->flags & PREF_UTF ) { // Ґб«Ё Їа®в®Є®« Ї®¤¤Ґа¦Ёў Ґв utf8 - в®Ј¤  ®вЇа ў«пҐ¬ ў utf8 + int olen = (int)strlen(szOldMsg)+1; + szNewMsg = (LPSTR) mir_alloc(olen); + memcpy(szNewMsg,szOldMsg,olen); + } + else { + int olen = ((int)strlen(szOldMsg)+1)*(sizeof(WCHAR)+1); + szNewMsg = (LPSTR) mir_alloc(olen); + memcpy(szNewMsg,szOldMsg,olen); + ppre->flags |= PREF_UNICODE; + pccsd->wParam |= PREF_UNICODE; + } + } + ppre->szMessage = szNewMsg; + return szNewMsg; +} + + +BOOL LoadKeyPGP(pUinKey ptr) { + int mode = DBGetContactSettingByte(ptr->hContact,szModuleName,"pgp_mode",255); + if(mode==0) { + DBVARIANT dbv; + DBGetContactSetting(ptr->hContact,szModuleName,"pgp",&dbv); + BOOL r=(dbv.type==DBVT_BLOB); + if(r) pgp_set_keyid(ptr->cntx,(PVOID)dbv.pbVal); + DBFreeVariant(&dbv); + return r; + } + else + if(mode==1) { + LPSTR key = myDBGetStringDecode(ptr->hContact,szModuleName,"pgp"); + if ( key ) { + pgp_set_key(ptr->cntx,key); + mir_free(key); + return 1; + } + } + return 0; +} + + +BOOL LoadKeyGPG(pUinKey ptr) { + + LPSTR key = myDBGetString(ptr->hContact,szModuleName,"gpg"); + if ( key ) { + gpg_set_keyid(ptr->cntx,key); + mir_free(key); + return 2; + } + return 0; +} + +// EOF diff --git a/plugins/SecureIM/src/crypt_icons.cpp b/plugins/SecureIM/src/crypt_icons.cpp new file mode 100644 index 0000000000..6c5984c345 --- /dev/null +++ b/plugins/SecureIM/src/crypt_icons.cpp @@ -0,0 +1,151 @@ +#include "commonheaders.h" + + +typedef struct { + HICON icon; + SHORT mode; +} ICON_CACHE; + + +ICON_CACHE *ICONS_CACHE = NULL; +int icons_cache = 0; + + +// преобразует mode в HICON который НЕ НУЖНО разрушать в конце +HICON mode2icon(int mode,int type) { + + int m=mode&0x0f,s=(mode&SECURED)>>4,i; // разобрали на части - режим и состояние + HICON icon; + + if ( icons_cache ) { + for(i=0;i>4; // разобрали на части - режим и состояние + + if ( mode==-1 || (!s && !bASI && m!=MODE_PGP && m!=MODE_GPG)) { + return g_IEC[0]; // вернем пустое место + } + + int i=1+m*IEC_CNT+IEC_CL_DIS+s; + if ( g_IEC[i].hImage==(HANDLE)-1 ) { +/* g_hIEC[i] = mode2icon(mode,1); + g_IEC[i].hImage = (HANDLE) CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)g_hIEC[i], (LPARAM)0);*/ + HICON icon = mode2icon(mode,1); + g_IEC[i].hImage = (HANDLE) CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)icon, (LPARAM)0); + } + return g_IEC[i]; +} + + +// обновляет иконки в clist и в messagew +void ShowStatusIcon(HANDLE hContact,int mode) { + + HANDLE hMC = getMetaContact(hContact); + if ( bADV || g_hCLIcon ) { // обновить иконки в clist + if ( mode!= -1 ) { + IconExtraColumn iec=mode2iec(mode); + if ( g_hCLIcon ) { + ExtraIcon_SetIcon(g_hCLIcon, hContact, iec.hImage); + if ( hMC ) + ExtraIcon_SetIcon(g_hCLIcon, hMC, iec.hImage); + } + else { + CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM)hContact, (LPARAM)&iec); + if ( hMC ) + CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM)hMC, (LPARAM)&iec); + } + } + } + if ( ServiceExists(MS_MSG_MODIFYICON)) { // обновить иконки в srmm + StatusIconData sid; + memset(&sid,0,sizeof(sid)); + sid.cbSize = sizeof(sid); + sid.szModule = (char*)szModuleName; + for(int i=MODE_NATIVE; itype == PROTOTYPE_PROTOCOL && protos[i]->szName && (CallProtoService(protos[i]->szName,PS_GETCAPS,PFLAGNUM_2,0)||strcmp(protos[i]->szName,"MetaContacts")==0)) { + if (protos[i]->type == PROTOTYPE_PROTOCOL && protos[i]->szName && CallProtoService(protos[i]->szName,PS_GETCAPS,PFLAGNUM_2,0)) { + int j = proto_cnt; proto_cnt++; + proto = (pSupPro) mir_realloc(proto,sizeof(SupPro)*proto_cnt); + memset(&proto[j],0,sizeof(SupPro)); + proto[j].name = mir_strdup(protos[i]->szName); + if ( szNames ) { + if ( proto[j].name ) { + char tmp[128]; strcpy(tmp,proto[j].name); strcat(tmp,":"); + LPSTR szName = strstr(szNames,tmp); + if ( szName ) { + szName = strchr(szName,':'); + if ( szName ) { + proto[j].inspecting = (*++szName == '1'); + szName = strchr(szName,':'); + if ( szName ) { + proto[j].split_on = atoi(++szName); proto[j].tsplit_on = proto[j].split_on; + szName = strchr(szName,':'); + if ( szName ) { + proto[j].split_off = atoi(++szName); proto[j].tsplit_off = proto[j].split_off; + } + } + } + } + } + } + else { + proto[j].inspecting = true; + } + } + } + SAFE_FREE(szNames); +} + + +void freeSupportedProtocols() { + for (int j=0;jmsgQueue==NULL){ + // create new + ptr->msgQueue = (pWM) mir_alloc(sizeof(struct waitingMessage)); + ptrMessage = ptr->msgQueue; + } + else { + // add to list + ptrMessage = ptr->msgQueue; + while (ptrMessage->nextMessage) { + ptrMessage = ptrMessage->nextMessage; + } + ptrMessage->nextMessage = (pWM) mir_alloc(sizeof(struct waitingMessage)); + ptrMessage = ptrMessage->nextMessage; + } + + ptrMessage->wParam = wParam; + ptrMessage->nextMessage = NULL; + + if(wParam & PREF_UNICODE) { + int slen = (int)strlen(szMsg)+1; + int wlen = (int)wcslen((wchar_t *)(szMsg+slen))+1; + ptrMessage->Message = (LPSTR) mir_alloc(slen+wlen*sizeof(WCHAR)); + memcpy(ptrMessage->Message,szMsg,slen+wlen*sizeof(WCHAR)); + } + else{ + ptrMessage->Message = mir_strdup(szMsg); + } + + LeaveCriticalSection(&localQueueMutex); +} + + +void getContactNameA(HANDLE hContact, LPSTR szName) { + strcpy(szName,(LPCSTR)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,0)); +} + + +void getContactName(HANDLE hContact, LPSTR szName) { + if ( bCoreUnicode ) wcscpy((LPWSTR)szName,(LPWSTR)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,GSMDF_UNICODE)); + else getContactNameA(hContact, szName); +} + + +void getContactUinA(HANDLE hContact, LPSTR szUIN) { + + *szUIN = 0; + + pSupPro ptr = getSupPro(hContact); + if (!ptr) return; + + DBVARIANT dbv_uniqueid; + LPSTR uID = (LPSTR) CallProtoService(ptr->name, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); + if ( uID==(LPSTR)CALLSERVICE_NOTFOUND ) uID = 0; // Billy_Bons + if ( uID && DBGetContactSetting(hContact, ptr->name, uID, &dbv_uniqueid)==0 ) { + if (dbv_uniqueid.type == DBVT_WORD) + sprintf(szUIN, "%u [%s]", dbv_uniqueid.wVal, ptr->name); + else + if (dbv_uniqueid.type == DBVT_DWORD) + sprintf(szUIN, "%u [%s]", (UINT)dbv_uniqueid.dVal, ptr->name); + else + if (dbv_uniqueid.type == DBVT_BLOB) + sprintf(szUIN, "%s [%s]", dbv_uniqueid.pbVal, ptr->name); + else + sprintf(szUIN, "%s [%s]", dbv_uniqueid.pszVal, ptr->name); + } + else { + strcpy(szUIN, "=== unknown ==="); + } + DBFreeVariant(&dbv_uniqueid); +} + + +void getContactUin(HANDLE hContact, LPSTR szUIN) { + getContactUinA(hContact, szUIN); + if ( bCoreUnicode && *szUIN ) { + LPWSTR tmp = mir_a2u(szUIN); + wcscpy((LPWSTR)szUIN, tmp); + mir_free(tmp); + } +} + + +// EOF diff --git a/plugins/SecureIM/src/crypt_metacontacts.cpp b/plugins/SecureIM/src/crypt_metacontacts.cpp new file mode 100644 index 0000000000..f36c7e4dd3 --- /dev/null +++ b/plugins/SecureIM/src/crypt_metacontacts.cpp @@ -0,0 +1,60 @@ +#include "commonheaders.h" + + +BOOL isProtoMetaContacts(HANDLE hContact) { + if(bMetaContacts) { + LPSTR proto = (LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + if ( proto && strcmp(proto,"MetaContacts")==0 ) { + return true; + } + } +// for(int j=0;jinspecting) +// return strstr(clist[j].proto->name,"MetaContacts")!=NULL; + return false; +} + + +BOOL isDefaultSubContact(HANDLE hContact) { + + if(bMetaContacts) { + return (HANDLE)CallService(MS_MC_GETDEFAULTCONTACT,(WPARAM)CallService(MS_MC_GETMETACONTACT,(WPARAM)hContact,0),0)==hContact; + } + return false; +} + + +HANDLE getMetaContact(HANDLE hContact) { + + if(bMetaContacts) { + return (HANDLE)CallService(MS_MC_GETMETACONTACT,(WPARAM)hContact,0); + } + return 0; +} + + +HANDLE getMostOnline(HANDLE hContact) { + + if(bMetaContacts) { + return (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT,(WPARAM)hContact,0); + } + return 0; +} + + +// remove all secureim connections on subcontacts +void DeinitMetaContact(HANDLE hContact) { + + HANDLE hMetaContact = isProtoMetaContacts(hContact) ? hContact : getMetaContact(hContact); + + if ( hMetaContact ) { + for(int i=0;ihEvent, INFINITE ); + + Sleep( 100 ); + if ( tParam->msg == NULL ) + SendBroadcast( tParam->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, ( HANDLE )tParam->id, 0 ); + else + SendBroadcast( tParam->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, ( HANDLE )tParam->id, LPARAM( tParam->msg )); + + CloseHandle( tParam->hEvent ); + delete tParam; + + return 0; +} + + +unsigned __stdcall sttWaitForExchange( LPVOID param ) { + + TWaitForExchange* tParam = ( TWaitForExchange* )param; + WaitForSingleObject( tParam->hEvent, INFINITE ); + + pUinKey ptr = getUinKey(tParam->hContact); + delete tParam; + + if ( !ptr ) return 0; + + for(int i=0;iwaitForExchange != 1 ) break; + } // for + +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("sttWaitForExchange: %d",ptr->waitForExchange); +#endif + // if keyexchange failed or timeout + if ( ptr->waitForExchange==1 || ptr->waitForExchange==3 ) { // Їа®вге«® - ®вЇа ў«пҐ¬ ­Ґ§ иЁда®ў ­­®, Ґб«Ё ­ ¤® + if ( ptr->msgQueue && msgbox1(0,sim104,szModuleName,MB_YESNO|MB_ICONQUESTION)==IDYES ) { + EnterCriticalSection(&localQueueMutex); + ptr->sendQueue = true; + pWM ptrMessage = ptr->msgQueue; + while( ptrMessage ) { +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("Sent (unencrypted) message from queue: %s",ptrMessage->Message); +#endif + // send unencrypted messages + CallContactService(ptr->hContact,PSS_MESSAGE,(WPARAM)ptrMessage->wParam|PREF_METANODB,(LPARAM)ptrMessage->Message); + mir_free(ptrMessage->Message); + pWM tmp = ptrMessage; + ptrMessage = ptrMessage->nextMessage; + mir_free(tmp); + } + ptr->msgQueue = NULL; + ptr->sendQueue = false; + LeaveCriticalSection(&localQueueMutex); + } + ptr->waitForExchange = 0; + ShowStatusIconNotify(ptr->hContact); + } + else + if ( ptr->waitForExchange==2 ) { // ¤®б« вм ®зҐаҐ¤м зҐаҐ§ гбв ­®ў«Ґ­­®Ґ ᮥ¤Ё­Ґ­ЁҐ + EnterCriticalSection(&localQueueMutex); + // we need to resend last send back message with new crypto Key + pWM ptrMessage = ptr->msgQueue; + while (ptrMessage) { +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("Sent (encrypted) message from queue: %s",ptrMessage->Message); +#endif + // send unencrypted messages + CallContactService(ptr->hContact,PSS_MESSAGE,(WPARAM)ptrMessage->wParam|PREF_METANODB,(LPARAM)ptrMessage->Message); + mir_free(ptrMessage->Message); + pWM tmp = ptrMessage; + ptrMessage = ptrMessage->nextMessage; + mir_free(tmp); + } + ptr->msgQueue = NULL; + ptr->waitForExchange = 0; + LeaveCriticalSection(&localQueueMutex); + } + else + if ( ptr->waitForExchange==0 ) { // ®зЁбвЁвм ®зҐаҐ¤м + EnterCriticalSection(&localQueueMutex); + // we need to resend last send back message with new crypto Key + pWM ptrMessage = ptr->msgQueue; + while (ptrMessage) { + mir_free(ptrMessage->Message); + pWM tmp = ptrMessage; + ptrMessage = ptrMessage->nextMessage; + mir_free(tmp); + } + ptr->msgQueue = NULL; + LeaveCriticalSection(&localQueueMutex); + } + return 0; +} + + +// set wait flag and run thread +void waitForExchange(pUinKey ptr, int flag) { + switch( flag ) { + case 0: // бЎа®бЁвм + case 2: // ¤®б« вм иЁда®ў ­® + case 3: // ¤®б« вм ­ҐиЁда®ў ­® + if ( ptr->waitForExchange ) + ptr->waitForExchange = flag; + break; + case 1: // § ЇгбвЁвм + if ( ptr->waitForExchange ) + break; + ptr->waitForExchange = 1; + // § ЇгбЄ Ґ¬ ван¤ + HANDLE hEvent = CreateEvent( NULL, TRUE, FALSE, NULL ); + unsigned int tID; + CloseHandle( (HANDLE) _beginthreadex(NULL, 0, sttWaitForExchange, new TWaitForExchange(hEvent,ptr->hContact), 0, &tID)); + SetEvent( hEvent ); + break; + } +} + + +// EOF diff --git a/plugins/SecureIM/src/crypt_popups.cpp b/plugins/SecureIM/src/crypt_popups.cpp new file mode 100644 index 0000000000..836a68efc1 --- /dev/null +++ b/plugins/SecureIM/src/crypt_popups.cpp @@ -0,0 +1,153 @@ +#include "commonheaders.h" + +/* +static int CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { + switch(message) { + case WM_COMMAND: + if (wParam == STN_CLICKED) { // It was a click on the Popup. + PUDeletePopUp(hWnd); + return TRUE; + } + break; + case UM_FREEPLUGINDATA: { + return TRUE; //TRUE or FALSE is the same, it gets ignored. + } + default: + break; + } + return DefWindowProc(hWnd, message, wParam, lParam); +} +*/ + +void showPopUp(LPCSTR lpzText,HANDLE hContact,HICON hIcon, UINT type) { + //type=0 key colors + //type=1 session colors + //type=2 SR colors + + if (!bPopupExists) return; + + //hContact = A_VALID_HANDLE_YOU_GOT_FROM_SOMEWHERE; + COLORREF colorBackKey = RGB(230,230,255); + COLORREF colorTextKey = RGB(0,0,0); + COLORREF colorBackSec = RGB(255,255,200); + COLORREF colorTextSec = RGB(0,0,0); + COLORREF colorBackSR = RGB(200,255,200); + COLORREF colorTextSR = RGB(0,0,0); + COLORREF colorBack = 0; + COLORREF colorText = 0; + int timeout=0; + int res; + + DBVARIANT dbv_timeout; + + if (type==0) { + colorBack=DBGetContactSettingDword(0,szModuleName,"colorKeyb",(UINT)-1); + colorText=DBGetContactSettingDword(0,szModuleName,"colorKeyt",(UINT)-1); + if (colorBack==(UINT)-1) colorBack=colorBackKey; + if (colorText==(UINT)-1) colorText=colorTextKey; + + res=DBGetContactSetting(0,szModuleName,"timeoutKey",&dbv_timeout); + if (res==0) timeout=atoi(dbv_timeout.pszVal); + DBFreeVariant(&dbv_timeout); + } + else if (type==1) { + colorBack=DBGetContactSettingDword(0,szModuleName,"colorSecb",(UINT)-1); + colorText=DBGetContactSettingDword(0,szModuleName,"colorSect",(UINT)-1); + if (colorBack==(UINT)-1) colorBack=colorBackSec; + if (colorText==(UINT)-1) colorText=colorTextSec; + + res=DBGetContactSetting(0,szModuleName,"timeoutSec",&dbv_timeout); + if (res==0) timeout=atoi(dbv_timeout.pszVal); + DBFreeVariant(&dbv_timeout); + } + else if (type>=2) { + colorBack=DBGetContactSettingDword(0, szModuleName, "colorSRb", (UINT)-1); + colorText=DBGetContactSettingDword(0, szModuleName, "colorSRt", (UINT)-1); + if (colorBack==(UINT)-1) colorBack=colorBackSR; + if (colorText==(UINT)-1) colorText=colorTextSR; + + res=DBGetContactSetting(0,szModuleName,"timeoutSR",&dbv_timeout); + if (res==0) timeout=atoi(dbv_timeout.pszVal); + DBFreeVariant(&dbv_timeout); + } + + if ( bCoreUnicode && bPopupUnicode ) { + POPUPDATAW ppd = {0}; + + ppd.lchContact = hContact; //Be sure to use a GOOD handle, since this will not be checked. + ppd.lchIcon = hIcon; + LPWSTR lpwzContactName = (LPWSTR)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,GSMDF_UNICODE); + wcscpy(ppd.lpwzContactName, lpwzContactName); + LPWSTR lpwzText = mir_a2u(lpzText); + wcscpy(ppd.lpwzText, TranslateW(lpwzText)); + mir_free(lpwzText); + ppd.colorBack = colorBack; + ppd.colorText = colorText; + ppd.iSeconds = timeout; +// ppd.PluginWindowProc = (WNDPROC)PopupDlgProc; + + //Now that the plugin data has been filled, we add it to the PopUpData. +// ppd.PluginData = NULL; + + //Now that every field has been filled, we want to see the popup. + PUAddPopUpW(&ppd); + } + else { + POPUPDATAEX ppd = {0}; + + ppd.lchContact = hContact; //Be sure to use a GOOD handle, since this will not be checked. + ppd.lchIcon = hIcon; + LPSTR lpzContactName = (LPSTR)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,0); + strcpy(ppd.lpzContactName, lpzContactName); + strcpy(ppd.lpzText, Translate(lpzText)); + ppd.colorBack = colorBack; + ppd.colorText = colorText; + ppd.iSeconds = timeout; +// ppd.PluginWindowProc = (WNDPROC)PopupDlgProc; + + //Now that the plugin data has been filled, we add it to the PopUpData. +// ppd.PluginData = NULL; + + //Now that every field has been filled, we want to see the popup. + PUAddPopUpEx(&ppd); + } +} + + +void showPopUpDCmsg(HANDLE hContact,LPCSTR msg) { + int indic=DBGetContactSettingByte(0, szModuleName, "dc",1); + if (indic==1) showPopUp(msg,hContact,g_hPOP[POP_PU_DIS],1); +} +void showPopUpDC(HANDLE hContact) { + int indic=DBGetContactSettingByte(0, szModuleName, "dc",1); + if (indic==1) showPopUp(sim006,hContact,g_hPOP[POP_PU_DIS],1); +} +void showPopUpEC(HANDLE hContact) { + int indic=DBGetContactSettingByte(0, szModuleName, "ec",1); + if (indic==1) showPopUp(sim001,hContact,g_hPOP[POP_PU_EST],1); +} +void showPopUpKS(HANDLE hContact) { + int indic=DBGetContactSettingByte(0, szModuleName, "ks",1); + if (indic==1) showPopUp(sim007,hContact,g_hPOP[POP_PU_PRC],0); +} +void showPopUpKRmsg(HANDLE hContact,LPCSTR msg) { + int indic=DBGetContactSettingByte(0, szModuleName, "kr",1); + if (indic==1) showPopUp(msg,hContact,g_hPOP[POP_PU_PRC],0); +} +void showPopUpKR(HANDLE hContact) { + int indic=DBGetContactSettingByte(0, szModuleName, "kr",1); + if (indic==1) showPopUp(sim008,hContact,g_hPOP[POP_PU_PRC],0); +} +void showPopUpSM(HANDLE hContact) { + int indic=DBGetContactSettingByte(0, szModuleName, "ss",0); + if (indic==1) showPopUp(sim009,hContact,g_hPOP[POP_PU_MSS],2); + SkinPlaySound("OutgoingSecureMessage"); +} +void showPopUpRM(HANDLE hContact) { + int indic=DBGetContactSettingByte(0, szModuleName, "sr",0); + if (indic==1) showPopUp(sim010,hContact,g_hPOP[POP_PU_MSR],2); + SkinPlaySound("IncomingSecureMessage"); +} + + +// EOF diff --git a/plugins/SecureIM/src/cryptopp.h b/plugins/SecureIM/src/cryptopp.h new file mode 100644 index 0000000000..bfa4e097b3 --- /dev/null +++ b/plugins/SecureIM/src/cryptopp.h @@ -0,0 +1,73 @@ +#ifndef __CRYPTOPP_H__ +#define __CRYPTOPP_H__ + +#define CPP_FEATURES_UTF8 0x01 +#define CPP_FEATURES_BASE64 0x02 +#define CPP_FEATURES_GZIP 0x04 +#define CPP_FEATURES_CRC32 0x08 +#define CPP_FEATURES_PSK 0x10 +#define CPP_FEATURES_NEWPG 0x20 +#define CPP_FEATURES_RSA 0x40 + +#define CPP_MODE_BASE16 0x0000 +#define CPP_MODE_BASE64 0x0001 +#define CPP_MODE_PGP 0x0002 +#define CPP_MODE_GPG 0x0004 +#define CPP_MODE_GPG_ANSI 0x0008 +#define CPP_MODE_PRIV_KEY 0x0010 +#define CPP_MODE_RSA_2048 0x0020 +#define CPP_MODE_RSA_4096 0x0040 +#define CPP_MODE_RSA CPP_MODE_RSA_4096 +#define CPP_MODE_RSA_ONLY 0x0080 +#define CPP_MODE_RSA_ZLIB 0x0100 +#define CPP_MODE_RSA_BER 0x0200 + +#define CPP_ERROR_NONE 0 +#define CPP_ERROR_SEH 1 +#define CPP_ERROR_NO_KEYA 2 +#define CPP_ERROR_NO_KEYB 3 +#define CPP_ERROR_NO_KEYX 4 +#define CPP_ERROR_BAD_LEN 5 +#define CPP_ERROR_BAD_CRC 6 +#define CPP_ERROR_NO_PSK 7 +#define CPP_ERROR_BAD_PSK 8 +#define CPP_ERROR_BAD_KEYB 9 +#define CPP_ERROR_NO_PGP_KEY 10 + +typedef struct { + int (__cdecl *rsa_gen_keypair)(short); // генерит RSA-ключи для указанной длины (либо тока 2048, либо 2048 и 4096) + int (__cdecl *rsa_get_keypair)(short,PBYTE,int*,PBYTE,int*); // возвращает пару ключей для указанной длины + int (__cdecl *rsa_get_keyhash)(short,PBYTE,int*,PBYTE,int*); // возвращает hash пары ключей для указанной длины + int (__cdecl *rsa_set_keypair)(short,PBYTE,int); // устанавливает ключи, указанной длины + int (__cdecl *rsa_get_pubkey)(HANDLE,PBYTE,int*); // возвращает паблик ключ из указанного контекста + int (__cdecl *rsa_set_pubkey)(HANDLE,PBYTE,int); // загружает паблик ключ для указанного контекста + void (__cdecl *rsa_set_timeout)(int); // установить таймаут для установки секюрного соединения + int (__cdecl *rsa_get_state)(HANDLE); // получить статус указанного контекста + int (__cdecl *rsa_get_hash)(PBYTE,int,PBYTE,int*); // вычисляет SHA1(key) + int (__cdecl *rsa_connect)(HANDLE); // запускает процесс установки содинения с указанным контекстом + int (__cdecl *rsa_disconnect)(HANDLE); // разрывает соединение с указанным контекстом + int (__cdecl *rsa_disabled)(HANDLE); // разрывает соединение по причине "disabled" + LPSTR (__cdecl *rsa_recv)(HANDLE,LPCSTR); // необходимо передавать сюда все входящие протокольные сообщения + int (__cdecl *rsa_send)(HANDLE,LPCSTR); // вызываем для отправки сообщения клиенту + int (__cdecl *rsa_encrypt_file)(HANDLE,LPCSTR,LPCSTR); + int (__cdecl *rsa_decrypt_file)(HANDLE,LPCSTR,LPCSTR); + LPSTR (__cdecl *utf8encode)(LPCWSTR); + LPWSTR (__cdecl *utf8decode)(LPCSTR); + int (__cdecl *is_7bit_string)(LPCSTR); + int (__cdecl *is_utf8_string)(LPCSTR); + int (__cdecl *rsa_export_keypair)(short,LPSTR,LPSTR,LPSTR); // export private key + int (__cdecl *rsa_import_keypair)(short,LPSTR,LPSTR); // import & activate private key + int (__cdecl *rsa_export_pubkey)(HANDLE,LPSTR); // export public key from context + int (__cdecl *rsa_import_pubkey)(HANDLE,LPSTR); // import public key into context +} RSA_EXPORT; +typedef RSA_EXPORT* pRSA_EXPORT; + +typedef struct { + int (__cdecl *rsa_inject)(HANDLE,LPCSTR); // вставляет сообщение в очередь на отправку + int (__cdecl *rsa_check_pub)(HANDLE,PBYTE,int,PBYTE,int); // проверяет интерактивно SHA и сохраняет ключ, если все нормально + void (__cdecl *rsa_notify)(HANDLE,int); // нотификация о смене состояния +} RSA_IMPORT; +typedef RSA_IMPORT* pRSA_IMPORT; + + +#endif diff --git a/plugins/SecureIM/src/dbevent.cpp b/plugins/SecureIM/src/dbevent.cpp new file mode 100644 index 0000000000..9b7d8f10c0 --- /dev/null +++ b/plugins/SecureIM/src/dbevent.cpp @@ -0,0 +1,21 @@ +#include "commonheaders.h" + + +void HistoryLog(HANDLE hContact, LPCSTR szText) { + + DBEVENTINFO dbei; + memset(&dbei, 0, sizeof(dbei)); + + dbei.cbSize = sizeof(dbei); + dbei.szModule = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + dbei.flags = DBEF_SENT|DBEF_READ; + dbei.timestamp = time(NULL); + dbei.eventType = EVENTTYPE_MESSAGE; + dbei.cbBlob = (int)strlen(szText) + 1; + dbei.pBlob = (PBYTE)szText; + + CallService(MS_DB_EVENT_ADD, (WPARAM)0, (LPARAM)&dbei); +} + + +// EOF diff --git a/plugins/SecureIM/src/dbevent.h b/plugins/SecureIM/src/dbevent.h new file mode 100644 index 0000000000..68719c21c0 --- /dev/null +++ b/plugins/SecureIM/src/dbevent.h @@ -0,0 +1,8 @@ +#ifndef __DBEVENT_H__ +#define __DBEVENT_H__ + +#include + +void HistoryLog(HANDLE,LPCSTR); + +#endif diff --git a/plugins/SecureIM/src/gettime.cpp b/plugins/SecureIM/src/gettime.cpp new file mode 100644 index 0000000000..529a8e0c8e --- /dev/null +++ b/plugins/SecureIM/src/gettime.cpp @@ -0,0 +1,29 @@ +#include "commonheaders.h" + + +/* FILETIME unit is 100 nanoseconds */ +const static long div_100_nsec = 10000000; + +/* POSIX or Unix Epoch (1-Jan-1970 00:00) in FILETIME units */ +#ifdef _MSC_VER +const static ULONGLONG ix_epoch = 116444736000000000; +#else +const static ULONGLONG ix_epoch = 116444736000000000LL; +#endif + +DWORD gettime(void) { + + ULONGLONG diff_100_nsec; + union { + FILETIME f; + ULARGE_INTEGER u; + } now; + + GetSystemTimeAsFileTime( &now.f ); + + diff_100_nsec = now.u.QuadPart - ix_epoch; + + return (DWORD)( diff_100_nsec / div_100_nsec ); +} + +// EOF diff --git a/plugins/SecureIM/src/gettime.h b/plugins/SecureIM/src/gettime.h new file mode 100644 index 0000000000..e84276c609 --- /dev/null +++ b/plugins/SecureIM/src/gettime.h @@ -0,0 +1,8 @@ +#ifndef __GETTIME_H__ +#define __GETTIME_H__ + +#include + +DWORD gettime(void); + +#endif diff --git a/plugins/SecureIM/src/images.cpp b/plugins/SecureIM/src/images.cpp new file mode 100644 index 0000000000..eb4c87dea1 --- /dev/null +++ b/plugins/SecureIM/src/images.cpp @@ -0,0 +1,358 @@ +#include "commonheaders.h" + + +void HalfBitmap32Alpha(HBITMAP hBitmap) +{ + BITMAP bmp; + DWORD dwLen; + BYTE *p; + int x, y; + + GetObject(hBitmap, sizeof(bmp), &bmp); + + if (bmp.bmBitsPixel != 32) + return; + + dwLen = bmp.bmWidth * bmp.bmHeight * (bmp.bmBitsPixel / 8); + p = (BYTE *)malloc(dwLen); + if (p == NULL) + return; + memset(p, 0, dwLen); + + GetBitmapBits(hBitmap, dwLen, p); + + for (y = 0; y < bmp.bmHeight; ++y) { + BYTE *px = p + bmp.bmWidth * 4 * y; + + for (x = 0; x < bmp.bmWidth; ++x) + { + px[3]>>=1; + px += 4; + } + } + + SetBitmapBits(hBitmap, dwLen, p); + + free(p); +} + + +// Make a bitmap all transparent, but only if it is a 32bpp +void MakeBmpTransparent(HBITMAP hBitmap) +{ + BITMAP bmp; + DWORD dwLen; + BYTE *p; + + GetObject(hBitmap, sizeof(bmp), &bmp); + + if (bmp.bmBitsPixel != 32) + return; + + dwLen = bmp.bmWidth * bmp.bmHeight * (bmp.bmBitsPixel / 8); + p = (BYTE *)malloc(dwLen); + if (p == NULL) + return; + + memset(p, 0, dwLen); + SetBitmapBits(hBitmap, dwLen, p); + + free(p); +} + + +// Correct alpha from bitmaps loaded without it (it cames with 0 and should be 255) +void CorrectBitmap32Alpha(HBITMAP hBitmap, BOOL force) +{ + BITMAP bmp; + DWORD dwLen; + BYTE *p; + int x, y; + BOOL fixIt; + + GetObject(hBitmap, sizeof(bmp), &bmp); + + if (bmp.bmBitsPixel != 32) + return; + + dwLen = bmp.bmWidth * bmp.bmHeight * (bmp.bmBitsPixel / 8); + p = (BYTE *)malloc(dwLen); + if (p == NULL) + return; + memset(p, 0, dwLen); + + GetBitmapBits(hBitmap, dwLen, p); + + fixIt = TRUE; + for (y = 0; fixIt && y < bmp.bmHeight; ++y) { + BYTE *px = p + bmp.bmWidth * 4 * y; + + for (x = 0; fixIt && x < bmp.bmWidth; ++x) + { + if (px[3] != 0 && !force) + { + fixIt = FALSE; + } + else + { + if (px[0] != 0 || px[1] != 0 || px[2] != 0) + px[3] = 255; + } + + px += 4; + } + } + + if (fixIt) + SetBitmapBits(hBitmap, dwLen, p); + + free(p); +} + + +HBITMAP CopyBitmapTo32(HBITMAP hBitmap) +{ + BITMAPINFO RGB32BitsBITMAPINFO; + BYTE * ptPixels; + HBITMAP hDirectBitmap; + + BITMAP bmp; + DWORD dwLen; + BYTE *p; + + GetObject(hBitmap, sizeof(bmp), &bmp); + + dwLen = bmp.bmWidth * bmp.bmHeight * 4; + p = (BYTE *)malloc(dwLen); + if (p == NULL) + return NULL; + + // Create bitmap + ZeroMemory(&RGB32BitsBITMAPINFO, sizeof(BITMAPINFO)); + RGB32BitsBITMAPINFO.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + RGB32BitsBITMAPINFO.bmiHeader.biWidth = bmp.bmWidth; + RGB32BitsBITMAPINFO.bmiHeader.biHeight = bmp.bmHeight; + RGB32BitsBITMAPINFO.bmiHeader.biPlanes = 1; + RGB32BitsBITMAPINFO.bmiHeader.biBitCount = 32; + + hDirectBitmap = CreateDIBSection(NULL, + (BITMAPINFO *)&RGB32BitsBITMAPINFO, + DIB_RGB_COLORS, + (void **)&ptPixels, + NULL, 0); + + // Copy data + if (bmp.bmBitsPixel != 32) + { + HDC hdcOrig, hdcDest; + HBITMAP oldOrig, oldDest; + + hdcOrig = CreateCompatibleDC(NULL); + oldOrig = (HBITMAP) SelectObject(hdcOrig, hBitmap); + + hdcDest = CreateCompatibleDC(NULL); + oldDest = (HBITMAP) SelectObject(hdcDest, hDirectBitmap); + + BitBlt(hdcDest, 0, 0, bmp.bmWidth, bmp.bmHeight, hdcOrig, 0, 0, SRCCOPY); + + SelectObject(hdcDest, oldDest); + DeleteObject(hdcDest); + SelectObject(hdcOrig, oldOrig); + DeleteObject(hdcOrig); + + // Set alpha + CorrectBitmap32Alpha(hDirectBitmap, FALSE); + } + else + { + GetBitmapBits(hBitmap, dwLen, p); + SetBitmapBits(hDirectBitmap, dwLen, p); + } + + free(p); + + return hDirectBitmap; +} + + +HBITMAP CreateBitmap32(int cx, int cy) +{ + BITMAPINFO RGB32BitsBITMAPINFO; + UINT * ptPixels; + HBITMAP DirectBitmap; + + ZeroMemory(&RGB32BitsBITMAPINFO,sizeof(BITMAPINFO)); + RGB32BitsBITMAPINFO.bmiHeader.biSize=sizeof(BITMAPINFOHEADER); + RGB32BitsBITMAPINFO.bmiHeader.biWidth=cx;//bm.bmWidth; + RGB32BitsBITMAPINFO.bmiHeader.biHeight=cy;//bm.bmHeight; + RGB32BitsBITMAPINFO.bmiHeader.biPlanes=1; + RGB32BitsBITMAPINFO.bmiHeader.biBitCount=32; + + DirectBitmap = CreateDIBSection(NULL, + (BITMAPINFO *)&RGB32BitsBITMAPINFO, + DIB_RGB_COLORS, + (void **)&ptPixels, + NULL, 0); + return DirectBitmap; +} + + +BOOL MakeBitmap32(HBITMAP *hBitmap) +{ + BITMAP bmp; + + GetObject(*hBitmap, sizeof(bmp), &bmp); + + if (bmp.bmBitsPixel != 32) { + // Convert to 32 bpp + HBITMAP hBmpTmp = CopyBitmapTo32(*hBitmap); + DeleteObject(*hBitmap); + *hBitmap = hBmpTmp; + } + + return TRUE; +} + + +#define GET_PIXEL(__P__, __X__, __Y__) ( __P__ + width * 4 * (__Y__) + 4 * (__X__)) + +BOOL MakeGrayscale(HBITMAP *hBitmap) +{ + BYTE *p = NULL; + BYTE *p1; + DWORD dwLen; + int width, height, x, y; + BITMAP bmp; + + GetObject(*hBitmap, sizeof(bmp), &bmp); + width = bmp.bmWidth; + height = bmp.bmHeight; + + dwLen = width * height * 4; + p = (BYTE *)malloc(dwLen); + if (p == NULL) + { + return FALSE; + } + + if (bmp.bmBitsPixel != 32) + { + // Convert to 32 bpp + HBITMAP hBmpTmp = CopyBitmapTo32(*hBitmap); + DeleteObject(*hBitmap); + *hBitmap = hBmpTmp; + } + GetBitmapBits(*hBitmap, dwLen, p); + + // Make grayscale + for (y = 0 ; y < height ; y++) + { + for (x = 0 ; x < width ; x++) + { + p1 = GET_PIXEL(p, x, y); + p1[0] = p1[1] = p1[2] = ( p1[0] + p1[1] + p1[2] ) / 3; + } + } + + dwLen = SetBitmapBits(*hBitmap, dwLen, p); + free(p); + + return TRUE; +} + + +HICON MakeHalfAlphaIcon(HICON SourceIcon) +{ + ICONINFO TargetIconInfo; + BITMAP TargetBitmapInfo; + HICON TargetIcon, TempIcon; + + TempIcon = CopyIcon(SourceIcon); + if ( !GetIconInfo(TempIcon, &TargetIconInfo)) + return NULL; + + if ( !GetObject(TargetIconInfo.hbmColor, sizeof(BITMAP), &TargetBitmapInfo)) + return NULL; + + MakeBitmap32(&TargetIconInfo.hbmColor); + HalfBitmap32Alpha(TargetIconInfo.hbmColor); + TargetIcon = CreateIconIndirect(&TargetIconInfo); + + DestroyIcon(TempIcon); + DeleteObject(TargetIconInfo.hbmColor); + DeleteObject(TargetIconInfo.hbmMask); + return TargetIcon; +} + + +HICON MakeGrayscaleIcon(HICON SourceIcon) +{ + ICONINFO TargetIconInfo; + BITMAP TargetBitmapInfo; + HICON TargetIcon, TempIcon; + + TempIcon = CopyIcon(SourceIcon); + if (! GetIconInfo(TempIcon, &TargetIconInfo) || GetObject(TargetIconInfo.hbmColor, sizeof(BITMAP), &TargetBitmapInfo)==0) return NULL; + + MakeGrayscale(&TargetIconInfo.hbmColor); + + TargetIcon = CreateIconIndirect(&TargetIconInfo); + DestroyIcon(TempIcon); + + return TargetIcon; +} + + +HICON BindOverlayIcon(HICON SourceIcon,HICON OverlayIcon) +{ + ICONINFO OverlayIconInfo, TargetIconInfo; + BITMAP OverlayBitmapInfo, TargetBitmapInfo; + HBITMAP OldOverlayBitmap, OldTargetBitmap; + HICON TargetIcon, TempIcon; + HDC OverlayDC, TargetDC; + BLENDFUNCTION bf = {0,0,255,1}; + + TempIcon = CopyIcon(SourceIcon); + if ( !GetIconInfo( TempIcon, &TargetIconInfo )) + return NULL; + + MakeBitmap32(&TargetIconInfo.hbmColor); + CorrectBitmap32Alpha(TargetIconInfo.hbmColor, FALSE); + GetObject(TargetIconInfo.hbmColor, sizeof(BITMAP), &TargetBitmapInfo); + + if ( !GetIconInfo(OverlayIcon, &OverlayIconInfo) || !GetObject(OverlayIconInfo.hbmColor, sizeof(BITMAP), &OverlayBitmapInfo)) + return NULL; + + TargetDC = CreateCompatibleDC(NULL); + OldTargetBitmap = (HBITMAP)SelectObject(TargetDC, TargetIconInfo.hbmColor); + + OverlayDC = CreateCompatibleDC(NULL); + OldOverlayBitmap = (HBITMAP)SelectObject(OverlayDC, OverlayIconInfo.hbmColor); + + AlphaBlend(TargetDC, 0, 0, TargetBitmapInfo.bmWidth, TargetBitmapInfo.bmHeight, + OverlayDC, 0, 0, OverlayBitmapInfo.bmWidth, OverlayBitmapInfo.bmHeight, bf); + + SelectObject(TargetDC, TargetIconInfo.hbmMask); + SelectObject(OverlayDC, OverlayIconInfo.hbmMask); + + BitBlt(TargetDC, 0, 0, TargetBitmapInfo.bmWidth, TargetBitmapInfo.bmHeight, + OverlayDC, 0, 0, SRCCOPY); + + TargetIcon = CreateIconIndirect(&TargetIconInfo); + DestroyIcon(TempIcon); + + SelectObject(TargetDC, OldTargetBitmap); + DeleteObject(TargetIconInfo.hbmColor); + DeleteObject(TargetIconInfo.hbmMask); + DeleteDC(TargetDC); + + SelectObject(OverlayDC, OldOverlayBitmap); + DeleteObject(OverlayIconInfo.hbmColor); + DeleteObject(OverlayIconInfo.hbmMask); + DeleteDC(OverlayDC); + + return TargetIcon; +} + + +// EOF diff --git a/plugins/SecureIM/src/images.h b/plugins/SecureIM/src/images.h new file mode 100644 index 0000000000..ea65b09893 --- /dev/null +++ b/plugins/SecureIM/src/images.h @@ -0,0 +1,8 @@ +#ifndef __IMAGE_UTILS_H__ +#define __IMAGE_UTILS_H__ + +HICON BindOverlayIcon(HICON,HICON); +//HICON MakeGrayscaleIcon(HICON); +HICON MakeHalfAlphaIcon(HICON); + +#endif // __IMAGE_UTILS_H__ diff --git a/plugins/SecureIM/src/language.cpp b/plugins/SecureIM/src/language.cpp new file mode 100644 index 0000000000..9bdf620cea --- /dev/null +++ b/plugins/SecureIM/src/language.cpp @@ -0,0 +1,104 @@ +#include "commonheaders.h" + +//Popup Messages +LPCSTR sim001 = "SecureIM established..."; +LPCSTR sim002 = "Key exchange failed..."; +LPCSTR sim003 = "Key from disabled..."; +LPCSTR sim004 = "Sended back message received..."; +LPCSTR sim005 = "Sending back secure message..."; +LPCSTR sim006 = "SecureIM disabled..."; +LPCSTR sim007 = "Sending Key..."; +LPCSTR sim008 = "Key Received..."; +LPCSTR sim009 = "Sending Message..."; +LPCSTR sim010 = "Message Received..."; +LPCSTR sim011 = "Encrypting File:"; +LPCSTR sim012 = "Decrypting File:"; +LPCSTR sim013 = "Bad key received..."; + +//Error Messages +LPCSTR sim101 = "SecureIM: Error while decrypting the message."; +LPCSTR sim102 = "SecureIM: Error while decrypting the message, bad message length."; +LPCSTR sim103 = "SecureIM: Error while decrypting the message, bad message CRC."; +LPCSTR sim104 = "User has not answered to key exchange !\nYour messages are still in SecureIM queue, do you want to send them Unencrypted now ?"; +LPCSTR sim105 = "SecureIM not enabled! You Must Enable SecureIM with this user..."; +LPCSTR sim106 = "Can't Send Encrypted Message !\nUser is offline now and his secure key has been expired, Do you want to send your message ?\nIt will be unencrypted !"; +LPCSTR sim107 = "SecureIM won't be loaded because cryptopp.dll is missing or wrong version !"; +LPCSTR sim108 = "SecureIM can't load PGP/GPG key! Check PGP/GPG settings!"; +LPCSTR sim109 = "SecureIM can't encrypt message! Check trust of PGP/GPG key!"; +LPCSTR sim110 = "Can't Send Encrypted Message !\nDo you want to send your message ?\nIt will be unencrypted !"; +LPCSTR sim111 = "Can't change mode! Secure connection established!"; +LPCSTR sim112 = "Can't export RSA private key!"; +LPCSTR sim113 = "Can't import RSA private key!"; +LPCSTR sim114 = "Can't export RSA public key!"; +LPCSTR sim115 = "Can't import RSA public key!"; + +//Options +LPCSTR sim201 = "General"; +LPCSTR sim202 = "Protocols"; +LPCSTR sim203 = "Nickname"; +LPCSTR sim204 = "UIN/Email/Jid/..."; +LPCSTR sim205 = "Status"; +LPCSTR sim206 = "PSK"; +LPCSTR sim210 = "Name"; +LPCSTR sim211 = "Password is too short!"; +LPCSTR sim212 = "ON"; +LPCSTR sim213 = "Off"; +LPCSTR sim214 = "PGP"; +LPCSTR sim215 = "Key ID"; +LPCSTR sim216 = "Keyrings loaded."; +LPCSTR sim217 = "Keyrings not loaded!"; +LPCSTR sim218 = "PGP SDK v%i.%i.%i found."; +LPCSTR sim219 = "PGP SDK not found!"; +LPCSTR sim220 = "This version not supported!"; +LPCSTR sim221 = "(none)"; +LPCSTR sim222 = "Private key loaded."; +LPCSTR sim223 = "Private key not loaded!"; +LPCSTR sim224 = "The new settings will become valid when you restart MirandaIM!"; +LPCSTR sim225 = "Keyrings disabled!"; +LPCSTR sim226 = "GPG"; +LPCSTR sim227 = "CP"; +LPCSTR sim228 = "ANSI"; +LPCSTR sim229 = "UTF8"; +LPCSTR sim230 = "Mode"; +LPCSTR sim231[] = { "Native", "PGP", "GPG", "RSA/AES", "RSA" }; +LPCSTR sim232[] = { "Disabled", "Enabled", "Always try" }; +LPCSTR sim233 = "PUB"; +LPCSTR sim234 = "SHA1"; + +//Context Menu +LPCSTR sim301 = "Create SecureIM connection"; +LPCSTR sim302 = "Disable SecureIM connection"; +LPCSTR sim306 = "Load PGP Key"; +LPCSTR sim307 = "Unload PGP Key"; +LPCSTR sim308 = "Load GPG Key"; +LPCSTR sim309 = "Unload GPG Key"; +LPCSTR sim310 = "Delete RSA Key"; +LPCSTR sim311[] = { "SecureIM mode (Native)", + "SecureIM mode (PGP)", + "SecureIM mode (GPG)", + "SecureIM mode (RSA/AES)", + "SecureIM mode (RSA)" }; +LPCSTR sim312[] = { "SecureIM status (disabled)", + "SecureIM status (enabled)", + "SecureIM status (always try)" }; + +//System messages +LPCSTR sim401 = "SecureIM: Sorry, unable to decrypt this message due you have no PGP/GPG installed. Visit www.pgp.com or www.gnupg.org for more info."; +LPCSTR sim402 = "SecureIM received unencryped message:\n"; +LPCSTR sim403 = "SecureIM received encryped message:\n"; + +//RSA messages +LPCSTR sim501 = "Session closed by receiving incorrect message type"; +LPCSTR sim502 = "Session closed by other side on error"; +LPCSTR sim505 = "Error while decoding AES message"; +LPCSTR sim506 = "Error while decoding RSA message"; +LPCSTR sim507 = "Session closed on timeout"; +LPCSTR sim508 = "Session closed by other side when status \"disabled\""; +LPCSTR sim510 = "Session closed on error: %02x"; +LPCSTR sim520 = "SecureIM received RSA Public Key from \"%s\"\n\nSHA1: %s\n\nDo you Accept this Key ?"; +LPCSTR sim521 = "SecureIM auto accepted RSA Public key from: %s uin: %s SHA1: %s"; +LPCSTR sim522 = "SecureIM received NEW RSA Public Key from \"%s\"\n\nNew SHA1: %s\n\nOld SHA1: %s\n\nDo you Replace this Key ?"; +LPCSTR sim523 = "SecureIM auto accepted NEW RSA Public key from: %s uin: %s New SHA1: %s Old SHA1: %s"; + + +// EOF diff --git a/plugins/SecureIM/src/language.h b/plugins/SecureIM/src/language.h new file mode 100644 index 0000000000..154e306814 --- /dev/null +++ b/plugins/SecureIM/src/language.h @@ -0,0 +1,100 @@ +#ifndef __LANGUAGE_H__ +#define __LANGUAGE_H__ + +#include + +//Popup Messages +extern LPCSTR sim001; +extern LPCSTR sim002; +extern LPCSTR sim003; +extern LPCSTR sim004; +extern LPCSTR sim005; +extern LPCSTR sim006; +extern LPCSTR sim007; +extern LPCSTR sim008; +extern LPCSTR sim009; +extern LPCSTR sim010; +extern LPCSTR sim011; +extern LPCSTR sim012; +extern LPCSTR sim013; + +//Error Messages +extern LPCSTR sim101; +extern LPCSTR sim102; +extern LPCSTR sim103; +extern LPCSTR sim104; +extern LPCSTR sim105; +extern LPCSTR sim106; +extern LPCSTR sim107; +extern LPCSTR sim108; +extern LPCSTR sim109; +extern LPCSTR sim110; +extern LPCSTR sim111; +extern LPCSTR sim112; +extern LPCSTR sim113; +extern LPCSTR sim114; +extern LPCSTR sim115; + +//Options +extern LPCSTR sim201; +extern LPCSTR sim202; +extern LPCSTR sim203; +extern LPCSTR sim204; +extern LPCSTR sim205; +extern LPCSTR sim206; +extern LPCSTR sim210; +extern LPCSTR sim211; +extern LPCSTR sim212; +extern LPCSTR sim213; +extern LPCSTR sim214; +extern LPCSTR sim215; +extern LPCSTR sim216; +extern LPCSTR sim217; +extern LPCSTR sim218; +extern LPCSTR sim219; +extern LPCSTR sim220; +extern LPCSTR sim221; +extern LPCSTR sim222; +extern LPCSTR sim223; +extern LPCSTR sim224; +extern LPCSTR sim225; +extern LPCSTR sim226; +extern LPCSTR sim227; +extern LPCSTR sim228; +extern LPCSTR sim229; +extern LPCSTR sim230; +extern LPCSTR sim231[]; +extern LPCSTR sim232[]; +extern LPCSTR sim233; +extern LPCSTR sim234; + +//Context Menu +extern LPCSTR sim301; +extern LPCSTR sim302; +extern LPCSTR sim306; +extern LPCSTR sim307; +extern LPCSTR sim308; +extern LPCSTR sim309; +extern LPCSTR sim310; +extern LPCSTR sim311[]; +extern LPCSTR sim312[]; + +//System messages +extern LPCSTR sim401; +extern LPCSTR sim402; +extern LPCSTR sim403; + +//RSA messages +extern LPCSTR sim501; +extern LPCSTR sim502; +extern LPCSTR sim505; +extern LPCSTR sim506; +extern LPCSTR sim507; +extern LPCSTR sim508; +extern LPCSTR sim510; +extern LPCSTR sim520; +extern LPCSTR sim521; +extern LPCSTR sim522; +extern LPCSTR sim523; + +#endif diff --git a/plugins/SecureIM/src/loadicons.cpp b/plugins/SecureIM/src/loadicons.cpp new file mode 100644 index 0000000000..3303424626 --- /dev/null +++ b/plugins/SecureIM/src/loadicons.cpp @@ -0,0 +1,96 @@ +#include "commonheaders.h" + + +HINSTANCE LoadIconsPack(const char* szIconsPack) +{ + HINSTANCE hNewIconInst = NULL; + WORD i; + + hNewIconInst = LoadLibrary(szIconsPack); + + if (hNewIconInst != NULL) + { + for(i=ID_FIRSTICON; i<=ID_LASTICON; i++) + if (LoadIcon(hNewIconInst, MAKEINTRESOURCE(i)) == NULL) + { + FreeLibrary(hNewIconInst); + hNewIconInst = NULL; + break; + } + } + return hNewIconInst; +} + + + +int ReloadIcons(WPARAM wParam, LPARAM lParam) +{ + HICON hIcon; + for (int i=0; icons[i].key; i++) { + hIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)icons[i].name); + if(icons[i].tbl == TBL_IEC) + g_hIEC[icons[i].idx]=hIcon; + else + if(icons[i].tbl == TBL_ICO) + g_hICO[icons[i].idx]=hIcon; + else + if(icons[i].tbl == TBL_POP) + g_hPOP[icons[i].idx]=hIcon; + } + + return 0; +} + + +void InitIcons(void) +{ + HINSTANCE hNewIconInst = NULL; + + if ( g_hFolders ) { + LPSTR pathname = (LPSTR) alloca(MAX_PATH); + FoldersGetCustomPathEx(g_hFolders, pathname, MAX_PATH, "icons\\", "secureim_icons.dll"); + if (hNewIconInst == NULL) + hNewIconInst = LoadIconsPack(pathname); + } + + if (hNewIconInst == NULL) + hNewIconInst = LoadIconsPack("icons\\secureim_icons.dll"); + + if (hNewIconInst == NULL) + hNewIconInst = LoadIconsPack("plugins\\secureim_icons.dll"); + + if (hNewIconInst == NULL) + g_hIconInst = g_hInst; + else + g_hIconInst = hNewIconInst; + + + SKINICONDESC sid = { 0 }; + sid.cbSize = sizeof(sid); + sid.pszSection = "SecureIM"; + + HICON hIcon; + for (int i=0; icons[i].key; i++) { + sid.pszSection = icons[i].section; + sid.pszName = icons[i].name; + sid.pszDescription = icons[i].text; + sid.pszDefaultFile = "secureim_icons.dll"; + sid.iDefaultIndex = icons[i].key; + sid.hDefaultIcon = (HICON)LoadImage(g_hIconInst, MAKEINTRESOURCE(icons[i].key), IMAGE_ICON, 16, 16, LR_SHARED); + Skin_AddIcon(&sid); + hIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)icons[i].name); + + if(icons[i].tbl == TBL_IEC) + g_hIEC[icons[i].idx]=hIcon; + else + if(icons[i].tbl == TBL_ICO) + g_hICO[icons[i].idx]=hIcon; + else + if(icons[i].tbl == TBL_POP) + g_hPOP[icons[i].idx]=hIcon; + } + + AddHookFunction(ME_SKIN2_ICONSCHANGED, ReloadIcons); +} + +// EOF diff --git a/plugins/SecureIM/src/loadicons.h b/plugins/SecureIM/src/loadicons.h new file mode 100644 index 0000000000..f5258a41a0 --- /dev/null +++ b/plugins/SecureIM/src/loadicons.h @@ -0,0 +1,7 @@ +#ifndef __LOADICONS_H__ +#define __LOADICONS_H__ + +HINSTANCE LoadIconsPack(const char*); +void InitIcons(); + +#endif diff --git a/plugins/SecureIM/src/loadlib.cpp b/plugins/SecureIM/src/loadlib.cpp new file mode 100644 index 0000000000..ac0d2f9272 --- /dev/null +++ b/plugins/SecureIM/src/loadlib.cpp @@ -0,0 +1,76 @@ +#include "commonheaders.h" + +CRYPTOPP_INFO cpp; + +BOOL loadlib(void) { + + HMODULE h = LoadLibraryA("plugins/cryptopp.dll"); + if ( h == NULL ) { + h = LoadLibraryA("cryptopp.dll"); + if ( h == NULL ) return 0; + } + + cpp.cc = (_cpp_create_context) GetProcAddress(h, "cpp_create_context"); + cpp.dc = (_cpp_delete_context) GetProcAddress(h, "cpp_delete_context"); + cpp.rc = (_cpp_reset_context) GetProcAddress(h, "cpp_reset_context"); + cpp.ika = (_cpp_init_keya) GetProcAddress(h, "cpp_init_keya"); + cpp.ikb = (_cpp_init_keyb) GetProcAddress(h, "cpp_init_keyb"); + cpp.ckx = (_cpp_calc_keyx) GetProcAddress(h, "cpp_calc_keyx"); + cpp.ikp = (_cpp_init_keyp) GetProcAddress(h, "cpp_init_keyp"); + cpp.ea = (_cpp_encodeA) GetProcAddress(h, "cpp_encodeA"); + cpp.ew = (_cpp_encodeW) GetProcAddress(h, "cpp_encodeW"); + cpp.eu = (_cpp_encodeU) GetProcAddress(h, "cpp_encodeU"); + cpp.daw = (_cpp_decode) GetProcAddress(h, "cpp_decode"); + cpp.du = (_cpp_decodeU) GetProcAddress(h, "cpp_decodeU"); + cpp.ef = (_cpp_encrypt_file) GetProcAddress(h, "cpp_encrypt_file"); + cpp.df = (_cpp_decrypt_file) GetProcAddress(h, "cpp_decrypt_file"); + cpp.gf = (_cpp_get_features) GetProcAddress(h, "cpp_get_features"); + cpp.ge = (_cpp_get_error) GetProcAddress(h, "cpp_get_error"); + cpp.gv = (_cpp_get_version) GetProcAddress(h, "cpp_get_version"); + cpp.kxs = (_cpp_size_keyx) GetProcAddress(h, "cpp_size_keyx"); + cpp.gkx = (_cpp_get_keyx) GetProcAddress(h, "cpp_get_keyx"); + cpp.skx = (_cpp_set_keyx) GetProcAddress(h, "cpp_set_keyx"); + cpp.kps = (_cpp_size_keyp) GetProcAddress(h, "cpp_size_keyp"); + cpp.gkp = (_cpp_get_keyp) GetProcAddress(h, "cpp_get_keyp"); + cpp.skp = (_cpp_set_keyp) GetProcAddress(h, "cpp_set_keyp"); + cpp.ka = (_cpp_keya) GetProcAddress(h, "cpp_keya"); + cpp.kb = (_cpp_keyb) GetProcAddress(h, "cpp_keyb"); + cpp.kx = (_cpp_keyx) GetProcAddress(h, "cpp_keyx"); + cpp.kp = (_cpp_keyp) GetProcAddress(h, "cpp_keyp"); + + cpp.pgp_i = (_pgp_init ) GetProcAddress(h, "pgp_init"); + cpp.pgp_d = (_pgp_done ) GetProcAddress(h, "pgp_done"); + cpp.pgp_ok = (_pgp_open_keyrings ) GetProcAddress(h, "pgp_open_keyrings"); + cpp.pgp_ck = (_pgp_close_keyrings ) GetProcAddress(h, "pgp_close_keyrings"); + cpp.pgp_gv = (_pgp_get_version ) GetProcAddress(h, "pgp_get_version"); + cpp.pgp_ge = (_pgp_get_error ) GetProcAddress(h, "pgp_get_error"); + cpp.pgp_spk = (_pgp_set_priv_key ) GetProcAddress(h, "pgp_set_priv_key"); + cpp.pgp_sk = (_pgp_set_key ) GetProcAddress(h, "pgp_set_key"); + cpp.pgp_ski = (_pgp_set_keyid ) GetProcAddress(h, "pgp_set_keyid"); + cpp.pgp_szki = (_pgp_size_keyid ) GetProcAddress(h, "pgp_size_keyid"); + cpp.pgp_slki = (_pgp_select_keyid ) GetProcAddress(h, "pgp_select_keyid"); + cpp.pgp_eu = (_pgp_encode ) GetProcAddress(h, "pgp_encode"); + cpp.pgp_de = (_pgp_decode ) GetProcAddress(h, "pgp_decode"); + + cpp.gpg_i = (_gpg_init ) GetProcAddress(h, "gpg_init"); + cpp.gpg_d = (_gpg_done ) GetProcAddress(h, "gpg_done"); + cpp.gpg_ok = (_gpg_open_keyrings ) GetProcAddress(h, "gpg_open_keyrings"); + cpp.gpg_ck = (_gpg_close_keyrings ) GetProcAddress(h, "gpg_close_keyrings"); + cpp.gpg_sl = (_gpg_set_log ) GetProcAddress(h, "gpg_set_log"); + cpp.gpg_st = (_gpg_set_tmp ) GetProcAddress(h, "gpg_set_tmp"); + cpp.gpg_ge = (_gpg_get_error ) GetProcAddress(h, "gpg_get_error"); + cpp.gpg_ski = (_gpg_set_keyid ) GetProcAddress(h, "gpg_set_keyid"); + cpp.gpg_szki = (_gpg_size_keyid ) GetProcAddress(h, "gpg_size_keyid"); + cpp.gpg_slki = (_gpg_select_keyid ) GetProcAddress(h, "gpg_select_keyid"); + cpp.gpg_eu = (_gpg_encode ) GetProcAddress(h, "gpg_encode"); + cpp.gpg_de = (_gpg_decode ) GetProcAddress(h, "gpg_decode"); + cpp.gpg_gph = (_gpg_get_passphrases ) GetProcAddress(h, "gpg_get_passphrases"); + cpp.gpg_sph = (_gpg_set_passphrases ) GetProcAddress(h, "gpg_set_passphrases"); + + cpp.rsa_i = (_rsa_init) GetProcAddress(h, "rsa_init"); + cpp.rsa_d = (_rsa_done) GetProcAddress(h, "rsa_done"); + + return (cpp_get_version()>=0x01000403); +} + +// EOF diff --git a/plugins/SecureIM/src/loadlib.h b/plugins/SecureIM/src/loadlib.h new file mode 100644 index 0000000000..105f441dc9 --- /dev/null +++ b/plugins/SecureIM/src/loadlib.h @@ -0,0 +1,188 @@ +#ifndef __LOADLIB_H__ +#define __LOADLIB_H__ + +#include +#include "cryptopp.h" + +BOOL loadlib(void); + +typedef HANDLE (__cdecl * _cpp_create_context) (int); +typedef void (__cdecl * _cpp_delete_context) (HANDLE); +typedef void (__cdecl * _cpp_reset_context) (HANDLE); +typedef LPSTR (__cdecl * _cpp_init_keya) (HANDLE,int); +typedef int (__cdecl * _cpp_init_keyb) (HANDLE,LPCSTR); +typedef int (__cdecl * _cpp_calc_keyx) (HANDLE); +typedef int (__cdecl * _cpp_init_keyp) (HANDLE,LPCSTR); +typedef LPSTR (__cdecl * _cpp_encodeA) (HANDLE,LPCSTR); +typedef LPSTR (__cdecl * _cpp_encodeW) (HANDLE,LPWSTR); +typedef LPSTR (__cdecl * _cpp_encodeU) (HANDLE,LPCSTR); +typedef LPSTR (__cdecl * _cpp_decode) (HANDLE,LPCSTR); +typedef LPSTR (__cdecl * _cpp_decodeU) (HANDLE,LPCSTR); +typedef int (__cdecl * _cpp_encrypt_file) (HANDLE,LPCSTR,LPCSTR); +typedef int (__cdecl * _cpp_decrypt_file) (HANDLE,LPCSTR,LPCSTR); +typedef int (__cdecl * _cpp_get_features) (HANDLE); +typedef int (__cdecl * _cpp_get_error) (HANDLE); +typedef int (__cdecl * _cpp_get_version) (void); +typedef int (__cdecl * _cpp_size_keyx) (void); +typedef void (__cdecl * _cpp_get_keyx) (HANDLE,BYTE*); +typedef void (__cdecl * _cpp_set_keyx) (HANDLE,BYTE*); +typedef int (__cdecl * _cpp_size_keyp) (void); +typedef void (__cdecl * _cpp_get_keyp) (HANDLE,BYTE*); +typedef void (__cdecl * _cpp_set_keyp) (HANDLE,BYTE*); +typedef int (__cdecl * _cpp_keya) (HANDLE); +typedef int (__cdecl * _cpp_keyb) (HANDLE); +typedef int (__cdecl * _cpp_keyx) (HANDLE); +typedef int (__cdecl * _cpp_keyp) (HANDLE); + +typedef int (__cdecl * _pgp_init) (void); +typedef int (__cdecl * _pgp_done) (void); +typedef int (__cdecl * _pgp_open_keyrings) (LPSTR,LPSTR); +typedef int (__cdecl * _pgp_close_keyrings) (void); +typedef int (__cdecl * _pgp_get_version) (void); +typedef LPSTR (__cdecl * _pgp_get_error) (void); +typedef int (__cdecl * _pgp_set_priv_key) (LPCSTR); +typedef int (__cdecl * _pgp_set_key) (HANDLE,LPCSTR); +typedef int (__cdecl * _pgp_set_keyid) (HANDLE,PVOID); +typedef int (__cdecl * _pgp_size_keyid) (void); +typedef PVOID (__cdecl * _pgp_select_keyid) (HWND,LPSTR); +typedef LPSTR (__cdecl * _pgp_encode) (HANDLE,LPCSTR); +typedef LPSTR (__cdecl * _pgp_decode) (HANDLE,LPCSTR); + +typedef int (__cdecl * _gpg_init) (void); +typedef int (__cdecl * _gpg_done) (void); +typedef int (__cdecl * _gpg_open_keyrings) (LPSTR,LPSTR); +typedef int (__cdecl * _gpg_close_keyrings) (void); +typedef void (__cdecl * _gpg_set_log) (LPCSTR); +typedef void (__cdecl * _gpg_set_tmp) (LPCSTR); +typedef LPSTR (__cdecl * _gpg_get_error) (void); +typedef int (__cdecl * _gpg_set_keyid) (HANDLE,LPCSTR); +typedef int (__cdecl * _gpg_size_keyid) (void); +typedef int (__cdecl * _gpg_select_keyid) (HWND,LPSTR); +typedef LPSTR (__cdecl * _gpg_encode) (HANDLE,LPCSTR); +typedef LPSTR (__cdecl * _gpg_decode) (HANDLE,LPCSTR); +typedef LPSTR (__cdecl * _gpg_get_passphrases) (void); +typedef void (__cdecl * _gpg_set_passphrases) (LPCSTR); + +typedef int (__cdecl * _rsa_init) (pRSA_EXPORT*,pRSA_IMPORT); +typedef int (__cdecl * _rsa_done) (void); + + +typedef struct { + _cpp_create_context cc; + _cpp_delete_context dc; + _cpp_reset_context rc; + _cpp_init_keya ika; + _cpp_init_keyb ikb; + _cpp_calc_keyx ckx; + _cpp_init_keyp ikp; + _cpp_encodeA ea; + _cpp_encodeW ew; + _cpp_encodeU eu; + _cpp_decode daw; + _cpp_decodeU du; + _cpp_encrypt_file ef; + _cpp_decrypt_file df; + _cpp_get_features gf; + _cpp_get_error ge; + _cpp_get_version gv; + _cpp_size_keyx kxs; + _cpp_get_keyx gkx; + _cpp_set_keyx skx; + _cpp_size_keyp kps; + _cpp_get_keyp gkp; + _cpp_set_keyp skp; + _cpp_keya ka; + _cpp_keyb kb; + _cpp_keyx kx; + _cpp_keyp kp; + _pgp_init pgp_i; + _pgp_done pgp_d; + _pgp_open_keyrings pgp_ok; + _pgp_close_keyrings pgp_ck; + _pgp_get_version pgp_gv; + _pgp_get_error pgp_ge; + _pgp_set_keyid pgp_ski; + _pgp_set_key pgp_sk; + _pgp_set_priv_key pgp_spk; + _pgp_size_keyid pgp_szki; + _pgp_select_keyid pgp_slki; + _pgp_encode pgp_eu; + _pgp_decode pgp_de; + _gpg_init gpg_i; + _gpg_done gpg_d; + _gpg_open_keyrings gpg_ok; + _gpg_close_keyrings gpg_ck; + _gpg_set_log gpg_sl; + _gpg_set_tmp gpg_st; + _gpg_get_error gpg_ge; + _gpg_set_keyid gpg_ski; + _gpg_size_keyid gpg_szki; + _gpg_select_keyid gpg_slki; + _gpg_encode gpg_eu; + _gpg_decode gpg_de; + _gpg_get_passphrases gpg_gph; + _gpg_set_passphrases gpg_sph; + _rsa_init rsa_i; + _rsa_done rsa_d; +} CRYPTOPP_INFO; + +extern CRYPTOPP_INFO cpp; + +#define cpp_create_context cpp.cc +#define cpp_delete_context cpp.dc +#define cpp_reset_context cpp.rc +#define cpp_init_keya cpp.ika +#define cpp_init_keyb cpp.ikb +#define cpp_calc_keyx cpp.ckx +#define cpp_init_keyp cpp.ikp +#define cpp_encodeA cpp.ea +#define cpp_encodeW cpp.ew +#define cpp_encodeU cpp.eu +#define cpp_decode cpp.daw +#define cpp_decodeU cpp.du +#define cpp_encrypt_file cpp.ef +#define cpp_decrypt_file cpp.df +#define cpp_get_features cpp.gf +#define cpp_get_error cpp.ge +#define cpp_get_version cpp.gv +#define cpp_size_keyx cpp.kxs +#define cpp_get_keyx cpp.gkx +#define cpp_set_keyx cpp.skx +#define cpp_size_keyp cpp.kps +#define cpp_get_keyp cpp.gkp +#define cpp_set_keyp cpp.skp +#define cpp_keya cpp.ka +#define cpp_keyb cpp.kb +#define cpp_keyx cpp.kx +#define cpp_keyp cpp.kp +#define pgp_init cpp.pgp_i +#define pgp_done cpp.pgp_d +#define pgp_open_keyrings cpp.pgp_ok +#define pgp_close_keyrings cpp.pgp_ck +#define pgp_get_version cpp.pgp_gv +#define pgp_get_error cpp.pgp_ge +#define pgp_set_priv_key cpp.pgp_spk +#define pgp_set_key cpp.pgp_sk +#define pgp_set_keyid cpp.pgp_ski +#define pgp_size_keyid cpp.pgp_szki +#define pgp_select_keyid cpp.pgp_slki +#define pgp_encode cpp.pgp_eu +#define pgp_decode cpp.pgp_de +#define gpg_init cpp.gpg_i +#define gpg_done cpp.gpg_d +#define gpg_open_keyrings cpp.gpg_ok +#define gpg_close_keyrings cpp.gpg_ck +#define gpg_set_log cpp.gpg_sl +#define gpg_set_tmp cpp.gpg_st +#define gpg_get_error cpp.gpg_ge +#define gpg_set_keyid cpp.gpg_ski +#define gpg_size_keyid cpp.gpg_szki +#define gpg_select_keyid cpp.gpg_slki +#define gpg_encode cpp.gpg_eu +#define gpg_decode cpp.gpg_de +#define gpg_get_passphrases cpp.gpg_gph +#define gpg_set_passphrases cpp.gpg_sph +#define rsa_init cpp.rsa_i +#define rsa_done cpp.rsa_d + +#endif diff --git a/plugins/SecureIM/src/main.cpp b/plugins/SecureIM/src/main.cpp new file mode 100644 index 0000000000..205a025ffe --- /dev/null +++ b/plugins/SecureIM/src/main.cpp @@ -0,0 +1,534 @@ +#include "commonheaders.h" + +int hLangpack = 0; + +BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID) { + g_hInst = hInst; + if (dwReason == DLL_PROCESS_ATTACH) { + INITCOMMONCONTROLSEX icce = { + sizeof(icce), ICC_LISTVIEW_CLASSES | ICC_TAB_CLASSES + }; + InitCommonControlsEx(&icce); + } + return TRUE; +} + +extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_SECUREIM, MIID_LAST}; + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfoEx; +} + +void AddServiceFunction(LPCSTR serviceName, MIRANDASERVICE serviceFunction) { + + g_hService = (HANDLE*) mir_realloc(g_hService,sizeof(HANDLE)*(iService+1)); + g_hService[iService] = CreateServiceFunction(serviceName, serviceFunction); + iService++; +} + + +void AddProtoServiceFunction(LPCSTR serviceName, MIRANDASERVICE serviceFunction) { + + g_hService = (HANDLE*) mir_realloc(g_hService,sizeof(HANDLE)*(iService+1)); + g_hService[iService] = CreateProtoServiceFunction(szModuleName, serviceName, serviceFunction); + iService++; +} + + +void AddHookFunction(LPCSTR eventName, MIRANDAHOOK hookFunction) { + + g_hHook = (HANDLE*) mir_realloc(g_hHook,sizeof(HANDLE)*(iHook+1)); + g_hHook[iHook] = HookEvent(eventName, hookFunction); + iHook++; +} + + +HANDLE AddMenuItem(LPCSTR name,int pos,HICON hicon,LPCSTR service,int flags=0,WPARAM wParam=0) +{ + CLISTMENUITEM mi = { 0 }; + mi.cbSize=sizeof(mi); + mi.flags=flags | CMIF_HIDDEN; + mi.position=pos; + mi.hIcon=hicon; + mi.pszName= (char*)name; + mi.pszPopupName=(char*)-1; + mi.pszService=(char*)service; + return Menu_AddContactMenuItem(&mi); +} + + +HANDLE AddSubItem(HANDLE rootid,LPCSTR name,int pos,int poppos,LPCSTR service,WPARAM wParam=0) +{ + CLISTMENUITEM mi = { 0 }; + memset(&mi,0,sizeof(mi)); + mi.cbSize=sizeof(mi); + mi.flags=CMIF_CHILDPOPUP | CMIF_HIDDEN; + mi.position=pos; + mi.popupPosition=poppos; + mi.hIcon=NULL; + mi.pszName=(char*)name; + mi.pszPopupName=(char*)rootid; + mi.pszService=(char*)service; + return Menu_AddContactMenuItem(&mi); +} + + +extern "C" __declspec(dllexport) int __cdecl Load(void) +{ + DisableThreadLibraryCalls(g_hInst); + InitializeCriticalSection(&localQueueMutex); + + { + char temp[MAX_PATH]; + GetTempPath(sizeof(temp),temp); + GetLongPathName(temp,TEMP,sizeof(TEMP)); + TEMP_SIZE = (int)strlen(TEMP); + if(TEMP[TEMP_SIZE-1]=='\\') { + TEMP_SIZE--; + TEMP[TEMP_SIZE]='\0'; + } + } + + // get memoryManagerInterface address + //get per-plugin langpack interface + mir_getLP(&pluginInfoEx); + + // check for support TrueColor Icons + BOOL bIsComCtl6 = FALSE; + HMODULE hComCtlDll = LoadLibrary("comctl32.dll"); + if ( hComCtlDll ) { + typedef HRESULT (CALLBACK *PFNDLLGETVERSION)(DLLVERSIONINFO*); + PFNDLLGETVERSION pfnDllGetVersion = (PFNDLLGETVERSION) GetProcAddress(hComCtlDll,"DllGetVersion"); + if ( pfnDllGetVersion ) { + DLLVERSIONINFO dvi; + memset(&dvi,0,sizeof(dvi)); + dvi.cbSize = sizeof(dvi); + HRESULT hRes = (*pfnDllGetVersion)( &dvi ); + if ( SUCCEEDED(hRes) && dvi.dwMajorVersion >= 6 ) { + bIsComCtl6 = TRUE; + } + } + FreeLibrary(hComCtlDll); + } + if (bIsComCtl6) iBmpDepth = ILC_COLOR32 | ILC_MASK; // 32-bit images are supported + else iBmpDepth = ILC_COLOR24 | ILC_MASK; + +// iBmpDepth = ILC_COLOR32 | ILC_MASK; + + char version[512]; + CallService(MS_SYSTEM_GETVERSIONTEXT, sizeof(version), (LPARAM)&version); + bCoreUnicode = strstr(version, "Unicode")!=0; + iCoreVersion = CallService(MS_SYSTEM_GETVERSION,0,0); + + // load crypo++ dll + if ( !loadlib()) { + msgbox1(0,sim107,szModuleName,MB_OK|MB_ICONSTOP); + return 1; + } + + load_rtfconv(); + + // register plugin module + PROTOCOLDESCRIPTOR pd; + memset(&pd,0,sizeof(pd)); + pd.cbSize = sizeof(pd); + pd.szName = (char*)szModuleName; + pd.type = PROTOTYPE_ENCRYPTION; + CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd); + + // hook events + AddHookFunction(ME_SYSTEM_MODULESLOADED, onModulesLoaded); + AddHookFunction(ME_SYSTEM_OKTOEXIT, onSystemOKToExit); + + g_hEvent[0] = CreateHookableEvent(MODULENAME"/Disabled"); + g_hEvent[1] = CreateHookableEvent(MODULENAME"/Established"); + + AddServiceFunction(MODULENAME"/IsContactSecured",Service_IsContactSecured); + AddServiceFunction(MODULENAME"/SIM_EST",Service_CreateIM); + AddServiceFunction(MODULENAME"/SIM_DIS",Service_DisableIM); + AddServiceFunction(MODULENAME"/SIM_ST_DIS",Service_StatusDis); + AddServiceFunction(MODULENAME"/SIM_ST_ENA",Service_StatusEna); + AddServiceFunction(MODULENAME"/SIM_ST_TRY",Service_StatusTry); + AddServiceFunction(MODULENAME"/PGP_SET",Service_PGPsetKey); + AddServiceFunction(MODULENAME"/PGP_DEL",Service_PGPdelKey); + AddServiceFunction(MODULENAME"/GPG_SET",Service_GPGsetKey); + AddServiceFunction(MODULENAME"/GPG_DEL",Service_GPGdelKey); + AddServiceFunction(MODULENAME"/MODE_NAT",Service_ModeNative); + AddServiceFunction(MODULENAME"/MODE_PGP",Service_ModePGP); + AddServiceFunction(MODULENAME"/MODE_GPG",Service_ModeGPG); + AddServiceFunction(MODULENAME"/MODE_RSA",Service_ModeRSAAES); + + return 0; +} + +extern "C" __declspec(dllexport) int __cdecl Unload() { + DeleteCriticalSection(&localQueueMutex); + return 0; +} + + +int __cdecl onModulesLoaded(WPARAM wParam,LPARAM lParam) { + +#if defined(_DEBUG) || defined(NETLIB_LOG) + InitNetlib(); + Sent_NetLog("onModuleLoaded begin"); +#endif + + bMetaContacts = ServiceExists(MS_MC_GETMETACONTACT)!=0; + bPopupExists = ServiceExists(MS_POPUP_ADDPOPUPEX)!=0; + bPopupUnicode = ServiceExists(MS_POPUP_ADDPOPUPW)!=0; + + g_hFolders = FoldersRegisterCustomPath(szModuleName, "Icons", MIRANDA_PATH"\\icons"); + if ( g_hFolders==(HANDLE)CALLSERVICE_NOTFOUND ) g_hFolders = 0; + + InitIcons(); + GetFlags(); + +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("rsa_init"); +#endif + { // RSA/AES + rsa_init(&exp,&imp); + + DBVARIANT dbv; + dbv.type = DBVT_BLOB; + + if ( DBGetContactSetting(0,szModuleName,"rsa_priv",&dbv) == 0 ) { + exp->rsa_set_keypair(CPP_MODE_RSA_4096,dbv.pbVal,dbv.cpbVal); + DBFreeVariant(&dbv); + rsa_4096=1; + } + else + if ( DBGetContactSetting(0,szModuleName,"rsa_priv_4096",&dbv) == 0 ) { + exp->rsa_set_keypair(CPP_MODE_RSA_4096|CPP_MODE_RSA_BER,dbv.pbVal,dbv.cpbVal); + DBFreeVariant(&dbv); + + char priv_key[4096]; int priv_len; + char pub_key[4096]; int pub_len; + + DBCONTACTWRITESETTING cws; + cws.szModule = szModuleName; + cws.value.type = DBVT_BLOB; + + exp->rsa_get_keypair(CPP_MODE_RSA_4096,(PBYTE)&priv_key,&priv_len,(PBYTE)&pub_key,&pub_len); + + cws.szSetting = "rsa_priv"; + cws.value.pbVal = (PBYTE)&priv_key; + cws.value.cpbVal = priv_len; + CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)0, (LPARAM)&cws); + + cws.szSetting = "rsa_pub"; + cws.value.pbVal = (PBYTE)&pub_key; + cws.value.cpbVal = pub_len; + CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)0, (LPARAM)&cws); + + DBDeleteContactSetting(0, szModuleName, "rsa_priv_2048"); + DBDeleteContactSetting(0, szModuleName, "rsa_pub_2048"); +// DBDeleteContactSetting(0, szModuleName, "rsa_priv_4096"); +// DBDeleteContactSetting(0, szModuleName, "rsa_pub_4096"); + + rsa_4096=1; + } + + if ( !rsa_4096 ) { + unsigned int tID; + CloseHandle( (HANDLE) _beginthreadex(NULL, 0, sttGenerateRSA, NULL, 0, &tID)); + } + + exp->rsa_set_timeout( DBGetContactSettingWord(0,szModuleName,"ket",10)); + } + +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("pgp_init"); +#endif + bPGP = DBGetContactSettingByte(0, szModuleName, "pgp", 0); + if(bPGP) { //PGP + bPGPloaded = pgp_init(); + bUseKeyrings = DBGetContactSettingByte(0,szModuleName,"ukr",1); + LPSTR priv = myDBGetStringDecode(0,szModuleName,"pgpPrivKey"); + if(priv) { + bPGPprivkey = true; + if(bPGPloaded) + pgp_set_priv_key(priv); + mir_free(priv); + }// if(priv) + if(bPGPloaded && bUseKeyrings) { + char PubRingPath[MAX_PATH], SecRingPath[MAX_PATH]; + PubRingPath[0]='\0'; SecRingPath[0]='\0'; + if(pgp_get_version()<0x02000000) { // 6xx + bPGPkeyrings = pgp_open_keyrings(PubRingPath,SecRingPath); + } + else { + LPSTR tmp; + tmp = myDBGetString(0,szModuleName,"pgpPubRing"); + if(tmp) { + strncpy(PubRingPath,tmp,sizeof(PubRingPath)); + mir_free(tmp); + } + tmp = myDBGetString(0,szModuleName,"pgpSecRing"); + if(tmp) { + strncpy(SecRingPath,tmp,sizeof(SecRingPath)); + mir_free(tmp); + } + if(PubRingPath[0] && SecRingPath[0]) { + bPGPkeyrings = pgp_open_keyrings(PubRingPath,SecRingPath); + if(bPGPkeyrings) { + DBWriteContactSettingString(0,szModuleName,"pgpPubRing",PubRingPath); + DBWriteContactSettingString(0,szModuleName,"pgpSecRing",SecRingPath); + } + else { + DBDeleteContactSetting(0, szModuleName, "pgpPubRing"); + DBDeleteContactSetting(0, szModuleName, "pgpSecRing"); + } + } + } + }// if(bPGPloaded && bUseKeyrings) + }// if(bPGP) + +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("gpg_init"); +#endif + bGPG = DBGetContactSettingByte(0, szModuleName, "gpg", 0); + if(bGPG) { //GPG + + LPSTR tmp; + + bGPGloaded = gpg_init(); + + char gpgexec[MAX_PATH], gpghome[MAX_PATH]; + gpgexec[0]='\0'; gpghome[0]='\0'; + + tmp = myDBGetString(0,szModuleName,"gpgExec"); + if(tmp) { + strncpy(gpgexec,tmp,sizeof(gpgexec)); + mir_free(tmp); + } + tmp = myDBGetString(0,szModuleName,"gpgHome"); + if(tmp) { + strncpy(gpghome,tmp,sizeof(gpghome)); + mir_free(tmp); + } + + if(DBGetContactSettingByte(0, szModuleName, "gpgLogFlag",0)) { + tmp = myDBGetString(0,szModuleName,"gpgLog"); + if(tmp) { + gpg_set_log(tmp); + mir_free(tmp); + } + } + + if(DBGetContactSettingByte(0, szModuleName, "gpgTmpFlag",0)) { + tmp = myDBGetString(0,szModuleName,"gpgTmp"); + if(tmp) { + gpg_set_tmp(tmp); + mir_free(tmp); + } + } + + bGPGkeyrings = gpg_open_keyrings(gpgexec,gpghome); + if(bGPGkeyrings) { + DBWriteContactSettingString(0,szModuleName,"gpgExec",gpgexec); + DBWriteContactSettingString(0,szModuleName,"gpgHome",gpghome); + } + else { + DBDeleteContactSetting(0, szModuleName, "gpgExec"); + DBDeleteContactSetting(0, szModuleName, "gpgHome"); + } + + bSavePass = DBGetContactSettingByte(0,szModuleName,"gpgSaveFlag",0); + if(bSavePass) { + tmp = myDBGetString(0,szModuleName,"gpgSave"); + if(tmp) { + gpg_set_passphrases(tmp); + mir_free(tmp); + } + } + } + +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("loadContactList"); +#endif + loadContactList(); + + // add new skin sound + SkinAddNewSound("IncomingSecureMessage",LPGEN("Incoming Secure Message"),"Sounds\\iSecureMessage.wav"); + SkinAddNewSound("OutgoingSecureMessage",LPGEN("Outgoing Secure Message"),"Sounds\\oSecureMessage.wav"); + +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("init extra icons"); +#endif + // init extra icons + for(int i=0;i<1+MODE_CNT*IEC_CNT;i++) { + g_IEC[i].cbSize = sizeof(g_IEC[i]); + g_IEC[i].ColumnType = bADV; + g_IEC[i].hImage = (HANDLE)-1; + } + + // build extra imagelist + //onExtraImageListRebuilding(0,0); + +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("hook events"); +#endif + AddHookFunction(ME_CLIST_PREBUILDCONTACTMENU, onRebuildContactMenu); +// g_hMC = HookEvent(ME_MC_SUBCONTACTSCHANGED, onMC); + + if ( ServiceExists(MS_EXTRAICON_REGISTER)) { + g_hCLIcon = ExtraIcon_Register(szModuleName, Translate("SecureIM status"), "sim_cm_est", + onExtraImageListRebuilding, + onExtraImageApplying); + } + else { + AddHookFunction(ME_CLIST_EXTRA_LIST_REBUILD, onExtraImageListRebuilding); + AddHookFunction(ME_CLIST_EXTRA_IMAGE_APPLY, onExtraImageApplying); + } + + // hook init options + AddHookFunction(ME_OPT_INITIALISE, onRegisterOptions); + if(bPopupExists) + AddHookFunction(ME_OPT_INITIALISE, onRegisterPopOptions); + AddHookFunction(ME_PROTO_ACK, onProtoAck); + AddHookFunction(ME_DB_CONTACT_SETTINGCHANGED, onContactSettingChanged); + AddHookFunction(ME_DB_CONTACT_ADDED, onContactAdded); + AddHookFunction(ME_DB_CONTACT_DELETED, onContactDeleted); + + // hook message transport + AddProtoServiceFunction(PSR_MESSAGE, onRecvMsg); + AddProtoServiceFunction(PSS_MESSAGE, (MIRANDASERVICE)onSendMsg); + AddProtoServiceFunction(PSS_MESSAGE"W", (MIRANDASERVICE)onSendMsgW); + AddProtoServiceFunction(PSS_FILE, (MIRANDASERVICE)onSendFile); + +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("create Native/RSA menu"); +#endif + // create a menu item for creating a secure im connection to the user. + g_hMenu[0] = AddMenuItem(sim301,110000,g_hICO[ICO_CM_EST],MODULENAME"/SIM_EST",CMIF_NOTOFFLINE); + g_hMenu[1] = AddMenuItem(sim302,110001,g_hICO[ICO_CM_DIS],MODULENAME"/SIM_DIS",CMIF_NOTOFFLINE); + + if(ServiceExists(MS_CLIST_MENUBUILDSUBGROUP)) { + g_hMenu[2] = AddMenuItem(sim312[0],110002,NULL,NULL,CMIF_ROOTPOPUP); + g_hMenu[3] = AddSubItem(g_hMenu[2],sim232[0],110003,110002,MODULENAME"/SIM_ST_DIS"); + g_hMenu[4] = AddSubItem(g_hMenu[2],sim232[1],110004,110002,MODULENAME"/SIM_ST_ENA"); + g_hMenu[5] = AddSubItem(g_hMenu[2],sim232[2],110005,110002,MODULENAME"/SIM_ST_TRY"); + } + else { + g_hMenu[2] = 0; + g_hMenu[3] = AddMenuItem(sim232[0],110003,NULL,MODULENAME"/SIM_ST_DIS"); + g_hMenu[4] = AddMenuItem(sim232[1],110004,NULL,MODULENAME"/SIM_ST_ENA"); + g_hMenu[5] = AddMenuItem(sim232[2],110005,NULL,MODULENAME"/SIM_ST_TRY"); + } + +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("create PGP/GPG menu"); +#endif + HICON icon; + if ( bPGPloaded ) { + icon=mode2icon(MODE_PGP|SECURED,2); + g_hMenu[6] = AddMenuItem(sim306,110006,icon,MODULENAME"/PGP_SET",0); + icon=mode2icon(MODE_PGP,2); + g_hMenu[7] = AddMenuItem(sim307,110007,icon,MODULENAME"/PGP_DEL",0); + } + + if(bGPGloaded) { + icon=mode2icon(MODE_GPG|SECURED,2); + g_hMenu[8] = AddMenuItem(sim308,110008,icon,MODULENAME"/GPG_SET",0); + icon=mode2icon(MODE_GPG,2); + g_hMenu[9] = AddMenuItem(sim309,110009,icon,MODULENAME"/GPG_DEL",0); + } + +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("create Mode menu"); +#endif + if(ServiceExists(MS_CLIST_MENUBUILDSUBGROUP)) { + g_hMenu[10] = AddMenuItem(sim311[0],110010,NULL,NULL,CMIF_ROOTPOPUP); + g_hMenu[11] = AddSubItem(g_hMenu[10],sim231[0],110011,110010,MODULENAME"/MODE_NAT"); + g_hMenu[12] = AddSubItem(g_hMenu[10],sim231[1],110012,110010,MODULENAME"/MODE_PGP"); + g_hMenu[13] = AddSubItem(g_hMenu[10],sim231[2],110013,110010,MODULENAME"/MODE_GPG"); + g_hMenu[14] = AddSubItem(g_hMenu[10],sim231[3],110014,110010,MODULENAME"/MODE_RSA"); + } + else { + g_hMenu[10] = 0; + g_hMenu[11] = AddMenuItem(sim231[0],110011,NULL,MODULENAME"/MODE_NAT"); + g_hMenu[12] = AddMenuItem(sim231[1],110012,NULL,MODULENAME"/MODE_PGP"); + g_hMenu[13] = AddMenuItem(sim231[2],110013,NULL,MODULENAME"/MODE_GPG"); + g_hMenu[14] = AddMenuItem(sim231[3],110014,NULL,MODULENAME"/MODE_RSA"); + } + + +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("create srmm icons"); +#endif + // add icon to srmm status icons + if(ServiceExists(MS_MSG_ADDICON)) { + + StatusIconData sid; + memset(&sid,0,sizeof(sid)); + sid.cbSize = sizeof(sid); + sid.szModule = (char*)szModuleName; + sid.flags = MBF_DISABLED|MBF_HIDDEN; + // Native + sid.dwId = MODE_NATIVE; + sid.hIcon = mode2icon(MODE_NATIVE|SECURED,3); + sid.hIconDisabled = mode2icon(MODE_NATIVE,3); + sid.szTooltip = Translate("SecureIM [Native]"); + CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid); + // PGP + sid.dwId = MODE_PGP; + sid.hIcon = mode2icon(MODE_PGP|SECURED,3); + sid.hIconDisabled = mode2icon(MODE_PGP,3); + sid.szTooltip = Translate("SecureIM [PGP]"); + CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid); + // GPG + sid.dwId = MODE_GPG; + sid.hIcon = mode2icon(MODE_GPG|SECURED,3); + sid.hIconDisabled = mode2icon(MODE_GPG,3); + sid.szTooltip = Translate("SecureIM [GPG]"); + CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid); + // RSAAES + sid.dwId = MODE_RSAAES; + sid.hIcon = mode2icon(MODE_RSAAES|SECURED,3); + sid.hIconDisabled = mode2icon(MODE_RSAAES,3); + sid.szTooltip = Translate("SecureIM [RSA/AES]"); + CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid); + + // hook the window events so that we can can change the status of the icon + AddHookFunction(ME_MSG_WINDOWEVENT, onWindowEvent); + AddHookFunction(ME_MSG_ICONPRESSED, onIconPressed); + } + +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onModuleLoaded end"); +#endif + return 0; +} + + +int __cdecl onSystemOKToExit(WPARAM wParam,LPARAM lParam) { + + if(bSavePass) { + LPSTR tmp = gpg_get_passphrases(); + DBWriteContactSettingString(0,szModuleName,"gpgSave",tmp); + LocalFree(tmp); + } + else { + DBDeleteContactSetting(0,szModuleName,"gpgSave"); + } + if(bPGPloaded) pgp_done(); + if(bGPGloaded) gpg_done(); + rsa_done(); + while(iHook--) UnhookEvent(g_hHook[iHook]); + mir_free(g_hHook); + while(iService--) DestroyServiceFunction(g_hService[iService]); + mir_free(g_hService); + DestroyHookableEvent(g_hEvent[0]); + DestroyHookableEvent(g_hEvent[1]); + freeContactList(); + free_rtfconv(); +#if defined(_DEBUG) || defined(NETLIB_LOG) + DeinitNetlib(); +#endif + return 0; +} + +// EOF diff --git a/plugins/SecureIM/src/mmi.cpp b/plugins/SecureIM/src/mmi.cpp new file mode 100644 index 0000000000..2269d76a51 --- /dev/null +++ b/plugins/SecureIM/src/mmi.cpp @@ -0,0 +1,155 @@ +#include "commonheaders.h" + + +void *operator new(size_t sz) { + return mir_alloc(sz); +} + + +void *operator new[](size_t size) { + return operator new(size); +} + + +void operator delete(void *p) { + mir_free(p); +} + + +void operator delete[](void * p) { + operator delete(p); +} + + +// ANSIzUCS2z + ANSIzUCS2z = ANSIzUCS2z +char *m_wwstrcat(LPCSTR strA, LPCSTR strB) { + int lenA = (int)strlen(strA); + int lenB = (int)strlen(strB); + LPSTR str = (LPSTR)mir_alloc((lenA+lenB+1)*(sizeof(WCHAR)+1)); + memcpy(str, strA, lenA); + memcpy(str+lenA, strB, lenB+1); + memcpy(str+lenA+lenB+1, strA+lenA+1, lenA*sizeof(WCHAR)); + memcpy(str+lenA+lenB+1+lenA*sizeof(WCHAR), strB+lenB+1, (lenB+1)*sizeof(WCHAR)); + return str; +} + + +// ANSIz + ANSIzUCS2z = ANSIzUCS2z +char *m_awstrcat(LPCSTR strA, LPCSTR strB) { + int lenA = (int)strlen(strA); + LPSTR tmpA = (LPSTR)mir_alloc((lenA+1)*(sizeof(WCHAR)+1)); + strcpy(tmpA, strA); + MultiByteToWideChar(CP_ACP, 0, strA, -1, (LPWSTR)(tmpA+lenA+1), (lenA+1)*sizeof(WCHAR)); + LPSTR str = m_wwstrcat(tmpA, strB); + mir_free(tmpA); + return str; +} + + +// ANSIz + ANSIz = ANSIzUCS2z +char *m_aastrcat(LPCSTR strA, LPCSTR strB) { + int lenA = (int)strlen(strA); + int lenB = (int)strlen(strB); + LPSTR str = (LPSTR)mir_alloc((lenA+lenB+1)*(sizeof(WCHAR)+1)); + strcpy(str,strA); + strcat(str,strB); + MultiByteToWideChar(CP_ACP, 0, str, -1, (LPWSTR)(str+lenA+lenB+1), (lenA+lenB+1)*sizeof(WCHAR)); + return str; +} + + +LPSTR m_string = NULL; + +// ANSIz + ANSIz = ANSIz +char *m_ustrcat(LPCSTR strA, LPCSTR strB) { + SAFE_FREE(m_string); + m_string = (LPSTR) mir_alloc(strlen(strA)+strlen(strB)+1); + strcpy(m_string,strA); strcat(m_string,strB); + return m_string; +} + + +LPSTR m_hex = NULL; + +LPSTR to_hex(PBYTE bin, int len) { + SAFE_FREE(m_hex); + m_hex = (LPSTR) mir_alloc(len*3+1); + LPSTR m_ptr = m_hex; + for ( int i=0; iutf8decode(szUtfMsg); + LPSTR szMsg = mir_u2a(wszMsg); + if ( bCoreUnicode ) { + flags |= PREF_UNICODE; + int olen = (int)wcslen((LPWSTR)wszMsg)+1; + int nlen = olen*(sizeof(WCHAR)+1); + szNewMsg = (LPSTR) mir_alloc(nlen); + memcpy(szNewMsg,szMsg,olen); + memcpy(szNewMsg+olen,wszMsg,olen*sizeof(WCHAR)); + mir_free(szMsg); + } + else { + szNewMsg = szMsg; + } + } + else { + flags &= ~PREF_UNICODE; flags |= PREF_UTF; + szNewMsg = (LPSTR) mir_strdup(szUtfMsg); + } + return szNewMsg; +} + + +// ЇаҐ®Ўа §гҐ¬ ⥪бв Ё§ д®а¬ в  ¬Ёа ­¤л ў зЁбвл© UTF8 +LPSTR miranda_to_utf8(LPCSTR szMirMsg, DWORD flags) { + LPSTR szNewMsg; + if(flags & PREF_UTF) { + szNewMsg = (LPSTR) szMirMsg; + } + else + if(flags & PREF_UNICODE) { + szNewMsg = exp->utf8encode((LPCWSTR)(szMirMsg+strlen(szMirMsg)+1)); + } + else { + LPWSTR wszMirMsg = mir_a2u(szMirMsg); + szNewMsg = exp->utf8encode((LPCWSTR)wszMirMsg); + mir_free(wszMirMsg); + } + return mir_strdup(szNewMsg); +} + + +// EOF diff --git a/plugins/SecureIM/src/mmi.h b/plugins/SecureIM/src/mmi.h new file mode 100644 index 0000000000..7b3027e232 --- /dev/null +++ b/plugins/SecureIM/src/mmi.h @@ -0,0 +1,27 @@ +#ifndef __MMI_H__ +#define __MMI_H__ + +#include "commonheaders.h" + +char *m_wwstrcat(LPCSTR,LPCSTR); +char *m_awstrcat(LPCSTR,LPCSTR); +char *m_aastrcat(LPCSTR,LPCSTR); +char *m_ustrcat(LPCSTR,LPCSTR); +LPSTR to_hex(PBYTE,int); + +LPSTR utf8_to_miranda(LPCSTR,DWORD&); +LPSTR miranda_to_utf8(LPCSTR,DWORD); + +void *operator new(size_t sz); +void operator delete(void *p); +void *operator new[](size_t size); +void operator delete[](void * p); + +#define SAFE_INIT(t,p) t p=NULL; +#define SAFE_FREE(p) safe_free((void **)&(p)); +#define SAFE_DELETE(p) safe_delete((void **)&(p)); + +void __fastcall safe_free(void** p); +void __fastcall safe_delete(void** p); + +#endif diff --git a/plugins/SecureIM/src/options.cpp b/plugins/SecureIM/src/options.cpp new file mode 100644 index 0000000000..d6cc1a70d6 --- /dev/null +++ b/plugins/SecureIM/src/options.cpp @@ -0,0 +1,1928 @@ +#include "commonheaders.h" + +#define PSKSIZE (4096+1) +#define RSASIZE (4096+1) + +BOOL bChangeSortOrder = false; +const char *szAdvancedIcons[] = {"None", "Email", "Protocol", "SMS", "Advanced 1", "Advanced 2", "Web", "Client", "VisMode", "Advanced 6", "Advanced 7", 0}; + + +BOOL hasKey(pUinKey ptr) { + BOOL ret = 0; + if ( ptr->mode==MODE_NATIVE ) { + LPSTR str = myDBGetString(ptr->hContact,szModuleName,"PSK"); + ret = (str!=NULL); SAFE_FREE(str); + } + else + if ( ptr->mode==MODE_RSAAES ) { + DBVARIANT dbv; + dbv.type = DBVT_BLOB; + if ( DBGetContactSetting(ptr->hContact,szModuleName,"rsa_pub",&dbv) == 0 ) { + ret = 1; + DBFreeVariant(&dbv); + } + } + return ret; +} + + +void TC_InsertItem(HWND hwnd, WPARAM wparam, TCITEM *tci) { + if ( bCoreUnicode ) { + LPWSTR tmp = mir_a2u(tci->pszText); + tci->pszText = (LPSTR)TranslateW(tmp); + SNDMSG(hwnd, TCM_INSERTITEMW, wparam, (LPARAM)tci); + mir_free(tmp); + } + else { + tci->pszText = Translate(tci->pszText); + SNDMSG(hwnd, TCM_INSERTITEMA, wparam, (LPARAM)tci); + } +} + + +static void LV_InsertColumn(HWND hwnd, WPARAM wparam, LVCOLUMN *lvc) { + if ( bCoreUnicode ) { + LPWSTR tmp = mir_a2u(lvc->pszText); + lvc->pszText = (LPSTR)TranslateW(tmp); + SNDMSG(hwnd, LVM_INSERTCOLUMNW, wparam, (LPARAM)lvc); + mir_free(tmp); + } + else { + lvc->pszText = Translate(lvc->pszText); + SNDMSG(hwnd, LVM_INSERTCOLUMNA, wparam, (LPARAM)lvc); + } +} + + +int LV_InsertItem(HWND hwnd, LVITEM *lvi) { + return SNDMSG(hwnd, bCoreUnicode ? LVM_INSERTITEMW : LVM_INSERTITEMA, 0, (LPARAM)lvi); +} + + +int LV_InsertItemA(HWND hwnd, LVITEM *lvi) { + if ( bCoreUnicode ) lvi->pszText = (LPSTR) mir_a2u(lvi->pszText); + int ret = LV_InsertItem(hwnd, lvi); + if ( bCoreUnicode ) mir_free(lvi->pszText); + return ret; +} + + +void LV_SetItemText(HWND hwnd, WPARAM wparam, int subitem, LPSTR text) { + LV_ITEM lvi; memset(&lvi,0,sizeof(lvi)); + lvi.iSubItem = subitem; + lvi.pszText = text; + SNDMSG(hwnd, bCoreUnicode ? LVM_SETITEMTEXTW : LVM_SETITEMTEXTA, wparam, (LPARAM)&lvi); +} + + +void LV_SetItemTextA(HWND hwnd, WPARAM wparam, int subitem, LPSTR text) { + if ( bCoreUnicode ) text = (LPSTR) mir_a2u(text); + LV_SetItemText(hwnd, wparam, subitem, text); + if ( bCoreUnicode ) mir_free(text); +} + + +void LV_GetItemTextA(HWND hwnd, WPARAM wparam, int iSubItem, LPSTR text, int cchTextMax) { + LV_ITEM lvi; memset(&lvi,0,sizeof(lvi)); + lvi.iSubItem = iSubItem; + lvi.cchTextMax = cchTextMax; + lvi.pszText = text; + SNDMSG(hwnd, bCoreUnicode ? LVM_GETITEMTEXTW : LVM_GETITEMTEXTA, wparam, (LPARAM)&lvi); + if ( bCoreUnicode ) { + lvi.pszText = mir_u2a((LPWSTR)text); + strcpy(text, lvi.pszText); + mir_free(lvi.pszText); + } +} + +/* + * tabbed options dialog + */ + +INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { + + static int iInit = TRUE; + TCITEM tci; + + switch(msg) { + case WM_INITDIALOG: { + RECT rcClient; + GetClientRect(hwnd, &rcClient); + + iInit = TRUE; + tci.mask = TCIF_PARAM|TCIF_TEXT; + + tci.lParam = (LPARAM)CreateDialog(g_hInst,MAKEINTRESOURCE(IDD_TAB_GENERAL),hwnd,DlgProcOptionsGeneral); + tci.pszText = (LPSTR)sim201; + TC_InsertItem(GetDlgItem(hwnd, IDC_OPTIONSTAB), 0, &tci); + MoveWindow((HWND)tci.lParam,5,26,rcClient.right-8,rcClient.bottom-29,1); + + tci.lParam = (LPARAM)CreateDialog(g_hInst,MAKEINTRESOURCE(IDD_TAB_PROTO),hwnd,DlgProcOptionsProto); + tci.pszText = (LPSTR)sim202; + TC_InsertItem(GetDlgItem(hwnd, IDC_OPTIONSTAB), 2, &tci); + MoveWindow((HWND)tci.lParam,5,26,rcClient.right-8,rcClient.bottom-29,1); + ShowWindow((HWND)tci.lParam, SW_HIDE); + + if(bPGP && bPGPloaded) { + tci.lParam = (LPARAM)CreateDialog(g_hInst,MAKEINTRESOURCE(IDD_TAB_PGP),hwnd,DlgProcOptionsPGP); + tci.pszText = (LPSTR)sim214; + TC_InsertItem(GetDlgItem(hwnd, IDC_OPTIONSTAB), 3, &tci); + MoveWindow((HWND)tci.lParam,5,26,rcClient.right-8,rcClient.bottom-29,1); + ShowWindow((HWND)tci.lParam, SW_HIDE); + } + + if(bGPG && bGPGloaded) { + tci.lParam = (LPARAM)CreateDialog(g_hInst,MAKEINTRESOURCE(IDD_TAB_GPG),hwnd,DlgProcOptionsGPG); + tci.pszText = (LPSTR)sim226; + TC_InsertItem(GetDlgItem(hwnd, IDC_OPTIONSTAB), 4, &tci); + MoveWindow((HWND)tci.lParam,5,26,rcClient.right-8,rcClient.bottom-29,1); + ShowWindow((HWND)tci.lParam, SW_HIDE); + } + + // add more tabs here if needed + // activate the final tab + iInit = FALSE; + return TRUE; + } + break; + + case PSM_CHANGED: // used so tabs dont have to call SendMessage(GetParent(GetParent(hwnd)), PSM_CHANGED, 0, 0); + if (!iInit) + SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); + break; + + case WM_COMMAND: { + switch(LOWORD(wParam)) { + case ID_UPDATE_CLIST: { + tci.mask = TCIF_PARAM; + TabCtrl_GetItem(GetDlgItem(hwnd,IDC_OPTIONSTAB),0,&tci); + SendMessage((HWND)tci.lParam,WM_COMMAND,ID_UPDATE_CLIST,0); + } + break; +/* case ID_UPDATE_PROTO: { + tci.mask = TCIF_PARAM; + TabCtrl_GetItem(GetDlgItem(hwnd,IDC_OPTIONSTAB),1,&tci); + SendMessage((HWND)tci.lParam,WM_COMMAND,ID_UPDATE_PROTO,0); + } + break;*/ + case ID_UPDATE_PLIST: { + if ( !bPGP ) break; + tci.mask = TCIF_PARAM; + TabCtrl_GetItem(GetDlgItem(hwnd,IDC_OPTIONSTAB),2,&tci); + SendMessage((HWND)tci.lParam,WM_COMMAND,ID_UPDATE_CLIST,0); + } + break; + case ID_UPDATE_GLIST: { + if ( !bGPG ) break; + tci.mask = TCIF_PARAM; + TabCtrl_GetItem(GetDlgItem(hwnd,IDC_OPTIONSTAB),3,&tci); + SendMessage((HWND)tci.lParam,WM_COMMAND,ID_UPDATE_GLIST,0); + } + break; + } + } + break; + + case WM_NOTIFY: { + switch(((LPNMHDR)lParam)->idFrom) { + case 0: { + switch (((LPNMHDR)lParam)->code) { + case PSN_APPLY: { + tci.mask = TCIF_PARAM; + int cnt = TabCtrl_GetItemCount(GetDlgItem(hwnd,IDC_OPTIONSTAB)); + for (int i=0;icode) { + case TCN_SELCHANGING: { + tci.mask = TCIF_PARAM; + TabCtrl_GetItem(GetDlgItem(hwnd,IDC_OPTIONSTAB),TabCtrl_GetCurSel(GetDlgItem(hwnd,IDC_OPTIONSTAB)),&tci); + ShowWindow((HWND)tci.lParam,SW_HIDE); + } + break; + case TCN_SELCHANGE: { + tci.mask = TCIF_PARAM; + TabCtrl_GetItem(GetDlgItem(hwnd,IDC_OPTIONSTAB),TabCtrl_GetCurSel(GetDlgItem(hwnd,IDC_OPTIONSTAB)),&tci); + ShowWindow((HWND)tci.lParam,SW_SHOW); + } + break; + } + } // case IDC_OPTIONSTAB + break; + } + } // case WM_NOTIFY + break; + } + return FALSE; +} + + +INT_PTR CALLBACK DlgProcOptionsGeneral(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam) { + + static int iInit = TRUE; + static HIMAGELIST hLarge, hSmall; + int i,idx; pUinKey ptr; + + HWND hLV = GetDlgItem(hDlg,IDC_STD_USERLIST); + + switch (wMsg) { + case WM_INITDIALOG: { + + TranslateDialogDefault(hDlg); + +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("DlgProcOptionsGeneral(WN_INITDIALOG)"); +#endif + iInit = TRUE; +// SendMessage(hLV, WM_SETREDRAW, FALSE, 0); + ListView_SetExtendedListViewStyle(hLV, ListView_GetExtendedListViewStyle(hLV) | LVS_EX_FULLROWSELECT); + + hLarge = ImageList_Create(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), iBmpDepth, 1, 1); + hSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), iBmpDepth, 1, 1); +// COLORREF rgbTransparentColor; + for (i = 0; i < ICO_CNT; i++) { +// ImageList_AddMasked(himgl, hbmp, rgbTransparentColor); + ImageList_AddIcon(hSmall, g_hICO[i]); + ImageList_AddIcon(hLarge, g_hICO[i]); + } + + ListView_SetImageList(hLV, hSmall, LVSIL_SMALL); + ListView_SetImageList(hLV, hLarge, LVSIL_NORMAL); + + static const char *szColHdr[] = { sim203, sim204, sim230, sim205, "", sim234, 0 }; + static int iColWidth[] = { 150, 110, 60, 55, 35, 330 }; + LVCOLUMN lvc; + lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; + lvc.fmt = LVCFMT_LEFT; + for (i = 0; szColHdr[i]; i++) { + lvc.iSubItem = i; + lvc.pszText = (LPSTR)szColHdr[i]; + lvc.cx = iColWidth[i]; + LV_InsertColumn(hLV, i, &lvc); + } + for (i = 0; szAdvancedIcons[i]; i++) { + SendMessage(GetDlgItem(hDlg, IDC_ADVICON), CB_ADDSTRING, 0, (LPARAM) Translate(szAdvancedIcons[i])); + } + + RefreshGeneralDlg(hDlg,TRUE); + EnableWindow(hLV, true); +// SendMessage(hLV, WM_SETREDRAW, TRUE, 0); + + iInit = FALSE; + return TRUE; + } // WM_INITDIALOG + break; + + case WM_DESTROY: { + ImageList_Destroy(hSmall); + ImageList_Destroy(hLarge); + } // WM_DESTROY + break; + + case WM_PAINT: { + if (!iInit) + InvalidateRect(hDlg,NULL,FALSE); + } // WM_PAINT + break; + + case WM_COMMAND: { + switch(LOWORD(wParam)) { + case ID_ALWAYS: + case ID_ENABLED: + case ID_DISABLED: { + idx = ListView_GetSelectionMark(hLV); + ptr = (pUinKey) getListViewParam(hLV,idx); + if (ptr) { + ptr->tstatus = LOWORD(wParam)-ID_DISABLED; + setListViewStatus(hLV,idx,ptr->tstatus); + setListViewIcon(hLV,idx,ptr); + } + } + break; + + case ID_SIM_NATIVE: + case ID_SIM_PGP: + case ID_SIM_GPG: + case ID_SIM_RSAAES: + case ID_SIM_RSA: { + idx = ListView_GetSelectionMark(hLV); + ptr = (pUinKey) getListViewParam(hLV,idx); + if (ptr) { + ptr->tmode = LOWORD(wParam)-ID_SIM_NATIVE; + setListViewMode(hLV,idx,ptr->tmode); + setListViewIcon(hLV,idx,ptr); + } + } + break; + + case ID_SETPSK: { + idx = ListView_GetSelectionMark(hLV); + ptr = (pUinKey) getListViewParam(hLV,idx); + if(ptr) { + LPSTR buffer = (LPSTR)alloca(PSKSIZE+1); + getContactName(ptr->hContact, buffer); + int res = DialogBoxParam(g_hInst,MAKEINTRESOURCE(IDD_PSK),NULL,(DLGPROC)DlgProcSetPSK,(LPARAM)buffer); + if(res == IDOK) { + setListViewPSK(hLV,idx,1); + DBWriteContactSettingString(ptr->hContact,szModuleName,"tPSK",buffer); + } + } + } + break; + + case ID_DELPSK: { + idx = ListView_GetSelectionMark(hLV); + ptr = (pUinKey) getListViewParam(hLV,idx); + if(ptr) { + setListViewPSK(hLV,idx,0); + DBDeleteContactSetting(ptr->hContact, szModuleName, "tPSK"); + } + } + break; + + case ID_DELPUBL: { + idx = ListView_GetSelectionMark(hLV); + ptr = (pUinKey) getListViewParam(hLV,idx); + if(ptr) { + setListViewPUB(hLV,idx,0); + } + } + break; + + case ID_EXPPUBL: { + idx = ListView_GetSelectionMark(hLV); + ptr = (pUinKey) getListViewParam(hLV,idx); + if(ptr) { + if ( !ptr->keyLoaded ) { + createRSAcntx(ptr); + loadRSAkey(ptr); + } + if ( ptr->keyLoaded ) { + LPSTR buffer = (LPSTR) alloca(RSASIZE); + exp->rsa_export_pubkey(ptr->cntx,buffer); + if ( !SaveExportRSAKeyDlg(hDlg,buffer,0)) + msgbox(hDlg,sim114,szModuleName,MB_OK|MB_ICONEXCLAMATION); + } + } + return TRUE; + } + break; + + case ID_IMPPUBL: { + idx = ListView_GetSelectionMark(hLV); + ptr = (pUinKey) getListViewParam(hLV,idx); + if(ptr) { + createRSAcntx(ptr); + LPSTR pub = (LPSTR) alloca(RSASIZE); + if ( !LoadImportRSAKeyDlg(hDlg,pub,0)) return TRUE; + if ( exp->rsa_import_pubkey(ptr->cntx,pub)) { + int len; + exp->rsa_get_pubkey(ptr->cntx,(PBYTE)pub,&len); + + DBCONTACTWRITESETTING cws; + cws.szModule = szModuleName; + cws.szSetting = "rsa_pub"; + cws.value.type = DBVT_BLOB; + cws.value.pbVal = (PBYTE)pub; + cws.value.cpbVal = len; + CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)ptr->hContact, (LPARAM)&cws); + + setListViewPUB(hLV,idx,1); + } + else + msgbox(hDlg,sim115,szModuleName,MB_OK|MB_ICONEXCLAMATION); + } + return TRUE; + } + break; + + case ID_UPDATE_CLIST: { +// iInit = TRUE; +// RefreshGeneralDlg(hDlg,FALSE); +// iInit = FALSE; + return TRUE; + } + break; + + case IDC_RESET: { + if (!iInit) + ResetGeneralDlg(hDlg); + } + break; + + case IDC_ADV8: + case IDC_ADV7: + case IDC_ADV6: + case IDC_ADV5: + case IDC_ADV4: + case IDC_ADV3: + case IDC_ADV2: + case IDC_ADV1: + case IDC_ADV0: + case IDC_GPG: + case IDC_PGP: + case IDC_NO_PGP: + case IDC_NOL: + case IDC_AAK: + case IDC_MCM: + case IDC_AIP: + case IDC_SOM: + case IDC_SFT: + case IDC_ASI: + case IDC_MCD: + case IDC_KET: + case IDC_SCM: + case IDC_DGP: + case IDC_OKT: + case IDC_ADVICON: + break; + + default: + return FALSE; + } + if (!iInit) + SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); + } // WM_COMMAND + break; + + case WM_NOTIFY: { + switch(((LPNMHDR)lParam)->idFrom) { + case 0: { + if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) { + iInit = TRUE; + ApplyGeneralSettings(hDlg); + RefreshContactListIcons(); +// SendMessage(GetParent(hDlg),WM_COMMAND,ID_UPDATE_PLIST,0); +// SendMessage(GetParent(hDlg),WM_COMMAND,ID_UPDATE_GLIST,0); + iInit = FALSE; + } + } + break; + + case IDC_STD_USERLIST: { + switch(((LPNMHDR)lParam)->code) { + case NM_DBLCLK: { + if(LPNMLISTVIEW(lParam)->iSubItem == 2) { + idx = LPNMLISTVIEW(lParam)->iItem; + ptr = (pUinKey) getListViewParam(hLV,idx); + if (ptr) { + ptr->tmode++; + if ( !bPGP && ptr->tmode==MODE_PGP ) ptr->tmode++; + if ( !bGPG && ptr->tmode==MODE_GPG ) ptr->tmode++; + if ( ptr->tmode>=MODE_CNT ) ptr->tmode=MODE_NATIVE; + setListViewMode(hLV,idx,ptr->tmode); + setListViewIcon(hLV,idx,ptr); + SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); + } + } + if(LPNMLISTVIEW(lParam)->iSubItem == 3) { + idx = LPNMLISTVIEW(lParam)->iItem; + ptr = (pUinKey) getListViewParam(hLV,idx); + if (ptr) { + ptr->tstatus++; if(ptr->tstatus>(ptr->tmode==MODE_RSAAES?1:2)) ptr->tstatus=0; + setListViewStatus(hLV,idx,ptr->tstatus); + setListViewIcon(hLV,idx,ptr); + SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); + } + } + } break; + case NM_RCLICK: { +// idx = ListView_GetSelectionMark(hLV); + LPNMLISTVIEW lpLV = (LPNMLISTVIEW)lParam; + ptr = (pUinKey) getListViewParam(hLV,lpLV->iItem); + if (ptr) { + POINT p; GetCursorPos(&p); + HMENU hMenu = NULL; + if ( ptr->tmode==MODE_NATIVE || ptr->tmode==MODE_RSAAES ) { + switch( lpLV->iSubItem ) { + case 2: // mode + hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDM_CLIST2)); + break; + case 3: // status + hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE((ptr->tmode==MODE_NATIVE)?IDM_CLIST01:IDM_CLIST11)); + break; + case 4: // PSK/PUB + case 5: // SHA1 + hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE((ptr->tmode==MODE_NATIVE)?IDM_CLIST02:IDM_CLIST12)); + break; + default: // full menu + hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE((ptr->tmode==MODE_NATIVE)?IDM_CLIST0:IDM_CLIST1)); + break; + } + CheckMenuItem(hMenu, ID_DISABLED+ptr->tstatus, MF_CHECKED ); + if ( ptr->tmode==MODE_NATIVE ) { + if ( !hasKey(ptr)) EnableMenuItem(hMenu, ID_DELPSK, MF_GRAYED ); + } + else + if ( ptr->tmode==MODE_RSAAES ) { + if ( !hasKey(ptr)) { + EnableMenuItem(hMenu, ID_EXPPUBL, MF_GRAYED ); + EnableMenuItem(hMenu, ID_DELPUBL, MF_GRAYED ); + } + } + } + if ( !hMenu ) + hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDM_CLIST2)); + TranslateMenu(hMenu); + CheckMenuItem(hMenu, ID_SIM_NATIVE+ptr->tmode, MF_CHECKED ); + if ( !bPGP ) EnableMenuItem(hMenu, ID_SIM_PGP, MF_GRAYED ); + if ( !bGPG ) EnableMenuItem(hMenu, ID_SIM_GPG, MF_GRAYED ); +// CheckMenuItem(hMenu, ID_ENCRYPTION, MF_BYCOMMAND ); + TrackPopupMenu(GetSubMenu(hMenu, 0), TPM_LEFTALIGN | TPM_TOPALIGN, p.x, p.y, 0, hDlg, 0); + DestroyMenu(hMenu); + } + } break; + case LVN_COLUMNCLICK: { + bChangeSortOrder = true; + ListView_Sort(hLV,(LPARAM)(LPNMLISTVIEW(lParam)->iSubItem+0x01)); + bChangeSortOrder = false; + } + } + } + break; + } + } // WM_NOTIFY + break; + } + return FALSE; +} + + +INT_PTR CALLBACK DlgProcOptionsProto(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam) { + + static int iInit = TRUE; + char buf[32]; + int idx; + + HWND hLV = GetDlgItem(hDlg,IDC_PROTO); + + switch (wMsg) { + case WM_INITDIALOG: { + + TranslateDialogDefault(hDlg); + +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("DlgProcOptionsProto(WN_INITDIALOG)"); +#endif + iInit = TRUE; + ListView_SetExtendedListViewStyle(hLV, ListView_GetExtendedListViewStyle(hLV) | LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES); + + LVCOLUMN lvc; + lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; + lvc.fmt = LVCFMT_LEFT; + lvc.pszText = (LPSTR)sim210; + lvc.cx = 150; + LV_InsertColumn(hLV, 0, &lvc); + + RefreshProtoDlg(hDlg); + EnableWindow(hLV, true); + + iInit = FALSE; + return TRUE; + } // WM_INITDIALOG + break; + + case WM_PAINT: { + if (!iInit) + InvalidateRect(hDlg,NULL,FALSE); + } // WM_PAINT + break; + + case WM_COMMAND: { + switch(LOWORD(wParam)) { + case IDC_RSA_COPY: { + char txt[128]; + GetDlgItemText(hDlg, IDC_RSA_SHA, txt, sizeof(txt)); + CopyToClipboard(hDlg,txt); + return TRUE; + } break; + case IDC_RSA_EXP: { + LPSTR pub = (LPSTR) alloca(RSASIZE); + exp->rsa_export_keypair(CPP_MODE_RSA,NULL,pub,NULL); + if ( !SaveExportRSAKeyDlg(hDlg,pub,0)) + msgbox(hDlg,sim114,szModuleName,MB_OK|MB_ICONEXCLAMATION); + return TRUE; + } break; + case IDC_RSA_EXPPRIV: { + LPSTR passphrase = (LPSTR) alloca(RSASIZE); + int res = DialogBoxParam(g_hInst,MAKEINTRESOURCE(IDD_PASSPHRASE),NULL,(DLGPROC)DlgProcSetPassphrase,(LPARAM)passphrase); + if ( res==IDOK ) { + LPSTR priv = (LPSTR) alloca(RSASIZE); + exp->rsa_export_keypair(CPP_MODE_RSA,priv,NULL,passphrase); + if ( !SaveExportRSAKeyDlg(hDlg,priv,1)) + msgbox(hDlg,sim112,szModuleName,MB_OK|MB_ICONEXCLAMATION); + } + return TRUE; + } break; + case IDC_RSA_IMPPRIV: { + LPSTR priv = (LPSTR) alloca(RSASIZE); + if ( !LoadImportRSAKeyDlg(hDlg,priv,1)) return TRUE; + // + LPSTR passphrase = (LPSTR) alloca(RSASIZE); + int res = DialogBoxParam(g_hInst,MAKEINTRESOURCE(IDD_PASSPHRASE),NULL,(DLGPROC)DlgProcSetPassphrase,(LPARAM)passphrase); + if ( res==IDOK ) { + if ( !exp->rsa_import_keypair(CPP_MODE_RSA,priv,passphrase)) { + msgbox(hDlg,sim113,szModuleName,MB_OK|MB_ICONEXCLAMATION); + } + else { + // обновить SHA1 значение + RefreshProtoDlg(hDlg); + } + } + return TRUE; + } break; + case IDC_SPLITON: + case IDC_SPLITOFF: { + if ( HIWORD(wParam) == EN_CHANGE ) { + idx = ListView_GetSelectionMark(hLV); + if ( idx == -1 ) break; + idx = (int) getListViewParam(hLV,idx); + switch(LOWORD(wParam)) { + case IDC_SPLITON: + GetDlgItemText(hDlg,IDC_SPLITON,buf,5); + proto[idx].tsplit_on = atoi(buf); + break; + case IDC_SPLITOFF: + GetDlgItemText(hDlg,IDC_SPLITOFF,buf,5); + proto[idx].tsplit_off = atoi(buf); + break; + } + } + if (!iInit) + SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); + } break; + } + } + break; + + case WM_NOTIFY: { + switch(((LPNMHDR)lParam)->idFrom) { + case 0: { + if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) { + iInit = TRUE; + ApplyProtoSettings(hDlg); + RefreshProtoDlg(hDlg); + RefreshContactListIcons(); + SendMessage(GetParent(hDlg),WM_COMMAND,ID_UPDATE_CLIST,0); +// SendMessage(GetParent(hDlg),WM_COMMAND,ID_UPDATE_PLIST,0); +// SendMessage(GetParent(hDlg),WM_COMMAND,ID_UPDATE_GLIST,0); + iInit = FALSE; + } + } + break; + + case IDC_PROTO: { + if (((LPNMHDR)lParam)->code == (UINT)NM_CLICK) { + idx = (int) getListViewParam(hLV,LPNMLISTVIEW(lParam)->iItem); + if ( idx == -1 ) break; + EnableWindow(GetDlgItem(hDlg,IDC_SPLITON), true); + EnableWindow(GetDlgItem(hDlg,IDC_SPLITOFF), true); + mir_itoa(proto[idx].tsplit_on,buf,10); SetDlgItemText(hDlg,IDC_SPLITON,buf); + mir_itoa(proto[idx].tsplit_off,buf,10); SetDlgItemText(hDlg,IDC_SPLITOFF,buf); + SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); + } + } + break; + } + } // WM_NOTIFY + break; + } + return FALSE; +} + + +static BOOL bPGP9; + +INT_PTR CALLBACK DlgProcOptionsPGP(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam) { + + static int iInit = TRUE; + static HIMAGELIST hLarge, hSmall; + int i; + + HWND hLV = GetDlgItem(hDlg,IDC_PGP_USERLIST); + + switch (wMsg) { + case WM_INITDIALOG: { + + TranslateDialogDefault(hDlg); + +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("DlgProcOptionsPGP(WN_INITDIALOG)"); +#endif + iInit = TRUE; + ListView_SetExtendedListViewStyle(hLV, ListView_GetExtendedListViewStyle(hLV) | LVS_EX_FULLROWSELECT); + + hLarge = ImageList_Create(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), iBmpDepth, 1, 1); + hSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), iBmpDepth, 1, 1); + for (i = ICO_ST_DIS; i <= ICO_ST_TRY; i++) { + ImageList_AddIcon(hSmall, g_hICO[i]); + ImageList_AddIcon(hLarge, g_hICO[i]); + } + + ListView_SetImageList(hLV, hSmall, LVSIL_SMALL); + ListView_SetImageList(hLV, hLarge, LVSIL_NORMAL); + + static const char *szColHdr[] = { sim203, sim204, sim215, 0 }; + static int iColWidth[] = { 160, 150, 80 }; + LVCOLUMN lvc; + lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; + lvc.fmt = LVCFMT_LEFT; + for (i = 0; szColHdr[i]; i++) { + lvc.iSubItem = i; + lvc.pszText = (LPSTR)szColHdr[i]; + lvc.cx = iColWidth[i]; + LV_InsertColumn(hLV, i, &lvc); + } + + RefreshPGPDlg(hDlg,TRUE); +// EnableWindow(hLV, bPGPkeyrings); + + iInit = FALSE; + return TRUE; + } // WM_INITDIALOG + break; + + case WM_DESTROY: { + ImageList_Destroy(hSmall); + ImageList_Destroy(hLarge); + } // WM_DESTROY + break; + + case WM_PAINT: { + if (!iInit) + InvalidateRect(hDlg,NULL,FALSE); + } // WM_PAINT + break; + + case WM_COMMAND: { + switch(LOWORD(wParam)) { + case IDC_SET_KEYRINGS: { + char PubRingPath[MAX_PATH], SecRingPath[MAX_PATH]; + PubRingPath[0]='\0'; SecRingPath[0]='\0'; + bPGPkeyrings = pgp_open_keyrings(PubRingPath,SecRingPath); + if(bPGPkeyrings && PubRingPath[0] && SecRingPath[0]) { + DBWriteContactSettingString(0,szModuleName,"pgpPubRing",PubRingPath); + DBWriteContactSettingString(0,szModuleName,"pgpSecRing",SecRingPath); + } + SetDlgItemText(hDlg, IDC_KEYRING_STATUS, bPGPkeyrings?Translate(sim216):Translate(sim217)); +// EnableWindow(hLV, bPGPkeyrings); +// RefreshPGPDlg(hDlg); + return FALSE; + } + break; + case IDC_NO_KEYRINGS: { + BOOL bNoKR = (SendMessage(GetDlgItem(hDlg, IDC_NO_KEYRINGS),BM_GETCHECK,0L,0L)==BST_CHECKED); + EnableWindow(GetDlgItem(hDlg, IDC_SET_KEYRINGS), !bNoKR); + EnableWindow(GetDlgItem(hDlg, IDC_LOAD_PRIVKEY), bNoKR); + SetDlgItemText(hDlg, IDC_KEYRING_STATUS, bNoKR?Translate(sim225):((bPGP9)?Translate(sim220):(bPGPkeyrings?Translate(sim216):Translate(sim217)))); + } + break; + case IDC_LOAD_PRIVKEY: { + char KeyPath[MAX_PATH]; KeyPath[0]='\0'; + if(ShowSelectKeyDlg(hDlg,KeyPath)) { + char *priv = LoadKeys(KeyPath,true); + if(priv) { + DBWriteContactSettingString(0,szModuleName,"tpgpPrivKey",priv); + mir_free(priv); + } + else { + DBDeleteContactSetting(0,szModuleName,"tpgpPrivKey"); + } + } + } + break; + case ID_UPDATE_PLIST: { + iInit = TRUE; + RefreshPGPDlg(hDlg,FALSE); + iInit = FALSE; + return TRUE; + } + break; + default: + break; + } + if (!iInit) + SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); + } + break; + + case WM_NOTIFY: { + switch(((LPNMHDR)lParam)->idFrom) { + case 0: { + if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) { + iInit = TRUE; + ApplyPGPSettings(hDlg); + RefreshPGPDlg(hDlg,FALSE); +// SendMessage(GetParent(hDlg),WM_COMMAND,ID_UPDATE_CLIST,0); + iInit = FALSE; + } + } + break; + case IDC_PGP_USERLIST: { + switch(((LPNMHDR)lParam)->code) { +/* case NM_RCLICK: { + POINT p; + GetCursorPos(&p); + HMENU hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDM_CLIST)); + CheckMenuItem(hMenu, ID_ENCRYPTION, MF_BYCOMMAND ); + TranslateMenu(hMenu); + TrackPopupMenu(GetSubMenu(hMenu, 0), TPM_LEFTALIGN | TPM_TOPALIGN, p.x, p.y, 0, hDlg, 0); + DestroyMenu(hMenu); + } break;*/ + case LVN_COLUMNCLICK: { + bChangeSortOrder = true; + ListView_Sort(hLV,(LPARAM)(LPNMLISTVIEW(lParam)->iSubItem+0x11)); + bChangeSortOrder = false; + } + } + } + break; + } + } // WM_NOTIFY + break; + } + return FALSE; +} + + +INT_PTR CALLBACK DlgProcOptionsGPG(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam) { + + static int iInit = TRUE; + static HIMAGELIST hLarge, hSmall; + int i, idx; pUinKey ptr; + + HWND hLV = GetDlgItem(hDlg,IDC_GPG_USERLIST); + + switch (wMsg) { + case WM_INITDIALOG: { + + TranslateDialogDefault(hDlg); + +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("DlgProcOptionsGPG(WN_INITDIALOG)"); +#endif + iInit = TRUE; + ListView_SetExtendedListViewStyle(hLV, ListView_GetExtendedListViewStyle(hLV) | LVS_EX_FULLROWSELECT); + + hLarge = ImageList_Create(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), iBmpDepth, 1, 1); + hSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), iBmpDepth, 1, 1); + for (i = ICO_ST_DIS; i <= ICO_ST_TRY; i++) { + ImageList_AddIcon(hSmall, g_hICO[i]); + ImageList_AddIcon(hLarge, g_hICO[i]); + } + + ListView_SetImageList(hLV, hSmall, LVSIL_SMALL); + ListView_SetImageList(hLV, hLarge, LVSIL_NORMAL); + + static const char *szColHdr[] = { sim203, sim204, sim215, sim227, 0 }; + static int iColWidth[] = { 140, 120, 120, 40 }; + LVCOLUMN lvc; + lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; + lvc.fmt = LVCFMT_LEFT; + for (i = 0; szColHdr[i]; i++) { + lvc.iSubItem = i; + lvc.pszText = (LPSTR)szColHdr[i]; + lvc.cx = iColWidth[i]; + LV_InsertColumn(hLV, i, &lvc); + } + + RefreshGPGDlg(hDlg,TRUE); +// EnableWindow(hLV, bPGPkeyrings); + + iInit = FALSE; + return TRUE; + } // WM_INITDIALOG + break; + + case WM_DESTROY: { + ImageList_Destroy(hSmall); + ImageList_Destroy(hLarge); + } // WM_DESTROY + break; + + case WM_PAINT: { + if (!iInit) + InvalidateRect(hDlg,NULL,FALSE); + } // WM_PAINT + break; + + case WM_COMMAND: { + switch(LOWORD(wParam)) { +/* case IDC_LOAD_PRIVKEY: { + char KeyPath[MAX_PATH] = {0}; + if(ShowSelectKeyDlg(hDlg,KeyPath)) { + char *priv = LoadKeys(KeyPath,true); + if(priv) { + DBWriteContactSettingString(0,szModuleName,"tpgpPrivKey",priv); + mir_free(priv); + } + else { + DBDeleteContactSetting(0,szModuleName,"tpgpPrivKey"); + } + } + } + break;*/ + case IDC_BROWSEEXECUTABLE_BTN: { + char gpgexe[256]; + char filter[128]; + OPENFILENAME ofn; + + GetDlgItemText(hDlg, IDC_GPGEXECUTABLE_EDIT, gpgexe, sizeof(gpgexe)); + + char *txtexecutablefiles="Executable Files"; /*lang*/ + char *txtselectexecutable="Select GnuPG Executable"; /*lang*/ + + // filter zusammensetzen + memset(&filter,0,sizeof(filter)); + strcpy(filter, Translate(txtexecutablefiles)); + strcat(filter, " (*.exe)"); + strcpy(filter+strlen(filter)+1, "*.exe"); + + // OPENFILENAME initialisieren + memset(&ofn,0,sizeof(ofn)); + ofn.lStructSize=sizeof(ofn); + ofn.hwndOwner=hDlg; + ofn.lpstrFilter=filter; + ofn.lpstrFile=gpgexe; + ofn.nMaxFile=sizeof(gpgexe); + ofn.lpstrTitle=Translate(txtselectexecutable); + ofn.Flags=OFN_FILEMUSTEXIST|OFN_LONGNAMES|OFN_HIDEREADONLY; + + if (GetOpenFileName(&ofn)) + { + SetDlgItemText(hDlg, IDC_GPGEXECUTABLE_EDIT, ofn.lpstrFile); + } + } + break; + case ID_UPDATE_GLIST: { + iInit = TRUE; + RefreshGPGDlg(hDlg,FALSE); + iInit = FALSE; + return TRUE; + } + break; + default: + break; + } + if (!iInit) + SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); + } + break; + + case WM_NOTIFY: { + switch(((LPNMHDR)lParam)->idFrom) { + case 0: { + if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) { + iInit = TRUE; + ApplyGPGSettings(hDlg); + RefreshGPGDlg(hDlg,FALSE); +// SendMessage(GetParent(hDlg),WM_COMMAND,ID_UPDATE_CLIST,0); + iInit = FALSE; + } + } + break; + case IDC_GPG_USERLIST: { + switch(((LPNMHDR)lParam)->code) { + case NM_DBLCLK: { + if(LPNMLISTVIEW(lParam)->iSubItem == 3) { + idx = LPNMLISTVIEW(lParam)->iItem; + ptr = (pUinKey) getListViewParam(hLV,idx); + if ( !ptr ) break; + ptr->tgpgMode++; ptr->tgpgMode&=1; + LV_SetItemTextA(hLV, LPNMLISTVIEW(lParam)->iItem, LPNMLISTVIEW(lParam)->iSubItem, (ptr->tgpgMode)?Translate(sim228):Translate(sim229)); + SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); + } + } break; +/* case NM_RCLICK: { + POINT p; + GetCursorPos(&p); + HMENU hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDM_CLIST)); + CheckMenuItem(hMenu, ID_ENCRYPTION, MF_BYCOMMAND ); + TranslateMenu(hMenu); + TrackPopupMenu(GetSubMenu(hMenu, 0), TPM_LEFTALIGN | TPM_TOPALIGN, p.x, p.y, 0, hDlg, 0); + DestroyMenu(hMenu); + } break;*/ + case LVN_COLUMNCLICK: { + bChangeSortOrder = true; + ListView_Sort(hLV,(LPARAM)(LPNMLISTVIEW(lParam)->iSubItem+0x21)); + bChangeSortOrder = false; + } + } + } + break; + } + } // WM_NOTIFY + break; + } + return FALSE; +} + + +BOOL CALLBACK DlgProcSetPSK(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) { + static char *buffer; + switch(uMsg) { + case WM_INITDIALOG: { + TranslateDialogDefault(hDlg); + SendDlgItemMessage(hDlg,IDC_EDIT1,EM_LIMITTEXT,PSKSIZE-1,0); + if ( bCoreUnicode ) SetDlgItemTextW(hDlg,IDC_EDIT2,(LPWSTR)lParam); + else SetDlgItemTextA(hDlg,IDC_EDIT2,(LPCSTR)lParam); + buffer = (LPSTR)lParam; + return (TRUE); + } + case WM_COMMAND: { + switch(LOWORD(wParam)) { + case IDOK: { + int len = GetDlgItemTextA(hDlg,IDC_EDIT1,buffer,PSKSIZE); + if(len<8) { + msgbox1(hDlg,sim211,szModuleName,MB_OK|MB_ICONEXCLAMATION); + return TRUE; + } + else { + EndDialog(hDlg,IDOK); + } + } + break; + case IDCANCEL: { + EndDialog(hDlg,IDCANCEL); + } + break; + } + } + break; + default: + return (FALSE); + } + return (TRUE); +} + + +BOOL CALLBACK DlgProcSetPassphrase(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) { + static LPSTR buffer; + switch(uMsg) { + case WM_INITDIALOG: { + TranslateDialogDefault(hDlg); + SendDlgItemMessage(hDlg,IDC_PASSPHRASE,EM_LIMITTEXT,RSASIZE-1,0); + buffer = (LPSTR)lParam; + return (TRUE); + } + case WM_COMMAND: { + switch(LOWORD(wParam)) { + case IDOK: { +// memset(buffer,0,RSASIZE); + GetDlgItemTextA(hDlg,IDC_PASSPHRASE,buffer,RSASIZE); + EndDialog(hDlg,IDOK); + } + break; + case IDCANCEL: { + EndDialog(hDlg,IDCANCEL); + } + break; + } + } + break; + default: + return (FALSE); + } + return (TRUE); +} + + +/////////////////// +// R E F R E S H // +/////////////////// + + +void RefreshGeneralDlg(HWND hDlg, BOOL iInit) { + + char timeout[10]; + UINT data; + +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("RefreshGeneralDlg"); +#endif + // Key Exchange Timeout + data = DBGetContactSettingWord(0, szModuleName, "ket", 10); + mir_itoa(data,timeout,10); + SetDlgItemText(hDlg,IDC_KET,timeout); + + // Offline Key Timeout + data = DBGetContactSettingWord(0, szModuleName, "okt", 2); + mir_itoa(data,timeout,10); + SetDlgItemText(hDlg,IDC_OKT,timeout); + + GetFlags(); + + SendMessage(GetDlgItem(hDlg,IDC_SFT),BM_SETCHECK,(bSFT)?BST_CHECKED:BST_UNCHECKED,0L); + SendMessage(GetDlgItem(hDlg,IDC_SOM),BM_SETCHECK,(bSOM)?BST_CHECKED:BST_UNCHECKED,0L); + SendMessage(GetDlgItem(hDlg,IDC_ASI),BM_SETCHECK,(bASI)?BST_CHECKED:BST_UNCHECKED,0L); + SendMessage(GetDlgItem(hDlg,IDC_MCD),BM_SETCHECK,(bMCD)?BST_CHECKED:BST_UNCHECKED,0L); + SendMessage(GetDlgItem(hDlg,IDC_SCM),BM_SETCHECK,(bSCM)?BST_CHECKED:BST_UNCHECKED,0L); + SendMessage(GetDlgItem(hDlg,IDC_DGP),BM_SETCHECK,(bDGP)?BST_CHECKED:BST_UNCHECKED,0L); + SendMessage(GetDlgItem(hDlg,IDC_AIP),BM_SETCHECK,(bAIP)?BST_CHECKED:BST_UNCHECKED,0L); + SendMessage(GetDlgItem(hDlg,IDC_NOL),BM_SETCHECK,(bNOL)?BST_CHECKED:BST_UNCHECKED,0L); + SendMessage(GetDlgItem(hDlg,IDC_AAK),BM_SETCHECK,(bAAK)?BST_CHECKED:BST_UNCHECKED,0L); + SendMessage(GetDlgItem(hDlg,IDC_MCM),BM_SETCHECK,(bMCM)?BST_CHECKED:BST_UNCHECKED,0L); + + // Advanced + SendMessage(GetDlgItem(hDlg, IDC_ADVICON), CB_SETCURSEL, bADV, 0); + if ( g_hCLIcon ) { + EnableWindow(GetDlgItem(hDlg, IDC_ADVICON), false); + } + + // Select {OFF,PGP,GPG} + SendMessage(GetDlgItem(hDlg,IDC_PGP),BM_SETCHECK,bPGP?BST_CHECKED:BST_UNCHECKED,0L); + SendMessage(GetDlgItem(hDlg,IDC_GPG),BM_SETCHECK,bGPG?BST_CHECKED:BST_UNCHECKED,0L); + + // rebuild list of contacts + HWND hLV = GetDlgItem(hDlg,IDC_STD_USERLIST); + ListView_DeleteAllItems(hLV); + + LVITEM lvi; memset(&lvi,0,sizeof(lvi)); + lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; + + HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + char tmp[NAMSIZE]; + + while (hContact) { + + pUinKey ptr = getUinKey(hContact); + if ( ptr && isSecureProtocol(hContact) /*&& !getMetaContact(hContact)*/ && !isChatRoom(hContact)) { + + if ( iInit ) { + ptr->tmode = ptr->mode; + ptr->tstatus = ptr->status; + } + + lvi.iItem++; + lvi.iImage = ptr->tstatus; + lvi.lParam = (LPARAM)ptr; + + getContactName(hContact, tmp); + lvi.pszText = (LPSTR)&tmp; + int itemNum = LV_InsertItem(hLV, &lvi); + + getContactUin(hContact, tmp); + LV_SetItemText(hLV, itemNum, 1, tmp); + + setListViewMode(hLV, itemNum, ptr->tmode); + setListViewStatus(hLV, itemNum, ptr->tstatus); + if ( ptr->mode==MODE_NATIVE ) setListViewPSK(hLV, itemNum, hasKey(ptr)); + else setListViewPUB(hLV, itemNum, hasKey(ptr)); + setListViewIcon(hLV, itemNum, ptr); + } + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); + } + ListView_Sort(hLV,(LPARAM)0); +} + + +void RefreshProtoDlg(HWND hDlg) { + + int i; + +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("RefreshProtoDlg"); +#endif + HWND hLV = GetDlgItem(hDlg,IDC_PROTO); + ListView_DeleteAllItems(hLV); + + LVITEM lvi; memset(&lvi,0,sizeof(lvi)); + lvi.mask = LVIF_TEXT | LVIF_PARAM; + + for(i=0;irsa_get_keyhash(CPP_MODE_RSA,NULL,NULL,(PBYTE)&sha,&len); + LPSTR txt = mir_strdup(to_hex(sha,len)); + SetDlgItemText(hDlg, IDC_RSA_SHA, txt); + mir_free(txt); +} + + +void RefreshPGPDlg(HWND hDlg, BOOL iInit) { + + int ver = pgp_get_version(); + bPGP9 = (ver>=0x03050000); + +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("RefreshPGPDlg"); +#endif + EnableWindow(GetDlgItem(hDlg, IDC_SET_KEYRINGS), bUseKeyrings && !bPGP9); + EnableWindow(GetDlgItem(hDlg, IDC_LOAD_PRIVKEY), !bUseKeyrings); + SetDlgItemText(hDlg, IDC_PGP_PRIVKEY, bPGPprivkey?Translate(sim222):Translate(sim223)); + + if(bPGPloaded && ver) { + char pgpVerStr[64]; + sprintf(pgpVerStr, Translate(sim218), ver >> 24, (ver >> 16) & 255, (ver >> 8) & 255); + SetDlgItemText(hDlg, IDC_PGP_SDK, pgpVerStr); + } + else { + SetDlgItemText(hDlg, IDC_PGP_SDK, Translate(sim219)); + } + SetDlgItemText(hDlg, IDC_KEYRING_STATUS, !bUseKeyrings?Translate(sim225):((bPGP9)?Translate(sim220):(bPGPkeyrings?Translate(sim216):Translate(sim217)))); + + // Disable keyrings use + SendMessage(GetDlgItem(hDlg,IDC_NO_KEYRINGS),BM_SETCHECK,(bUseKeyrings)?BST_UNCHECKED:BST_CHECKED,0L); + + // rebuild list of contacts + HWND hLV = GetDlgItem(hDlg,IDC_PGP_USERLIST); + ListView_DeleteAllItems(hLV); + + LVITEM lvi; memset(&lvi,0,sizeof(lvi)); + lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; + + HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + char tmp[NAMSIZE]; + + while (hContact) { + + pUinKey ptr = getUinKey(hContact); + if (ptr && ptr->mode==MODE_PGP && isSecureProtocol(hContact) /*&& !getMetaContact(hContact)*/ && !isChatRoom(hContact)) { + + LPSTR szKeyID = myDBGetString(hContact,szModuleName,"pgp_abbr"); + + lvi.iItem++; + lvi.iImage = (szKeyID!=0); + lvi.lParam = (LPARAM)ptr; + + getContactName(hContact, tmp); + lvi.pszText = (LPSTR)&tmp; + int itemNum = LV_InsertItem(hLV, &lvi); + + getContactUin(hContact, tmp); + LV_SetItemText(hLV, itemNum, 1, tmp); + + LV_SetItemTextA(hLV, itemNum, 2, (szKeyID)?szKeyID:Translate(sim221)); + SAFE_FREE(szKeyID); + } + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); + } + ListView_Sort(hLV,(LPARAM)0x10); +} + + +void RefreshGPGDlg(HWND hDlg, BOOL iInit) { + + LPSTR path; + +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("RefreshGPGDlg"); +#endif + path = myDBGetString(0,szModuleName,"gpgExec"); + if(path) { + SetDlgItemText(hDlg, IDC_GPGEXECUTABLE_EDIT, path); + mir_free(path); + } + path = myDBGetString(0,szModuleName,"gpgHome"); + if(path) { + SetDlgItemText(hDlg, IDC_GPGHOME_EDIT, path); + mir_free(path); + } + BOOL bGPGLogFlag = DBGetContactSettingByte(0, szModuleName, "gpgLogFlag",0); + SendMessage(GetDlgItem(hDlg,IDC_LOGGINGON_CBOX),BM_SETCHECK,(bGPGLogFlag)?BST_CHECKED:BST_UNCHECKED,0L); + path = myDBGetString(0,szModuleName,"gpgLog"); + if(path) { + SetDlgItemText(hDlg, IDC_GPGLOGFILE_EDIT, path); + mir_free(path); + } + SendMessage(GetDlgItem(hDlg,IDC_SAVEPASS_CBOX),BM_SETCHECK,(bSavePass)?BST_CHECKED:BST_UNCHECKED,0L); + BOOL bGPGTmpFlag = DBGetContactSettingByte(0, szModuleName, "gpgTmpFlag",0); + SendMessage(GetDlgItem(hDlg,IDC_TMPPATHON_CBOX),BM_SETCHECK,(bGPGTmpFlag)?BST_CHECKED:BST_UNCHECKED,0L); + path = myDBGetString(0,szModuleName,"gpgTmp"); + if(path) { + SetDlgItemText(hDlg, IDC_GPGTMPPATH_EDIT, path); + mir_free(path); + } + + // rebuild list of contacts + HWND hLV = GetDlgItem(hDlg,IDC_GPG_USERLIST); + ListView_DeleteAllItems(hLV); + + LVITEM lvi; memset(&lvi,0,sizeof(lvi)); + lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; + + HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + char tmp[NAMSIZE]; + + while (hContact) { + + pUinKey ptr = getUinKey(hContact); + if (ptr && ptr->mode==MODE_GPG && isSecureProtocol(hContact) /*&& !getMetaContact(hContact)*/ && !isChatRoom(hContact)) { + + if ( iInit ) { + ptr->tgpgMode = ptr->gpgMode; + } + + LPSTR szKeyID = myDBGetString(hContact,szModuleName,"gpg"); + + lvi.iItem++; + lvi.iImage = (szKeyID!=0); + lvi.lParam = (LPARAM)ptr; + + getContactName(hContact, tmp); + lvi.pszText = (LPSTR)&tmp; + int itemNum = LV_InsertItem(hLV, &lvi); + + getContactUin(hContact, tmp); + LV_SetItemText(hLV, itemNum, 1, tmp); + + LV_SetItemTextA(hLV, itemNum, 2, (szKeyID)?szKeyID:Translate(sim221)); + LV_SetItemTextA(hLV, itemNum, 3, (ptr->tgpgMode)?Translate(sim228):Translate(sim229)); + SAFE_FREE(szKeyID); + } + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); + } + ListView_Sort(hLV,(LPARAM)0x20); +} + + +/////////////// +// R E S E T // +/////////////// + + +void ResetGeneralDlg(HWND hDlg) { + + SetDlgItemText(hDlg,IDC_KET,"10"); + SetDlgItemText(hDlg,IDC_OKT,"2"); + + SendMessage(GetDlgItem(hDlg,IDC_SFT),BM_SETCHECK,BST_UNCHECKED,0L); + SendMessage(GetDlgItem(hDlg,IDC_SOM),BM_SETCHECK,BST_UNCHECKED,0L); + SendMessage(GetDlgItem(hDlg,IDC_ASI),BM_SETCHECK,BST_UNCHECKED,0L); + SendMessage(GetDlgItem(hDlg,IDC_MCD),BM_SETCHECK,BST_UNCHECKED,0L); + SendMessage(GetDlgItem(hDlg,IDC_SCM),BM_SETCHECK,BST_UNCHECKED,0L); + SendMessage(GetDlgItem(hDlg,IDC_DGP),BM_SETCHECK,BST_UNCHECKED,0L); + SendMessage(GetDlgItem(hDlg,IDC_AIP),BM_SETCHECK,BST_UNCHECKED,0L); + SendMessage(GetDlgItem(hDlg,IDC_MCM),BM_SETCHECK,BST_UNCHECKED,0L); + +// for(int i=0;itmode=MODE_NATIVE; + ptr->tstatus=STATUS_ENABLED; + + lvi.iItem++; + lvi.iImage = ptr->tstatus; + lvi.lParam = (LPARAM)ptr; + + getContactName(hContact, tmp); + lvi.pszText = (LPSTR)&tmp; + int itemNum = LV_InsertItem(hLV, &lvi); + + getContactUin(hContact, tmp); + LV_SetItemText(hLV, itemNum, 1, tmp); + + setListViewMode(hLV, itemNum, ptr->tmode); + setListViewStatus(hLV, itemNum, ptr->tstatus); + if ( ptr->mode==MODE_NATIVE ) setListViewPSK(hLV, itemNum, 0); + else setListViewPUB(hLV, itemNum, 0); + setListViewIcon(hLV, itemNum, ptr); + } + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); + } +} + + +void ResetProtoDlg(HWND hDlg) { +} + + +/////////////// +// A P P L Y // +/////////////// + + +void ApplyGeneralSettings(HWND hDlg) { + + char timeout[5]; + int tmp,i; + + // Key Exchange Timeout + GetDlgItemText(hDlg,IDC_KET,timeout,5); + tmp = atoi(timeout); if(tmp > 65535) tmp = 65535; + DBWriteContactSettingWord(0,szModuleName,"ket",tmp); + exp->rsa_set_timeout( DBGetContactSettingWord(0,szModuleName,"ket",10)); + mir_itoa(tmp,timeout,10); + SetDlgItemText(hDlg,IDC_KET,timeout); + + // Offline Key Timeout + GetDlgItemText(hDlg,IDC_OKT,timeout,5); + tmp = atoi(timeout); if(tmp > 65535) tmp = 65535; + DBWriteContactSettingWord(0,szModuleName,"okt",tmp); + mir_itoa(tmp,timeout,10); + SetDlgItemText(hDlg,IDC_OKT,timeout); + + bSFT = (SendMessage(GetDlgItem(hDlg, IDC_SFT),BM_GETCHECK,0L,0L)==BST_CHECKED); + bSOM = (SendMessage(GetDlgItem(hDlg, IDC_SOM),BM_GETCHECK,0L,0L)==BST_CHECKED); + bASI = (SendMessage(GetDlgItem(hDlg, IDC_ASI),BM_GETCHECK,0L,0L)==BST_CHECKED); + bMCD = (SendMessage(GetDlgItem(hDlg, IDC_MCD),BM_GETCHECK,0L,0L)==BST_CHECKED); + bSCM = (SendMessage(GetDlgItem(hDlg, IDC_SCM),BM_GETCHECK,0L,0L)==BST_CHECKED); + bDGP = (SendMessage(GetDlgItem(hDlg, IDC_DGP),BM_GETCHECK,0L,0L)==BST_CHECKED); + bAIP = (SendMessage(GetDlgItem(hDlg, IDC_AIP),BM_GETCHECK,0L,0L)==BST_CHECKED); + bNOL = (SendMessage(GetDlgItem(hDlg, IDC_NOL),BM_GETCHECK,0L,0L)==BST_CHECKED); + bAAK = (SendMessage(GetDlgItem(hDlg, IDC_AAK),BM_GETCHECK,0L,0L)==BST_CHECKED); + bMCM = (SendMessage(GetDlgItem(hDlg, IDC_MCM),BM_GETCHECK,0L,0L)==BST_CHECKED); + bADV = (BYTE)SendMessage(GetDlgItem(hDlg, IDC_ADVICON), CB_GETCURSEL, 0, 0); + + SetFlags(); + + // PGP &| GPG flags + { + tmp = 0; + i = SendMessage(GetDlgItem(hDlg, IDC_PGP),BM_GETCHECK,0L,0L)==BST_CHECKED; + if(i!=bPGP) { + bPGP = i; tmp++; + DBWriteContactSettingByte(0, szModuleName, "pgp", bPGP); + } + i = SendMessage(GetDlgItem(hDlg, IDC_GPG),BM_GETCHECK,0L,0L)==BST_CHECKED; + if(i!=bGPG) { + bGPG = i; tmp++; + DBWriteContactSettingByte(0, szModuleName, "gpg", bGPG); + } + if(tmp) msgbox1(hDlg, sim224, szModuleName, MB_OK|MB_ICONINFORMATION); + } + + HWND hLV = GetDlgItem(hDlg,IDC_STD_USERLIST); + i = ListView_GetNextItem(hLV,(UINT)-1,LVNI_ALL); + while(i!=-1) { + pUinKey ptr = (pUinKey)getListViewParam(hLV,i); + if ( !ptr ) continue; + if ( ptr->mode!=ptr->tmode ) { + ptr->mode = ptr->tmode; + DBWriteContactSettingByte(ptr->hContact, szModuleName, "mode", ptr->mode); + } + if ( ptr->status!=ptr->tstatus ) { + ptr->status = ptr->tstatus; + if(ptr->status==STATUS_ENABLED) DBDeleteContactSetting(ptr->hContact, szModuleName, "StatusID"); + else DBWriteContactSettingByte(ptr->hContact, szModuleName, "StatusID", ptr->status); + } + if ( ptr->mode==MODE_NATIVE ) { + if ( getListViewPSK(hLV,i)) { + LPSTR tmp = myDBGetString(ptr->hContact,szModuleName,"tPSK"); + DBWriteContactSettingString(ptr->hContact, szModuleName, "PSK", tmp); + mir_free(tmp); + } + else { + DBDeleteContactSetting(ptr->hContact, szModuleName, "PSK"); + } + DBDeleteContactSetting(ptr->hContact, szModuleName, "tPSK"); + } + else + if ( ptr->mode==MODE_RSAAES ) { + if ( !getListViewPUB(hLV,i)) { + DBDeleteContactSetting(ptr->hContact, szModuleName, "rsa_pub"); + } + } + i = ListView_GetNextItem(hLV,i,LVNI_ALL); + } +} + + +void ApplyProtoSettings(HWND hDlg) { + + LPSTR szNames = (LPSTR) alloca(2048); *szNames = '\0'; + + HWND hLV = GetDlgItem(hDlg,IDC_PROTO); + int i = ListView_GetNextItem(hLV,(UINT)-1,LVNI_ALL); + while(i!=-1) { + int j = getListViewProto(hLV,i); + proto[j].inspecting = ListView_GetCheckState(hLV,i); + char tmp[128]; + sprintf(tmp,"%s:%d:%d:%d;",proto[j].name,proto[j].inspecting,proto[j].tsplit_on,proto[j].tsplit_off); + strcat(szNames,tmp); + proto[j].split_on = proto[j].tsplit_on; + proto[j].split_off = proto[j].tsplit_off; + i = ListView_GetNextItem(hLV,i,LVNI_ALL); + } + + DBWriteContactSettingString(0,szModuleName,"protos",szNames); +} + + +void ApplyPGPSettings(HWND hDlg) { + + bUseKeyrings = !(SendMessage(GetDlgItem(hDlg, IDC_NO_KEYRINGS),BM_GETCHECK,0L,0L)==BST_CHECKED); + DBWriteContactSettingByte(0,szModuleName,"ukr",bUseKeyrings); + + char *priv = myDBGetString(0,szModuleName,"tpgpPrivKey"); + if(priv) { + bPGPprivkey = true; + pgp_set_priv_key(priv); + myDBWriteStringEncode(0,szModuleName,"pgpPrivKey",priv); + mir_free(priv); + DBDeleteContactSetting(0,szModuleName,"tpgpPrivKey"); + } +} + + +void ApplyGPGSettings(HWND hDlg) { + + char tmp[256]; + + GetDlgItemText(hDlg, IDC_GPGEXECUTABLE_EDIT, tmp, sizeof(tmp)); + DBWriteContactSettingString(0,szModuleName,"gpgExec",tmp); + GetDlgItemText(hDlg, IDC_GPGHOME_EDIT, tmp, sizeof(tmp)); + DBWriteContactSettingString(0,szModuleName,"gpgHome",tmp); + + bSavePass = (SendMessage(GetDlgItem(hDlg, IDC_SAVEPASS_CBOX),BM_GETCHECK,0L,0L)==BST_CHECKED); + DBWriteContactSettingByte(0,szModuleName,"gpgSaveFlag",bSavePass); + + BOOL bgpgLogFlag = (SendMessage(GetDlgItem(hDlg, IDC_LOGGINGON_CBOX),BM_GETCHECK,0L,0L)==BST_CHECKED); + DBWriteContactSettingByte(0,szModuleName,"gpgLogFlag",bgpgLogFlag); + GetDlgItemText(hDlg, IDC_GPGLOGFILE_EDIT, tmp, sizeof(tmp)); + DBWriteContactSettingString(0,szModuleName,"gpgLog",tmp); + if(bgpgLogFlag) gpg_set_log(tmp); + else gpg_set_log(0); + + BOOL bgpgTmpFlag = (SendMessage(GetDlgItem(hDlg, IDC_TMPPATHON_CBOX),BM_GETCHECK,0L,0L)==BST_CHECKED); + DBWriteContactSettingByte(0,szModuleName,"gpgTmpFlag",bgpgTmpFlag); + GetDlgItemText(hDlg, IDC_GPGTMPPATH_EDIT, tmp, sizeof(tmp)); + DBWriteContactSettingString(0,szModuleName,"gpgTmp",tmp); + if(bgpgTmpFlag) gpg_set_tmp(tmp); + else gpg_set_tmp(0); + + HWND hLV = GetDlgItem(hDlg,IDC_GPG_USERLIST); + int i = ListView_GetNextItem(hLV,(UINT)-1,LVNI_ALL); + while(i!=-1) { + pUinKey ptr = (pUinKey)getListViewParam(hLV,i); + if ( !ptr ) continue; + if ( ptr->gpgMode != ptr->tgpgMode ) { + ptr->gpgMode = ptr->tgpgMode; + if ( ptr->gpgMode ) DBWriteContactSettingByte(ptr->hContact,szModuleName,"gpgANSI",1); + else DBDeleteContactSetting(ptr->hContact,szModuleName,"gpgANSI"); + } + + i = ListView_GetNextItem(hLV,i,LVNI_ALL); + } +} + + +/////////////// +// O T H E R // +/////////////// + + +LPARAM getListViewParam(HWND hLV, UINT iItem) { + + LVITEM lvi; memset(&lvi,0,sizeof(lvi)); + lvi.iItem = iItem; + lvi.mask = LVIF_PARAM; + ListView_GetItem(hLV, &lvi); + return lvi.lParam; +} + + +void setListViewIcon(HWND hLV, UINT iItem, pUinKey ptr) { + + LVITEM lvi; memset(&lvi,0,sizeof(lvi)); + lvi.iItem = iItem; + switch(ptr->tmode) { + case MODE_NATIVE: + case MODE_RSAAES: + lvi.iImage = ICO_ST_DIS+ptr->tstatus; + break; + case MODE_PGP: + lvi.iImage = ICO_OV_PGP; + break; + case MODE_GPG: + lvi.iImage = ICO_OV_GPG; + break; + } + lvi.mask = LVIF_IMAGE; + ListView_SetItem(hLV, &lvi); +} + + +void setListViewMode(HWND hLV, UINT iItem, UINT iMode) { + + char tmp[256]; + strncpy(tmp, Translate(sim231[iMode]), sizeof(tmp)); + LV_SetItemTextA(hLV, iItem, 2, tmp); +} + + +void setListViewStatus(HWND hLV, UINT iItem, UINT iStatus) { + + char tmp[128]; + strncpy(tmp, Translate(sim232[iStatus]), sizeof(tmp)); + LV_SetItemTextA(hLV, iItem, 3, tmp); +} + + +UINT getListViewPSK(HWND hLV, UINT iItem) { + + char str[128]; + LV_GetItemTextA(hLV, iItem, 4, str, sizeof(str)); + return strncmp(str, Translate(sim206), sizeof(str))==0; +} + + +void setListViewPSK(HWND hLV, UINT iItem, UINT iStatus) { + + char str[128]; + strncpy(str, (iStatus)?Translate(sim206):"-", sizeof(str)); + LV_SetItemTextA(hLV, iItem, 4, str); +} + + +UINT getListViewPUB(HWND hLV, UINT iItem) { + + char str[128]; + LV_GetItemTextA(hLV, iItem, 4, str, sizeof(str)); + return strncmp(str, Translate(sim233), sizeof(str))==0; +} + + +void setListViewPUB(HWND hLV, UINT iItem, UINT iStatus) { + + char str[128]; + strncpy(str, (iStatus)?Translate(sim233):"-", sizeof(str)); + LV_SetItemTextA(hLV, iItem, 4, str); + + LPSTR sha = NULL; + if ( iStatus ) { + DBVARIANT dbv; + dbv.type = DBVT_BLOB; + pUinKey ptr = (pUinKey) getListViewParam(hLV, iItem); + if ( DBGetContactSetting(ptr->hContact,szModuleName,"rsa_pub",&dbv) == 0 ) { + int len; + exp->rsa_get_hash((PBYTE)dbv.pbVal,dbv.cpbVal,(PBYTE)str,&len); + sha = mir_strdup(to_hex((PBYTE)str,len)); + DBFreeVariant(&dbv); + } + } + if ( sha ) { + LV_SetItemTextA(hLV, iItem, 5, sha); + mir_free(sha); + } + else LV_SetItemTextA(hLV, iItem, 5, ""); +} + + +int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) { + char t1[NAMSIZE], t2[NAMSIZE]; + int s,d,m=1; + DBVARIANT dbv1,dbv2; + + if(lParamSort&0x100) { + lParamSort&=0xFF; + m=-1; + } + + switch(lParamSort){ + case 0x01: + case 0x11: + case 0x21: { + getContactNameA(pUinKey(lParam1)->hContact, t1); + getContactNameA(pUinKey(lParam2)->hContact, t2); + return strncmp(t1,t2,NAMSIZE)*m; + } break; + case 0x02: + case 0x12: + case 0x22: { + getContactUinA(pUinKey(lParam1)->hContact, t1); + getContactUinA(pUinKey(lParam2)->hContact, t2); + return strncmp(t1,t2,NAMSIZE)*m; + } break; + case 0x03: { + s = pUinKey(lParam1)->tmode; + d = pUinKey(lParam2)->tmode; + return (s-d)*m; + } break; + case 0x13: { + DBGetContactSetting(pUinKey(lParam1)->hContact,szModuleName,"pgp_abbr",&dbv1); + DBGetContactSetting(pUinKey(lParam2)->hContact,szModuleName,"pgp_abbr",&dbv2); + s=(dbv1.type==DBVT_ASCIIZ); + d=(dbv2.type==DBVT_ASCIIZ); + if(s && d) { + s=strcmp(dbv1.pszVal,dbv2.pszVal); + d=0; + } + DBFreeVariant(&dbv1); + DBFreeVariant(&dbv2); + return (s-d)*m; + } break; + case 0x23: { + DBGetContactSetting(pUinKey(lParam1)->hContact,szModuleName,"gpg",&dbv1); + DBGetContactSetting(pUinKey(lParam2)->hContact,szModuleName,"gpg",&dbv2); + s=(dbv1.type==DBVT_ASCIIZ); + d=(dbv2.type==DBVT_ASCIIZ); + if(s && d) { + s=strcmp(dbv1.pszVal,dbv2.pszVal); + d=0; + } + DBFreeVariant(&dbv1); + DBFreeVariant(&dbv2); + return (s-d)*m; + } break; + case 0x04: { + s = pUinKey(lParam1)->tstatus; + d = pUinKey(lParam2)->tstatus; + return (s-d)*m; + } break; + case 0x05: { + DBGetContactSetting(pUinKey(lParam1)->hContact,szModuleName,"PSK",&dbv1); + s=(dbv1.type==DBVT_ASCIIZ); + DBFreeVariant(&dbv1); + DBGetContactSetting(pUinKey(lParam2)->hContact,szModuleName,"PSK",&dbv2); + d=(dbv2.type==DBVT_ASCIIZ); + DBFreeVariant(&dbv2); + return (s-d)*m; + } break; + } + return 0; +} + + +void ListView_Sort(HWND hLV, LPARAM lParamSort) { + char t[32]; + + // restore sort column + sprintf(t,"os%02x",(UINT)lParamSort&0xF0); + if ((lParamSort&0x0F)==0) { + lParamSort=(int)DBGetContactSettingByte(0, szModuleName, t, lParamSort+1); + } + DBWriteContactSettingByte(0, szModuleName, t, (BYTE)lParamSort); + + // restore sort order + sprintf(t,"os%02x",(UINT)lParamSort); + int m=DBGetContactSettingByte(0, szModuleName, t, 0); + if(bChangeSortOrder){ m=!m; DBWriteContactSettingByte(0, szModuleName, t, m); } + + ListView_SortItems(hLV,&CompareFunc,lParamSort|(m<<8)); +} + + +BOOL ShowSelectKeyDlg(HWND hParent, LPSTR KeyPath) +{ + OPENFILENAME ofn; memset(&ofn, 0, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hParent; + ofn.nMaxFile = MAX_PATH; + ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_NONETWORKBUTTON; + + ofn.lpstrFile = KeyPath; + ofn.lpstrFilter = "ASC files\0*.asc\0All files (*.*)\0*.*\0"; + ofn.lpstrTitle = "Open Key File"; + if (!GetOpenFileName(&ofn)) return FALSE; + + return TRUE; +} + + +LPCSTR priv_beg = "-----BEGIN PGP PRIVATE KEY BLOCK-----"; +LPCSTR priv_end = "-----END PGP PRIVATE KEY BLOCK-----"; +LPCSTR publ_beg = "-----BEGIN PGP PUBLIC KEY BLOCK-----"; +LPCSTR publ_end = "-----END PGP PUBLIC KEY BLOCK-----"; + +LPSTR LoadKeys(LPCSTR file,BOOL priv) { + FILE *f=fopen(file,"r"); + if (!f) return NULL; + + fseek(f,0,SEEK_END); + int flen = ftell(f); + fseek(f,0,SEEK_SET); + + LPCSTR beg,end; + if(priv) { + beg = priv_beg; + end = priv_end; + } + else { + beg = publ_beg; + end = publ_end; + } + + LPSTR keys = (LPSTR)mir_alloc(flen+1); + int i=0; BOOL b=false; + while(fgets(keys+i,128,f)) { + if (!b && strncmp(keys+i,beg,strlen(beg))==0) { + b=true; + } + else + if(b && strncmp(keys+i,end,strlen(end))==0) { + i+=(int)strlen(keys+i); + b=false; + } + if(b) { + i+=(int)strlen(keys+i); + } + } + *(keys+i)='\0'; +/* while(flen) { + int block = (flen>32768)?32768:flen; + fread(keys+i,block,1,f); + i+=block; + flen-=block; + }*/ + fclose(f); + return keys; +} + + +BOOL SaveExportRSAKeyDlg(HWND hParent, LPSTR key, BOOL priv) +{ + char szFile[MAX_PATH] = "rsa_pub.asc"; + if ( priv ) strcpy(szFile,"rsa_priv.asc"); + + OPENFILENAME ofn; memset(&ofn, 0, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hParent; + ofn.nMaxFile = MAX_PATH; + ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_NONETWORKBUTTON; + ofn.lpstrFile = szFile; + ofn.lpstrFilter = "ASC files\0*.asc\0All files (*.*)\0*.*\0"; + ofn.lpstrTitle = (priv)?"Save Private Key File":"Save Public Key File"; + if (!GetSaveFileName(&ofn)) return FALSE; + + FILE *f=fopen(szFile,"wb"); + if ( !f ) return FALSE; + fwrite(key,strlen(key),1,f); + fclose(f); + + return TRUE; +} + + +BOOL LoadImportRSAKeyDlg(HWND hParent, LPSTR key, BOOL priv) +{ + char szFile[MAX_PATH] = "rsa_pub.asc"; + if ( priv ) strcpy(szFile,"rsa_priv.asc"); + + OPENFILENAME ofn; memset(&ofn, 0, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hParent; + ofn.nMaxFile = MAX_PATH; + ofn.Flags = OFN_EXPLORER | OFN_CREATEPROMPT | OFN_OVERWRITEPROMPT | OFN_NOREADONLYRETURN; + ofn.lpstrFile = szFile; + ofn.lpstrFilter = "ASC files\0*.asc\0All files (*.*)\0*.*\0"; + ofn.lpstrTitle = (priv)?"Load Private Key File":"Load Public Key File"; + if (!GetOpenFileName(&ofn)) return FALSE; + + FILE *f=fopen(szFile,"rb"); + if ( !f ) return FALSE; + + fseek(f,0,SEEK_END); + int flen = ftell(f); if(flen>RSASIZE) { fclose(f); return FALSE; } + fseek(f,0,SEEK_SET); + + fread(key,flen,1,f); + fclose(f); + + return TRUE; +} + + +int onRegisterOptions(WPARAM wParam, LPARAM) +{ + OPTIONSDIALOGPAGE odp = { 0 }; + odp.cbSize = sizeof(odp); + odp.hInstance = g_hInst; + odp.pszTemplate = MAKEINTRESOURCE(IDD_OPTIONSTAB); + odp.pszTitle = (char*)szModuleName; + odp.pszGroup = LPGEN("Services"); + odp.pfnDlgProc = OptionsDlgProc; + Options_AddPage(wParam, &odp); + return 0; +} + +// EOF diff --git a/plugins/SecureIM/src/options.h b/plugins/SecureIM/src/options.h new file mode 100644 index 0000000000..c87a0de34d --- /dev/null +++ b/plugins/SecureIM/src/options.h @@ -0,0 +1,40 @@ +#ifndef __OPTIONS_H__ +#define __OPTIONS_H__ + +INT_PTR CALLBACK OptionsDlgProc(HWND,UINT,WPARAM,LPARAM); +INT_PTR CALLBACK DlgProcOptionsGeneral(HWND,UINT,WPARAM,LPARAM); +INT_PTR CALLBACK DlgProcOptionsProto(HWND,UINT,WPARAM,LPARAM); +INT_PTR CALLBACK DlgProcOptionsPGP(HWND,UINT,WPARAM,LPARAM); +INT_PTR CALLBACK DlgProcOptionsGPG(HWND,UINT,WPARAM,LPARAM); +BOOL CALLBACK DlgProcSetPSK(HWND,UINT,WPARAM,LPARAM); +BOOL CALLBACK DlgProcSetPassphrase(HWND,UINT,WPARAM,LPARAM); +void ApplyGeneralSettings(HWND); +void ApplyProtoSettings(HWND); +void ApplyPGPSettings(HWND); +void ApplyGPGSettings(HWND); +void RefreshGeneralDlg(HWND,BOOL); +void RefreshProtoDlg(HWND); +void RefreshPGPDlg(HWND,BOOL); +void RefreshGPGDlg(HWND,BOOL); +void ResetGeneralDlg(HWND); +void ResetProtoDlg(HWND); +LPARAM getListViewParam(HWND,UINT); +void setListViewIcon(HWND,UINT,pUinKey); +void setListViewMode(HWND,UINT,UINT); +void setListViewStatus(HWND,UINT,UINT); +UINT getListViewPSK(HWND,UINT); +void setListViewPSK(HWND,UINT,UINT); +UINT getListViewPUB(HWND,UINT); +void setListViewPUB(HWND,UINT,UINT); +int onRegisterOptions(WPARAM,LPARAM); +int CALLBACK CompareFunc(LPARAM,LPARAM,LPARAM); +void ListView_Sort(HWND,LPARAM); +BOOL ShowSelectKeyDlg(HWND,LPSTR); +LPSTR LoadKeys(LPCSTR,BOOL); +BOOL SaveExportRSAKeyDlg(HWND,LPSTR,BOOL); +BOOL LoadImportRSAKeyDlg(HWND,LPSTR,BOOL); + +#define getListViewContact(h,i) (HANDLE)getListViewParam(h,i) +#define getListViewProto(h,i) (int)getListViewParam(h,i) + +#endif diff --git a/plugins/SecureIM/src/popupOptions.cpp b/plugins/SecureIM/src/popupOptions.cpp new file mode 100644 index 0000000000..6e08cd81fc --- /dev/null +++ b/plugins/SecureIM/src/popupOptions.cpp @@ -0,0 +1,239 @@ +#include "commonheaders.h" + + +INT_PTR CALLBACK PopOptionsDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam) { + + char getTimeout[5]; + + HWND hec = GetDlgItem(hDlg, IDC_EC); + HWND hdc = GetDlgItem(hDlg, IDC_DC); + HWND hks = GetDlgItem(hDlg, IDC_KS); + HWND hkr = GetDlgItem(hDlg, IDC_KR); + HWND hss = GetDlgItem(hDlg, IDC_SS); + HWND hsr = GetDlgItem(hDlg, IDC_SR); + + switch (wMsg) { + case WM_COMMAND: { + + if (HIWORD(wParam) == CPN_COLOURCHANGED) { + //It's a colour picker change. LOWORD(wParam) is the control id. + DWORD color = SendDlgItemMessage(hDlg,LOWORD(wParam),CPM_GETCOLOUR,0,0); + + switch(LOWORD(wParam)) { + case IDC_BACKKEY: + DBWriteContactSettingDword(0, szModuleName, "colorKeyb", color); + break; + case IDC_TEXTKEY: + DBWriteContactSettingDword(0, szModuleName, "colorKeyt", color); + break; + case IDC_BACKSEC: + DBWriteContactSettingDword(0, szModuleName, "colorSecb", color); + break; + case IDC_TEXTSEC: + DBWriteContactSettingDword(0, szModuleName, "colorSect", color); + break; + case IDC_BACKSR: + DBWriteContactSettingDword(0, szModuleName, "colorSRb", color); + break; + case IDC_TEXTSR: + DBWriteContactSettingDword(0, szModuleName, "colorSRt", color); + break; + } + return TRUE; + } + + switch (LOWORD(wParam)) { + case IDC_PREV: { + //preview popups... + showPopUp("Key Popup",NULL,g_hPOP[POP_PU_PRC],0); + showPopUp("Secure Popup",NULL,g_hPOP[POP_PU_EST],1); + showPopUp("Message Popup",NULL,g_hPOP[POP_PU_MSR],2); + } + break; + case IDC_EC: { + //set ec checkbox value + DBWriteContactSettingByte(0, szModuleName, "ec", (BYTE)(SendMessage(hec,BM_GETCHECK,0L,0L)==BST_CHECKED)); + } + break; + case IDC_DC: { + //set dc checkbox value + DBWriteContactSettingByte(0, szModuleName, "dc", (BYTE)(SendMessage(hdc,BM_GETCHECK,0L,0L)==BST_CHECKED)); + } + break; + case IDC_SS: { + //set ss checkbox value + DBWriteContactSettingByte(0, szModuleName, "ss", (BYTE)(SendMessage(hss,BM_GETCHECK,0L,0L)==BST_CHECKED)); + } + break; + case IDC_SR: { + //set sr checkbox value + DBWriteContactSettingByte(0, szModuleName, "sr", (BYTE)(SendMessage(hsr,BM_GETCHECK,0L,0L)==BST_CHECKED)); + } + break; + case IDC_KS: { + //set indicator checkbox value + DBWriteContactSettingByte(0, szModuleName, "ks", (BYTE)(SendMessage(hks,BM_GETCHECK,0L,0L)==BST_CHECKED)); + } + break; + case IDC_KR: { + //set indicator checkbox value + DBWriteContactSettingByte(0, szModuleName, "kr", (BYTE)(SendMessage(hkr,BM_GETCHECK,0L,0L)==BST_CHECKED)); + } + break; + case IDC_TIMEKEY: { + //set timeout value + GetDlgItemText(hDlg,IDC_TIMEKEY,getTimeout,sizeof(getTimeout)); + mir_itoa(atoi(getTimeout),getTimeout,10); + DBWriteContactSettingString(0, szModuleName, "timeoutKey", getTimeout); + } + break; + case IDC_TIMESEC: { + //set timeout value + GetDlgItemText(hDlg,IDC_TIMESEC,getTimeout,sizeof(getTimeout)); + mir_itoa(atoi(getTimeout),getTimeout,10); + DBWriteContactSettingString(0, szModuleName, "timeoutSec", getTimeout); + } + break; + case IDC_TIMESR: { + //set timeout value + GetDlgItemText(hDlg,IDC_TIMESR,getTimeout,sizeof(getTimeout)); + mir_itoa(atoi(getTimeout),getTimeout,10); + DBWriteContactSettingString(0, szModuleName, "timeoutSR", getTimeout); + } + break; + } //switch + + RefreshPopupOptionsDlg(hec,hdc,hss,hsr,hks,hkr); + break; + } + + case WM_DESTROY: + break; + + case WM_INITDIALOG: { + TranslateDialogDefault(hDlg); + RefreshPopupOptionsDlg(hec,hdc,hss,hsr,hks,hkr); + + DBVARIANT dbv; + char *timeout; + + //set timeout value for Key + if (DBGetContactSetting(0, szModuleName, "timeoutKey", &dbv) == 0) timeout=dbv.pszVal; + else timeout="0"; + SetDlgItemText(hDlg, IDC_TIMEKEY, timeout); + DBFreeVariant(&dbv); + + //set timeout value for SEC + if (DBGetContactSetting(0, szModuleName, "timeoutSec", &dbv) == 0) timeout=dbv.pszVal; + else timeout="0"; + SetDlgItemText(hDlg, IDC_TIMESEC, timeout); + DBFreeVariant(&dbv); + + //set timeout value for SR + if (DBGetContactSetting(0, szModuleName, "timeoutSR", &dbv) == 0) timeout=dbv.pszVal; + else timeout="0"; + SetDlgItemText(hDlg, IDC_TIMESR, timeout); + DBFreeVariant(&dbv); + + //key color + SendDlgItemMessage(hDlg,IDC_BACKKEY,CPM_SETCOLOUR,0,DBGetContactSettingDword(0, szModuleName, "colorKeyb", RGB(230,230,255))); + SendDlgItemMessage(hDlg,IDC_TEXTKEY,CPM_SETCOLOUR,0,DBGetContactSettingDword(0, szModuleName, "colorKeyt", RGB(0,0,0))); + + //Session color + SendDlgItemMessage(hDlg,IDC_BACKSEC,CPM_SETCOLOUR,0,DBGetContactSettingDword(0, szModuleName, "colorSecb", RGB(255,255,200))); + SendDlgItemMessage(hDlg,IDC_TEXTSEC,CPM_SETCOLOUR,0,DBGetContactSettingDword(0, szModuleName, "colorSect", RGB(0,0,0))); + + //SR color + SendDlgItemMessage(hDlg,IDC_BACKSR,CPM_SETCOLOUR,0,DBGetContactSettingDword(0, szModuleName, "colorSRb", RGB(200,255,200))); + SendDlgItemMessage(hDlg,IDC_TEXTSR,CPM_SETCOLOUR,0,DBGetContactSettingDword(0, szModuleName, "colorSRt", RGB(0,0,0))); + + break; + } + + case WM_NOTIFY: { + break; + } + default: + return FALSE; + } + return TRUE; +} + + +void RefreshPopupOptionsDlg(HWND hec,HWND hdc,HWND hss,HWND hsr,HWND hks,HWND hkr) { + + DBVARIANT dbv; + int indic; + + // ec checkbox + if (DBGetContactSetting(0, szModuleName, "ec", &dbv) == 0) + {indic=dbv.bVal; + } + else indic=1; + + if(indic==1)SendMessage(hec,BM_SETCHECK,BST_CHECKED,0L); + else SendMessage(hec,BM_SETCHECK,BST_UNCHECKED,0L); + + // dc checkbox + if (DBGetContactSetting(0, szModuleName, "dc", &dbv) == 0) + {indic=dbv.bVal; + } + else indic=1; + + if(indic==1)SendMessage(hdc,BM_SETCHECK,BST_CHECKED,0L); + else SendMessage(hdc,BM_SETCHECK,BST_UNCHECKED,0L); + + // ks checkbox + if (DBGetContactSetting(0, szModuleName, "ks", &dbv) == 0) + {indic=dbv.bVal; + } + else indic=1; + + if(indic==1)SendMessage(hks,BM_SETCHECK,BST_CHECKED,0L); + else SendMessage(hks,BM_SETCHECK,BST_UNCHECKED,0L); + + // kr checkbox + if (DBGetContactSetting(0, szModuleName, "kr", &dbv) == 0) + {indic=dbv.bVal; + } + else indic=1; + + if(indic==1)SendMessage(hkr,BM_SETCHECK,BST_CHECKED,0L); + else SendMessage(hkr,BM_SETCHECK,BST_UNCHECKED,0L); + + //ss checkbox + if (DBGetContactSetting(0, szModuleName, "ss", &dbv) == 0) + {indic=dbv.bVal; + } + else indic=0; + + if(indic==1)SendMessage(hss,BM_SETCHECK,BST_CHECKED,0L); + else SendMessage(hss,BM_SETCHECK,BST_UNCHECKED,0L); + + //sr checkbox + if (DBGetContactSetting(0, szModuleName, "sr", &dbv) == 0) + {indic=dbv.bVal; + } + else indic=0; + + if(indic==1)SendMessage(hsr,BM_SETCHECK,BST_CHECKED,0L); + else SendMessage(hsr,BM_SETCHECK,BST_UNCHECKED,0L); + + DBFreeVariant(&dbv); +} + + +int onRegisterPopOptions(WPARAM wParam, LPARAM) +{ + OPTIONSDIALOGPAGE odp = {0}; + odp.cbSize = sizeof(odp); + odp.hInstance = g_hInst; + odp.pszTemplate = MAKEINTRESOURCE(IDD_POPUP); + odp.pszTitle = (char*)szModuleName; + odp.pszGroup = LPGEN("Popups"); + odp.pfnDlgProc = PopOptionsDlgProc; + Options_AddPage(wParam, &odp); + return 0; +} + +// EOF diff --git a/plugins/SecureIM/src/popupOptions.h b/plugins/SecureIM/src/popupOptions.h new file mode 100644 index 0000000000..22d3453adc --- /dev/null +++ b/plugins/SecureIM/src/popupOptions.h @@ -0,0 +1,8 @@ +#ifndef __POPUP_OPTIONS__ +#define __POPUP_OPTIONS__ + +INT_PTR CALLBACK PopOptionsDlgProc(HWND,UINT,WPARAM,LPARAM); +void RefreshPopupOptionsDlg(HWND,HWND,HWND,HWND,HWND,HWND); +int onRegisterPopOptions(WPARAM,LPARAM); + +#endif diff --git a/plugins/SecureIM/src/resource.h b/plugins/SecureIM/src/resource.h new file mode 100644 index 0000000000..f8a753773d --- /dev/null +++ b/plugins/SecureIM/src/resource.h @@ -0,0 +1,160 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by resource.rc +// +#define ID_FIRSTICON 1 +#define IDI_CL_DIS 1 +#define IDI_CL_EST 2 +#define IDI_CM_DIS 3 +#define IDI_CM_EST 4 +#define IDI_MW_DIS 5 +#define IDI_MW_EST 6 +#define IDI_PU_DIS 7 +#define IDI_PU_EST 8 +#define IDI_PU_PRC 9 +#define IDI_PU_MSG 10 +#define IDI_ST_DIS 11 +#define IDI_ST_ENA 12 +#define IDI_ST_TRY 13 +#define IDI_OV_NAT 14 +#define IDI_OV_PGP 15 +#define IDI_OV_GPG 16 +#define IDI_OV_RSA 17 +#define ID_LASTICON 17 + +#define ID_DISABLED 111 +#define ID_ENABLED 112 +#define ID_ALWAYS 113 +#define ID_SETPSK 114 +#define ID_DELPSK 115 +#define ID_UPDATE_CLIST 116 +#define ID_UPDATE_PROTO 117 +#define ID_UPDATE_PLIST 118 +#define ID_UPDATE_GLIST 119 +#define ID_GETPUBL 120 +#define ID_DELPUBL 121 +#define ID_EXPPUBL 122 +#define ID_IMPPUBL 123 + +#define ID_SIM_NATIVE 130 +#define ID_SIM_PGP 131 +#define ID_SIM_GPG 132 +#define ID_SIM_RSAAES 133 +#define ID_SIM_RSA 134 + +#define IDM_CLIST0 150 +#define IDM_CLIST1 151 +#define IDM_CLIST2 152 +#define IDM_CLIST01 153 +#define IDM_CLIST02 154 +#define IDM_CLIST11 155 +#define IDM_CLIST12 156 + +#define IDD_OPTIONSTAB 501 +#define IDD_TAB_GENERAL 502 +#define IDD_TAB_PROTO 503 +#define IDD_TAB_PGP 504 +#define IDD_TAB_GPG 505 +#define IDD_TAB_MESSAGES 506 +#define IDD_POPUP 507 +#define IDD_PSK 508 +#define IDD_PASSPHRASE 509 + +#define IDC_STD_USERLIST 1001 +#define IDC_TIMEOUT 1002 +#define IDC_BACKKEY 1003 +#define IDC_TEXTKEY 1004 +#define IDC_PREV 1005 +#define IDC_BACKSEC 1006 +#define IDC_TEXTSEC 1007 +#define IDC_RESET 1008 +#define IDC_ALWAYSICON 1009 +#define IDC_EC 1010 +#define IDC_DC 1011 +#define IDC_KS 1012 +#define IDC_KR 1013 +#define IDC_SS 1014 +#define IDC_SR 1015 +#define IDC_BACKSR 1016 +#define IDC_BACKKEY6 1017 +#define IDC_TEXTSR 1018 +#define IDC_TIMEKEY 1019 +#define IDC_TIMESEC 1020 +#define IDC_TIMESR 1021 +#define IDC_PVALUES 1022 +#define IDC_ADD 1023 +#define IDC_DELETE 1024 +#define IDC_SFT 1025 +#define IDC_ASI 1026 +#define IDC_SOM 1027 +#define IDC_ADV0 1028 +#define IDC_ADV1 1029 +#define IDC_ADV2 1030 +#define IDC_ADV3 1031 +#define IDC_ADV4 1032 +#define IDC_ADV5 1033 +#define IDC_ADV6 1034 +#define IDC_ADV7 1035 +#define IDC_ADV8 1036 +#define IDC_MCD 1037 +#define IDC_KET 1038 +#define IDC_OPTIONSTAB 1039 +#define IDC_PROTO 1040 +#define IDC_EDIT1 1041 +#define IDC_EDIT2 1042 +#define IDC_SCM 1043 +#define IDC_DGP 1044 +#define IDC_OKT 1045 +#define IDC_AIP 1046 +#define IDC_ADVICON 1047 +#define IDC_SPLITON 1048 +#define IDC_SPLITOFF 1049 +#define IDC_RSA_SHA 1050 +#define IDC_NOL 1051 +#define IDC_AAK 1052 +#define IDC_MCM 1053 +#define IDC_RSA_COPY 1054 +#define IDC_RSA_EXP 1055 +#define IDC_RSA_EXPPRIV 1056 +#define IDC_RSA_IMPPRIV 1057 +#define IDC_PASSPHRASE 1058 + +#define IDC_NO_PGP 1100 +#define IDC_PGP 1101 +#define IDC_GPG 1102 + +#define IDC_PGP_SDK 1200 +#define IDC_PGP_USERLIST 1201 +#define IDC_SET_KEYRINGS 1202 +#define IDC_KEYRING_STATUS 1203 +#define IDC_PGP_PRIVKEY 1204 +#define IDC_LOAD_PRIVKEY 1205 +#define IDC_NO_KEYRINGS 1206 + +#define IDC_GPGEXECUTABLE_EDIT 1300 +#define IDC_BROWSEEXECUTABLE_BTN 1301 +#define IDC_GPGHOME_EDIT 1302 +#define IDC_SECRETKEY_DDOWN 1303 +#define IDC_SECRETREFRESH_BTN 1304 +#define IDC_GPG_USERLIST 1305 +#define IDC_PUBLICKEY_DDOWN 1306 +#define IDC_PUBLICREFRESH_BTN 1307 +#define IDC_LOGGINGON_CBOX 1308 +#define IDC_GPGLOGFILE_EDIT 1309 +#define IDC_SAVEPASS_CBOX 1310 +#define IDC_TMPPATHON_CBOX 1311 +#define IDC_GPGTMPPATH_EDIT 1312 + +#define IDC_STATIC -1 +#define ID_ENCRYPTION 40001 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 119 +#define _APS_NEXT_COMMAND_VALUE 40002 +#define _APS_NEXT_CONTROL_VALUE 1400 +#define _APS_NEXT_SYMED_VALUE 119 +#endif +#endif diff --git a/plugins/SecureIM/src/rtfconv.cpp b/plugins/SecureIM/src/rtfconv.cpp new file mode 100644 index 0000000000..994f541373 --- /dev/null +++ b/plugins/SecureIM/src/rtfconv.cpp @@ -0,0 +1,46 @@ +#include "commonheaders.h" + + +HINSTANCE hRtfconv = NULL; +RTFCONVSTRING pRtfconvString = NULL; + + +BOOL load_rtfconv () { + + hRtfconv = LoadLibrary( "rtfconv.dll" ) ; + if ( hRtfconv == NULL ) { + hRtfconv = LoadLibrary( "plugins\\rtfconv.dll" ) ; + if ( hRtfconv == NULL ) + return FALSE; + } + + pRtfconvString = (RTFCONVSTRING) GetProcAddress( hRtfconv, "RtfconvString" ) ; + if ( pRtfconvString == NULL ) { + FreeLibrary( hRtfconv ) ; + return FALSE; + } + + return TRUE; +} + +void free_rtfconv () { + + if ( hRtfconv ) + FreeLibrary( hRtfconv ) ; + pRtfconvString = NULL; + hRtfconv = NULL; +} + + +void rtfconvA(LPCSTR rtf, LPWSTR plain) { + + pRtfconvString( rtf, plain, 0, 1200, CONVMODE_USE_SYSTEM_TABLE, (strlen(rtf)+1)*sizeof(WCHAR)); +} + + +void rtfconvW(LPCWSTR rtf, LPWSTR plain) { + + pRtfconvString( rtf, plain, 0, 1200, CONVMODE_USE_SYSTEM_TABLE, (wcslen(rtf)+1)*sizeof(WCHAR)); +} + +// EOF diff --git a/plugins/SecureIM/src/rtfconv.h b/plugins/SecureIM/src/rtfconv.h new file mode 100644 index 0000000000..2a3e75089b --- /dev/null +++ b/plugins/SecureIM/src/rtfconv.h @@ -0,0 +1,23 @@ +#ifndef __RTFCONV_H__ +#define __RTFCONV_H__ + +#include + +#ifndef _INTPTR_T_DEFINED +#define intptr_t int +#endif + +#define CONVMODE_USE_SYSTEM_TABLE 0x800000 /* Use OS's table only */ + +typedef intptr_t (WINAPI *RTFCONVSTRING) ( const void *pSrcBuffer, void *pDstBuffer, + int nSrcCodePage, int nDstCodePage, unsigned long dwFlags, + size_t nMaxLen ); + +extern RTFCONVSTRING pRtfconvString; + +BOOL load_rtfconv (); +void free_rtfconv (); +void rtfconvA(LPCSTR rtf, LPWSTR plain); +void rtfconvW(LPCWSTR rtf, LPWSTR plain); + +#endif diff --git a/plugins/SecureIM/src/secureim.h b/plugins/SecureIM/src/secureim.h new file mode 100644 index 0000000000..a307d1e5a2 --- /dev/null +++ b/plugins/SecureIM/src/secureim.h @@ -0,0 +1,172 @@ +#ifndef __SECURE_IM__ +#define __SECURE_IM__ + +#include "resource.h" + +// режимы шифрования SecureIM +#define MODE_NATIVE 0 +#define MODE_PGP 1 +#define MODE_GPG 2 +#define MODE_RSAAES 3 +#define MODE_CNT (3+1) +#define MODE_RSA 4 + +#define SECURED 0x10 + +// статусы для Native и RSA/AES режимов +#define STATUS_DISABLED 0 +#define STATUS_ENABLED 1 +#define STATUS_ALWAYSTRY 2 + +#define SiG_KEYR 0 +#define SiG_KEY3 SiG_KEYR +#define SiG_KEY4 SiG_KEYR +#define SiG_ENON 1 +#define SiG_ENOF 2 +#define SiG_RSND 3 +#define SiG_INIT 4 +#define SiG_DEIN 5 +#define SiG_DISA 6 +#define SiG_FAKE 7 +#define SiG_KEYA 8 +#define SiG_KEYB 9 +#define SiG_PART 10 +#define SiG_SECU 11 +#define SiG_SECP 12 +#define SiG_PGPM 13 +#define SiG_NONE -1 +#define SiG_GAME -2 + +struct SIG { + char *sig; + BYTE len; + char key; +}; + +const SIG signs[] = { + {"----Key3@hell----", 17, SiG_KEYR}, + {"----Key4@hell----", 17, SiG_KEYR}, + {"----Secured@hell----", 20, SiG_ENON}, + {"----Offline@hell----", 20, SiG_ENOF}, + {"----Resend@hell----", 19, SiG_RSND}, + {"----INIT@HELL----", 17, SiG_INIT}, + {"----DEINIT@HELL----", 19, SiG_DEIN}, + {"----DISABLED@HELL----", 21, SiG_DISA}, + {"----FAKE@HELL----", 17, SiG_FAKE}, + {"----KeyA@hell----", 17, SiG_KEYA}, + {"----KeyB@hell----", 17, SiG_KEYB}, + {"----Part@hell----", 17, SiG_PART}, + {"[SECURE]", 8, SiG_SECU}, + {"[$ECURE]", 8, SiG_SECP}, + {"-----BEGIN PGP MESSAGE-----", 27, SiG_PGPM}, + {"@@BattleShip", 12, SiG_GAME}, + {"GoMoku 0.0.2.2:", 15, SiG_GAME}, + {"@@GoMoku", 8, SiG_GAME}, + {"pbiChess:", 9, SiG_GAME}, + {"pbiReverse:", 11, SiG_GAME}, + {"pbiCorners:", 11, SiG_GAME}, + {"pbiCheckersInt:", 15, SiG_GAME}, + {"pbiCheckersRus:", 15, SiG_GAME}, + {"pbiCheckersPool:", 16, SiG_GAME}, + {0} +}; + +#define SIG_KEY3 signs[ 0].sig +#define SIG_KEY4 signs[ 1].sig +#define SIG_ENON signs[ 2].sig +#define SIG_ENOF signs[ 3].sig +#define SIG_RSND signs[ 4].sig +#define SIG_INIT signs[ 5].sig +#define SIG_DEIN signs[ 6].sig +#define SIG_DISA signs[ 7].sig +#define SIG_FAKE signs[ 8].sig +#define SIG_KEYA signs[ 9].sig +#define SIG_KEYB signs[10].sig +#define SIG_PART signs[11].sig +#define SIG_SECU signs[12].sig +#define SIG_SECP signs[13].sig + +#define LEN_KEY3 signs[ 0].len +#define LEN_KEY4 signs[ 1].len +#define LEN_ENON signs[ 2].len +#define LEN_ENOF signs[ 3].len +#define LEN_RSND signs[ 4].len +#define LEN_INIT signs[ 5].len +#define LEN_DEIN signs[ 6].len +#define LEN_DISA signs[ 7].len +#define LEN_FAKE signs[ 8].len +#define LEN_KEYA signs[ 9].len +#define LEN_KEYB signs[10].len +#define LEN_PART signs[11].len +#define LEN_SECU signs[12].len +#define LEN_SECP signs[13].len + +#define TBL_IEC 0x01 +#define TBL_ICO 0x02 +#define TBL_POP 0x03 + +#define IEC_CL_DIS 0x00 +#define IEC_CL_EST 0x01 +#define IEC_CNT (0x01+1) + +#define ICO_CM_DIS 0x00 +#define ICO_CM_EST 0x01 +#define ICO_MW_DIS 0x02 +#define ICO_MW_EST 0x03 +#define ICO_ST_DIS 0x04 +#define ICO_ST_ENA 0x05 +#define ICO_ST_TRY 0x06 +#define ICO_OV_NAT 0x07 +#define ICO_OV_PGP 0x08 +#define ICO_OV_GPG 0x09 +#define ICO_OV_RSA 0x0A +#define ICO_CNT (0x0A+1) + +#define POP_PU_DIS 0x00 +#define POP_PU_EST 0x01 +#define POP_PU_PRC 0x02 +#define POP_PU_MSR 0x03 +#define POP_PU_MSS 0x04 +#define POP_CNT (0x04+1) + +#define ADV_CNT 8 +#define ALL_CNT (IEC_CNT+ICO_CNT+POP_CNT) + +struct ICONS { + UINT key; // Resource ID + BYTE tbl; // Table NUM + BYTE idx; // Table IDX + char *section; + char *name; + char *text; +}; + +const ICONS icons[] = { + // Contact List + {IDI_CL_DIS, TBL_IEC, IEC_CL_DIS, MODULENAME"/Contact List", "sim_cl_dis", "Connection Disabled"}, + {IDI_CL_EST, TBL_IEC, IEC_CL_EST, MODULENAME"/Contact List", "sim_cl_est", "Connection Established"}, + // Contact Menu + {IDI_CM_DIS, TBL_ICO, ICO_CM_DIS, MODULENAME"/Contact Menu", "sim_cm_dis", "Disable Secure Connection"}, + {IDI_CM_EST, TBL_ICO, ICO_CM_EST, MODULENAME"/Contact Menu", "sim_cm_est", "Establishe Secure Connection"}, + // Message Window + {IDI_MW_DIS, TBL_ICO, ICO_MW_DIS, MODULENAME"/Message Window", "sim_mw_dis", "Connection Disabled"}, + {IDI_MW_EST, TBL_ICO, ICO_MW_EST, MODULENAME"/Message Window", "sim_mw_est", "Connection Established"}, + // popup's + {IDI_PU_DIS, TBL_POP, POP_PU_DIS, MODULENAME"/Popups", "sim_pu_dis", "Secure Connection Disabled"}, + {IDI_PU_EST, TBL_POP, POP_PU_EST, MODULENAME"/Popups", "sim_pu_est", "Secure Connection Established"}, + {IDI_PU_PRC, TBL_POP, POP_PU_PRC, MODULENAME"/Popups", "sim_pu_prc", "Secure Connection In Process"}, + {IDI_PU_MSG, TBL_POP, POP_PU_MSR, MODULENAME"/Popups", "sim_pu_msr", "Recv Secured Message"}, + {IDI_PU_MSG, TBL_POP, POP_PU_MSS, MODULENAME"/Popups", "sim_pu_mss", "Sent Secured Message"}, + // statuses + {IDI_ST_DIS, TBL_ICO, ICO_ST_DIS, MODULENAME"/Menu State", "sim_st_dis", "Disabled"}, + {IDI_ST_ENA, TBL_ICO, ICO_ST_ENA, MODULENAME"/Menu State", "sim_st_ena", "Enabled"}, + {IDI_ST_TRY, TBL_ICO, ICO_ST_TRY, MODULENAME"/Menu State", "sim_st_try", "Always Try"}, + // overlay + {IDI_OV_NAT, TBL_ICO, ICO_OV_NAT, MODULENAME"/Overlays", "sim_ov_nat", "Native mode"}, + {IDI_OV_PGP, TBL_ICO, ICO_OV_PGP, MODULENAME"/Overlays", "sim_ov_pgp", "PGP mode"}, + {IDI_OV_GPG, TBL_ICO, ICO_OV_GPG, MODULENAME"/Overlays", "sim_ov_gpg", "GPG mode"}, + {IDI_OV_RSA, TBL_ICO, ICO_OV_RSA, MODULENAME"/Overlays", "sim_ov_rsa", "RSA/AES mode"}, + {0} +}; + +#endif diff --git a/plugins/SecureIM/src/splitmsg.cpp b/plugins/SecureIM/src/splitmsg.cpp new file mode 100644 index 0000000000..ca4f0635cf --- /dev/null +++ b/plugins/SecureIM/src/splitmsg.cpp @@ -0,0 +1,124 @@ +#include "commonheaders.h" + + +// разбивает сообщение szMsg на части длиной iLen, возвращает строку вида PARTzPARTzz +LPSTR splitMsg(LPSTR szMsg, int iLen) { + +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("split: msg: -----\n%s\n-----\n",szMsg); +#endif + int len = (int)strlen(szMsg); + LPSTR out = (LPSTR) mir_alloc(len*2); + LPSTR buf = out; + + WORD msg_id = DBGetContactSettingWord(0, szModuleName, "msgid", 0) + 1; + DBWriteContactSettingWord(0, szModuleName, "msgid", msg_id); + + int part_all = (len+iLen-1)/iLen; + for(int part_num=0; part_numiLen)?iLen:len; + mir_snprintf(buf,32,"%s%04X%02X%02X",SIG_SECP,msg_id,part_num,part_all); + memcpy(buf+LEN_SECP+8,szMsg,sz); + *(buf+LEN_SECP+8+sz) = '\0'; +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("split: part: %s",buf); +#endif + buf += LEN_SECP+8+sz+1; + szMsg += sz; + len -= sz; + } + *buf = '\0'; + return out; +} + + +// собираем сообщение из частей, части храним в структуре у контакта +LPSTR combineMessage(pUinKey ptr, LPSTR szMsg) { + +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("combine: part: %s",szMsg); +#endif + int msg_id,part_num,part_all; + sscanf(szMsg,"%4X%2X%2X",&msg_id,&part_num,&part_all); + // + pPM ppm = NULL, pm = ptr->msgPart; + if ( !ptr->msgPart ) { + pm = ptr->msgPart = new partitionMessage; + memset(pm,0,sizeof(partitionMessage)); + pm->id = msg_id; + pm->message = new LPSTR[part_all]; + memset(pm->message,0,sizeof(LPSTR)*part_all); + } + else + while(pm) { + if ( pm->id == msg_id ) break; + ppm = pm; pm = pm->nextMessage; + } + if (!pm) { // nothing to found + pm = ppm->nextMessage = new partitionMessage; + memset(pm,0,sizeof(partitionMessage)); + pm->id = msg_id; + pm->message = new LPSTR[part_all]; + memset(pm->message,0,sizeof(LPSTR)*part_all); + } + pm->message[part_num] = new char[strlen(szMsg)]; + strcpy(pm->message[part_num],szMsg+8); +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("combine: save part: %s",pm->message[part_num]); +#endif + int len=0,i; + for ( i=0; imessage[i]==NULL) break; + len+=(int)strlen(pm->message[i]); + } + if ( i==part_all ) { // combine message + SAFE_FREE(ptr->tmp); + ptr->tmp = (LPSTR) mir_alloc(len+1); *(ptr->tmp)='\0'; + for ( i=0; itmp,pm->message[i]); + delete pm->message[i]; + } + delete pm->message; + if(ppm) ppm->nextMessage = pm->nextMessage; + else ptr->msgPart = pm->nextMessage; + delete pm; +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("combine: all parts: -----\n%s\n-----\n", ptr->tmp); +#endif + // собрали одно сообщение + return ptr->tmp; + } +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("combine: not all parts"); +#endif + // еще не собрали + return NULL; +} + + +// отправляет сообщение, если надо то разбивает на части +int splitMessageSend(pUinKey ptr, LPSTR szMsg) { + + int ret; + int len = (int)strlen(szMsg); + int par = (getContactStatus(ptr->hContact)==ID_STATUS_OFFLINE)?ptr->proto->split_off:ptr->proto->split_on; + if ( par && len>par ) { + LPSTR msg = splitMsg(szMsg,par); + LPSTR buf = msg; + while( *buf ) { + len = (int)strlen(buf); + LPSTR tmp = mir_strdup(buf); + ret = CallContactService(ptr->hContact,PSS_MESSAGE,(WPARAM)PREF_METANODB,(LPARAM)tmp); + mir_free(tmp); + buf += len+1; + } + SAFE_FREE(msg); + } + else { + ret = CallContactService(ptr->hContact,PSS_MESSAGE,(WPARAM)PREF_METANODB,(LPARAM)szMsg); + } + return ret; +} + + +// EOF diff --git a/plugins/SecureIM/src/splitmsg.h b/plugins/SecureIM/src/splitmsg.h new file mode 100644 index 0000000000..9f55c2784e --- /dev/null +++ b/plugins/SecureIM/src/splitmsg.h @@ -0,0 +1,9 @@ +#ifndef __SPLITMSG_H__ +#define __SPLITMSG_H__ + +#include + +LPSTR combineMessage(pUinKey,LPSTR); +int splitMessageSend(pUinKey,LPSTR); + +#endif diff --git a/plugins/SecureIM/src/svcs_clist.cpp b/plugins/SecureIM/src/svcs_clist.cpp new file mode 100644 index 0000000000..12402a58be --- /dev/null +++ b/plugins/SecureIM/src/svcs_clist.cpp @@ -0,0 +1,224 @@ +#include "commonheaders.h" + + +int __cdecl onContactSettingChanged(WPARAM wParam,LPARAM lParam) { + + HANDLE hContact = (HANDLE)wParam; + DBCONTACTWRITESETTING *cws=(DBCONTACTWRITESETTING*)lParam; + if (!hContact || strcmp(cws->szSetting,"Status")) return 0; + + pUinKey ptr = getUinKey(hContact); + int stat = getContactStatus(hContact); + if (!ptr || stat==-1) return 0; + +// HANDLE hMetaContact = getMetaContact(hContact); +// if(hMetaContact) { +// ptr = getUinKey(hMetaContact); +// if (!ptr) return 0; +// } + + if (stat==ID_STATUS_OFFLINE) { // go offline + if (ptr->mode==MODE_NATIVE && cpp_keyx(ptr->cntx)) { // have active context + cpp_delete_context(ptr->cntx); ptr->cntx=0; // reset context +// if(hMetaContact) { // is subcontact of metacontact +// showPopUpDC(hMetaContact); +// ShowStatusIconNotify(hMetaContact); +// if(getMostOnline(hMetaContact)) { // make handover +// CallContactService(hMetaContact,PSS_MESSAGE,0,(LPARAM)SIG_INIT); +// } +// } +// else { // is contact or metacontact (not subcontact) + showPopUpDC(hContact); // show popup "Disabled" + ShowStatusIconNotify(hContact); // change icon in CL +// } + } + else + if (ptr->mode==MODE_RSAAES && exp->rsa_get_state(ptr->cntx)==7) { + deleteRSAcntx(ptr); +// if(hMetaContact) { // is subcontact of metacontact +// showPopUpDC(hMetaContact); +// ShowStatusIconNotify(hMetaContact); +// if(getMostOnline(hMetaContact)) { // make handover +// CallContactService(hMetaContact,PSS_MESSAGE,0,(LPARAM)SIG_INIT); +// } +// } +// else { // is contact or metacontact (not subcontact) + showPopUpDC(hContact); // show popup "Disabled" + ShowStatusIconNotify(hContact); // change icon in CL +// } + } + } + else { // go not offline +// if (!hMetaContact) { // is contact or metacontact (not subcontact) + if (ptr->offlineKey) { + cpp_reset_context(ptr->cntx); + ptr->offlineKey = false; + } + ShowStatusIconNotify(hContact); // change icon in CL +// } + } + return 0; +} + + +// wParam=(WPARAM)(HANDLE)hContact +// lParam=0 +int __cdecl onContactAdded(WPARAM wParam,LPARAM lParam) { + addContact((HANDLE)wParam); + return 0; +} + + +// wParam=(WPARAM)(HANDLE)hContact +// lParam=0 +int __cdecl onContactDeleted(WPARAM wParam,LPARAM lParam) { + delContact((HANDLE)wParam); + return 0; +} + + +int __cdecl onExtraImageListRebuilding(WPARAM, LPARAM) { + +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onExtraImageListRebuilding"); +#endif + if ( (bADV || g_hCLIcon) && ServiceExists(MS_CLIST_EXTRA_ADD_ICON)) { + RefreshContactListIcons(); + } + return 0; +} + + +int __cdecl onExtraImageApplying(WPARAM wParam, LPARAM) { + + if ( (bADV || g_hCLIcon) && ServiceExists(MS_CLIST_EXTRA_SET_ICON) && isSecureProtocol((HANDLE)wParam)) { + IconExtraColumn iec = mode2iec(isContactSecured((HANDLE)wParam)); + if ( g_hCLIcon ) { + ExtraIcon_SetIcon(g_hCLIcon, (HANDLE)wParam, iec.hImage); + } + else { + CallService(MS_CLIST_EXTRA_SET_ICON, wParam, (LPARAM)&iec); + } + } + return 0; +} + + +int __cdecl onRebuildContactMenu(WPARAM wParam,LPARAM lParam) { + +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onRebuildContactMenu"); +#endif + HANDLE hContact = (HANDLE)wParam; + BOOL bMC = isProtoMetaContacts(hContact); + if ( bMC ) hContact = getMostOnline(hContact); // возьмем тот, через который пойдет сообщение + pUinKey ptr = getUinKey(hContact); + int i; + + CLISTMENUITEM mi; + memset(&mi,0,sizeof(mi)); + mi.cbSize = sizeof(CLISTMENUITEM); + + ShowStatusIconNotify(hContact); + + // check offline/online + if (!ptr) { + // hide menu bars + mi.flags = CMIM_FLAGS | CMIF_NOTOFFLINE | CMIF_HIDDEN; + for(i=0;imode==MODE_NATIVE || ptr->mode==MODE_RSAAES)) { + // Native/RSAAES + mi.flags = CMIM_FLAGS | CMIF_NOTOFFLINE | CMIM_ICON; + if ( !isSecured ) { + // create secureim connection + mi.hIcon = mode2icon(ptr->mode|SECURED,2); + CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)g_hMenu[0],(LPARAM)&mi); + } + else { + // disable secureim connection + mi.hIcon = mode2icon(ptr->mode,2); + CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)g_hMenu[1],(LPARAM)&mi); + } + // set status menu + if ( bSCM && !bMC && + ( !isSecured || ptr->mode==MODE_PGP || ptr->mode==MODE_GPG )) { + + mi.flags = CMIM_FLAGS | CMIM_NAME | CMIM_ICON; + mi.hIcon = g_hICO[ICO_ST_DIS+ptr->status]; + mi.pszName = (LPSTR)sim312[ptr->status]; + CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)g_hMenu[2],(LPARAM)&mi); + + mi.flags = CMIM_FLAGS | CMIM_ICON; + for(i=0;i<=(ptr->mode==MODE_RSAAES?1:2);i++) { + mi.hIcon = (i == ptr->status) ? g_hICO[ICO_ST_DIS+ptr->status] : NULL; + CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)g_hMenu[3+i],(LPARAM)&mi); + } + } + } + else + if ( isSecureProto && !isChat && (ptr->mode==MODE_PGP || ptr->mode==MODE_GPG)) { + // PGP, GPG + if ( ptr->mode==MODE_PGP && bPGPloaded ) { + if ((bPGPkeyrings || bPGPprivkey) && !isGPG) { + mi.flags = CMIM_FLAGS; + CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)g_hMenu[isPGP+6],(LPARAM)&mi); + } + } + if ( ptr->mode==MODE_GPG && bGPGloaded ) { + if(bGPGkeyrings && !isPGP) { + mi.flags = CMIM_FLAGS; + CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)g_hMenu[isGPG+8],(LPARAM)&mi); + } + } + } + if ( isSecureProto && !isChat && isMiranda ) { + // set mode menu + if ( bMCM && !bMC && + ( !isSecured || ptr->mode==MODE_PGP || ptr->mode==MODE_GPG )) { + + mi.flags = CMIM_FLAGS | CMIM_NAME | CMIM_ICON; + mi.hIcon = g_hICO[ICO_OV_NAT+ptr->mode]; + mi.pszName = (LPSTR)sim311[ptr->mode]; + CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)g_hMenu[10],(LPARAM)&mi); + + mi.flags = CMIM_FLAGS | CMIM_ICON; + for(i=0;imode!=MODE_PGP && !bPGP ) continue; + if ( i==MODE_GPG && ptr->mode!=MODE_GPG && !bGPG ) continue; + mi.hIcon = (i == ptr->mode) ? g_hICO[ICO_ST_ENA] : NULL; + CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)g_hMenu[11+i],(LPARAM)&mi); + } + } + } + + return 0; +} + + +// EOF diff --git a/plugins/SecureIM/src/svcs_clist.h b/plugins/SecureIM/src/svcs_clist.h new file mode 100644 index 0000000000..8c2dd192b6 --- /dev/null +++ b/plugins/SecureIM/src/svcs_clist.h @@ -0,0 +1,13 @@ +#ifndef __SVCS_CLIST_H__ +#define __SVCS_CLIST_H__ + +#include + +int __cdecl onContactSettingChanged(WPARAM,LPARAM); +int __cdecl onContactAdded(WPARAM,LPARAM); +int __cdecl onContactDeleted(WPARAM,LPARAM); +int __cdecl onExtraImageListRebuilding(WPARAM,LPARAM); +int __cdecl onExtraImageApplying(WPARAM,LPARAM); +int __cdecl onRebuildContactMenu(WPARAM,LPARAM); + +#endif diff --git a/plugins/SecureIM/src/svcs_menu.cpp b/plugins/SecureIM/src/svcs_menu.cpp new file mode 100644 index 0000000000..310d367e1b --- /dev/null +++ b/plugins/SecureIM/src/svcs_menu.cpp @@ -0,0 +1,232 @@ +#include "commonheaders.h" + + +INT_PTR __cdecl Service_IsContactSecured(WPARAM wParam, LPARAM lParam) { + + return (isContactSecured((HANDLE)wParam)&SECURED) || isContactPGP((HANDLE)wParam) || isContactGPG((HANDLE)wParam); +} + + +INT_PTR __cdecl Service_CreateIM(WPARAM wParam,LPARAM lParam){ + if (!CallService(MS_PROTO_ISPROTOONCONTACT, (WPARAM)wParam, (LPARAM)szModuleName)) + CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)wParam, (LPARAM)szModuleName); +// WPARAM flags = 0; +// HANDLE hMetaContact = getMetaContact((HANDLE)wParam); +// if ( hMetaContact ) { +// wParam = (WPARAM)hMetaContact; +// flags = PREF_METANODB; +// } + CallContactService((HANDLE)wParam,PSS_MESSAGE,(WPARAM)PREF_METANODB,(LPARAM)SIG_INIT); + return 1; +} + + +INT_PTR __cdecl Service_DisableIM(WPARAM wParam,LPARAM lParam) { +// WPARAM flags = 0; +// HANDLE hMetaContact = getMetaContact((HANDLE)wParam); +// if ( hMetaContact ) { +// wParam = (WPARAM)hMetaContact; +// flags = PREF_METANODB; +// } + CallContactService((HANDLE)wParam,PSS_MESSAGE,(WPARAM)PREF_METANODB,(LPARAM)SIG_DEIN); + return 1; +} + + +INT_PTR __cdecl Service_Status(WPARAM wParam, LPARAM lParam) { + + switch(--lParam) { + case STATUS_DISABLED: + case STATUS_ENABLED: + case STATUS_ALWAYSTRY: + pUinKey ptr = getUinKey((HANDLE)wParam); + if(ptr) { + ptr->status=ptr->tstatus=(BYTE)lParam; + if(ptr->status==STATUS_ENABLED) DBDeleteContactSetting(ptr->hContact, szModuleName, "StatusID"); + else DBWriteContactSettingByte(ptr->hContact, szModuleName, "StatusID", ptr->status); + } + break; + } + + return 1; +} + + +INT_PTR __cdecl Service_StatusDis(WPARAM wParam, LPARAM lParam) { + + return Service_Status(wParam,STATUS_DISABLED+1); +} + + +INT_PTR __cdecl Service_StatusEna(WPARAM wParam, LPARAM lParam) { + + return Service_Status(wParam,STATUS_ENABLED+1); +} + + +INT_PTR __cdecl Service_StatusTry(WPARAM wParam, LPARAM lParam) { + + return Service_Status(wParam,STATUS_ALWAYSTRY+1); +} + + +INT_PTR __cdecl Service_PGPdelKey(WPARAM wParam, LPARAM lParam) { + + if(bPGPloaded) { + DBDeleteContactSetting((HANDLE)wParam, szModuleName, "pgp"); + DBDeleteContactSetting((HANDLE)wParam, szModuleName, "pgp_mode"); + DBDeleteContactSetting((HANDLE)wParam, szModuleName, "pgp_abbr"); + } + { + pUinKey ptr = getUinKey((HANDLE)wParam); + cpp_delete_context(ptr->cntx); ptr->cntx=0; + } + ShowStatusIconNotify((HANDLE)wParam); + return 1; +} + + +INT_PTR __cdecl Service_PGPsetKey(WPARAM wParam, LPARAM lParam) { + + BOOL del = true; + if(bPGPloaded) { + if(bPGPkeyrings) { + char szKeyID[128]; szKeyID[0]='\0'; + PVOID KeyID = pgp_select_keyid(GetForegroundWindow(),szKeyID); + if(szKeyID[0]) { + DBDeleteContactSetting((HANDLE)wParam,szModuleName,"pgp"); + DBCONTACTWRITESETTING cws; + memset(&cws,0,sizeof(cws)); + cws.szModule = szModuleName; + cws.szSetting = "pgp"; + cws.value.type = DBVT_BLOB; + cws.value.pbVal = (LPBYTE)KeyID; + cws.value.cpbVal = pgp_size_keyid(); + CallService(MS_DB_CONTACT_WRITESETTING,wParam,(LPARAM)&cws); + DBWriteContactSettingByte((HANDLE)wParam,szModuleName,"pgp_mode",0); + DBWriteContactSettingString((HANDLE)wParam,szModuleName,"pgp_abbr",szKeyID); + del = false; + } + } + else + if(bPGPprivkey) { + char KeyPath[MAX_PATH]; KeyPath[0]='\0'; + if(ShowSelectKeyDlg(0,KeyPath)) { + char *publ = LoadKeys(KeyPath,false); + if(publ) { + DBDeleteContactSetting((HANDLE)wParam,szModuleName,"pgp"); + myDBWriteStringEncode((HANDLE)wParam,szModuleName,"pgp",publ); + DBWriteContactSettingByte((HANDLE)wParam,szModuleName,"pgp_mode",1); + DBWriteContactSettingString((HANDLE)wParam,szModuleName,"pgp_abbr","(binary)"); + mir_free(publ); + del = false; + } + } + } + } + + if(del) Service_PGPdelKey(wParam,lParam); + else { + pUinKey ptr = getUinKey((HANDLE)wParam); + cpp_delete_context(ptr->cntx); ptr->cntx=0; + } + ShowStatusIconNotify((HANDLE)wParam); + return 1; +} + + +INT_PTR __cdecl Service_GPGdelKey(WPARAM wParam, LPARAM lParam) { + + if(bGPGloaded) { + DBDeleteContactSetting((HANDLE)wParam, szModuleName, "gpg"); + } + { + pUinKey ptr = getUinKey((HANDLE)wParam); + cpp_delete_context(ptr->cntx); ptr->cntx=0; + } + ShowStatusIconNotify((HANDLE)wParam); + return 1; +} + + +INT_PTR __cdecl Service_GPGsetKey(WPARAM wParam, LPARAM lParam) { + + BOOL del = true; + if(bGPGloaded && bGPGkeyrings) { + char szKeyID[128]; szKeyID[0]='\0'; + gpg_select_keyid(GetForegroundWindow(),szKeyID); + if(szKeyID[0]) { + DBWriteContactSettingString((HANDLE)wParam,szModuleName,"gpg",szKeyID); + del = false; + } + } + + if(del) Service_GPGdelKey(wParam,lParam); + else { + pUinKey ptr = getUinKey((HANDLE)wParam); + cpp_delete_context(ptr->cntx); ptr->cntx=0; + } + ShowStatusIconNotify((HANDLE)wParam); + return 1; +} + + +INT_PTR __cdecl Service_Mode(WPARAM wParam, LPARAM lParam) { + + pUinKey ptr = getUinKey((HANDLE)wParam); + + switch(--lParam) { + case MODE_NATIVE: + case MODE_RSAAES: + if ( isContactSecured((HANDLE)wParam)&SECURED ) { + msgbox(NULL, sim111, szModuleName, MB_OK); + return 0; + } + if ( lParam!=MODE_NATIVE && ptr->status>STATUS_ENABLED ) { + Service_Status(wParam,STATUS_ENABLED+1); + } + case MODE_PGP: + case MODE_GPG: + // нужно много проверок и отключение активного контекста если необходимо + if(ptr) { + if ( ptr->cntx ) { + cpp_delete_context(ptr->cntx); + ptr->cntx = 0; + ptr->keyLoaded = 0; + } + ptr->mode=(BYTE)lParam; + DBWriteContactSettingByte((HANDLE)wParam, szModuleName, "mode", (BYTE)lParam); + } + ShowStatusIcon((HANDLE)wParam); + break; + } + + return 1; +} + + +INT_PTR __cdecl Service_ModeNative(WPARAM wParam, LPARAM lParam) { + + return Service_Mode(wParam,MODE_NATIVE+1); +} + + +INT_PTR __cdecl Service_ModePGP(WPARAM wParam, LPARAM lParam) { + + return Service_Mode(wParam,MODE_PGP+1); +} + + +INT_PTR __cdecl Service_ModeGPG(WPARAM wParam, LPARAM lParam) { + + return Service_Mode(wParam,MODE_GPG+1); +} + + +INT_PTR __cdecl Service_ModeRSAAES(WPARAM wParam, LPARAM lParam) { + + return Service_Mode(wParam,MODE_RSAAES+1); +} + + +// EOF diff --git a/plugins/SecureIM/src/svcs_menu.h b/plugins/SecureIM/src/svcs_menu.h new file mode 100644 index 0000000000..69b079ebf7 --- /dev/null +++ b/plugins/SecureIM/src/svcs_menu.h @@ -0,0 +1,26 @@ +#ifndef __SVCS_MENU_H__ +#define __SVCS_MENU_H__ + +#include + +INT_PTR __cdecl Service_IsContactSecured(WPARAM,LPARAM); + +INT_PTR __cdecl Service_CreateIM(WPARAM,LPARAM); +INT_PTR __cdecl Service_DisableIM(WPARAM,LPARAM); + +INT_PTR __cdecl Service_StatusDis(WPARAM,LPARAM); +INT_PTR __cdecl Service_StatusEna(WPARAM,LPARAM); +INT_PTR __cdecl Service_StatusTry(WPARAM,LPARAM); + +INT_PTR __cdecl Service_PGPdelKey(WPARAM,LPARAM); +INT_PTR __cdecl Service_PGPsetKey(WPARAM,LPARAM); + +INT_PTR __cdecl Service_GPGdelKey(WPARAM,LPARAM); +INT_PTR __cdecl Service_GPGsetKey(WPARAM,LPARAM); + +INT_PTR __cdecl Service_ModeNative(WPARAM,LPARAM); +INT_PTR __cdecl Service_ModePGP(WPARAM,LPARAM); +INT_PTR __cdecl Service_ModeGPG(WPARAM,LPARAM); +INT_PTR __cdecl Service_ModeRSAAES(WPARAM,LPARAM); + +#endif diff --git a/plugins/SecureIM/src/svcs_popup.cpp b/plugins/SecureIM/src/svcs_popup.cpp new file mode 100644 index 0000000000..bb1eb88355 --- /dev/null +++ b/plugins/SecureIM/src/svcs_popup.cpp @@ -0,0 +1,115 @@ +#include "commonheaders.h" + +/* +static int CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { + switch(message) { + case WM_COMMAND: + if (wParam == STN_CLICKED) { // It was a click on the Popup. + PUDeletePopUp(hWnd); + return TRUE; + } + break; + case UM_FREEPLUGINDATA: { + return TRUE; //TRUE or FALSE is the same, it gets ignored. + } + default: + break; + } + return DefWindowProc(hWnd, message, wParam, lParam); +} +*/ + +void showPopupMsg(HANDLE hContact, LPCSTR lpzText, HICON hIcon, int type) { + + // type: + // 0 - error + // 1 - key sent + // 2 - key recv + // 3 - established + // 4 - disabled + // 5 - msg recv + // 6 - msg sent + // + + if (!bPopupExists) return; + + char nback[32]; mir_snprintf(nback,sizeof(nback),"popup%dback", $type); + char ntext[32]; mir_snprintf(ntext,sizeof(ntext),"popup%dtext", $type); + char ntime[32]; mir_snprintf(ntime,sizeof(ntime),"popup%dtime", $type); + + COLORREF colorBack = (COLORREF)DBGetContactSettingDword(0,szModuleName,nback,(DWORD)RGB(230,230,255)); + COLORREF colorText = (COLORREF)DBGetContactSettingDword(0,szModuleName,ntext,(DWORD)RGB(0,0,0)); + int timeout = (int)DBGetContactSettingWord(0,szModuleName,ntime,0); + + if ( bCoreUnicode && bPopupUnicode ) { + POPUPDATAW ppd; + memset(&ppd,0,sizeof(POPUPDATAW)); + ppd.lchContact = hContact; + ppd.lchIcon = hIcon; + LPWSTR lpwzContactName = (LPWSTR)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,GCMDF_UNICODE); + wcscpy(ppd.lpwzContactName, lpwzContactName); + LPWSTR lpwzText = mir_a2u(lpzText); + wcscpy(ppd.lpwzText, TranslateW(lpwzText)); + mir_free(lpwzText); + ppd.colorBack = colorBack; + ppd.colorText = colorText; + ppd.iSeconds = timeout; +// ppd.PluginWindowProc = (WNDPROC)PopupDlgProc; +// ppd.PluginData = NULL; + CallService(MS_POPUP_ADDPOPUPW, (WPARAM)&ppd, 0); + } + else { + POPUPDATAEX ppd; + memset(&ppd,0,sizeof(POPUPDATAEX)); + ppd.lchContact = hContact; + ppd.lchIcon = hIcon; + LPSTR lpzContactName = (LPSTR)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,0); + strcpy(ppd.lpzContactName, lpzContactName); + strcpy(ppd.lpzText, Translate(lpzText)); + ppd.colorBack = colorBack; + ppd.colorText = colorText; + ppd.iSeconds = timeout; +// ppd.PluginWindowProc = (WNDPROC)PopupDlgProc; +// ppd.PluginData = NULL; + CallService(MS_POPUP_ADDPOPUPEX, (WPARAM)&ppd, 0); + } +} + + +void showPopUpDCmsg(HANDLE hContact,LPCSTR msg) { + int indic=DBGetContactSettingByte(0, szModuleName, "dc",1); + if (indic==1) showPopUp(msg,hContact,g_hPOP[POP_PU_DIS],1); +} +void showPopUpDC(HANDLE hContact) { + int indic=DBGetContactSettingByte(0, szModuleName, "dc",1); + if (indic==1) showPopUp(sim006,hContact,g_hPOP[POP_PU_DIS],1); +} +void showPopUpEC(HANDLE hContact) { + int indic=DBGetContactSettingByte(0, szModuleName, "ec",1); + if (indic==1) showPopUp(sim001,hContact,g_hPOP[POP_PU_EST],1); +} +void showPopUpKS(HANDLE hContact) { + int indic=DBGetContactSettingByte(0, szModuleName, "ks",1); + if (indic==1) showPopUp(sim007,hContact,g_hPOP[POP_PU_PRC],0); +} +void showPopUpKRmsg(HANDLE hContact,LPCSTR msg) { + int indic=DBGetContactSettingByte(0, szModuleName, "kr",1); + if (indic==1) showPopUp(msg,hContact,g_hPOP[POP_PU_PRC],0); +} +void showPopUpKR(HANDLE hContact) { + int indic=DBGetContactSettingByte(0, szModuleName, "kr",1); + if (indic==1) showPopUp(sim008,hContact,g_hPOP[POP_PU_PRC],0); +} +void showPopUpSM(HANDLE hContact) { + int indic=DBGetContactSettingByte(0, szModuleName, "ss",0); + if (indic==1) showPopUp(sim009,hContact,g_hPOP[POP_PU_MSS],2); + SkinPlaySound("OutgoingSecureMessage"); +} +void showPopUpRM(HANDLE hContact) { + int indic=DBGetContactSettingByte(0, szModuleName, "sr",0); + if (indic==1) showPopUp(sim010,hContact,g_hPOP[POP_PU_MSR],2); + SkinPlaySound("IncomingSecureMessage"); +} + + +// EOF diff --git a/plugins/SecureIM/src/svcs_proto.cpp b/plugins/SecureIM/src/svcs_proto.cpp new file mode 100644 index 0000000000..ef8d6c850c --- /dev/null +++ b/plugins/SecureIM/src/svcs_proto.cpp @@ -0,0 +1,1130 @@ +#include "commonheaders.h" + + +// return SignID +int getSecureSig(LPCSTR szMsg, LPSTR *szPlainMsg=NULL) { + if(szPlainMsg) *szPlainMsg=(LPSTR)szMsg; + for(int i=0;signs[i].len;i++) { + if (memcmp(szMsg,signs[i].sig,signs[i].len)==0) { +/* for(int i=strlen(szMsg)-1;i;i--) { + if ( szMsg[i] == '\x0D' || szMsg[i] == '\x0A' ) + ((LPSTR)szMsg)[i] = '\0'; + else + break; + }*/ + if(szPlainMsg) *szPlainMsg = (LPSTR)(szMsg+signs[i].len); + if(signs[i].key==SiG_GAME && !bDGP) + return SiG_NONE; + return signs[i].key; + } + } + return SiG_NONE; +} + + +int returnNoError(HANDLE hContact) { + HANDLE hEvent = CreateEvent( NULL, TRUE, FALSE, NULL ); + unsigned int tID; + CloseHandle( (HANDLE) _beginthreadex(NULL, 0, sttFakeAck, new TFakeAckParams(hEvent,hContact,777,0), 0, &tID)); + SetEvent( hEvent ); + return 777; +} + + +int returnError(HANDLE hContact, LPCSTR err) { + HANDLE hEvent = CreateEvent( NULL, TRUE, FALSE, NULL ); + unsigned int tID; + CloseHandle( (HANDLE) _beginthreadex(NULL, 0, sttFakeAck, new TFakeAckParams(hEvent,hContact,666,err), 0, &tID)); + SetEvent( hEvent ); + return 666; +} + + +LPSTR szUnrtfMsg = NULL; + + +// RecvMsg handler +INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) { + + CCSDATA *pccsd = (CCSDATA *)lParam; + PROTORECVEVENT *ppre = (PROTORECVEVENT *)pccsd->lParam; + pUinKey ptr = getUinKey(pccsd->hContact); + LPSTR szEncMsg = ppre->szMessage, szPlainMsg = NULL; + +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onRecvMsg: %s", szEncMsg); +#endif + + // cut rtf tags + if ( pRtfconvString && memcmp(szEncMsg,"{\\rtf1",6)==0 ) { + SAFE_FREE(szUnrtfMsg); + int len = (int)strlen(szEncMsg)+1; + LPWSTR szTemp = (LPWSTR)mir_alloc(len*sizeof(WCHAR)); + if(ppre->flags & PREF_UNICODE) + rtfconvW((LPWSTR)(szEncMsg+len),szTemp); + else + rtfconvA(szEncMsg,szTemp); + len = (int)wcslen(szTemp)-1; + while(len) { + if ( szTemp[len] == 0x0D || szTemp[len] == 0x0A ) + szTemp[len] = 0; + else + break; + len--; + } + len = (int)wcslen(&szTemp[1])+1; + szUnrtfMsg = (LPSTR)mir_alloc(len*(sizeof(WCHAR)+1)); + WideCharToMultiByte(CP_ACP, 0, &szTemp[1], -1, szUnrtfMsg, len*(sizeof(WCHAR)+1), NULL, NULL); + memcpy(szUnrtfMsg+len,&szTemp[1],len*sizeof(WCHAR)); + ppre->szMessage = szEncMsg = szUnrtfMsg; + ppre->flags |= PREF_UNICODE; + mir_free(szTemp); + } + + int ssig = getSecureSig(ppre->szMessage,&szEncMsg); + BOOL bSecured = isContactSecured(pccsd->hContact)&SECURED; + BOOL bPGP = isContactPGP(pccsd->hContact); + BOOL bGPG = isContactGPG(pccsd->hContact); + +// HANDLE hMetaContact = getMetaContact(pccsd->hContact); +// if ( hMetaContact ) { +// ptr = getUinKey(hMetaContact); +// } + + // pass any unchanged message + if ( !ptr || + ssig==SiG_GAME || + !isSecureProtocol(pccsd->hContact) || + (isProtoMetaContacts(pccsd->hContact) && (pccsd->wParam & PREF_SIMNOMETA)) || + isChatRoom(pccsd->hContact) || + (ssig==SiG_NONE && !ptr->msgSplitted && !bSecured && !bPGP && !bGPG) + ) { +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onRecvMsg: pass unhandled"); +#endif + return CallService(MS_PROTO_CHAINRECV, wParam, lParam); + } + + // drop message: fake, unsigned or from invisible contacts + if ( isContactInvisible(pccsd->hContact) || ssig==SiG_FAKE ) { +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onRecvMsg: drop unhandled (contact invisible or hidden)"); +#endif + return 1; + } + + // receive non-secure message in secure mode + if ( ssig==SiG_NONE && !ptr->msgSplitted ) { +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onRecvMsg: non-secure message"); +#endif + if(ppre->flags & PREF_UNICODE) { + szPlainMsg = m_awstrcat(Translate(sim402),szEncMsg); + } + else { + szPlainMsg = m_aastrcat(Translate(sim402),szEncMsg); + } + ppre->szMessage = szPlainMsg; + pccsd->wParam |= PREF_SIMNOMETA; + int ret = CallService(MS_PROTO_CHAINRECV, wParam, lParam); + mir_free(szPlainMsg); + return ret; + } + + // received non-pgp secure message from disabled contact + if ( ssig!=SiG_PGPM && !bPGP && !bGPG && ptr->status==STATUS_DISABLED ) { +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onRecvMsg: message from disabled"); +#endif + if ( ptr->mode==MODE_NATIVE ) { + // tell to the other side that we have the plugin disabled with him + pccsd->wParam |= PREF_METANODB; + pccsd->lParam = (LPARAM) SIG_DISA; + pccsd->szProtoService = PSS_MESSAGE; + CallService(MS_PROTO_CHAINSEND, wParam, lParam); + + showPopUp(sim003,pccsd->hContact,g_hPOP[POP_PU_DIS],0); + } + else { + createRSAcntx(ptr); + exp->rsa_disabled(ptr->cntx); + deleteRSAcntx(ptr); + } + SAFE_FREE(ptr->msgSplitted); + return 1; + } + + // combine message splitted by protocol (no tags) + if ( ssig==SiG_NONE && ptr->msgSplitted ) { +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onRecvMsg: combine untagged splitted message"); +#endif + LPSTR tmp = (LPSTR) mir_alloc(strlen(ptr->msgSplitted)+strlen(szEncMsg)+1); + strcpy(tmp,ptr->msgSplitted); + strcat(tmp,szEncMsg); + mir_free(ptr->msgSplitted); + ptr->msgSplitted = szEncMsg = ppre->szMessage = tmp; + ssig = getSecureSig(tmp,&szEncMsg); + } + else { + SAFE_FREE(ptr->msgSplitted); + } + + // combine message splitted by secureim (with tags) + if ( ssig==SiG_SECP || ssig==SiG_PART ) { + LPSTR msg = combineMessage(ptr,szEncMsg); + if ( !msg ) return 1; + szEncMsg = ppre->szMessage = msg; + ssig = getSecureSig(msg,&szEncMsg); + } + + // decrypt PGP/GPG message + if ( ssig==SiG_PGPM && + ((bPGPloaded && (bPGPkeyrings || bPGPprivkey))|| + (bGPGloaded && bGPGkeyrings)) + ) { +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onRecvMsg: PGP/GPG message"); +#endif + szEncMsg = ppre->szMessage; + if ( !ptr->cntx ) { + ptr->cntx = cpp_create_context(((bGPGloaded && bGPGkeyrings)?CPP_MODE_GPG:CPP_MODE_PGP) | ((DBGetContactSettingByte(pccsd->hContact,szModuleName,"gpgANSI",0))?CPP_MODE_GPG_ANSI:0)); + ptr->keyLoaded = 0; + } + + if (!strstr(szEncMsg,"-----END PGP MESSAGE-----")) + return 1; // no end tag, don't display it ... + + LPSTR szNewMsg = NULL; + LPSTR szOldMsg = NULL; + + if (!ptr->keyLoaded && bPGPloaded) ptr->keyLoaded = LoadKeyPGP(ptr); + if (!ptr->keyLoaded && bGPGloaded) ptr->keyLoaded = LoadKeyGPG(ptr); + + if(ptr->keyLoaded==1) szOldMsg = pgp_decode(ptr->cntx, szEncMsg); + else + if(ptr->keyLoaded==2) szOldMsg = gpg_decode(ptr->cntx, szEncMsg); + + if (!szOldMsg) { // error while decrypting message, send error + SAFE_FREE(ptr->msgSplitted); + ppre->flags &= ~(PREF_UNICODE|PREF_UTF); + pccsd->wParam &= ~(PREF_UNICODE|PREF_UTF); + ppre->szMessage = Translate(sim401); + return CallService(MS_PROTO_CHAINRECV, wParam, lParam); + } + + // receive encrypted message in non-encrypted mode + if (!isContactPGP(pccsd->hContact) && !isContactGPG(pccsd->hContact)) { + szNewMsg = m_ustrcat(TranslateU(sim403),szOldMsg); + szOldMsg = szNewMsg; + } + szNewMsg = utf8_to_miranda(szOldMsg,ppre->flags); pccsd->wParam = ppre->flags; + ppre->szMessage = szNewMsg; + + // show decoded message + showPopUpRM(ptr->hContact); + SAFE_FREE(ptr->msgSplitted); + pccsd->wParam |= PREF_SIMNOMETA; + int ret = CallService(MS_PROTO_CHAINRECV, wParam, lParam); + mir_free(szNewMsg); + return ret; + } + +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onRecvMsg: switch(ssig)=%d",ssig); +#endif + switch(ssig) { + + case SiG_PGPM: + return CallService(MS_PROTO_CHAINRECV, wParam, lParam); + + case SiG_SECU: { // new secured msg, pass to rsa_recv +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onRecvMsg: RSA/AES message"); +#endif + if ( ptr->mode==MODE_NATIVE ) { + ptr->mode = MODE_RSAAES; + deleteRSAcntx(ptr); + DBWriteContactSettingByte(ptr->hContact, szModuleName, "mode", ptr->mode); + } + createRSAcntx(ptr); + loadRSAkey(ptr); + if ( exp->rsa_get_state(ptr->cntx)==0 ) + showPopUpKR(ptr->hContact); + + LPSTR szOldMsg = exp->rsa_recv(ptr->cntx,szEncMsg); + if ( !szOldMsg ) return 1; // don't display it ... + + LPSTR szNewMsg = utf8_to_miranda(szOldMsg,ppre->flags); pccsd->wParam = ppre->flags; + ppre->szMessage = szNewMsg; + + // show decoded message + showPopUpRM(ptr->hContact); + SAFE_FREE(ptr->msgSplitted); + pccsd->wParam |= PREF_SIMNOMETA; + int ret = CallService(MS_PROTO_CHAINRECV, wParam, lParam); + mir_free(szNewMsg); + return ret; + } break; + + case SiG_ENON: { // online message +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onRecvMsg: Native SiG_ENON message"); +#endif + if ( cpp_keyx(ptr->cntx)) { + // decrypting message + szPlainMsg = decodeMsg(ptr,lParam,szEncMsg); + if (!ptr->decoded) { + mir_free(szPlainMsg); + SAFE_FREE(ptr->msgSplitted); + ptr->msgSplitted=mir_strdup(szEncMsg); + return 1; // don't display it ... + } +// showPopUpRM(ptr->hContact); + } + else { + // reinit key exchange user has send an encrypted message and i have no key + cpp_reset_context(ptr->cntx); + + LPSTR reSend = (LPSTR) mir_alloc(strlen(szEncMsg)+LEN_RSND); + strcpy(reSend,SIG_RSND); // copy resend sig + strcat(reSend,szEncMsg); // add mess + + pccsd->wParam |= PREF_METANODB; + pccsd->lParam = (LPARAM) reSend; // reSend Message to reemit + pccsd->szProtoService = PSS_MESSAGE; + CallService(MS_PROTO_CHAINSEND, wParam, lParam); // send back cipher message + mir_free(reSend); + + LPSTR keyToSend = InitKeyA(ptr,0); // calculate public and private key + + pccsd->lParam = (LPARAM) keyToSend; + CallService(MS_PROTO_CHAINSEND, wParam, lParam); // send new key + mir_free(keyToSend); + + showPopUp(sim005,NULL,g_hPOP[POP_PU_DIS],0); + showPopUpKS(ptr->hContact); + + return 1; + } + } break; + + case SiG_ENOF: { // offline message +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onRecvMsg: Native SiG_ENOF message"); +#endif + // if offline key is set and we have not an offline message unset key + if (ptr->offlineKey && cpp_keyx(ptr->cntx)) { + cpp_reset_context(ptr->cntx); + ptr->offlineKey = false; + } + // decrypting message with last offline key + DBVARIANT dbv; + dbv.type = DBVT_BLOB; + + if ( DBGetContactSetting(ptr->hContact,szModuleName,"offlineKey",&dbv) == 0 ) { + // if valid key is succefully retrieved + ptr->offlineKey = true; + InitKeyX(ptr,dbv.pbVal); + DBFreeVariant(&dbv); + + // decrypting message + szPlainMsg = decodeMsg(ptr,lParam,szEncMsg); + +// showPopUpRM(ptr->hContact); + ShowStatusIconNotify(ptr->hContact); + } + else { + // exit and show messsage + return CallService(MS_PROTO_CHAINRECV, wParam, lParam); + } + } break; + + case SiG_RSND: { // resend message +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onRecvMsg: Native SiG_RSND message"); +#endif + if (cpp_keyx(ptr->cntx)) { + // decrypt sended back message and save message for future sending with a new secret key + szPlainMsg = decodeMsg(ptr,(LPARAM)pccsd,szEncMsg); + addMsg2Queue(ptr,pccsd->wParam,szPlainMsg); + mir_free(szPlainMsg); + + showPopUpRM(ptr->hContact); + showPopUp(sim004,NULL,g_hPOP[POP_PU_DIS],0); + } + return 1; // don't display it ... + } break; + + case SiG_DISA: { // disabled message +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onRecvMsg: Native SiG_DISA message"); +#endif +// ptr->status=ptr->tstatus=STATUS_DISABLED; +// DBWriteContactSettingByte(ptr->hContact, szModuleName, "StatusID", ptr->status); + } + case SiG_DEIN: { // deinit message + // other user has disabled SecureIM with you + cpp_delete_context(ptr->cntx); ptr->cntx=0; + + showPopUpDC(ptr->hContact); + ShowStatusIconNotify(ptr->hContact); + + waitForExchange(ptr,3); // дослать нешифрованно + return 1; + } break; + + case SiG_KEYR: // key3 message + case SiG_KEYA: // keyA message + case SiG_KEYB: { // keyB message + if ( ptr->mode==MODE_RSAAES ) { + ptr->mode = MODE_NATIVE; + cpp_delete_context(ptr->cntx); + ptr->cntx = 0; + ptr->keyLoaded = 0; + DBWriteContactSettingByte(ptr->hContact, szModuleName, "mode", ptr->mode); + } + switch(ssig) { + case SiG_KEYR: { // key3 message +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onRecvMsg: SiG_KEYR received"); +#endif + // receive KeyB from user; + showPopUpKR(ptr->hContact); + + if ( ptr->cntx && cpp_keyb(ptr->cntx)) { + // reinit key exchange if an old key from user is found + cpp_reset_context(ptr->cntx); + } + + if ( InitKeyB(ptr,szEncMsg)!=CPP_ERROR_NONE ) { +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onRecvMsg: SiG_KEYR InitKeyB error"); +#endif + // tell to the other side that we have the plugin disabled with him +/* + pccsd->wParam |= PREF_METANODB; + pccsd->lParam = (LPARAM) SIG_DISA; + pccsd->szProtoService = PSS_MESSAGE; + CallService(MS_PROTO_CHAINSEND, wParam, lParam); +*/ + showPopUp(sim013,ptr->hContact,g_hPOP[POP_PU_DIS],0); + ShowStatusIconNotify(ptr->hContact); + + waitForExchange(ptr,3); // дослать нешифрованно + return 1; + } + + // other side support RSA mode ? + if ( ptr->features & CPP_FEATURES_RSA ) { + // switch to RSAAES mode + ptr->mode = MODE_RSAAES; + DBWriteContactSettingByte(ptr->hContact, szModuleName, "mode", ptr->mode); + + resetRSAcntx(ptr); + loadRSAkey(ptr); + exp->rsa_connect(ptr->cntx); + + showPopUpKS(pccsd->hContact); + ShowStatusIconNotify(pccsd->hContact); + return 1; + } + + // other side support new key format ? + if ( ptr->features & CPP_FEATURES_NEWPG ) { + cpp_reset_context(ptr->cntx); + + LPSTR keyToSend = InitKeyA(ptr,CPP_FEATURES_NEWPG|KEY_A_SIG); // calculate NEW public and private key +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onRecvMsg: Sending KEYA %s", keyToSend); +#endif + pccsd->wParam |= PREF_METANODB; + pccsd->lParam = (LPARAM)keyToSend; + pccsd->szProtoService = PSS_MESSAGE; + CallService(MS_PROTO_CHAINSEND, wParam, lParam); + mir_free(keyToSend); + + showPopUpKS(ptr->hContact); + waitForExchange(ptr); // запустим ожидание + return 1; + } + + // auto send my public key to keyB user if not done before + if ( !cpp_keya(ptr->cntx)) { + LPSTR keyToSend = InitKeyA(ptr,0); // calculate public and private key +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onRecvMsg: Sending KEYA %s", keyToSend); +#endif + pccsd->wParam |= PREF_METANODB; + pccsd->lParam = (LPARAM)keyToSend; + pccsd->szProtoService = PSS_MESSAGE; + CallService(MS_PROTO_CHAINSEND, wParam, lParam); + mir_free(keyToSend); + + showPopUpKS(ptr->hContact); + } + } break; + + case SiG_KEYA: { // keyA message +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onRecvMsg: SiG_KEYA received"); +#endif + // receive KeyA from user; + showPopUpKR(ptr->hContact); + + cpp_reset_context(ptr->cntx); + if(InitKeyB(ptr,szEncMsg)!=CPP_ERROR_NONE) { +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onRecvMsg: SiG_KEYA InitKeyB error"); +#endif + // tell to the other side that we have the plugin disabled with him +/* + pccsd->wParam |= PREF_METANODB; + pccsd->lParam = (LPARAM) SIG_DISA; + pccsd->szProtoService = PSS_MESSAGE; + CallService(MS_PROTO_CHAINSEND, wParam, lParam); +*/ + showPopUp(sim013,ptr->hContact,g_hPOP[POP_PU_DIS],0); + ShowStatusIconNotify(ptr->hContact); + + waitForExchange(ptr,3); // дослать нешифрованно + return 1; + } + + LPSTR keyToSend = InitKeyA(ptr,CPP_FEATURES_NEWPG|KEY_B_SIG); // calculate NEW public and private key +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onRecvMsg: Sending KEYB %s", keyToSend); +#endif + pccsd->wParam |= PREF_METANODB; + pccsd->lParam = (LPARAM)keyToSend; + pccsd->szProtoService = PSS_MESSAGE; + CallService(MS_PROTO_CHAINSEND, wParam, lParam); + mir_free(keyToSend); + } break; + + case SiG_KEYB: { // keyB message +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onRecvMsg: SiG_KEYB received"); +#endif + // receive KeyB from user; + showPopUpKR(ptr->hContact); + + // clear all and send DISA if received KeyB, and not exist KeyA or error on InitKeyB + if (!cpp_keya(ptr->cntx) || InitKeyB(ptr,szEncMsg)!=CPP_ERROR_NONE) { +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onRecvMsg: SiG_KEYB InitKeyB error"); +#endif + // tell to the other side that we have the plugin disabled with him +/* + pccsd->wParam |= PREF_METANODB; + pccsd->lParam = (LPARAM) SIG_DISA; + pccsd->szProtoService = PSS_MESSAGE; + CallService(MS_PROTO_CHAINSEND, wParam, lParam); +*/ + showPopUp(sim013,ptr->hContact,g_hPOP[POP_PU_DIS],0); + ShowStatusIconNotify(ptr->hContact); + + cpp_reset_context(ptr->cntx); + waitForExchange(ptr,3); // дослать нешифрованно + return 1; + } + } break; + + } // switch + + /* common part (CalcKeyX & SendQueue) */ + // calculate KeyX + if ( cpp_keya(ptr->cntx) && cpp_keyb(ptr->cntx) && !cpp_keyx(ptr->cntx)) + CalculateKeyX(ptr,ptr->hContact); + + ShowStatusIconNotify(ptr->hContact); +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onRecvMsg: Session established"); +#endif + + waitForExchange(ptr,2); // дошлем через шифрованное соединение + return 1; + /* common part (CalcKeyX & SendQueue) */ + } break; + + } //switch + + // receive message + if ( cpp_keyx(ptr->cntx) && (ssig==SiG_ENON||ssig==SiG_ENOF)) { +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onRecvMsg: message received"); +#endif + showPopUpRM(ptr->hContact); + } +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onRecvMsg: exit"); +#endif + pccsd->wParam |= PREF_SIMNOMETA; + int ret = CallService(MS_PROTO_CHAINRECV, wParam, lParam); + SAFE_FREE(szPlainMsg); + return ret; +} + + +// SendMsgW handler +INT_PTR __cdecl onSendMsgW(WPARAM wParam, LPARAM lParam) { + if (!lParam) return 0; + + CCSDATA *ccs = (CCSDATA *) lParam; + if ( !(ccs->wParam & PREF_UTF)) + ccs->wParam |= PREF_UNICODE; + + return onSendMsg(wParam, lParam); +} + + +// SendMsg handler +INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) { + + CCSDATA *pccsd = (CCSDATA *)lParam; + pUinKey ptr = getUinKey(pccsd->hContact); + int ssig = getSecureSig((LPCSTR)pccsd->lParam); + int stat = getContactStatus(pccsd->hContact); + +// HANDLE hMetaContact = getMetaContact(pccsd->hContact); +// if ( hMetaContact ) { +// ptr = getUinKey(hMetaContact); +// } +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onSend: %s",(LPSTR)pccsd->lParam); +#endif + // pass unhandled messages + if ( !ptr || + ssig==SiG_GAME || ssig==SiG_PGPM || ssig==SiG_SECU || ssig==SiG_SECP || + isChatRoom(pccsd->hContact) || +/* (ssig!=SiG_NONE && hMetaContact && (pccsd->wParam & PREF_METANODB)) || */ + stat==-1 || + (ssig==SiG_NONE && ptr->sendQueue) || + (ssig==SiG_NONE && ptr->status==STATUS_DISABLED) // Disabled - pass unhandled + ) { + return CallService(MS_PROTO_CHAINSEND, wParam, lParam); +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onSendMsg: pass unhandled"); +#endif + } + + // + // PGP/GPG mode + // + if ( ptr->mode==MODE_PGP || ptr->mode==MODE_GPG ) { +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onSendMsg: PGP|GPG mode"); +#endif + // если можно зашифровать - шифруем + if ( isContactPGP(ptr->hContact) || isContactGPG(ptr->hContact)) { +/* + if(stat==ID_STATUS_OFFLINE) { + if (msgbox1(0,sim110,szModuleName,MB_YESNO|MB_ICONQUESTION)==IDNO) { + return returnNoError(pccsd->hContact); + } + // exit and send unencrypted message + return CallService(MS_PROTO_CHAINSEND, wParam, lParam); + } +*/ + if ( !ptr->cntx ) { + ptr->cntx = cpp_create_context((isContactGPG(ptr->hContact)?CPP_MODE_GPG:CPP_MODE_PGP) | ((DBGetContactSettingByte(ptr->hContact,szModuleName,"gpgANSI",0))?CPP_MODE_GPG_ANSI:0)); + ptr->keyLoaded = 0; + } + if ( !ptr->keyLoaded && bPGPloaded ) ptr->keyLoaded = LoadKeyPGP(ptr); + if ( !ptr->keyLoaded && bGPGloaded ) ptr->keyLoaded = LoadKeyGPG(ptr); + if ( !ptr->keyLoaded ) return returnError(pccsd->hContact,Translate(sim108)); + + LPSTR szNewMsg = NULL; + LPSTR szUtfMsg = miranda_to_utf8((LPCSTR)pccsd->lParam,pccsd->wParam); + if ( ptr->keyLoaded == 1 ) { // PGP + szNewMsg = pgp_encode(ptr->cntx,szUtfMsg); + } + else + if ( ptr->keyLoaded == 2 ) { // GPG + szNewMsg = gpg_encode(ptr->cntx,szUtfMsg); + } + mir_free(szUtfMsg); + if ( !szNewMsg ) { + return returnError(pccsd->hContact,Translate(sim109)); + } + + // отправляем зашифрованное сообщение + splitMessageSend(ptr,szNewMsg); + + showPopUpSM(ptr->hContact); + + return returnNoError(pccsd->hContact); + } + else { + // отправляем незашифрованное + return CallService(MS_PROTO_CHAINSEND, wParam, lParam); + } + } + + // get contact SecureIM status + int stid = ptr->status; + + // + // RSA/AES mode + // + if ( ptr->mode==MODE_RSAAES ) { +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onSendMsg: RSA/AES mode"); +#endif + // contact is offline + if ( stat==ID_STATUS_OFFLINE ) { + if ( ptr->cntx ) { + if ( exp->rsa_get_state(ptr->cntx)!=0 ) { + resetRSAcntx(ptr); + } + } + else { + createRSAcntx(ptr); + } + if ( !bSOM || (!isClientMiranda(ptr,1) && !isSecureIM(ptr,1)) || !loadRSAkey(ptr)) { + if ( ssig==SiG_NONE ) { + // просто шлем незашифрованное в оффлайн + return CallService(MS_PROTO_CHAINSEND, wParam, lParam); + } + else { + // ничего не шлем дальше - это служебное сообщение + return returnNoError(pccsd->hContact); + } + } + // шлем шифрованное в оффлайн + LPSTR szUtfMsg = miranda_to_utf8((LPCSTR)pccsd->lParam,pccsd->wParam); + exp->rsa_send(ptr->cntx,szUtfMsg); + mir_free(szUtfMsg); + showPopUpSM(ptr->hContact); + return returnNoError(pccsd->hContact); + } + // SecureIM connection with this contact is disabled + if ( stid==STATUS_DISABLED ) { + if ( ptr->cntx ) { + exp->rsa_disabled(ptr->cntx); + deleteRSAcntx(ptr); + } + if ( ssig==SiG_NONE ) { + // просто шлем незашифрованное + return CallService(MS_PROTO_CHAINSEND, wParam, lParam); + } + // ничего не шлем дальше - это служебное сообщение + return returnNoError(pccsd->hContact); + } + // разорвать соединение + if ( ssig==SiG_DEIN ) { + if ( ptr->cntx ) { + exp->rsa_disconnect(ptr->cntx); + deleteRSAcntx(ptr); + } + waitForExchange(ptr,3); // дошлем нешифрованно + return returnNoError(pccsd->hContact); + } + // соединение установлено + if ( ptr->cntx && exp->rsa_get_state(ptr->cntx)==7 ) { + LPSTR szUtfMsg = miranda_to_utf8((LPCSTR)pccsd->lParam,pccsd->wParam); + exp->rsa_send(ptr->cntx,szUtfMsg); + mir_free(szUtfMsg); + showPopUpSM(ptr->hContact); + return returnNoError(pccsd->hContact); + } + // просто сообщение (без тэгов, нет контекста и работают AIP & NOL) + if ( ssig==SiG_NONE && isSecureIM(ptr->hContact)) { + // добавим его в очередь + addMsg2Queue(ptr, pccsd->wParam, (LPSTR)pccsd->lParam); + // запускаем процесс установки соединения + ssig=SiG_INIT; + // запускаем трэд ожидания и досылки + waitForExchange(ptr); + } + // установить соединение + if ( ssig==SiG_INIT ) { + createRSAcntx(ptr); + loadRSAkey(ptr); + exp->rsa_connect(ptr->cntx); + showPopUpKS(pccsd->hContact); + ShowStatusIconNotify(pccsd->hContact); + return returnNoError(pccsd->hContact); + } + // просто шлем незашифрованное (не знаю даже когда такое случится) + return CallService(MS_PROTO_CHAINSEND, wParam, lParam); + } + + // + // Native mode + // +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onSendMsg: Native mode"); +#endif + + // SecureIM connection with this contact is disabled + if ( stid==STATUS_DISABLED ) { +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onSendMsg: message for Disabled"); +#endif + // if user try initialize connection + if ( ssig==SiG_INIT ) { + // secure IM is disabled ... + return returnError(pccsd->hContact,Translate(sim105)); + } + if (ptr->cntx) { // if exist secure context + cpp_delete_context(ptr->cntx); ptr->cntx=0; + + CCSDATA ccsd; + memcpy(&ccsd, (HLOCAL)lParam, sizeof(CCSDATA)); + + pccsd->wParam |= PREF_METANODB; + ccsd.lParam = (LPARAM) SIG_DEIN; + ccsd.szProtoService = PSS_MESSAGE; + CallService(MS_PROTO_CHAINSEND, wParam, (LPARAM)&ccsd); + + showPopUpDC(pccsd->hContact); + ShowStatusIconNotify(pccsd->hContact); + } + return CallService(MS_PROTO_CHAINSEND, wParam, lParam); + } + + // contact is offline + if ( stat==ID_STATUS_OFFLINE ) { +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onSendMsg: message for offline"); +#endif + if ( ssig==SiG_INIT && cpp_keyx(ptr->cntx)) { + // reinit key exchange + cpp_reset_context(ptr->cntx); + } + + if ( !bSOM ) { + if ( ssig!=SiG_NONE ) { + return returnNoError(pccsd->hContact); + } + // exit and send unencrypted message + return CallService(MS_PROTO_CHAINSEND, wParam, lParam); + } + BOOL isMiranda = isClientMiranda(ptr->hContact); + + if ( stid==STATUS_ALWAYSTRY && isMiranda ) { // always try && Miranda + // set key for offline user + DBVARIANT dbv; dbv.type = DBVT_BLOB; + if ( DBGetContactSettingDword(ptr->hContact, szModuleName, "offlineKeyTimeout", 0) > gettime() && + DBGetContactSetting(ptr->hContact, szModuleName, "offlineKey", &dbv) == 0 + ) { + // if valid key is succefully retrieved + ptr->offlineKey = true; + InitKeyX(ptr,dbv.pbVal); + DBFreeVariant(&dbv); + } + else { + DBDeleteContactSetting(ptr->hContact,szModuleName,"offlineKey"); + DBDeleteContactSetting(ptr->hContact,szModuleName,"offlineKeyTimeout"); + if (msgbox1(0,sim106,szModuleName,MB_YESNO|MB_ICONQUESTION)==IDNO) { + return returnNoError(pccsd->hContact); + } + // exit and send unencrypted message + return CallService(MS_PROTO_CHAINSEND, wParam, lParam); + } + } + else { +/* if (stid==STATUS_ALWAYSTRY && !isMiranda || stid!=STATUS_ALWAYSTRY && isMiranda) { + int res=msgbox1(0,"User is offline now, Do you want to send your message ?\nIt will be unencrypted !","Can't Send Encrypted Message !",MB_YESNO); + if (res==IDNO) return 1; + }*/ + if ( ssig!=SiG_NONE ) { + return returnNoError(pccsd->hContact); + } + // exit and send unencrypted message + return CallService(MS_PROTO_CHAINSEND, wParam, lParam); + } + + } + else { +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onSendMsg: message for online"); +#endif + // contact is online and we use an offline key -> reset offline key + if ( ptr->offlineKey ) { + cpp_reset_context(ptr->cntx); + ptr->offlineKey = false; + ShowStatusIconNotify(ptr->hContact); + } + } + + // if init is called from contact menu list reinit secure im connection + if ( ssig==SiG_INIT ) { +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onSendMsg: SiG_INIT"); +#endif + cpp_reset_context(ptr->cntx); + } + + // if deinit is called from contact menu list deinit secure im connection + if ( ssig==SiG_DEIN ) { +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onSendMsg: SiG_DEIN"); +#endif + // disable SecureIM only if it was enabled + if (ptr->cntx) { + cpp_delete_context(ptr->cntx); ptr->cntx=0; + + pccsd->wParam |= PREF_METANODB; + CallService(MS_PROTO_CHAINSEND, wParam, lParam); + + showPopUpDC(pccsd->hContact); + ShowStatusIconNotify(pccsd->hContact); + } + return returnNoError(pccsd->hContact); + } + + if ( cpp_keya(ptr->cntx) && cpp_keyb(ptr->cntx) && !cpp_keyx(ptr->cntx)) + CalculateKeyX(ptr,ptr->hContact); + + ShowStatusIconNotify(pccsd->hContact); + + // if cryptokey exist + if ( cpp_keyx(ptr->cntx)) { +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onSendMsg: cryptokey exist"); +#endif +/* if ( !hMetaContact && isProtoMetaContacts(pccsd->hContact) && (DBGetContactSettingByte(NULL, "MetaContacts", "SubcontactHistory", 1) == 1)) { + // add sent event to subcontact + DBEVENTINFO dbei; HANDLE hC = getMostOnline(pccsd->hContact); + ZeroMemory(&dbei, sizeof(dbei)); + dbei.cbSize = sizeof(dbei); + dbei.szModule = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hC, 0); + dbei.flags = DBEF_SENT; + dbei.timestamp = time(NULL); + dbei.eventType = EVENTTYPE_MESSAGE; + if(pccsd->wParam & PREF_RTL) dbei.flags |= DBEF_RTL; + if(pccsd->wParam & PREF_UTF) dbei.flags |= DBEF_UTF; + dbei.cbBlob = strlen((char *)pccsd->lParam) + 1; + if ( pccsd->wParam & PREF_UNICODE ) + dbei.cbBlob *= ( sizeof( wchar_t )+1 ); + dbei.pBlob = (PBYTE)pccsd->lParam; + + CallService(MS_DB_EVENT_ADD, (WPARAM)hC, (LPARAM)&dbei); + } */ + + LPSTR szNewMsg = encodeMsg(ptr,(LPARAM)pccsd); + +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onSend: encrypted msg '%s'",szNewMsg); +#endif + + pccsd->wParam |= PREF_METANODB; + pccsd->lParam = (LPARAM) szNewMsg; + pccsd->szProtoService = PSS_MESSAGE; + int ret = CallService(MS_PROTO_CHAINSEND, wParam, lParam); + + mir_free(szNewMsg); + + showPopUpSM(ptr->hContact); + + return ret; + } + else { +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onSendMsg: cryptokey not exist, try establishe connection"); +#endif + // send KeyA if init || always_try || waitkey || always_if_possible + if ( ssig==SiG_INIT || (stid==STATUS_ALWAYSTRY && isClientMiranda(ptr->hContact)) || isSecureIM(ptr->hContact) || ptr->waitForExchange ) { + if (ssig==SiG_NONE) { + addMsg2Queue(ptr, pccsd->wParam, (LPSTR)pccsd->lParam); + } + if ( !ptr->waitForExchange ) { + // init || always_try || always_if_possible + LPSTR keyToSend = InitKeyA(ptr,0); // calculate public and private key & fill KeyA +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("Sending KEY3: %s", keyToSend); +#endif + pccsd->wParam &= ~PREF_UNICODE; + pccsd->wParam |= PREF_METANODB; + pccsd->lParam = (LPARAM) keyToSend; + pccsd->szProtoService = PSS_MESSAGE; + CallService(MS_PROTO_CHAINSEND, wParam, lParam); + mir_free(keyToSend); + + showPopUpKS(pccsd->hContact); + ShowStatusIconNotify(pccsd->hContact); + + waitForExchange(ptr); // запускаем ожидание + } + return returnNoError(pccsd->hContact); + } +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("onSendMsg: pass unchanged to chain"); +#endif + return CallService(MS_PROTO_CHAINSEND, wParam, lParam); + } +} + + +int file_idx = 0; + +INT_PTR __cdecl onSendFile(WPARAM wParam, LPARAM lParam) { + + CCSDATA *pccsd=(CCSDATA*)lParam; + + pUinKey ptr = getUinKey(pccsd->hContact); + if (!ptr || !bSFT) return CallService(PSS_FILE, wParam, lParam); + + if ( isContactSecured(pccsd->hContact)&SECURED ) { + + char **file=(char **)pccsd->lParam; + if(file_idx==100) file_idx=0; + int i; + for(i=0;file[i];i++) { + + if (strstr(file[i],".AESHELL")) continue; + + char *name = strrchr(file[i],'\\'); + if ( !name ) name = file[i]; + else name++; + + char *file_out = (char*) mir_alloc(TEMP_SIZE+strlen(name)+20); + sprintf(file_out,"%s\\%s.AESHELL(%d)",TEMP,name,file_idx++); + + char buf[MAX_PATH]; + sprintf(buf,"%s\n%s",Translate(sim011),file[i]); + showPopUp(buf,NULL,g_hPOP[POP_PU_MSS],2); + + if ( ptr->mode==MODE_RSAAES ) { + exp->rsa_encrypt_file(ptr->cntx,file[i],file_out); + } + else { + cpp_encrypt_file(ptr->cntx,file[i],file_out); + } + + mir_free(file[i]); + file[i]=file_out; + } + if ( ptr->fileSend ) { // очистим сохраненный список + for(int j=0;ptr->fileSend[j];j++) { + mir_free(ptr->fileSend[j]); + } + SAFE_FREE(ptr->fileSend); + } + if ( i ) { // скопируем новый список + ptr->fileSend = (char **) mir_alloc(sizeof(char*)*(i+1)); + for(i=0;file[i];i++) { + ptr->fileSend[i] = mir_strdup(file[i]); + } + ptr->fileSend[i] = NULL; + } + } + return CallService(PSS_FILE, wParam, lParam); +} + + +/* +typedef struct { + size_t cbSize; + HANDLE hContact; + int sending; //true if sending, false if receiving + char **files; + int totalFiles; + int currentFileNumber; + unsigned long totalBytes; + unsigned long totalProgress; + char *workingDir; + char *currentFile; + unsigned long currentFileSize; + unsigned long currentFileProgress; + unsigned long currentFileTime; //as seconds since 1970 +} PROTOFILETRANSFERSTATUS; +*/ + +int __cdecl onProtoAck(WPARAM wParam,LPARAM lParam) { + + ACKDATA *ack=(ACKDATA*)lParam; + if (ack->type!=ACKTYPE_FILE) return 0; //quit if not file transfer event + PROTOFILETRANSFERSTATUS *f = (PROTOFILETRANSFERSTATUS*) ack->lParam; + + pUinKey ptr = getUinKey(ack->hContact); + if (!ptr || (f && (f->flags & PFTS_SENDING) && !bSFT)) return 0; + + if ( isContactSecured(ack->hContact)&SECURED ) { + switch(ack->result) { +// case ACKRESULT_FILERESUME: + case ACKRESULT_DATA: { + if ( !( f->flags & PFTS_SENDING )) { + ptr->finFileRecv = (f->currentFileSize == f->currentFileProgress); + if ( !ptr->lastFileRecv ) ptr->lastFileRecv = mir_strdup(f->szCurrentFile); + } + else + if ( f->flags & PFTS_SENDING ) { + ptr->finFileSend = (f->currentFileSize == f->currentFileProgress); + if ( !ptr->lastFileSend ) ptr->lastFileSend = mir_strdup(f->szCurrentFile); + } + } break; +// case ACKRESULT_INITIALISING: + case ACKRESULT_DENIED: + case ACKRESULT_FAILED: { + if ( ptr->lastFileRecv ) { + if (strstr(ptr->lastFileRecv,".AESHELL")) mir_unlink(ptr->lastFileRecv); + SAFE_FREE(ptr->lastFileRecv); + } + if ( ptr->lastFileSend ) { + if (strstr(ptr->lastFileSend,".AESHELL")) mir_unlink(ptr->lastFileSend); + SAFE_FREE(ptr->lastFileSend); + } + if ( ptr->fileSend ) { + char **file=ptr->fileSend; + for(int j=0;file[j];j++) { + if ( strstr(file[j],".AESHELL")) mir_unlink(file[j]); + mir_free(file[j]); + } + SAFE_FREE(ptr->fileSend); + } + return 0; + } break; + case ACKRESULT_NEXTFILE: + case ACKRESULT_SUCCESS: { + if ( ptr->finFileRecv && ptr->lastFileRecv ) { + if ( strstr(ptr->lastFileRecv,".AESHELL")) { + char buf[MAX_PATH]; + LPSTR file_out=mir_strdup(ptr->lastFileRecv); + LPSTR pos=strrchr(file_out,'.'); //find last . + if (pos) *pos='\0'; //remove AESHELL from name + + if ( isFileExist(file_out)) { + buf[0]='\0'; + LPSTR p=strrchr(file_out,'.'); + LPSTR x=strrchr(file_out,'\\'); + if(p>x) { + strcpy(buf,p); + pos=p; + } + for(int i=1;i<10000;i++) { + sprintf(pos," (%d)%s",i,buf); + if ( !isFileExist(file_out)) break; + } + } + + sprintf(buf,"%s\n%s",Translate(sim012),file_out); + showPopUp(buf,NULL,g_hPOP[POP_PU_MSR],2); + + if ( ptr->mode==MODE_RSAAES ) { + exp->rsa_decrypt_file(ptr->cntx,ptr->lastFileRecv,file_out); + } + else { + cpp_decrypt_file(ptr->cntx,ptr->lastFileRecv,file_out); + } + mir_free(file_out); + mir_unlink(ptr->lastFileRecv); + } + SAFE_FREE(ptr->lastFileRecv); + ptr->finFileRecv = false; + } + if ( ptr->finFileSend && ptr->lastFileSend ) { + if ( strstr(ptr->lastFileSend,".AESHELL")) mir_unlink(ptr->lastFileSend); + SAFE_FREE(ptr->lastFileSend); + ptr->finFileSend = false; + } + } break; + } // switch + } + return 0; +} + + +// EOF diff --git a/plugins/SecureIM/src/svcs_proto.h b/plugins/SecureIM/src/svcs_proto.h new file mode 100644 index 0000000000..64ce1c43a3 --- /dev/null +++ b/plugins/SecureIM/src/svcs_proto.h @@ -0,0 +1,14 @@ +#ifndef __SVCS_PROTO_H__ +#define __SVCS_PROTO_H__ + +#include + +INT_PTR __cdecl onRecvMsg(WPARAM,LPARAM); +INT_PTR __cdecl onSendMsgW(WPARAM,LPARAM); +INT_PTR __cdecl onSendMsg(WPARAM,LPARAM); +INT_PTR __cdecl onSendFile(WPARAM,LPARAM); + +int __cdecl onProtoAck(WPARAM,LPARAM); +int __cdecl onContactSettingChanged(WPARAM,LPARAM); + +#endif diff --git a/plugins/SecureIM/src/svcs_rsa.cpp b/plugins/SecureIM/src/svcs_rsa.cpp new file mode 100644 index 0000000000..e72221dc91 --- /dev/null +++ b/plugins/SecureIM/src/svcs_rsa.cpp @@ -0,0 +1,226 @@ +#include "commonheaders.h" + + +pRSA_EXPORT exp = NULL; +RSA_IMPORT imp = { + rsa_inject, + rsa_check_pub, + rsa_notify +}; + +BOOL rsa_4096=0; + + +int __cdecl rsa_inject(HANDLE context, LPCSTR msg) { + pUinKey ptr = getUinCtx(context); if (!ptr) return 0; +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("rsa_inject: '%s'", msg); +#endif + int len = (int)strlen(msg)+1; + LPSTR buf = (LPSTR) mir_alloc(LEN_SECU+len); + memcpy(buf,SIG_SECU,LEN_SECU); + memcpy(buf+LEN_SECU,msg,len); + // отправляем сообщение + splitMessageSend(ptr,buf); + mir_free(buf); + return 1; +} + + +#define MSGSIZE 1024 + +int __cdecl rsa_check_pub(HANDLE context, PBYTE pub, int pubLen, PBYTE sig, int sigLen) { + int v=0, k=0; + pUinKey ptr = getUinCtx(context); if (!ptr) return 0; + LPSTR cnm = (LPSTR) mir_alloc(NAMSIZE); getContactNameA(ptr->hContact,cnm); + LPSTR uin = (LPSTR) mir_alloc(KEYSIZE); getContactUinA(ptr->hContact,uin); + LPSTR msg = (LPSTR) mir_alloc(MSGSIZE); + LPSTR sha = mir_strdup(to_hex(sig,sigLen)); + LPSTR sha_old = NULL; +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("rsa_check_pub: %s %s %s", cnm, uin, sha); +#endif + DBVARIANT dbv; + dbv.type = DBVT_BLOB; + if ( DBGetContactSetting(ptr->hContact,szModuleName,"rsa_pub",&dbv) == 0 ) { + k = 1; + PBYTE buf = (PBYTE) alloca(sigLen); int len; + exp->rsa_get_hash((PBYTE)dbv.pbVal,dbv.cpbVal,(PBYTE)buf,&len); + sha_old = mir_strdup(to_hex(buf,len)); + DBFreeVariant(&dbv); + } + if ( bAAK ) { + if ( k ) mir_snprintf(msg,MSGSIZE,Translate(sim523),cnm,uin,sha,sha_old); + else mir_snprintf(msg,MSGSIZE,Translate(sim521),cnm,uin,sha); + showPopUpKRmsg(ptr->hContact,msg); + HistoryLog(ptr->hContact,msg); + v = 1; +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("rsa_check_pub: auto accepted"); +#endif + } + else { + if ( k ) mir_snprintf(msg,MSGSIZE,Translate(sim522),cnm,sha,sha_old); + else mir_snprintf(msg,MSGSIZE,Translate(sim520),cnm,sha); + v = (msgbox(0,msg,szModuleName,MB_YESNO|MB_ICONQUESTION)==IDYES); +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("rsa_check_pub: manual accepted %d",v); +#endif + } + if(v) { + DBCONTACTWRITESETTING cws; + cws.szModule = szModuleName; + cws.szSetting = "rsa_pub"; + cws.value.type = DBVT_BLOB; + cws.value.pbVal = pub; + cws.value.cpbVal = pubLen; + CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)ptr->hContact, (LPARAM)&cws); + ptr->keyLoaded = true; + } + mir_free(cnm); + mir_free(uin); + mir_free(msg); + mir_free(sha); + SAFE_FREE(sha_old); + return v; +} + + +void __cdecl rsa_notify(HANDLE context, int state) { + pUinKey ptr = getUinCtx(context); if (!ptr) return; + LPCSTR msg=NULL; +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("rsa_notify: 0x%x", state); +#endif + switch( state ) { + case 1: { + showPopUpEC(ptr->hContact); + ShowStatusIconNotify(ptr->hContact); + waitForExchange(ptr,2); // досылаем сообщения из очереди + return; + } + case -1: // сессия разорвана по ошибке, неверный тип сообщения + msg=sim501; break; + case -2: // сессия разорвана по ошибке другой стороной + msg=sim502; break; + case -5: // ошибка декодирования AES сообщения + msg=sim505; break; + case -6: // ошибка декодирования RSA сообщения + msg=sim506; break; + case -7: // таймаут установки соединения (10 секунд) + msg=sim507; break; + case -8: { // сессия разорвана по причине "disabled" + msg=sim508; +// ptr->status=ptr->tstatus=STATUS_DISABLED; +// DBWriteContactSettingByte(ptr->hContact, szModuleName, "StatusID", ptr->status); + } break; + case -0x10: // сессия разорвана по ошибке + case -0x21: + case -0x22: + case -0x23: + case -0x24: + case -0x32: + case -0x33: + case -0x34: + case -0x40: + case -0x50: + case -0x60: { + char buf[1024]; + sprintf(buf,sim510,-state); + showPopUpDCmsg(ptr->hContact,buf); + ShowStatusIconNotify(ptr->hContact); + if(ptr->cntx) deleteRSAcntx(ptr); + waitForExchange(ptr,3); // досылаем нешифровано + return; + } + case -3: // соединение разорвано вручную + case -4: { // соединение разорвано вручную другой стороной + showPopUpDC(ptr->hContact); + ShowStatusIconNotify(ptr->hContact); + if(ptr->cntx) deleteRSAcntx(ptr); + waitForExchange(ptr,3); // досылаем нешифровано + return; + } + default: + return; + } + showPopUpDCmsg(ptr->hContact,msg); + ShowStatusIconNotify(ptr->hContact); + if(ptr->cntx) deleteRSAcntx(ptr); + waitForExchange(ptr,3); // досылаем нешифровано +} + + +unsigned __stdcall sttGenerateRSA( LPVOID param ) { + + char priv_key[4096]; int priv_len; + char pub_key[4096]; int pub_len; + + exp->rsa_gen_keypair(CPP_MODE_RSA_4096); + + DBCONTACTWRITESETTING cws; + cws.szModule = szModuleName; + cws.value.type = DBVT_BLOB; + + exp->rsa_get_keypair(CPP_MODE_RSA_4096,(PBYTE)&priv_key,&priv_len,(PBYTE)&pub_key,&pub_len); + + cws.szSetting = "rsa_priv"; + cws.value.pbVal = (PBYTE)&priv_key; + cws.value.cpbVal = priv_len; + CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)0, (LPARAM)&cws); + + cws.szSetting = "rsa_pub"; + cws.value.pbVal = (PBYTE)&pub_key; + cws.value.cpbVal = pub_len; + CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)0, (LPARAM)&cws); + + rsa_4096=1; + + return 0; +} + + +// загружает паблик-ключ в RSA контекст +BYTE loadRSAkey(pUinKey ptr) { + if ( !ptr->keyLoaded ) { + DBVARIANT dbv; + dbv.type = DBVT_BLOB; + if ( DBGetContactSetting(ptr->hContact,szModuleName,"rsa_pub",&dbv) == 0 ) { + ptr->keyLoaded = exp->rsa_set_pubkey(ptr->cntx,dbv.pbVal,dbv.cpbVal); +#if defined(_DEBUG) || defined(NETLIB_LOG) + Sent_NetLog("loadRSAkey %d", ptr->keyLoaded); +#endif + DBFreeVariant(&dbv); + } + } + return ptr->keyLoaded; +} + +// создает RSA контекст +void createRSAcntx(pUinKey ptr) { + if ( !ptr->cntx ) { + ptr->cntx = cpp_create_context(CPP_MODE_RSA); + ptr->keyLoaded = 0; + } +} + + +// пересоздает RSA контекст +void resetRSAcntx(pUinKey ptr) { + if ( ptr->cntx ) { + cpp_delete_context(ptr->cntx); + ptr->cntx = cpp_create_context(CPP_MODE_RSA); + ptr->keyLoaded = 0; + } +} + + +// удаляет RSA контекст +void deleteRSAcntx(pUinKey ptr) { + cpp_delete_context(ptr->cntx); + ptr->cntx = 0; + ptr->keyLoaded = 0; +} + + +// EOF diff --git a/plugins/SecureIM/src/svcs_rsa.h b/plugins/SecureIM/src/svcs_rsa.h new file mode 100644 index 0000000000..3f43e71d30 --- /dev/null +++ b/plugins/SecureIM/src/svcs_rsa.h @@ -0,0 +1,20 @@ +#ifndef __SVCS_RSA_H__ +#define __SVCS_RSA_H__ + +#include + +extern pRSA_EXPORT exp; +extern RSA_IMPORT imp; +extern BOOL rsa_4096; + +int __cdecl rsa_inject(HANDLE,LPCSTR); +int __cdecl rsa_check_pub(HANDLE,PBYTE,int,PBYTE,int); +void __cdecl rsa_notify(HANDLE,int); + +unsigned __stdcall sttGenerateRSA(LPVOID); +BYTE loadRSAkey(pUinKey); +void createRSAcntx(pUinKey); +void resetRSAcntx(pUinKey); +void deleteRSAcntx(pUinKey); + +#endif diff --git a/plugins/SecureIM/src/svcs_srmm.cpp b/plugins/SecureIM/src/svcs_srmm.cpp new file mode 100644 index 0000000000..688246847e --- /dev/null +++ b/plugins/SecureIM/src/svcs_srmm.cpp @@ -0,0 +1,37 @@ +#include "commonheaders.h" + + +int __cdecl onWindowEvent(WPARAM wParam, LPARAM lParam) { + + MessageWindowEventData *mwd = (MessageWindowEventData *)lParam; + if(mwd->uType == MSG_WINDOW_EVT_OPEN || mwd->uType == MSG_WINDOW_EVT_OPENING) { + ShowStatusIcon(mwd->hContact); + } + return 0; +} + + +int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam) { + HANDLE hContact = (HANDLE)wParam; + if ( isProtoMetaContacts(hContact)) + hContact = getMostOnline(hContact); // возьмем тот, через который пойдет сообщение + + StatusIconClickData *sicd = (StatusIconClickData *)lParam; + if ( strcmp(sicd->szModule, szModuleName) != 0 || + !isSecureProtocol(hContact)) return 0; // not our event + + BOOL isPGP = isContactPGP(hContact); + BOOL isGPG = isContactGPG(hContact); + BOOL isSecured = isContactSecured(hContact)&SECURED; + BOOL isChat = isChatRoom(hContact); + + if ( !isPGP && !isGPG && !isChat ) { + if(isSecured) Service_DisableIM(wParam,0); + else Service_CreateIM(wParam,0); + } + + return 0; +} + + +// EOF diff --git a/plugins/SecureIM/src/svcs_srmm.h b/plugins/SecureIM/src/svcs_srmm.h new file mode 100644 index 0000000000..d64c89ab4e --- /dev/null +++ b/plugins/SecureIM/src/svcs_srmm.h @@ -0,0 +1,9 @@ +#ifndef __SVCS_SRMM_H__ +#define __SVCS_SRMM_H__ + +#include + +int __cdecl onWindowEvent(WPARAM,LPARAM); +int __cdecl onIconPressed(WPARAM,LPARAM); + +#endif diff --git a/plugins/SecureIM/src/version.h b/plugins/SecureIM/src/version.h new file mode 100644 index 0000000000..22b458eac8 --- /dev/null +++ b/plugins/SecureIM/src/version.h @@ -0,0 +1,16 @@ +#ifndef __VERSION_H_INCLUDED +#define __VERSION_H_INCLUDED + +#define __MAJOR_VERSION 1 +#define __MINOR_VERSION 0 +#define __RELEASE_NUM 12 +#define __BUILD_NUM 4 + +#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM +#define __FILEVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM +#define __STRINGIFY(x) #x +#define __TOSTRING(x) __STRINGIFY(x) +#define __VERSION_STRING __TOSTRING(__FILEVERSION_STRING_DOTS) +#define __VERSION_DWORD ((__MAJOR_VERSION<<24) | (__MINOR_VERSION<<16) | (__RELEASE_NUM<<8) | __BUILD_NUM) + +#endif //__VERSION_H_INCLUDED diff --git a/plugins/SecureIM/svcs_clist.cpp b/plugins/SecureIM/svcs_clist.cpp deleted file mode 100644 index 12402a58be..0000000000 --- a/plugins/SecureIM/svcs_clist.cpp +++ /dev/null @@ -1,224 +0,0 @@ -#include "commonheaders.h" - - -int __cdecl onContactSettingChanged(WPARAM wParam,LPARAM lParam) { - - HANDLE hContact = (HANDLE)wParam; - DBCONTACTWRITESETTING *cws=(DBCONTACTWRITESETTING*)lParam; - if (!hContact || strcmp(cws->szSetting,"Status")) return 0; - - pUinKey ptr = getUinKey(hContact); - int stat = getContactStatus(hContact); - if (!ptr || stat==-1) return 0; - -// HANDLE hMetaContact = getMetaContact(hContact); -// if(hMetaContact) { -// ptr = getUinKey(hMetaContact); -// if (!ptr) return 0; -// } - - if (stat==ID_STATUS_OFFLINE) { // go offline - if (ptr->mode==MODE_NATIVE && cpp_keyx(ptr->cntx)) { // have active context - cpp_delete_context(ptr->cntx); ptr->cntx=0; // reset context -// if(hMetaContact) { // is subcontact of metacontact -// showPopUpDC(hMetaContact); -// ShowStatusIconNotify(hMetaContact); -// if(getMostOnline(hMetaContact)) { // make handover -// CallContactService(hMetaContact,PSS_MESSAGE,0,(LPARAM)SIG_INIT); -// } -// } -// else { // is contact or metacontact (not subcontact) - showPopUpDC(hContact); // show popup "Disabled" - ShowStatusIconNotify(hContact); // change icon in CL -// } - } - else - if (ptr->mode==MODE_RSAAES && exp->rsa_get_state(ptr->cntx)==7) { - deleteRSAcntx(ptr); -// if(hMetaContact) { // is subcontact of metacontact -// showPopUpDC(hMetaContact); -// ShowStatusIconNotify(hMetaContact); -// if(getMostOnline(hMetaContact)) { // make handover -// CallContactService(hMetaContact,PSS_MESSAGE,0,(LPARAM)SIG_INIT); -// } -// } -// else { // is contact or metacontact (not subcontact) - showPopUpDC(hContact); // show popup "Disabled" - ShowStatusIconNotify(hContact); // change icon in CL -// } - } - } - else { // go not offline -// if (!hMetaContact) { // is contact or metacontact (not subcontact) - if (ptr->offlineKey) { - cpp_reset_context(ptr->cntx); - ptr->offlineKey = false; - } - ShowStatusIconNotify(hContact); // change icon in CL -// } - } - return 0; -} - - -// wParam=(WPARAM)(HANDLE)hContact -// lParam=0 -int __cdecl onContactAdded(WPARAM wParam,LPARAM lParam) { - addContact((HANDLE)wParam); - return 0; -} - - -// wParam=(WPARAM)(HANDLE)hContact -// lParam=0 -int __cdecl onContactDeleted(WPARAM wParam,LPARAM lParam) { - delContact((HANDLE)wParam); - return 0; -} - - -int __cdecl onExtraImageListRebuilding(WPARAM, LPARAM) { - -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onExtraImageListRebuilding"); -#endif - if ( (bADV || g_hCLIcon) && ServiceExists(MS_CLIST_EXTRA_ADD_ICON)) { - RefreshContactListIcons(); - } - return 0; -} - - -int __cdecl onExtraImageApplying(WPARAM wParam, LPARAM) { - - if ( (bADV || g_hCLIcon) && ServiceExists(MS_CLIST_EXTRA_SET_ICON) && isSecureProtocol((HANDLE)wParam)) { - IconExtraColumn iec = mode2iec(isContactSecured((HANDLE)wParam)); - if ( g_hCLIcon ) { - ExtraIcon_SetIcon(g_hCLIcon, (HANDLE)wParam, iec.hImage); - } - else { - CallService(MS_CLIST_EXTRA_SET_ICON, wParam, (LPARAM)&iec); - } - } - return 0; -} - - -int __cdecl onRebuildContactMenu(WPARAM wParam,LPARAM lParam) { - -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onRebuildContactMenu"); -#endif - HANDLE hContact = (HANDLE)wParam; - BOOL bMC = isProtoMetaContacts(hContact); - if ( bMC ) hContact = getMostOnline(hContact); // возьмем тот, через который пойдет сообщение - pUinKey ptr = getUinKey(hContact); - int i; - - CLISTMENUITEM mi; - memset(&mi,0,sizeof(mi)); - mi.cbSize = sizeof(CLISTMENUITEM); - - ShowStatusIconNotify(hContact); - - // check offline/online - if (!ptr) { - // hide menu bars - mi.flags = CMIM_FLAGS | CMIF_NOTOFFLINE | CMIF_HIDDEN; - for(i=0;imode==MODE_NATIVE || ptr->mode==MODE_RSAAES)) { - // Native/RSAAES - mi.flags = CMIM_FLAGS | CMIF_NOTOFFLINE | CMIM_ICON; - if ( !isSecured ) { - // create secureim connection - mi.hIcon = mode2icon(ptr->mode|SECURED,2); - CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)g_hMenu[0],(LPARAM)&mi); - } - else { - // disable secureim connection - mi.hIcon = mode2icon(ptr->mode,2); - CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)g_hMenu[1],(LPARAM)&mi); - } - // set status menu - if ( bSCM && !bMC && - ( !isSecured || ptr->mode==MODE_PGP || ptr->mode==MODE_GPG )) { - - mi.flags = CMIM_FLAGS | CMIM_NAME | CMIM_ICON; - mi.hIcon = g_hICO[ICO_ST_DIS+ptr->status]; - mi.pszName = (LPSTR)sim312[ptr->status]; - CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)g_hMenu[2],(LPARAM)&mi); - - mi.flags = CMIM_FLAGS | CMIM_ICON; - for(i=0;i<=(ptr->mode==MODE_RSAAES?1:2);i++) { - mi.hIcon = (i == ptr->status) ? g_hICO[ICO_ST_DIS+ptr->status] : NULL; - CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)g_hMenu[3+i],(LPARAM)&mi); - } - } - } - else - if ( isSecureProto && !isChat && (ptr->mode==MODE_PGP || ptr->mode==MODE_GPG)) { - // PGP, GPG - if ( ptr->mode==MODE_PGP && bPGPloaded ) { - if ((bPGPkeyrings || bPGPprivkey) && !isGPG) { - mi.flags = CMIM_FLAGS; - CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)g_hMenu[isPGP+6],(LPARAM)&mi); - } - } - if ( ptr->mode==MODE_GPG && bGPGloaded ) { - if(bGPGkeyrings && !isPGP) { - mi.flags = CMIM_FLAGS; - CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)g_hMenu[isGPG+8],(LPARAM)&mi); - } - } - } - if ( isSecureProto && !isChat && isMiranda ) { - // set mode menu - if ( bMCM && !bMC && - ( !isSecured || ptr->mode==MODE_PGP || ptr->mode==MODE_GPG )) { - - mi.flags = CMIM_FLAGS | CMIM_NAME | CMIM_ICON; - mi.hIcon = g_hICO[ICO_OV_NAT+ptr->mode]; - mi.pszName = (LPSTR)sim311[ptr->mode]; - CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)g_hMenu[10],(LPARAM)&mi); - - mi.flags = CMIM_FLAGS | CMIM_ICON; - for(i=0;imode!=MODE_PGP && !bPGP ) continue; - if ( i==MODE_GPG && ptr->mode!=MODE_GPG && !bGPG ) continue; - mi.hIcon = (i == ptr->mode) ? g_hICO[ICO_ST_ENA] : NULL; - CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)g_hMenu[11+i],(LPARAM)&mi); - } - } - } - - return 0; -} - - -// EOF diff --git a/plugins/SecureIM/svcs_clist.h b/plugins/SecureIM/svcs_clist.h deleted file mode 100644 index 8c2dd192b6..0000000000 --- a/plugins/SecureIM/svcs_clist.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef __SVCS_CLIST_H__ -#define __SVCS_CLIST_H__ - -#include - -int __cdecl onContactSettingChanged(WPARAM,LPARAM); -int __cdecl onContactAdded(WPARAM,LPARAM); -int __cdecl onContactDeleted(WPARAM,LPARAM); -int __cdecl onExtraImageListRebuilding(WPARAM,LPARAM); -int __cdecl onExtraImageApplying(WPARAM,LPARAM); -int __cdecl onRebuildContactMenu(WPARAM,LPARAM); - -#endif diff --git a/plugins/SecureIM/svcs_menu.cpp b/plugins/SecureIM/svcs_menu.cpp deleted file mode 100644 index 310d367e1b..0000000000 --- a/plugins/SecureIM/svcs_menu.cpp +++ /dev/null @@ -1,232 +0,0 @@ -#include "commonheaders.h" - - -INT_PTR __cdecl Service_IsContactSecured(WPARAM wParam, LPARAM lParam) { - - return (isContactSecured((HANDLE)wParam)&SECURED) || isContactPGP((HANDLE)wParam) || isContactGPG((HANDLE)wParam); -} - - -INT_PTR __cdecl Service_CreateIM(WPARAM wParam,LPARAM lParam){ - if (!CallService(MS_PROTO_ISPROTOONCONTACT, (WPARAM)wParam, (LPARAM)szModuleName)) - CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)wParam, (LPARAM)szModuleName); -// WPARAM flags = 0; -// HANDLE hMetaContact = getMetaContact((HANDLE)wParam); -// if ( hMetaContact ) { -// wParam = (WPARAM)hMetaContact; -// flags = PREF_METANODB; -// } - CallContactService((HANDLE)wParam,PSS_MESSAGE,(WPARAM)PREF_METANODB,(LPARAM)SIG_INIT); - return 1; -} - - -INT_PTR __cdecl Service_DisableIM(WPARAM wParam,LPARAM lParam) { -// WPARAM flags = 0; -// HANDLE hMetaContact = getMetaContact((HANDLE)wParam); -// if ( hMetaContact ) { -// wParam = (WPARAM)hMetaContact; -// flags = PREF_METANODB; -// } - CallContactService((HANDLE)wParam,PSS_MESSAGE,(WPARAM)PREF_METANODB,(LPARAM)SIG_DEIN); - return 1; -} - - -INT_PTR __cdecl Service_Status(WPARAM wParam, LPARAM lParam) { - - switch(--lParam) { - case STATUS_DISABLED: - case STATUS_ENABLED: - case STATUS_ALWAYSTRY: - pUinKey ptr = getUinKey((HANDLE)wParam); - if(ptr) { - ptr->status=ptr->tstatus=(BYTE)lParam; - if(ptr->status==STATUS_ENABLED) DBDeleteContactSetting(ptr->hContact, szModuleName, "StatusID"); - else DBWriteContactSettingByte(ptr->hContact, szModuleName, "StatusID", ptr->status); - } - break; - } - - return 1; -} - - -INT_PTR __cdecl Service_StatusDis(WPARAM wParam, LPARAM lParam) { - - return Service_Status(wParam,STATUS_DISABLED+1); -} - - -INT_PTR __cdecl Service_StatusEna(WPARAM wParam, LPARAM lParam) { - - return Service_Status(wParam,STATUS_ENABLED+1); -} - - -INT_PTR __cdecl Service_StatusTry(WPARAM wParam, LPARAM lParam) { - - return Service_Status(wParam,STATUS_ALWAYSTRY+1); -} - - -INT_PTR __cdecl Service_PGPdelKey(WPARAM wParam, LPARAM lParam) { - - if(bPGPloaded) { - DBDeleteContactSetting((HANDLE)wParam, szModuleName, "pgp"); - DBDeleteContactSetting((HANDLE)wParam, szModuleName, "pgp_mode"); - DBDeleteContactSetting((HANDLE)wParam, szModuleName, "pgp_abbr"); - } - { - pUinKey ptr = getUinKey((HANDLE)wParam); - cpp_delete_context(ptr->cntx); ptr->cntx=0; - } - ShowStatusIconNotify((HANDLE)wParam); - return 1; -} - - -INT_PTR __cdecl Service_PGPsetKey(WPARAM wParam, LPARAM lParam) { - - BOOL del = true; - if(bPGPloaded) { - if(bPGPkeyrings) { - char szKeyID[128]; szKeyID[0]='\0'; - PVOID KeyID = pgp_select_keyid(GetForegroundWindow(),szKeyID); - if(szKeyID[0]) { - DBDeleteContactSetting((HANDLE)wParam,szModuleName,"pgp"); - DBCONTACTWRITESETTING cws; - memset(&cws,0,sizeof(cws)); - cws.szModule = szModuleName; - cws.szSetting = "pgp"; - cws.value.type = DBVT_BLOB; - cws.value.pbVal = (LPBYTE)KeyID; - cws.value.cpbVal = pgp_size_keyid(); - CallService(MS_DB_CONTACT_WRITESETTING,wParam,(LPARAM)&cws); - DBWriteContactSettingByte((HANDLE)wParam,szModuleName,"pgp_mode",0); - DBWriteContactSettingString((HANDLE)wParam,szModuleName,"pgp_abbr",szKeyID); - del = false; - } - } - else - if(bPGPprivkey) { - char KeyPath[MAX_PATH]; KeyPath[0]='\0'; - if(ShowSelectKeyDlg(0,KeyPath)) { - char *publ = LoadKeys(KeyPath,false); - if(publ) { - DBDeleteContactSetting((HANDLE)wParam,szModuleName,"pgp"); - myDBWriteStringEncode((HANDLE)wParam,szModuleName,"pgp",publ); - DBWriteContactSettingByte((HANDLE)wParam,szModuleName,"pgp_mode",1); - DBWriteContactSettingString((HANDLE)wParam,szModuleName,"pgp_abbr","(binary)"); - mir_free(publ); - del = false; - } - } - } - } - - if(del) Service_PGPdelKey(wParam,lParam); - else { - pUinKey ptr = getUinKey((HANDLE)wParam); - cpp_delete_context(ptr->cntx); ptr->cntx=0; - } - ShowStatusIconNotify((HANDLE)wParam); - return 1; -} - - -INT_PTR __cdecl Service_GPGdelKey(WPARAM wParam, LPARAM lParam) { - - if(bGPGloaded) { - DBDeleteContactSetting((HANDLE)wParam, szModuleName, "gpg"); - } - { - pUinKey ptr = getUinKey((HANDLE)wParam); - cpp_delete_context(ptr->cntx); ptr->cntx=0; - } - ShowStatusIconNotify((HANDLE)wParam); - return 1; -} - - -INT_PTR __cdecl Service_GPGsetKey(WPARAM wParam, LPARAM lParam) { - - BOOL del = true; - if(bGPGloaded && bGPGkeyrings) { - char szKeyID[128]; szKeyID[0]='\0'; - gpg_select_keyid(GetForegroundWindow(),szKeyID); - if(szKeyID[0]) { - DBWriteContactSettingString((HANDLE)wParam,szModuleName,"gpg",szKeyID); - del = false; - } - } - - if(del) Service_GPGdelKey(wParam,lParam); - else { - pUinKey ptr = getUinKey((HANDLE)wParam); - cpp_delete_context(ptr->cntx); ptr->cntx=0; - } - ShowStatusIconNotify((HANDLE)wParam); - return 1; -} - - -INT_PTR __cdecl Service_Mode(WPARAM wParam, LPARAM lParam) { - - pUinKey ptr = getUinKey((HANDLE)wParam); - - switch(--lParam) { - case MODE_NATIVE: - case MODE_RSAAES: - if ( isContactSecured((HANDLE)wParam)&SECURED ) { - msgbox(NULL, sim111, szModuleName, MB_OK); - return 0; - } - if ( lParam!=MODE_NATIVE && ptr->status>STATUS_ENABLED ) { - Service_Status(wParam,STATUS_ENABLED+1); - } - case MODE_PGP: - case MODE_GPG: - // нужно много проверок и отключение активного контекста если необходимо - if(ptr) { - if ( ptr->cntx ) { - cpp_delete_context(ptr->cntx); - ptr->cntx = 0; - ptr->keyLoaded = 0; - } - ptr->mode=(BYTE)lParam; - DBWriteContactSettingByte((HANDLE)wParam, szModuleName, "mode", (BYTE)lParam); - } - ShowStatusIcon((HANDLE)wParam); - break; - } - - return 1; -} - - -INT_PTR __cdecl Service_ModeNative(WPARAM wParam, LPARAM lParam) { - - return Service_Mode(wParam,MODE_NATIVE+1); -} - - -INT_PTR __cdecl Service_ModePGP(WPARAM wParam, LPARAM lParam) { - - return Service_Mode(wParam,MODE_PGP+1); -} - - -INT_PTR __cdecl Service_ModeGPG(WPARAM wParam, LPARAM lParam) { - - return Service_Mode(wParam,MODE_GPG+1); -} - - -INT_PTR __cdecl Service_ModeRSAAES(WPARAM wParam, LPARAM lParam) { - - return Service_Mode(wParam,MODE_RSAAES+1); -} - - -// EOF diff --git a/plugins/SecureIM/svcs_menu.h b/plugins/SecureIM/svcs_menu.h deleted file mode 100644 index 69b079ebf7..0000000000 --- a/plugins/SecureIM/svcs_menu.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef __SVCS_MENU_H__ -#define __SVCS_MENU_H__ - -#include - -INT_PTR __cdecl Service_IsContactSecured(WPARAM,LPARAM); - -INT_PTR __cdecl Service_CreateIM(WPARAM,LPARAM); -INT_PTR __cdecl Service_DisableIM(WPARAM,LPARAM); - -INT_PTR __cdecl Service_StatusDis(WPARAM,LPARAM); -INT_PTR __cdecl Service_StatusEna(WPARAM,LPARAM); -INT_PTR __cdecl Service_StatusTry(WPARAM,LPARAM); - -INT_PTR __cdecl Service_PGPdelKey(WPARAM,LPARAM); -INT_PTR __cdecl Service_PGPsetKey(WPARAM,LPARAM); - -INT_PTR __cdecl Service_GPGdelKey(WPARAM,LPARAM); -INT_PTR __cdecl Service_GPGsetKey(WPARAM,LPARAM); - -INT_PTR __cdecl Service_ModeNative(WPARAM,LPARAM); -INT_PTR __cdecl Service_ModePGP(WPARAM,LPARAM); -INT_PTR __cdecl Service_ModeGPG(WPARAM,LPARAM); -INT_PTR __cdecl Service_ModeRSAAES(WPARAM,LPARAM); - -#endif diff --git a/plugins/SecureIM/svcs_popup.cpp b/plugins/SecureIM/svcs_popup.cpp deleted file mode 100644 index bb1eb88355..0000000000 --- a/plugins/SecureIM/svcs_popup.cpp +++ /dev/null @@ -1,115 +0,0 @@ -#include "commonheaders.h" - -/* -static int CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - switch(message) { - case WM_COMMAND: - if (wParam == STN_CLICKED) { // It was a click on the Popup. - PUDeletePopUp(hWnd); - return TRUE; - } - break; - case UM_FREEPLUGINDATA: { - return TRUE; //TRUE or FALSE is the same, it gets ignored. - } - default: - break; - } - return DefWindowProc(hWnd, message, wParam, lParam); -} -*/ - -void showPopupMsg(HANDLE hContact, LPCSTR lpzText, HICON hIcon, int type) { - - // type: - // 0 - error - // 1 - key sent - // 2 - key recv - // 3 - established - // 4 - disabled - // 5 - msg recv - // 6 - msg sent - // - - if (!bPopupExists) return; - - char nback[32]; mir_snprintf(nback,sizeof(nback),"popup%dback", $type); - char ntext[32]; mir_snprintf(ntext,sizeof(ntext),"popup%dtext", $type); - char ntime[32]; mir_snprintf(ntime,sizeof(ntime),"popup%dtime", $type); - - COLORREF colorBack = (COLORREF)DBGetContactSettingDword(0,szModuleName,nback,(DWORD)RGB(230,230,255)); - COLORREF colorText = (COLORREF)DBGetContactSettingDword(0,szModuleName,ntext,(DWORD)RGB(0,0,0)); - int timeout = (int)DBGetContactSettingWord(0,szModuleName,ntime,0); - - if ( bCoreUnicode && bPopupUnicode ) { - POPUPDATAW ppd; - memset(&ppd,0,sizeof(POPUPDATAW)); - ppd.lchContact = hContact; - ppd.lchIcon = hIcon; - LPWSTR lpwzContactName = (LPWSTR)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,GCMDF_UNICODE); - wcscpy(ppd.lpwzContactName, lpwzContactName); - LPWSTR lpwzText = mir_a2u(lpzText); - wcscpy(ppd.lpwzText, TranslateW(lpwzText)); - mir_free(lpwzText); - ppd.colorBack = colorBack; - ppd.colorText = colorText; - ppd.iSeconds = timeout; -// ppd.PluginWindowProc = (WNDPROC)PopupDlgProc; -// ppd.PluginData = NULL; - CallService(MS_POPUP_ADDPOPUPW, (WPARAM)&ppd, 0); - } - else { - POPUPDATAEX ppd; - memset(&ppd,0,sizeof(POPUPDATAEX)); - ppd.lchContact = hContact; - ppd.lchIcon = hIcon; - LPSTR lpzContactName = (LPSTR)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,0); - strcpy(ppd.lpzContactName, lpzContactName); - strcpy(ppd.lpzText, Translate(lpzText)); - ppd.colorBack = colorBack; - ppd.colorText = colorText; - ppd.iSeconds = timeout; -// ppd.PluginWindowProc = (WNDPROC)PopupDlgProc; -// ppd.PluginData = NULL; - CallService(MS_POPUP_ADDPOPUPEX, (WPARAM)&ppd, 0); - } -} - - -void showPopUpDCmsg(HANDLE hContact,LPCSTR msg) { - int indic=DBGetContactSettingByte(0, szModuleName, "dc",1); - if (indic==1) showPopUp(msg,hContact,g_hPOP[POP_PU_DIS],1); -} -void showPopUpDC(HANDLE hContact) { - int indic=DBGetContactSettingByte(0, szModuleName, "dc",1); - if (indic==1) showPopUp(sim006,hContact,g_hPOP[POP_PU_DIS],1); -} -void showPopUpEC(HANDLE hContact) { - int indic=DBGetContactSettingByte(0, szModuleName, "ec",1); - if (indic==1) showPopUp(sim001,hContact,g_hPOP[POP_PU_EST],1); -} -void showPopUpKS(HANDLE hContact) { - int indic=DBGetContactSettingByte(0, szModuleName, "ks",1); - if (indic==1) showPopUp(sim007,hContact,g_hPOP[POP_PU_PRC],0); -} -void showPopUpKRmsg(HANDLE hContact,LPCSTR msg) { - int indic=DBGetContactSettingByte(0, szModuleName, "kr",1); - if (indic==1) showPopUp(msg,hContact,g_hPOP[POP_PU_PRC],0); -} -void showPopUpKR(HANDLE hContact) { - int indic=DBGetContactSettingByte(0, szModuleName, "kr",1); - if (indic==1) showPopUp(sim008,hContact,g_hPOP[POP_PU_PRC],0); -} -void showPopUpSM(HANDLE hContact) { - int indic=DBGetContactSettingByte(0, szModuleName, "ss",0); - if (indic==1) showPopUp(sim009,hContact,g_hPOP[POP_PU_MSS],2); - SkinPlaySound("OutgoingSecureMessage"); -} -void showPopUpRM(HANDLE hContact) { - int indic=DBGetContactSettingByte(0, szModuleName, "sr",0); - if (indic==1) showPopUp(sim010,hContact,g_hPOP[POP_PU_MSR],2); - SkinPlaySound("IncomingSecureMessage"); -} - - -// EOF diff --git a/plugins/SecureIM/svcs_proto.cpp b/plugins/SecureIM/svcs_proto.cpp deleted file mode 100644 index ef8d6c850c..0000000000 --- a/plugins/SecureIM/svcs_proto.cpp +++ /dev/null @@ -1,1130 +0,0 @@ -#include "commonheaders.h" - - -// return SignID -int getSecureSig(LPCSTR szMsg, LPSTR *szPlainMsg=NULL) { - if(szPlainMsg) *szPlainMsg=(LPSTR)szMsg; - for(int i=0;signs[i].len;i++) { - if (memcmp(szMsg,signs[i].sig,signs[i].len)==0) { -/* for(int i=strlen(szMsg)-1;i;i--) { - if ( szMsg[i] == '\x0D' || szMsg[i] == '\x0A' ) - ((LPSTR)szMsg)[i] = '\0'; - else - break; - }*/ - if(szPlainMsg) *szPlainMsg = (LPSTR)(szMsg+signs[i].len); - if(signs[i].key==SiG_GAME && !bDGP) - return SiG_NONE; - return signs[i].key; - } - } - return SiG_NONE; -} - - -int returnNoError(HANDLE hContact) { - HANDLE hEvent = CreateEvent( NULL, TRUE, FALSE, NULL ); - unsigned int tID; - CloseHandle( (HANDLE) _beginthreadex(NULL, 0, sttFakeAck, new TFakeAckParams(hEvent,hContact,777,0), 0, &tID)); - SetEvent( hEvent ); - return 777; -} - - -int returnError(HANDLE hContact, LPCSTR err) { - HANDLE hEvent = CreateEvent( NULL, TRUE, FALSE, NULL ); - unsigned int tID; - CloseHandle( (HANDLE) _beginthreadex(NULL, 0, sttFakeAck, new TFakeAckParams(hEvent,hContact,666,err), 0, &tID)); - SetEvent( hEvent ); - return 666; -} - - -LPSTR szUnrtfMsg = NULL; - - -// RecvMsg handler -INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) { - - CCSDATA *pccsd = (CCSDATA *)lParam; - PROTORECVEVENT *ppre = (PROTORECVEVENT *)pccsd->lParam; - pUinKey ptr = getUinKey(pccsd->hContact); - LPSTR szEncMsg = ppre->szMessage, szPlainMsg = NULL; - -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onRecvMsg: %s", szEncMsg); -#endif - - // cut rtf tags - if ( pRtfconvString && memcmp(szEncMsg,"{\\rtf1",6)==0 ) { - SAFE_FREE(szUnrtfMsg); - int len = (int)strlen(szEncMsg)+1; - LPWSTR szTemp = (LPWSTR)mir_alloc(len*sizeof(WCHAR)); - if(ppre->flags & PREF_UNICODE) - rtfconvW((LPWSTR)(szEncMsg+len),szTemp); - else - rtfconvA(szEncMsg,szTemp); - len = (int)wcslen(szTemp)-1; - while(len) { - if ( szTemp[len] == 0x0D || szTemp[len] == 0x0A ) - szTemp[len] = 0; - else - break; - len--; - } - len = (int)wcslen(&szTemp[1])+1; - szUnrtfMsg = (LPSTR)mir_alloc(len*(sizeof(WCHAR)+1)); - WideCharToMultiByte(CP_ACP, 0, &szTemp[1], -1, szUnrtfMsg, len*(sizeof(WCHAR)+1), NULL, NULL); - memcpy(szUnrtfMsg+len,&szTemp[1],len*sizeof(WCHAR)); - ppre->szMessage = szEncMsg = szUnrtfMsg; - ppre->flags |= PREF_UNICODE; - mir_free(szTemp); - } - - int ssig = getSecureSig(ppre->szMessage,&szEncMsg); - BOOL bSecured = isContactSecured(pccsd->hContact)&SECURED; - BOOL bPGP = isContactPGP(pccsd->hContact); - BOOL bGPG = isContactGPG(pccsd->hContact); - -// HANDLE hMetaContact = getMetaContact(pccsd->hContact); -// if ( hMetaContact ) { -// ptr = getUinKey(hMetaContact); -// } - - // pass any unchanged message - if ( !ptr || - ssig==SiG_GAME || - !isSecureProtocol(pccsd->hContact) || - (isProtoMetaContacts(pccsd->hContact) && (pccsd->wParam & PREF_SIMNOMETA)) || - isChatRoom(pccsd->hContact) || - (ssig==SiG_NONE && !ptr->msgSplitted && !bSecured && !bPGP && !bGPG) - ) { -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onRecvMsg: pass unhandled"); -#endif - return CallService(MS_PROTO_CHAINRECV, wParam, lParam); - } - - // drop message: fake, unsigned or from invisible contacts - if ( isContactInvisible(pccsd->hContact) || ssig==SiG_FAKE ) { -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onRecvMsg: drop unhandled (contact invisible or hidden)"); -#endif - return 1; - } - - // receive non-secure message in secure mode - if ( ssig==SiG_NONE && !ptr->msgSplitted ) { -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onRecvMsg: non-secure message"); -#endif - if(ppre->flags & PREF_UNICODE) { - szPlainMsg = m_awstrcat(Translate(sim402),szEncMsg); - } - else { - szPlainMsg = m_aastrcat(Translate(sim402),szEncMsg); - } - ppre->szMessage = szPlainMsg; - pccsd->wParam |= PREF_SIMNOMETA; - int ret = CallService(MS_PROTO_CHAINRECV, wParam, lParam); - mir_free(szPlainMsg); - return ret; - } - - // received non-pgp secure message from disabled contact - if ( ssig!=SiG_PGPM && !bPGP && !bGPG && ptr->status==STATUS_DISABLED ) { -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onRecvMsg: message from disabled"); -#endif - if ( ptr->mode==MODE_NATIVE ) { - // tell to the other side that we have the plugin disabled with him - pccsd->wParam |= PREF_METANODB; - pccsd->lParam = (LPARAM) SIG_DISA; - pccsd->szProtoService = PSS_MESSAGE; - CallService(MS_PROTO_CHAINSEND, wParam, lParam); - - showPopUp(sim003,pccsd->hContact,g_hPOP[POP_PU_DIS],0); - } - else { - createRSAcntx(ptr); - exp->rsa_disabled(ptr->cntx); - deleteRSAcntx(ptr); - } - SAFE_FREE(ptr->msgSplitted); - return 1; - } - - // combine message splitted by protocol (no tags) - if ( ssig==SiG_NONE && ptr->msgSplitted ) { -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onRecvMsg: combine untagged splitted message"); -#endif - LPSTR tmp = (LPSTR) mir_alloc(strlen(ptr->msgSplitted)+strlen(szEncMsg)+1); - strcpy(tmp,ptr->msgSplitted); - strcat(tmp,szEncMsg); - mir_free(ptr->msgSplitted); - ptr->msgSplitted = szEncMsg = ppre->szMessage = tmp; - ssig = getSecureSig(tmp,&szEncMsg); - } - else { - SAFE_FREE(ptr->msgSplitted); - } - - // combine message splitted by secureim (with tags) - if ( ssig==SiG_SECP || ssig==SiG_PART ) { - LPSTR msg = combineMessage(ptr,szEncMsg); - if ( !msg ) return 1; - szEncMsg = ppre->szMessage = msg; - ssig = getSecureSig(msg,&szEncMsg); - } - - // decrypt PGP/GPG message - if ( ssig==SiG_PGPM && - ((bPGPloaded && (bPGPkeyrings || bPGPprivkey))|| - (bGPGloaded && bGPGkeyrings)) - ) { -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onRecvMsg: PGP/GPG message"); -#endif - szEncMsg = ppre->szMessage; - if ( !ptr->cntx ) { - ptr->cntx = cpp_create_context(((bGPGloaded && bGPGkeyrings)?CPP_MODE_GPG:CPP_MODE_PGP) | ((DBGetContactSettingByte(pccsd->hContact,szModuleName,"gpgANSI",0))?CPP_MODE_GPG_ANSI:0)); - ptr->keyLoaded = 0; - } - - if (!strstr(szEncMsg,"-----END PGP MESSAGE-----")) - return 1; // no end tag, don't display it ... - - LPSTR szNewMsg = NULL; - LPSTR szOldMsg = NULL; - - if (!ptr->keyLoaded && bPGPloaded) ptr->keyLoaded = LoadKeyPGP(ptr); - if (!ptr->keyLoaded && bGPGloaded) ptr->keyLoaded = LoadKeyGPG(ptr); - - if(ptr->keyLoaded==1) szOldMsg = pgp_decode(ptr->cntx, szEncMsg); - else - if(ptr->keyLoaded==2) szOldMsg = gpg_decode(ptr->cntx, szEncMsg); - - if (!szOldMsg) { // error while decrypting message, send error - SAFE_FREE(ptr->msgSplitted); - ppre->flags &= ~(PREF_UNICODE|PREF_UTF); - pccsd->wParam &= ~(PREF_UNICODE|PREF_UTF); - ppre->szMessage = Translate(sim401); - return CallService(MS_PROTO_CHAINRECV, wParam, lParam); - } - - // receive encrypted message in non-encrypted mode - if (!isContactPGP(pccsd->hContact) && !isContactGPG(pccsd->hContact)) { - szNewMsg = m_ustrcat(TranslateU(sim403),szOldMsg); - szOldMsg = szNewMsg; - } - szNewMsg = utf8_to_miranda(szOldMsg,ppre->flags); pccsd->wParam = ppre->flags; - ppre->szMessage = szNewMsg; - - // show decoded message - showPopUpRM(ptr->hContact); - SAFE_FREE(ptr->msgSplitted); - pccsd->wParam |= PREF_SIMNOMETA; - int ret = CallService(MS_PROTO_CHAINRECV, wParam, lParam); - mir_free(szNewMsg); - return ret; - } - -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onRecvMsg: switch(ssig)=%d",ssig); -#endif - switch(ssig) { - - case SiG_PGPM: - return CallService(MS_PROTO_CHAINRECV, wParam, lParam); - - case SiG_SECU: { // new secured msg, pass to rsa_recv -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onRecvMsg: RSA/AES message"); -#endif - if ( ptr->mode==MODE_NATIVE ) { - ptr->mode = MODE_RSAAES; - deleteRSAcntx(ptr); - DBWriteContactSettingByte(ptr->hContact, szModuleName, "mode", ptr->mode); - } - createRSAcntx(ptr); - loadRSAkey(ptr); - if ( exp->rsa_get_state(ptr->cntx)==0 ) - showPopUpKR(ptr->hContact); - - LPSTR szOldMsg = exp->rsa_recv(ptr->cntx,szEncMsg); - if ( !szOldMsg ) return 1; // don't display it ... - - LPSTR szNewMsg = utf8_to_miranda(szOldMsg,ppre->flags); pccsd->wParam = ppre->flags; - ppre->szMessage = szNewMsg; - - // show decoded message - showPopUpRM(ptr->hContact); - SAFE_FREE(ptr->msgSplitted); - pccsd->wParam |= PREF_SIMNOMETA; - int ret = CallService(MS_PROTO_CHAINRECV, wParam, lParam); - mir_free(szNewMsg); - return ret; - } break; - - case SiG_ENON: { // online message -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onRecvMsg: Native SiG_ENON message"); -#endif - if ( cpp_keyx(ptr->cntx)) { - // decrypting message - szPlainMsg = decodeMsg(ptr,lParam,szEncMsg); - if (!ptr->decoded) { - mir_free(szPlainMsg); - SAFE_FREE(ptr->msgSplitted); - ptr->msgSplitted=mir_strdup(szEncMsg); - return 1; // don't display it ... - } -// showPopUpRM(ptr->hContact); - } - else { - // reinit key exchange user has send an encrypted message and i have no key - cpp_reset_context(ptr->cntx); - - LPSTR reSend = (LPSTR) mir_alloc(strlen(szEncMsg)+LEN_RSND); - strcpy(reSend,SIG_RSND); // copy resend sig - strcat(reSend,szEncMsg); // add mess - - pccsd->wParam |= PREF_METANODB; - pccsd->lParam = (LPARAM) reSend; // reSend Message to reemit - pccsd->szProtoService = PSS_MESSAGE; - CallService(MS_PROTO_CHAINSEND, wParam, lParam); // send back cipher message - mir_free(reSend); - - LPSTR keyToSend = InitKeyA(ptr,0); // calculate public and private key - - pccsd->lParam = (LPARAM) keyToSend; - CallService(MS_PROTO_CHAINSEND, wParam, lParam); // send new key - mir_free(keyToSend); - - showPopUp(sim005,NULL,g_hPOP[POP_PU_DIS],0); - showPopUpKS(ptr->hContact); - - return 1; - } - } break; - - case SiG_ENOF: { // offline message -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onRecvMsg: Native SiG_ENOF message"); -#endif - // if offline key is set and we have not an offline message unset key - if (ptr->offlineKey && cpp_keyx(ptr->cntx)) { - cpp_reset_context(ptr->cntx); - ptr->offlineKey = false; - } - // decrypting message with last offline key - DBVARIANT dbv; - dbv.type = DBVT_BLOB; - - if ( DBGetContactSetting(ptr->hContact,szModuleName,"offlineKey",&dbv) == 0 ) { - // if valid key is succefully retrieved - ptr->offlineKey = true; - InitKeyX(ptr,dbv.pbVal); - DBFreeVariant(&dbv); - - // decrypting message - szPlainMsg = decodeMsg(ptr,lParam,szEncMsg); - -// showPopUpRM(ptr->hContact); - ShowStatusIconNotify(ptr->hContact); - } - else { - // exit and show messsage - return CallService(MS_PROTO_CHAINRECV, wParam, lParam); - } - } break; - - case SiG_RSND: { // resend message -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onRecvMsg: Native SiG_RSND message"); -#endif - if (cpp_keyx(ptr->cntx)) { - // decrypt sended back message and save message for future sending with a new secret key - szPlainMsg = decodeMsg(ptr,(LPARAM)pccsd,szEncMsg); - addMsg2Queue(ptr,pccsd->wParam,szPlainMsg); - mir_free(szPlainMsg); - - showPopUpRM(ptr->hContact); - showPopUp(sim004,NULL,g_hPOP[POP_PU_DIS],0); - } - return 1; // don't display it ... - } break; - - case SiG_DISA: { // disabled message -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onRecvMsg: Native SiG_DISA message"); -#endif -// ptr->status=ptr->tstatus=STATUS_DISABLED; -// DBWriteContactSettingByte(ptr->hContact, szModuleName, "StatusID", ptr->status); - } - case SiG_DEIN: { // deinit message - // other user has disabled SecureIM with you - cpp_delete_context(ptr->cntx); ptr->cntx=0; - - showPopUpDC(ptr->hContact); - ShowStatusIconNotify(ptr->hContact); - - waitForExchange(ptr,3); // дослать нешифрованно - return 1; - } break; - - case SiG_KEYR: // key3 message - case SiG_KEYA: // keyA message - case SiG_KEYB: { // keyB message - if ( ptr->mode==MODE_RSAAES ) { - ptr->mode = MODE_NATIVE; - cpp_delete_context(ptr->cntx); - ptr->cntx = 0; - ptr->keyLoaded = 0; - DBWriteContactSettingByte(ptr->hContact, szModuleName, "mode", ptr->mode); - } - switch(ssig) { - case SiG_KEYR: { // key3 message -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onRecvMsg: SiG_KEYR received"); -#endif - // receive KeyB from user; - showPopUpKR(ptr->hContact); - - if ( ptr->cntx && cpp_keyb(ptr->cntx)) { - // reinit key exchange if an old key from user is found - cpp_reset_context(ptr->cntx); - } - - if ( InitKeyB(ptr,szEncMsg)!=CPP_ERROR_NONE ) { -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onRecvMsg: SiG_KEYR InitKeyB error"); -#endif - // tell to the other side that we have the plugin disabled with him -/* - pccsd->wParam |= PREF_METANODB; - pccsd->lParam = (LPARAM) SIG_DISA; - pccsd->szProtoService = PSS_MESSAGE; - CallService(MS_PROTO_CHAINSEND, wParam, lParam); -*/ - showPopUp(sim013,ptr->hContact,g_hPOP[POP_PU_DIS],0); - ShowStatusIconNotify(ptr->hContact); - - waitForExchange(ptr,3); // дослать нешифрованно - return 1; - } - - // other side support RSA mode ? - if ( ptr->features & CPP_FEATURES_RSA ) { - // switch to RSAAES mode - ptr->mode = MODE_RSAAES; - DBWriteContactSettingByte(ptr->hContact, szModuleName, "mode", ptr->mode); - - resetRSAcntx(ptr); - loadRSAkey(ptr); - exp->rsa_connect(ptr->cntx); - - showPopUpKS(pccsd->hContact); - ShowStatusIconNotify(pccsd->hContact); - return 1; - } - - // other side support new key format ? - if ( ptr->features & CPP_FEATURES_NEWPG ) { - cpp_reset_context(ptr->cntx); - - LPSTR keyToSend = InitKeyA(ptr,CPP_FEATURES_NEWPG|KEY_A_SIG); // calculate NEW public and private key -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onRecvMsg: Sending KEYA %s", keyToSend); -#endif - pccsd->wParam |= PREF_METANODB; - pccsd->lParam = (LPARAM)keyToSend; - pccsd->szProtoService = PSS_MESSAGE; - CallService(MS_PROTO_CHAINSEND, wParam, lParam); - mir_free(keyToSend); - - showPopUpKS(ptr->hContact); - waitForExchange(ptr); // запустим ожидание - return 1; - } - - // auto send my public key to keyB user if not done before - if ( !cpp_keya(ptr->cntx)) { - LPSTR keyToSend = InitKeyA(ptr,0); // calculate public and private key -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onRecvMsg: Sending KEYA %s", keyToSend); -#endif - pccsd->wParam |= PREF_METANODB; - pccsd->lParam = (LPARAM)keyToSend; - pccsd->szProtoService = PSS_MESSAGE; - CallService(MS_PROTO_CHAINSEND, wParam, lParam); - mir_free(keyToSend); - - showPopUpKS(ptr->hContact); - } - } break; - - case SiG_KEYA: { // keyA message -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onRecvMsg: SiG_KEYA received"); -#endif - // receive KeyA from user; - showPopUpKR(ptr->hContact); - - cpp_reset_context(ptr->cntx); - if(InitKeyB(ptr,szEncMsg)!=CPP_ERROR_NONE) { -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onRecvMsg: SiG_KEYA InitKeyB error"); -#endif - // tell to the other side that we have the plugin disabled with him -/* - pccsd->wParam |= PREF_METANODB; - pccsd->lParam = (LPARAM) SIG_DISA; - pccsd->szProtoService = PSS_MESSAGE; - CallService(MS_PROTO_CHAINSEND, wParam, lParam); -*/ - showPopUp(sim013,ptr->hContact,g_hPOP[POP_PU_DIS],0); - ShowStatusIconNotify(ptr->hContact); - - waitForExchange(ptr,3); // дослать нешифрованно - return 1; - } - - LPSTR keyToSend = InitKeyA(ptr,CPP_FEATURES_NEWPG|KEY_B_SIG); // calculate NEW public and private key -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onRecvMsg: Sending KEYB %s", keyToSend); -#endif - pccsd->wParam |= PREF_METANODB; - pccsd->lParam = (LPARAM)keyToSend; - pccsd->szProtoService = PSS_MESSAGE; - CallService(MS_PROTO_CHAINSEND, wParam, lParam); - mir_free(keyToSend); - } break; - - case SiG_KEYB: { // keyB message -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onRecvMsg: SiG_KEYB received"); -#endif - // receive KeyB from user; - showPopUpKR(ptr->hContact); - - // clear all and send DISA if received KeyB, and not exist KeyA or error on InitKeyB - if (!cpp_keya(ptr->cntx) || InitKeyB(ptr,szEncMsg)!=CPP_ERROR_NONE) { -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onRecvMsg: SiG_KEYB InitKeyB error"); -#endif - // tell to the other side that we have the plugin disabled with him -/* - pccsd->wParam |= PREF_METANODB; - pccsd->lParam = (LPARAM) SIG_DISA; - pccsd->szProtoService = PSS_MESSAGE; - CallService(MS_PROTO_CHAINSEND, wParam, lParam); -*/ - showPopUp(sim013,ptr->hContact,g_hPOP[POP_PU_DIS],0); - ShowStatusIconNotify(ptr->hContact); - - cpp_reset_context(ptr->cntx); - waitForExchange(ptr,3); // дослать нешифрованно - return 1; - } - } break; - - } // switch - - /* common part (CalcKeyX & SendQueue) */ - // calculate KeyX - if ( cpp_keya(ptr->cntx) && cpp_keyb(ptr->cntx) && !cpp_keyx(ptr->cntx)) - CalculateKeyX(ptr,ptr->hContact); - - ShowStatusIconNotify(ptr->hContact); -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onRecvMsg: Session established"); -#endif - - waitForExchange(ptr,2); // дошлем через шифрованное соединение - return 1; - /* common part (CalcKeyX & SendQueue) */ - } break; - - } //switch - - // receive message - if ( cpp_keyx(ptr->cntx) && (ssig==SiG_ENON||ssig==SiG_ENOF)) { -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onRecvMsg: message received"); -#endif - showPopUpRM(ptr->hContact); - } -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onRecvMsg: exit"); -#endif - pccsd->wParam |= PREF_SIMNOMETA; - int ret = CallService(MS_PROTO_CHAINRECV, wParam, lParam); - SAFE_FREE(szPlainMsg); - return ret; -} - - -// SendMsgW handler -INT_PTR __cdecl onSendMsgW(WPARAM wParam, LPARAM lParam) { - if (!lParam) return 0; - - CCSDATA *ccs = (CCSDATA *) lParam; - if ( !(ccs->wParam & PREF_UTF)) - ccs->wParam |= PREF_UNICODE; - - return onSendMsg(wParam, lParam); -} - - -// SendMsg handler -INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) { - - CCSDATA *pccsd = (CCSDATA *)lParam; - pUinKey ptr = getUinKey(pccsd->hContact); - int ssig = getSecureSig((LPCSTR)pccsd->lParam); - int stat = getContactStatus(pccsd->hContact); - -// HANDLE hMetaContact = getMetaContact(pccsd->hContact); -// if ( hMetaContact ) { -// ptr = getUinKey(hMetaContact); -// } -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onSend: %s",(LPSTR)pccsd->lParam); -#endif - // pass unhandled messages - if ( !ptr || - ssig==SiG_GAME || ssig==SiG_PGPM || ssig==SiG_SECU || ssig==SiG_SECP || - isChatRoom(pccsd->hContact) || -/* (ssig!=SiG_NONE && hMetaContact && (pccsd->wParam & PREF_METANODB)) || */ - stat==-1 || - (ssig==SiG_NONE && ptr->sendQueue) || - (ssig==SiG_NONE && ptr->status==STATUS_DISABLED) // Disabled - pass unhandled - ) { - return CallService(MS_PROTO_CHAINSEND, wParam, lParam); -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onSendMsg: pass unhandled"); -#endif - } - - // - // PGP/GPG mode - // - if ( ptr->mode==MODE_PGP || ptr->mode==MODE_GPG ) { -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onSendMsg: PGP|GPG mode"); -#endif - // если можно зашифровать - шифруем - if ( isContactPGP(ptr->hContact) || isContactGPG(ptr->hContact)) { -/* - if(stat==ID_STATUS_OFFLINE) { - if (msgbox1(0,sim110,szModuleName,MB_YESNO|MB_ICONQUESTION)==IDNO) { - return returnNoError(pccsd->hContact); - } - // exit and send unencrypted message - return CallService(MS_PROTO_CHAINSEND, wParam, lParam); - } -*/ - if ( !ptr->cntx ) { - ptr->cntx = cpp_create_context((isContactGPG(ptr->hContact)?CPP_MODE_GPG:CPP_MODE_PGP) | ((DBGetContactSettingByte(ptr->hContact,szModuleName,"gpgANSI",0))?CPP_MODE_GPG_ANSI:0)); - ptr->keyLoaded = 0; - } - if ( !ptr->keyLoaded && bPGPloaded ) ptr->keyLoaded = LoadKeyPGP(ptr); - if ( !ptr->keyLoaded && bGPGloaded ) ptr->keyLoaded = LoadKeyGPG(ptr); - if ( !ptr->keyLoaded ) return returnError(pccsd->hContact,Translate(sim108)); - - LPSTR szNewMsg = NULL; - LPSTR szUtfMsg = miranda_to_utf8((LPCSTR)pccsd->lParam,pccsd->wParam); - if ( ptr->keyLoaded == 1 ) { // PGP - szNewMsg = pgp_encode(ptr->cntx,szUtfMsg); - } - else - if ( ptr->keyLoaded == 2 ) { // GPG - szNewMsg = gpg_encode(ptr->cntx,szUtfMsg); - } - mir_free(szUtfMsg); - if ( !szNewMsg ) { - return returnError(pccsd->hContact,Translate(sim109)); - } - - // отправляем зашифрованное сообщение - splitMessageSend(ptr,szNewMsg); - - showPopUpSM(ptr->hContact); - - return returnNoError(pccsd->hContact); - } - else { - // отправляем незашифрованное - return CallService(MS_PROTO_CHAINSEND, wParam, lParam); - } - } - - // get contact SecureIM status - int stid = ptr->status; - - // - // RSA/AES mode - // - if ( ptr->mode==MODE_RSAAES ) { -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onSendMsg: RSA/AES mode"); -#endif - // contact is offline - if ( stat==ID_STATUS_OFFLINE ) { - if ( ptr->cntx ) { - if ( exp->rsa_get_state(ptr->cntx)!=0 ) { - resetRSAcntx(ptr); - } - } - else { - createRSAcntx(ptr); - } - if ( !bSOM || (!isClientMiranda(ptr,1) && !isSecureIM(ptr,1)) || !loadRSAkey(ptr)) { - if ( ssig==SiG_NONE ) { - // просто шлем незашифрованное в оффлайн - return CallService(MS_PROTO_CHAINSEND, wParam, lParam); - } - else { - // ничего не шлем дальше - это служебное сообщение - return returnNoError(pccsd->hContact); - } - } - // шлем шифрованное в оффлайн - LPSTR szUtfMsg = miranda_to_utf8((LPCSTR)pccsd->lParam,pccsd->wParam); - exp->rsa_send(ptr->cntx,szUtfMsg); - mir_free(szUtfMsg); - showPopUpSM(ptr->hContact); - return returnNoError(pccsd->hContact); - } - // SecureIM connection with this contact is disabled - if ( stid==STATUS_DISABLED ) { - if ( ptr->cntx ) { - exp->rsa_disabled(ptr->cntx); - deleteRSAcntx(ptr); - } - if ( ssig==SiG_NONE ) { - // просто шлем незашифрованное - return CallService(MS_PROTO_CHAINSEND, wParam, lParam); - } - // ничего не шлем дальше - это служебное сообщение - return returnNoError(pccsd->hContact); - } - // разорвать соединение - if ( ssig==SiG_DEIN ) { - if ( ptr->cntx ) { - exp->rsa_disconnect(ptr->cntx); - deleteRSAcntx(ptr); - } - waitForExchange(ptr,3); // дошлем нешифрованно - return returnNoError(pccsd->hContact); - } - // соединение установлено - if ( ptr->cntx && exp->rsa_get_state(ptr->cntx)==7 ) { - LPSTR szUtfMsg = miranda_to_utf8((LPCSTR)pccsd->lParam,pccsd->wParam); - exp->rsa_send(ptr->cntx,szUtfMsg); - mir_free(szUtfMsg); - showPopUpSM(ptr->hContact); - return returnNoError(pccsd->hContact); - } - // просто сообщение (без тэгов, нет контекста и работают AIP & NOL) - if ( ssig==SiG_NONE && isSecureIM(ptr->hContact)) { - // добавим его в очередь - addMsg2Queue(ptr, pccsd->wParam, (LPSTR)pccsd->lParam); - // запускаем процесс установки соединения - ssig=SiG_INIT; - // запускаем трэд ожидания и досылки - waitForExchange(ptr); - } - // установить соединение - if ( ssig==SiG_INIT ) { - createRSAcntx(ptr); - loadRSAkey(ptr); - exp->rsa_connect(ptr->cntx); - showPopUpKS(pccsd->hContact); - ShowStatusIconNotify(pccsd->hContact); - return returnNoError(pccsd->hContact); - } - // просто шлем незашифрованное (не знаю даже когда такое случится) - return CallService(MS_PROTO_CHAINSEND, wParam, lParam); - } - - // - // Native mode - // -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onSendMsg: Native mode"); -#endif - - // SecureIM connection with this contact is disabled - if ( stid==STATUS_DISABLED ) { -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onSendMsg: message for Disabled"); -#endif - // if user try initialize connection - if ( ssig==SiG_INIT ) { - // secure IM is disabled ... - return returnError(pccsd->hContact,Translate(sim105)); - } - if (ptr->cntx) { // if exist secure context - cpp_delete_context(ptr->cntx); ptr->cntx=0; - - CCSDATA ccsd; - memcpy(&ccsd, (HLOCAL)lParam, sizeof(CCSDATA)); - - pccsd->wParam |= PREF_METANODB; - ccsd.lParam = (LPARAM) SIG_DEIN; - ccsd.szProtoService = PSS_MESSAGE; - CallService(MS_PROTO_CHAINSEND, wParam, (LPARAM)&ccsd); - - showPopUpDC(pccsd->hContact); - ShowStatusIconNotify(pccsd->hContact); - } - return CallService(MS_PROTO_CHAINSEND, wParam, lParam); - } - - // contact is offline - if ( stat==ID_STATUS_OFFLINE ) { -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onSendMsg: message for offline"); -#endif - if ( ssig==SiG_INIT && cpp_keyx(ptr->cntx)) { - // reinit key exchange - cpp_reset_context(ptr->cntx); - } - - if ( !bSOM ) { - if ( ssig!=SiG_NONE ) { - return returnNoError(pccsd->hContact); - } - // exit and send unencrypted message - return CallService(MS_PROTO_CHAINSEND, wParam, lParam); - } - BOOL isMiranda = isClientMiranda(ptr->hContact); - - if ( stid==STATUS_ALWAYSTRY && isMiranda ) { // always try && Miranda - // set key for offline user - DBVARIANT dbv; dbv.type = DBVT_BLOB; - if ( DBGetContactSettingDword(ptr->hContact, szModuleName, "offlineKeyTimeout", 0) > gettime() && - DBGetContactSetting(ptr->hContact, szModuleName, "offlineKey", &dbv) == 0 - ) { - // if valid key is succefully retrieved - ptr->offlineKey = true; - InitKeyX(ptr,dbv.pbVal); - DBFreeVariant(&dbv); - } - else { - DBDeleteContactSetting(ptr->hContact,szModuleName,"offlineKey"); - DBDeleteContactSetting(ptr->hContact,szModuleName,"offlineKeyTimeout"); - if (msgbox1(0,sim106,szModuleName,MB_YESNO|MB_ICONQUESTION)==IDNO) { - return returnNoError(pccsd->hContact); - } - // exit and send unencrypted message - return CallService(MS_PROTO_CHAINSEND, wParam, lParam); - } - } - else { -/* if (stid==STATUS_ALWAYSTRY && !isMiranda || stid!=STATUS_ALWAYSTRY && isMiranda) { - int res=msgbox1(0,"User is offline now, Do you want to send your message ?\nIt will be unencrypted !","Can't Send Encrypted Message !",MB_YESNO); - if (res==IDNO) return 1; - }*/ - if ( ssig!=SiG_NONE ) { - return returnNoError(pccsd->hContact); - } - // exit and send unencrypted message - return CallService(MS_PROTO_CHAINSEND, wParam, lParam); - } - - } - else { -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onSendMsg: message for online"); -#endif - // contact is online and we use an offline key -> reset offline key - if ( ptr->offlineKey ) { - cpp_reset_context(ptr->cntx); - ptr->offlineKey = false; - ShowStatusIconNotify(ptr->hContact); - } - } - - // if init is called from contact menu list reinit secure im connection - if ( ssig==SiG_INIT ) { -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onSendMsg: SiG_INIT"); -#endif - cpp_reset_context(ptr->cntx); - } - - // if deinit is called from contact menu list deinit secure im connection - if ( ssig==SiG_DEIN ) { -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onSendMsg: SiG_DEIN"); -#endif - // disable SecureIM only if it was enabled - if (ptr->cntx) { - cpp_delete_context(ptr->cntx); ptr->cntx=0; - - pccsd->wParam |= PREF_METANODB; - CallService(MS_PROTO_CHAINSEND, wParam, lParam); - - showPopUpDC(pccsd->hContact); - ShowStatusIconNotify(pccsd->hContact); - } - return returnNoError(pccsd->hContact); - } - - if ( cpp_keya(ptr->cntx) && cpp_keyb(ptr->cntx) && !cpp_keyx(ptr->cntx)) - CalculateKeyX(ptr,ptr->hContact); - - ShowStatusIconNotify(pccsd->hContact); - - // if cryptokey exist - if ( cpp_keyx(ptr->cntx)) { -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onSendMsg: cryptokey exist"); -#endif -/* if ( !hMetaContact && isProtoMetaContacts(pccsd->hContact) && (DBGetContactSettingByte(NULL, "MetaContacts", "SubcontactHistory", 1) == 1)) { - // add sent event to subcontact - DBEVENTINFO dbei; HANDLE hC = getMostOnline(pccsd->hContact); - ZeroMemory(&dbei, sizeof(dbei)); - dbei.cbSize = sizeof(dbei); - dbei.szModule = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hC, 0); - dbei.flags = DBEF_SENT; - dbei.timestamp = time(NULL); - dbei.eventType = EVENTTYPE_MESSAGE; - if(pccsd->wParam & PREF_RTL) dbei.flags |= DBEF_RTL; - if(pccsd->wParam & PREF_UTF) dbei.flags |= DBEF_UTF; - dbei.cbBlob = strlen((char *)pccsd->lParam) + 1; - if ( pccsd->wParam & PREF_UNICODE ) - dbei.cbBlob *= ( sizeof( wchar_t )+1 ); - dbei.pBlob = (PBYTE)pccsd->lParam; - - CallService(MS_DB_EVENT_ADD, (WPARAM)hC, (LPARAM)&dbei); - } */ - - LPSTR szNewMsg = encodeMsg(ptr,(LPARAM)pccsd); - -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onSend: encrypted msg '%s'",szNewMsg); -#endif - - pccsd->wParam |= PREF_METANODB; - pccsd->lParam = (LPARAM) szNewMsg; - pccsd->szProtoService = PSS_MESSAGE; - int ret = CallService(MS_PROTO_CHAINSEND, wParam, lParam); - - mir_free(szNewMsg); - - showPopUpSM(ptr->hContact); - - return ret; - } - else { -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onSendMsg: cryptokey not exist, try establishe connection"); -#endif - // send KeyA if init || always_try || waitkey || always_if_possible - if ( ssig==SiG_INIT || (stid==STATUS_ALWAYSTRY && isClientMiranda(ptr->hContact)) || isSecureIM(ptr->hContact) || ptr->waitForExchange ) { - if (ssig==SiG_NONE) { - addMsg2Queue(ptr, pccsd->wParam, (LPSTR)pccsd->lParam); - } - if ( !ptr->waitForExchange ) { - // init || always_try || always_if_possible - LPSTR keyToSend = InitKeyA(ptr,0); // calculate public and private key & fill KeyA -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("Sending KEY3: %s", keyToSend); -#endif - pccsd->wParam &= ~PREF_UNICODE; - pccsd->wParam |= PREF_METANODB; - pccsd->lParam = (LPARAM) keyToSend; - pccsd->szProtoService = PSS_MESSAGE; - CallService(MS_PROTO_CHAINSEND, wParam, lParam); - mir_free(keyToSend); - - showPopUpKS(pccsd->hContact); - ShowStatusIconNotify(pccsd->hContact); - - waitForExchange(ptr); // запускаем ожидание - } - return returnNoError(pccsd->hContact); - } -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("onSendMsg: pass unchanged to chain"); -#endif - return CallService(MS_PROTO_CHAINSEND, wParam, lParam); - } -} - - -int file_idx = 0; - -INT_PTR __cdecl onSendFile(WPARAM wParam, LPARAM lParam) { - - CCSDATA *pccsd=(CCSDATA*)lParam; - - pUinKey ptr = getUinKey(pccsd->hContact); - if (!ptr || !bSFT) return CallService(PSS_FILE, wParam, lParam); - - if ( isContactSecured(pccsd->hContact)&SECURED ) { - - char **file=(char **)pccsd->lParam; - if(file_idx==100) file_idx=0; - int i; - for(i=0;file[i];i++) { - - if (strstr(file[i],".AESHELL")) continue; - - char *name = strrchr(file[i],'\\'); - if ( !name ) name = file[i]; - else name++; - - char *file_out = (char*) mir_alloc(TEMP_SIZE+strlen(name)+20); - sprintf(file_out,"%s\\%s.AESHELL(%d)",TEMP,name,file_idx++); - - char buf[MAX_PATH]; - sprintf(buf,"%s\n%s",Translate(sim011),file[i]); - showPopUp(buf,NULL,g_hPOP[POP_PU_MSS],2); - - if ( ptr->mode==MODE_RSAAES ) { - exp->rsa_encrypt_file(ptr->cntx,file[i],file_out); - } - else { - cpp_encrypt_file(ptr->cntx,file[i],file_out); - } - - mir_free(file[i]); - file[i]=file_out; - } - if ( ptr->fileSend ) { // очистим сохраненный список - for(int j=0;ptr->fileSend[j];j++) { - mir_free(ptr->fileSend[j]); - } - SAFE_FREE(ptr->fileSend); - } - if ( i ) { // скопируем новый список - ptr->fileSend = (char **) mir_alloc(sizeof(char*)*(i+1)); - for(i=0;file[i];i++) { - ptr->fileSend[i] = mir_strdup(file[i]); - } - ptr->fileSend[i] = NULL; - } - } - return CallService(PSS_FILE, wParam, lParam); -} - - -/* -typedef struct { - size_t cbSize; - HANDLE hContact; - int sending; //true if sending, false if receiving - char **files; - int totalFiles; - int currentFileNumber; - unsigned long totalBytes; - unsigned long totalProgress; - char *workingDir; - char *currentFile; - unsigned long currentFileSize; - unsigned long currentFileProgress; - unsigned long currentFileTime; //as seconds since 1970 -} PROTOFILETRANSFERSTATUS; -*/ - -int __cdecl onProtoAck(WPARAM wParam,LPARAM lParam) { - - ACKDATA *ack=(ACKDATA*)lParam; - if (ack->type!=ACKTYPE_FILE) return 0; //quit if not file transfer event - PROTOFILETRANSFERSTATUS *f = (PROTOFILETRANSFERSTATUS*) ack->lParam; - - pUinKey ptr = getUinKey(ack->hContact); - if (!ptr || (f && (f->flags & PFTS_SENDING) && !bSFT)) return 0; - - if ( isContactSecured(ack->hContact)&SECURED ) { - switch(ack->result) { -// case ACKRESULT_FILERESUME: - case ACKRESULT_DATA: { - if ( !( f->flags & PFTS_SENDING )) { - ptr->finFileRecv = (f->currentFileSize == f->currentFileProgress); - if ( !ptr->lastFileRecv ) ptr->lastFileRecv = mir_strdup(f->szCurrentFile); - } - else - if ( f->flags & PFTS_SENDING ) { - ptr->finFileSend = (f->currentFileSize == f->currentFileProgress); - if ( !ptr->lastFileSend ) ptr->lastFileSend = mir_strdup(f->szCurrentFile); - } - } break; -// case ACKRESULT_INITIALISING: - case ACKRESULT_DENIED: - case ACKRESULT_FAILED: { - if ( ptr->lastFileRecv ) { - if (strstr(ptr->lastFileRecv,".AESHELL")) mir_unlink(ptr->lastFileRecv); - SAFE_FREE(ptr->lastFileRecv); - } - if ( ptr->lastFileSend ) { - if (strstr(ptr->lastFileSend,".AESHELL")) mir_unlink(ptr->lastFileSend); - SAFE_FREE(ptr->lastFileSend); - } - if ( ptr->fileSend ) { - char **file=ptr->fileSend; - for(int j=0;file[j];j++) { - if ( strstr(file[j],".AESHELL")) mir_unlink(file[j]); - mir_free(file[j]); - } - SAFE_FREE(ptr->fileSend); - } - return 0; - } break; - case ACKRESULT_NEXTFILE: - case ACKRESULT_SUCCESS: { - if ( ptr->finFileRecv && ptr->lastFileRecv ) { - if ( strstr(ptr->lastFileRecv,".AESHELL")) { - char buf[MAX_PATH]; - LPSTR file_out=mir_strdup(ptr->lastFileRecv); - LPSTR pos=strrchr(file_out,'.'); //find last . - if (pos) *pos='\0'; //remove AESHELL from name - - if ( isFileExist(file_out)) { - buf[0]='\0'; - LPSTR p=strrchr(file_out,'.'); - LPSTR x=strrchr(file_out,'\\'); - if(p>x) { - strcpy(buf,p); - pos=p; - } - for(int i=1;i<10000;i++) { - sprintf(pos," (%d)%s",i,buf); - if ( !isFileExist(file_out)) break; - } - } - - sprintf(buf,"%s\n%s",Translate(sim012),file_out); - showPopUp(buf,NULL,g_hPOP[POP_PU_MSR],2); - - if ( ptr->mode==MODE_RSAAES ) { - exp->rsa_decrypt_file(ptr->cntx,ptr->lastFileRecv,file_out); - } - else { - cpp_decrypt_file(ptr->cntx,ptr->lastFileRecv,file_out); - } - mir_free(file_out); - mir_unlink(ptr->lastFileRecv); - } - SAFE_FREE(ptr->lastFileRecv); - ptr->finFileRecv = false; - } - if ( ptr->finFileSend && ptr->lastFileSend ) { - if ( strstr(ptr->lastFileSend,".AESHELL")) mir_unlink(ptr->lastFileSend); - SAFE_FREE(ptr->lastFileSend); - ptr->finFileSend = false; - } - } break; - } // switch - } - return 0; -} - - -// EOF diff --git a/plugins/SecureIM/svcs_proto.h b/plugins/SecureIM/svcs_proto.h deleted file mode 100644 index 64ce1c43a3..0000000000 --- a/plugins/SecureIM/svcs_proto.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __SVCS_PROTO_H__ -#define __SVCS_PROTO_H__ - -#include - -INT_PTR __cdecl onRecvMsg(WPARAM,LPARAM); -INT_PTR __cdecl onSendMsgW(WPARAM,LPARAM); -INT_PTR __cdecl onSendMsg(WPARAM,LPARAM); -INT_PTR __cdecl onSendFile(WPARAM,LPARAM); - -int __cdecl onProtoAck(WPARAM,LPARAM); -int __cdecl onContactSettingChanged(WPARAM,LPARAM); - -#endif diff --git a/plugins/SecureIM/svcs_rsa.cpp b/plugins/SecureIM/svcs_rsa.cpp deleted file mode 100644 index e72221dc91..0000000000 --- a/plugins/SecureIM/svcs_rsa.cpp +++ /dev/null @@ -1,226 +0,0 @@ -#include "commonheaders.h" - - -pRSA_EXPORT exp = NULL; -RSA_IMPORT imp = { - rsa_inject, - rsa_check_pub, - rsa_notify -}; - -BOOL rsa_4096=0; - - -int __cdecl rsa_inject(HANDLE context, LPCSTR msg) { - pUinKey ptr = getUinCtx(context); if (!ptr) return 0; -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("rsa_inject: '%s'", msg); -#endif - int len = (int)strlen(msg)+1; - LPSTR buf = (LPSTR) mir_alloc(LEN_SECU+len); - memcpy(buf,SIG_SECU,LEN_SECU); - memcpy(buf+LEN_SECU,msg,len); - // отправляем сообщение - splitMessageSend(ptr,buf); - mir_free(buf); - return 1; -} - - -#define MSGSIZE 1024 - -int __cdecl rsa_check_pub(HANDLE context, PBYTE pub, int pubLen, PBYTE sig, int sigLen) { - int v=0, k=0; - pUinKey ptr = getUinCtx(context); if (!ptr) return 0; - LPSTR cnm = (LPSTR) mir_alloc(NAMSIZE); getContactNameA(ptr->hContact,cnm); - LPSTR uin = (LPSTR) mir_alloc(KEYSIZE); getContactUinA(ptr->hContact,uin); - LPSTR msg = (LPSTR) mir_alloc(MSGSIZE); - LPSTR sha = mir_strdup(to_hex(sig,sigLen)); - LPSTR sha_old = NULL; -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("rsa_check_pub: %s %s %s", cnm, uin, sha); -#endif - DBVARIANT dbv; - dbv.type = DBVT_BLOB; - if ( DBGetContactSetting(ptr->hContact,szModuleName,"rsa_pub",&dbv) == 0 ) { - k = 1; - PBYTE buf = (PBYTE) alloca(sigLen); int len; - exp->rsa_get_hash((PBYTE)dbv.pbVal,dbv.cpbVal,(PBYTE)buf,&len); - sha_old = mir_strdup(to_hex(buf,len)); - DBFreeVariant(&dbv); - } - if ( bAAK ) { - if ( k ) mir_snprintf(msg,MSGSIZE,Translate(sim523),cnm,uin,sha,sha_old); - else mir_snprintf(msg,MSGSIZE,Translate(sim521),cnm,uin,sha); - showPopUpKRmsg(ptr->hContact,msg); - HistoryLog(ptr->hContact,msg); - v = 1; -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("rsa_check_pub: auto accepted"); -#endif - } - else { - if ( k ) mir_snprintf(msg,MSGSIZE,Translate(sim522),cnm,sha,sha_old); - else mir_snprintf(msg,MSGSIZE,Translate(sim520),cnm,sha); - v = (msgbox(0,msg,szModuleName,MB_YESNO|MB_ICONQUESTION)==IDYES); -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("rsa_check_pub: manual accepted %d",v); -#endif - } - if(v) { - DBCONTACTWRITESETTING cws; - cws.szModule = szModuleName; - cws.szSetting = "rsa_pub"; - cws.value.type = DBVT_BLOB; - cws.value.pbVal = pub; - cws.value.cpbVal = pubLen; - CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)ptr->hContact, (LPARAM)&cws); - ptr->keyLoaded = true; - } - mir_free(cnm); - mir_free(uin); - mir_free(msg); - mir_free(sha); - SAFE_FREE(sha_old); - return v; -} - - -void __cdecl rsa_notify(HANDLE context, int state) { - pUinKey ptr = getUinCtx(context); if (!ptr) return; - LPCSTR msg=NULL; -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("rsa_notify: 0x%x", state); -#endif - switch( state ) { - case 1: { - showPopUpEC(ptr->hContact); - ShowStatusIconNotify(ptr->hContact); - waitForExchange(ptr,2); // досылаем сообщения из очереди - return; - } - case -1: // сессия разорвана по ошибке, неверный тип сообщения - msg=sim501; break; - case -2: // сессия разорвана по ошибке другой стороной - msg=sim502; break; - case -5: // ошибка декодирования AES сообщения - msg=sim505; break; - case -6: // ошибка декодирования RSA сообщения - msg=sim506; break; - case -7: // таймаут установки соединения (10 секунд) - msg=sim507; break; - case -8: { // сессия разорвана по причине "disabled" - msg=sim508; -// ptr->status=ptr->tstatus=STATUS_DISABLED; -// DBWriteContactSettingByte(ptr->hContact, szModuleName, "StatusID", ptr->status); - } break; - case -0x10: // сессия разорвана по ошибке - case -0x21: - case -0x22: - case -0x23: - case -0x24: - case -0x32: - case -0x33: - case -0x34: - case -0x40: - case -0x50: - case -0x60: { - char buf[1024]; - sprintf(buf,sim510,-state); - showPopUpDCmsg(ptr->hContact,buf); - ShowStatusIconNotify(ptr->hContact); - if(ptr->cntx) deleteRSAcntx(ptr); - waitForExchange(ptr,3); // досылаем нешифровано - return; - } - case -3: // соединение разорвано вручную - case -4: { // соединение разорвано вручную другой стороной - showPopUpDC(ptr->hContact); - ShowStatusIconNotify(ptr->hContact); - if(ptr->cntx) deleteRSAcntx(ptr); - waitForExchange(ptr,3); // досылаем нешифровано - return; - } - default: - return; - } - showPopUpDCmsg(ptr->hContact,msg); - ShowStatusIconNotify(ptr->hContact); - if(ptr->cntx) deleteRSAcntx(ptr); - waitForExchange(ptr,3); // досылаем нешифровано -} - - -unsigned __stdcall sttGenerateRSA( LPVOID param ) { - - char priv_key[4096]; int priv_len; - char pub_key[4096]; int pub_len; - - exp->rsa_gen_keypair(CPP_MODE_RSA_4096); - - DBCONTACTWRITESETTING cws; - cws.szModule = szModuleName; - cws.value.type = DBVT_BLOB; - - exp->rsa_get_keypair(CPP_MODE_RSA_4096,(PBYTE)&priv_key,&priv_len,(PBYTE)&pub_key,&pub_len); - - cws.szSetting = "rsa_priv"; - cws.value.pbVal = (PBYTE)&priv_key; - cws.value.cpbVal = priv_len; - CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)0, (LPARAM)&cws); - - cws.szSetting = "rsa_pub"; - cws.value.pbVal = (PBYTE)&pub_key; - cws.value.cpbVal = pub_len; - CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)0, (LPARAM)&cws); - - rsa_4096=1; - - return 0; -} - - -// загружает паблик-ключ в RSA контекст -BYTE loadRSAkey(pUinKey ptr) { - if ( !ptr->keyLoaded ) { - DBVARIANT dbv; - dbv.type = DBVT_BLOB; - if ( DBGetContactSetting(ptr->hContact,szModuleName,"rsa_pub",&dbv) == 0 ) { - ptr->keyLoaded = exp->rsa_set_pubkey(ptr->cntx,dbv.pbVal,dbv.cpbVal); -#if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("loadRSAkey %d", ptr->keyLoaded); -#endif - DBFreeVariant(&dbv); - } - } - return ptr->keyLoaded; -} - -// создает RSA контекст -void createRSAcntx(pUinKey ptr) { - if ( !ptr->cntx ) { - ptr->cntx = cpp_create_context(CPP_MODE_RSA); - ptr->keyLoaded = 0; - } -} - - -// пересоздает RSA контекст -void resetRSAcntx(pUinKey ptr) { - if ( ptr->cntx ) { - cpp_delete_context(ptr->cntx); - ptr->cntx = cpp_create_context(CPP_MODE_RSA); - ptr->keyLoaded = 0; - } -} - - -// удаляет RSA контекст -void deleteRSAcntx(pUinKey ptr) { - cpp_delete_context(ptr->cntx); - ptr->cntx = 0; - ptr->keyLoaded = 0; -} - - -// EOF diff --git a/plugins/SecureIM/svcs_rsa.h b/plugins/SecureIM/svcs_rsa.h deleted file mode 100644 index 3f43e71d30..0000000000 --- a/plugins/SecureIM/svcs_rsa.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef __SVCS_RSA_H__ -#define __SVCS_RSA_H__ - -#include - -extern pRSA_EXPORT exp; -extern RSA_IMPORT imp; -extern BOOL rsa_4096; - -int __cdecl rsa_inject(HANDLE,LPCSTR); -int __cdecl rsa_check_pub(HANDLE,PBYTE,int,PBYTE,int); -void __cdecl rsa_notify(HANDLE,int); - -unsigned __stdcall sttGenerateRSA(LPVOID); -BYTE loadRSAkey(pUinKey); -void createRSAcntx(pUinKey); -void resetRSAcntx(pUinKey); -void deleteRSAcntx(pUinKey); - -#endif diff --git a/plugins/SecureIM/svcs_srmm.cpp b/plugins/SecureIM/svcs_srmm.cpp deleted file mode 100644 index 688246847e..0000000000 --- a/plugins/SecureIM/svcs_srmm.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "commonheaders.h" - - -int __cdecl onWindowEvent(WPARAM wParam, LPARAM lParam) { - - MessageWindowEventData *mwd = (MessageWindowEventData *)lParam; - if(mwd->uType == MSG_WINDOW_EVT_OPEN || mwd->uType == MSG_WINDOW_EVT_OPENING) { - ShowStatusIcon(mwd->hContact); - } - return 0; -} - - -int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam) { - HANDLE hContact = (HANDLE)wParam; - if ( isProtoMetaContacts(hContact)) - hContact = getMostOnline(hContact); // возьмем тот, через который пойдет сообщение - - StatusIconClickData *sicd = (StatusIconClickData *)lParam; - if ( strcmp(sicd->szModule, szModuleName) != 0 || - !isSecureProtocol(hContact)) return 0; // not our event - - BOOL isPGP = isContactPGP(hContact); - BOOL isGPG = isContactGPG(hContact); - BOOL isSecured = isContactSecured(hContact)&SECURED; - BOOL isChat = isChatRoom(hContact); - - if ( !isPGP && !isGPG && !isChat ) { - if(isSecured) Service_DisableIM(wParam,0); - else Service_CreateIM(wParam,0); - } - - return 0; -} - - -// EOF diff --git a/plugins/SecureIM/svcs_srmm.h b/plugins/SecureIM/svcs_srmm.h deleted file mode 100644 index d64c89ab4e..0000000000 --- a/plugins/SecureIM/svcs_srmm.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef __SVCS_SRMM_H__ -#define __SVCS_SRMM_H__ - -#include - -int __cdecl onWindowEvent(WPARAM,LPARAM); -int __cdecl onIconPressed(WPARAM,LPARAM); - -#endif diff --git a/plugins/SecureIM/version.h b/plugins/SecureIM/version.h deleted file mode 100644 index 22b458eac8..0000000000 --- a/plugins/SecureIM/version.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef __VERSION_H_INCLUDED -#define __VERSION_H_INCLUDED - -#define __MAJOR_VERSION 1 -#define __MINOR_VERSION 0 -#define __RELEASE_NUM 12 -#define __BUILD_NUM 4 - -#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM -#define __FILEVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM -#define __STRINGIFY(x) #x -#define __TOSTRING(x) __STRINGIFY(x) -#define __VERSION_STRING __TOSTRING(__FILEVERSION_STRING_DOTS) -#define __VERSION_DWORD ((__MAJOR_VERSION<<24) | (__MINOR_VERSION<<16) | (__RELEASE_NUM<<8) | __BUILD_NUM) - -#endif //__VERSION_H_INCLUDED diff --git a/plugins/SecureIM/version.rc b/plugins/SecureIM/version.rc deleted file mode 100644 index cd57f59d78..0000000000 --- a/plugins/SecureIM/version.rc +++ /dev/null @@ -1,45 +0,0 @@ -#ifdef APSTUDIO_INVOKED -#error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - -#include "version.h" - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION __FILEVERSION_STRING - PRODUCTVERSION __FILEVERSION_STRING - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "Comments", "Licensed under the terms of the GNU General Public License" - VALUE "FileDescription", "SecureIM plugin for Miranda IM" - VALUE "FileVersion", __VERSION_STRING - VALUE "InternalName", "SecureIM" - VALUE "LegalCopyright", "Copyright й 2003 Johell, й 2005-09 Baloo" - VALUE "OriginalFilename", "secureim.dll" - VALUE "ProductName", "SecureIM plugin" - VALUE "ProductVersion", __VERSION_STRING - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0, 1200 - END -END - - diff --git a/plugins/SecureIM/version_icons.rc b/plugins/SecureIM/version_icons.rc deleted file mode 100644 index ca622fe360..0000000000 --- a/plugins/SecureIM/version_icons.rc +++ /dev/null @@ -1,44 +0,0 @@ -#ifdef APSTUDIO_INVOKED -#error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - -#include "version.h" - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION __FILEVERSION_STRING - PRODUCTVERSION __FILEVERSION_STRING - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "FileDescription", "Iconpack for SecureIM plugin of Miranda IM" - VALUE "FileVersion", __VERSION_STRING - VALUE "InternalName", "SecureIM_icons" - VALUE "LegalCopyright", "Copyright й 2006-09 Baloo" - VALUE "OriginalFilename", "SecureIM_icons.dll" - VALUE "ProductName", "Iconpack for SecureIM plugin" - VALUE "ProductVersion", __VERSION_STRING - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0, 1200 - END -END - - diff --git a/plugins/SeenPlugin/docs/readme_src.txt b/plugins/SeenPlugin/docs/readme_src.txt new file mode 100644 index 0000000000..0769b49b03 --- /dev/null +++ b/plugins/SeenPlugin/docs/readme_src.txt @@ -0,0 +1,23 @@ +This source code is licensed under the GPL (http://www.gnu.org/copyleft/gpl.html) + +Please notify me of any changes that improve the plugin or add +new features. + +If you have any questions on the code, feel free to contact me at +UIN: 46955367 or +eMail: micron@nexgo.de +Visit http://home.nexgo.de/micron/miranda for the latest source files + +micron-x + + + +Rebase information +****************** +enotify.dll 0x67700000 +dbviewer.dll 0x67600000 +hotkey.dll 0x67500000 +pluginsweeper.dll 0x67400000 +seenplugin.dll 0x67300000 +tipinfo.dll 0x67200000 +visibility.dll 0x67100000 \ No newline at end of file diff --git a/plugins/SeenPlugin/docs/seen_info.txt b/plugins/SeenPlugin/docs/seen_info.txt new file mode 100644 index 0000000000..5ba87f079a --- /dev/null +++ b/plugins/SeenPlugin/docs/seen_info.txt @@ -0,0 +1,216 @@ +Last Seen plugin +**************** +This plugin logs when a contact was last seen online. +You can choose between contactmenu item, userinfo page and file output. +Second feature is to show which users were online while you were away. + +micron-x + +Questions and comments to: +micron@nexgo.de + +Last Seen Mod +************* +I did some (quick'n'dirty) modifications to LastSeen plugin to fit better to my taste: + + 1. ICQ IPs are logged correctly; + 2. Variables can be used in the log filename. You could have separate files for different protocols/contacts or create new file each month; + 3. Rewritten "Protocols to watch". Now selecting/deselecting protocols is easy ;) + 4. Solved enable/disable file logging bug + 5. Introduced 6 new variables: + * %P - protocol name (ICQ, ICQ1, MSN...); + * %N - nick on the server; + * %C - Client Info; + * %G - Group; + * %o - Old status; + * %T - Status message + 6. Option to use # instead of % to get empty strings instead of + 7. extended support of multiple yahoo protocols(not tested); + 8. extended support for jabber/s. + 9. popup support + 10. delayed logging to wait for the protocols to update all the settings + 11. option to track idle statuses + +Y.B. +http://saaplugin.no-ip.info/ +http://forums.miranda-im.org/showthread.php?t=2822 + + +Langpack strings +**************** + +see seen_langpack.txt + + + +Version history +*************** + +Last Seen Mod +************* + * v. 5.0.4.7 + o Added special sound for "Uses Logged In" + o Used the core service MS_SYSTEM_FORK_THREAD_EX + + * v. 5.0.4.3 + o Included seenTS DB setting + o "suppress online notification" affects only sounds and popups + o Sounds are working now. Two new are added. + * v. 5.0.4.2 + o Implemented Idle support (Will include "/Idle" to the status if contact is idle) + * v. 5.0.4.1 + o Enabled 32bit icons in lastseen history dialog (fixes the "transperancy bug") + o New variable: %T: Status Message + o Parser rewritten to be safer + o Click on popup will open message window + * v. 5.0.4.0 + o Small memory leak in user info dialog fixed (thanks Tio Duke) + o Increased the delay to check offline contacts 2->10 seconds + o If the contact's status changer while we have been offline the time we went offline will be logged (not the current time) + o Fixed visual glitch in the "last seen history" dialog + o Suppress the DEFMOD_RNDUSERONLINE core functionality - LastSeenMod is not compatible with NewStatusNotify anylonger + o Option to enable clist online notify + * v. 5.0.3.2 + o Better protocol type guessing (based on PFLAG_UNIQUEIDSETTING) + o Popups colors are configurable + o Tabbed interface of the option page + * v. 5.0.3.1 (never released) + o Avoid multiple popups on login - only those for contacts with different status before logoff + o implemented delayed logging of the status changes using thread + o Doesn't show popups is the contact is "hidden" + o Better tracking if the contact went offline while we were offline + o %i and %r are replaced by "resource" and "system" for Jabber/JGmail + * v. 5.0.3.0 + o Enhanced PopUp support: + + separated fields for PopUp title and text + + Correct icon is chosen according to the protocol and status + o New Variable %o - "Old Status" + o JGmail is recognised as Jabber + * v. 5.0.2.6 + o Basic PopUp support + * v. 5.0.2.5 + o Added %G standing for "Group" + o Using variables in the path of the log file(s) is possible now + * v. 5.0.2.4 + o Updated MSN capability bits according to this post + * v. 5.0.2.3 + o Solved enable/disable file logging bug (hopefully) + o Option to use # instead of % to get empty strings instead of + * v. 5.0.2.2 + o Added %C (Client/version for ICQ; ClientID flags for MSN); + o Better support for multiple instances of same protocol; + o Logging contacts of protocol logon/off is back; + * v. 5.0.2.1 + o Updated plugin info + +Last Seen plugin +**************** +5.0.1.1: + - FIX: The protocol list now uses more uuser friendly names + - FIX: The "Missed Ones" feature options weren't saved correctly + - FIX: The "Offline" setting was added even to contacts whose protocol wasn't "watched" + - FIX: Minor cosmetics (icons and tooltips) + - UPDATE: seen_langpack.txt +5.0.1.0: + - FIX: Some protocols added an offline entry for every contact when the user logoff the network + - FIX: An extra character (0 or 1) was added to each line of the file log. + - UPDATE: seen_langpack.txt now contains the strings added on version 5.0.0.0 +5.0.0.1: + - FIX: Removed some code that flooded the network with requests (see http://miranda-icq.sourceforge.net/forums/viewtopic.php?t=11579) + - CHANGE: History now defaults to a "pretier" format. +5.0.0.0: + - FIX: Last statusmode icon displayed according to the contact's protocol + - NEW: Support for all protocols (user selectable) + - NEW: Added dialog showing the recent "seen history" of an user + - NEW: Added option to display an alert when a specified user changes its status + +4.1.6.2: - prevent plugin not loading & new base address + +4.1.6.1: - Silly bug with 4.1.6.0 fixed + +4.1.6.0: - Directory access fix + +4.1.5.0: - fixed 0AM/PM bug + - 'Missed Ones' window doesn't steal focus anymore + - 'Missed Ones' bugfixes + +4.1.4.0: - removed Miranda 0.1.2.0 support + +4.1.3.0: - 'Missed Ones' dismisses ignored contacts (online notification) + - reduced file size + +4.1.2.0: - Added support for Plugin sweeper + +4.1.1.0: - New option: count times a user was online while you were away + - Bug crashing Miranda on open userdetails fixed + +4.1.0.0: - 'Missed Ones' should finally work now + +4.0.9.0: - works now with Miranda v0.1.2.0 + - unknown values grayed out + +4.0.8.0: - fixed bug crashing miranda on status change + +4.0.7.0: - two new variables: %E - name of month and %e abrreviated name of month + - empty userinfo page fixed + +4.0.6.0: - attempted fix for bad userinfo page + - two new variables: %W - weekday and %w - abbr. weekday + +4.0.5.0: - Two new variables: %h - 12 hour time and %p - AM/PM + - New 'Missed Ones' popup (Dialog instead of MessageBox) + +4.0.4.0: - Option to show last statusmode icon + +4.0.3.0: - 'Missed Ones' feature reimplemented + - Miranda crashing on close fixed + +4.0.2.0: - Option to keep track of contacts going offline + - fixed crashing when %u was used + - file output implemented + - one new langpack string + +4.0.1.0: - IP/RealIP variables working now + +4.0.0.0: - Initial release of the totally rewritten version + Please mail me any bug reports + + + +Rebase information +****************** +seenplugin.dll 0x67300000 + +enotify.dll 0x67700000 +dbviewer.dll 0x67600000 +hotkey.dll 0x67500000 +pluginsweeper.dll 0x67400000 +tipinfo.dll 0x67200000 +visibility.dll 0x67100000 + + + +====================================== +"Last Seen mod" plugin for Miranda IM +Copyright ( C ) 2002-03 micron-x +Copyright ( C ) 2005-06 Y.B. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or ( at your option ) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/seen_info.txt $ +Revision : $Rev: 1570 $ +Last change on : $Date: 2007-12-30 01:30:07 +0300 (Р’СЃ, 30 дек 2007) $ +Last change by : $Author: y_b $ + diff --git a/plugins/SeenPlugin/docs/seenplugin-translation.txt b/plugins/SeenPlugin/docs/seenplugin-translation.txt new file mode 100644 index 0000000000..67bbc30ebf --- /dev/null +++ b/plugins/SeenPlugin/docs/seenplugin-translation.txt @@ -0,0 +1,101 @@ +; Common strings that belong to many files +;[] +;[Last seen] + +; ../../plugins/SeenPlugin/history.cpp +;[Send Instant Message] +;[User Menu] +;[View User's Details] +;[last seen history] + +; ../../plugins/SeenPlugin/main.cpp +;[Changed to Online] +;[LastSeen] +;[User Logged In] +;[User Logged Off] +;[User status change] + +; ../../plugins/SeenPlugin/options.cpp +;[Last Seen Variables] +;[PopUps] +;[Services] + +; ../../plugins/SeenPlugin/resource.rc +;[Alert when user status changes] +;[Away] +;[Count times] +;[DND] +;[Enable 'Missed Ones' feature] +;[Enable Idle support] +;[Free for chat] +;[Ignore contacts going offline] +;[Invisible] +;[Last seen menuitem] +;[Last seen options] +;[Last seen plugin] +;[Log to file] +;[Log to history] +;[Maximum size] +;[N/A] +;[OK] +;[Occupied] +;[Offline] +;[On the phone] +;[Online] +;[Out to lunch] +;[PopUp Colors] +;[Popup interoperability missing or disabled. You need Popups plugin] +;[Protocols to watch:] +;[Reset colors] +;[Show icon] +;[Test\nTest] +;[Text] +;[Title] +;[Use popups] +;[Userinfo tab] +;[Variable list] +;[Variablestest] +;[You missed following contacts:] + +; ../../plugins/SeenPlugin/seen.h +;[%i(%r)%bWas %o] +;[%n is %s (%u)] +;[-- Date --] +;[-- Format --] +;[-- Time --] +;[-- User --] +;[AM/PM] +;[Client info] +;[Group] +;[Name:%t%N%bStatus:%t%s%bDay:%t%d.%m.%Y%bTime:%t%H:%M:%S%bPrevious Status:%t%o%b%b%P ID:%t%u%bExternal IP:%t%i%bInternal IP:%t%r%bClientID: %t%C%b%bStatus Message:%t%T] +;[Note:] +;[Old status] +;[Protocol] +;[Status] +;[Status message] +;[UIN/handle] +;[Use] +;[day] +;[external IP] +;[for empty string] +;[hours (12)] +;[hours (24)] +;[instead of] +;[internal IP] +;[line break] +;[minutes] +;[month] +;[name of month] +;[nick] +;[seconds] +;[short name of month] +;[tabulator] +;[username] +;[weekday (abbreviated)] +;[weekday (full)] +;[year (2 digits)] +;[year (4 digits)] + +; ../../plugins/SeenPlugin/utils.cpp +;[] +;[Idle] diff --git a/plugins/SeenPlugin/file.cpp b/plugins/SeenPlugin/file.cpp deleted file mode 100644 index cac37f8c30..0000000000 --- a/plugins/SeenPlugin/file.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/* -"Last Seen mod" plugin for Miranda IM -Copyright ( C ) 2002-03 micron-x -Copyright ( C ) 2005-07 Y.B. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or ( at your option ) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/file.c $ -Revision : $Rev: 1570 $ -Last change on : $Date: 2007-12-30 01:30:07 +0300 (Р’СЃ, 30 дек 2007) $ -Last change by : $Author: y_b $ -*/ - -#include "seen.h" -/* -Prepares the log file: -- calculates the absolute path (and store it in the db) -- creates the directory - -*/ -int InitFileOutput(void) -{ - char szfpath[256]="",szmpath[256]="",*str; - DBVARIANT dbv; - - GetModuleFileName(NULL,szmpath,MAX_PATH); - strcpy(szfpath,!DBGetContactSetting(NULL,S_MOD,"FileName",&dbv)?dbv.pszVal:DEFAULT_FILENAME); - - DBFreeVariant(&dbv); - - if(szfpath[0]=='\\') - strcpy(szfpath,szfpath+1); - - str=strrchr(szmpath,'\\'); - if(str!=NULL) - *++str=0; - - strcat(szmpath,szfpath); - - strcpy(szfpath,szmpath); - - str=strrchr(szmpath,'\\'); - if(str!=NULL) - *++str=0; -/* -//we dont need this anylonger. the directory is created in filewrite - if (!CreateDirectory(szmpath,NULL)) - { - if (!(GetFileAttributes(szmpath) & FILE_ATTRIBUTE_DIRECTORY)) - { - MessageBox(NULL,"Directory could not be created\nPlease choose another!","Last seen plugin",MB_OK|MB_ICONERROR); - DBWriteContactSettingByte(NULL,S_MOD,"FileOutput",0); - return 0; - } - } -*/ - DBWriteContactSettingString(NULL,S_MOD,"PathToFile",szfpath); - - return 0; -} - -//borrowed from netliblog.c -static void CreateDirectoryTree(char *szDir) -{ - DWORD dwAttributes; - char *pszLastBackslash,szTestDir[MAX_PATH]; - - lstrcpynA(szTestDir,szDir,sizeof(szTestDir)); - if ((dwAttributes=GetFileAttributesA(szTestDir))!=0xffffffff && dwAttributes&FILE_ATTRIBUTE_DIRECTORY) return; - pszLastBackslash=strrchr(szTestDir,'\\'); - if(pszLastBackslash==NULL) return; - *pszLastBackslash='\0'; - CreateDirectoryTree(szTestDir); - CreateDirectoryA(szTestDir,NULL); -} - -/* -Writes a line into the log. -*/ -void FileWrite(HANDLE hcontact) -{ - HANDLE fhout; - DWORD byteswritten; - char szout[1024],sznl[3]="\r\n"; - DBVARIANT dbv; - - DBGetContactSetting(NULL,S_MOD,"PathToFile",&dbv); - strcpy(szout,ParseString(dbv.pszVal,hcontact,1)); - fhout=CreateFile(szout,GENERIC_WRITE,0,NULL,OPEN_ALWAYS,0,NULL); - if (fhout==INVALID_HANDLE_VALUE){ - CreateDirectoryTree(szout); - fhout=CreateFile(szout,GENERIC_WRITE,0,NULL,OPEN_ALWAYS,0,NULL); - if (fhout==INVALID_HANDLE_VALUE) return; - } - DBFreeVariant(&dbv); - SetFilePointer(fhout,0,0,FILE_END); - - strcpy(szout,ParseString(!DBGetContactSetting(NULL,S_MOD,"FileStamp",&dbv)?dbv.pszVal:DEFAULT_FILESTAMP,hcontact,1)); - DBFreeVariant(&dbv); - - WriteFile(fhout,szout, (DWORD)_tcslen(szout),&byteswritten,NULL); - WriteFile(fhout,sznl, (DWORD)_tcslen(sznl),&byteswritten,NULL); - - CloseHandle(fhout); - - -} diff --git a/plugins/SeenPlugin/history.cpp b/plugins/SeenPlugin/history.cpp deleted file mode 100644 index 724cfd5612..0000000000 --- a/plugins/SeenPlugin/history.cpp +++ /dev/null @@ -1,347 +0,0 @@ -/* -"Last Seen mod" plugin for Miranda IM -Copyright ( C ) 2002-03 micron-x -Copyright ( C ) 2005-06 Y.B. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or ( at your option ) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/history.c $ -Revision : $Rev: 1056 $ -Last change on : $Date: 2006-10-30 06:22:07 +0300 (РџРЅ, 30 РѕРєС‚ 2006) $ -Last change by : $Author: y_b $ -*/ -#include "seen.h" - - -extern HINSTANCE hInstance; - -static HANDLE hWindowList; - -char* BuildSetting(int historyLast) { - static char setting[15]; - static char sztemp[15]; - *setting = '\0'; - strcat(setting, "History_"); - strcat(setting, itoa(historyLast, sztemp, 10)); - return setting; -} - -void HistoryWrite(HANDLE hContact) -{ - short historyFirst, historyLast, historyMax; - DBVARIANT dbv; - - historyMax = DBGetContactSettingWord(NULL,S_MOD,"HistoryMax",10); - if (historyMax < 0) historyMax=0; else if (historyMax > 99) historyMax = 99; - if (historyMax == 0) return; - historyFirst = DBGetContactSettingWord(hContact,S_MOD,"HistoryFirst",0); - if (historyFirst >= historyMax) historyFirst = 0; - historyLast = DBGetContactSettingWord(hContact,S_MOD,"HistoryLast",0); - if (historyLast >= historyMax) historyLast = historyMax-1; - - DBWriteContactSettingString(hContact,S_MOD,BuildSetting(historyLast), - ParseString(!DBGetContactSetting(NULL,S_MOD,"HistoryStamp",&dbv)?dbv.pszVal:DEFAULT_HISTORYSTAMP,hContact,0)); - DBFreeVariant(&dbv); - - historyLast = (historyLast+1) % historyMax; - DBWriteContactSettingWord(hContact,S_MOD,"HistoryLast",historyLast); - if (historyLast == historyFirst) { - DBWriteContactSettingWord(hContact,S_MOD,"HistoryFirst",(short) ((historyFirst+1) % historyMax)); - } - -} - -void LoadHistoryList(HANDLE hContact, HWND hwnd, int nList) { - short historyFirst, historyLast, historyMax; - short i; - DBVARIANT dbv; - - - SendDlgItemMessage(hwnd, nList, LB_RESETCONTENT, 0, 0); - historyMax = DBGetContactSettingWord(NULL,S_MOD,"HistoryMax",10); - if (historyMax < 0) historyMax = 0; else if (historyMax > 99) historyMax = 99; - if (historyMax == 0) return; - historyFirst = DBGetContactSettingWord(hContact,S_MOD,"HistoryFirst",0); - if (historyFirst >= historyMax) historyFirst = 0; - historyLast = DBGetContactSettingWord(hContact,S_MOD,"HistoryLast",0); - if (historyLast >= historyMax) historyLast = historyMax-1; - - i = historyLast; - while (i != historyFirst) { - i = (i-1+historyMax) % historyMax; - SendDlgItemMessage(hwnd, nList, LB_ADDSTRING, 0, - (LPARAM)(!DBGetContactSetting(hContact,S_MOD,BuildSetting(i),&dbv)?dbv.pszVal:"")); - DBFreeVariant(&dbv); - } - -} - - -HDWP MyResizeWindow (HDWP hDwp, HWND hwndDlg, HWND hwndControl, - int nHorizontalOffset, int nVerticalOffset, - int nWidthOffset, int nHeightOffset) -{ - POINT pt; - RECT rcinit; - - // get current bounding rectangle - GetWindowRect(hwndControl, &rcinit); - - // get current top left point - pt.x = rcinit.left; - pt.y = rcinit.top; - ScreenToClient(hwndDlg, &pt); - - // resize control -/* MoveWindow(hwndControl, - pt.x + nHorizontalOffset, - pt.y + nVerticalOffset, - rcinit.right - rcinit.left + nWidthOffset, - rcinit.bottom - rcinit.top + nHeightOffset, - FALSE); -*/ - return DeferWindowPos(hDwp, hwndControl, NULL, - pt.x + nHorizontalOffset, - pt.y + nVerticalOffset, - rcinit.right - rcinit.left + nWidthOffset, - rcinit.bottom - rcinit.top + nHeightOffset, - SWP_NOZORDER); - - -} - -HDWP MyHorizCenterWindow (HDWP hDwp, HWND hwndDlg, HWND hwndControl, - int nClientWidth, int nVerticalOffset, - int nHeightOffset) -{ - POINT pt; - RECT rcinit; - - // get current bounding rectangle - GetWindowRect(hwndControl, &rcinit); - - // get current top left point - pt.x = rcinit.left; - pt.y = rcinit.top; - ScreenToClient(hwndDlg, &pt); - - // resize control -/* MoveWindow(hwndControl, - (int) ((nClientWidth - (rcinit.right - rcinit.left))/2), - pt.y + nVerticalOffset, - rcinit.right - rcinit.left, - rcinit.bottom - rcinit.top + nHeightOffset, - TRUE); -*/ - return DeferWindowPos(hDwp, hwndControl, NULL, - (int) ((nClientWidth - (rcinit.right - rcinit.left))/2), - pt.y + nVerticalOffset, - rcinit.right - rcinit.left, - rcinit.bottom - rcinit.top + nHeightOffset, - SWP_NOZORDER); - -} -void MyResizeGetOffset (HWND hwndDlg, HWND hwndControl, - int nWidth, int nHeight, - int* nDx, int* nDy) -{ - RECT rcinit; - - // get current bounding rectangle - GetWindowRect(hwndControl, &rcinit); - - // calculate offsets - *nDx = nWidth - (rcinit.right - rcinit.left); - *nDy = nHeight - (rcinit.bottom - rcinit.top); -} - -INT_PTR CALLBACK HistoryDlgProc(HWND hwndDlg, UINT Message, WPARAM wparam, LPARAM lparam) -{ - HANDLE hContact; - char sztemp[1024]=""; - static HIMAGELIST hIml=NULL; - - switch(Message) - { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - hContact = (HANDLE)lparam; - SetWindowLongPtr(hwndDlg,GWLP_USERDATA,lparam); - strcpy(sztemp,(char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,0)); - strcat(sztemp, ": "); - strcat(sztemp, Translate("last seen history")); - SendMessage(hwndDlg, WM_SETTEXT, 0, (LPARAM)sztemp); - SendMessage(hwndDlg, WM_SETICON, (WPARAM) ICON_BIG, (LPARAM) LoadSkinnedIcon(SKINICON_OTHER_MIRANDA)); - SendMessage(hwndDlg, WM_SETICON, (WPARAM) ICON_SMALL, (LPARAM) LoadSkinnedIcon(SKINICON_OTHER_MIRANDA)); - -// LoadHistoryList(hContact, hwndDlg, IDC_HISTORYLIST); - - if (DBGetContactSettingByte(hContact,S_MOD,"OnlineAlert",0)) - SendDlgItemMessage(hwndDlg, IDC_STATUSCHANGE, BM_SETCHECK, (WPARAM)BST_CHECKED, 0); - { - hIml=ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),ILC_COLOR32|ILC_MASK,3,3); - ImageList_AddIcon(hIml,LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_USERDETAILS))); - ImageList_AddIcon(hIml,LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_DOWNARROW))); - ImageList_AddIcon(hIml,LoadSkinnedIcon(SKINICON_EVENT_MESSAGE)); - SendDlgItemMessage(hwndDlg,IDC_DETAILS,BM_SETIMAGE,IMAGE_ICON,(WPARAM)ImageList_GetIcon(hIml,0,ILD_NORMAL)); - SendDlgItemMessage(hwndDlg,IDC_USERMENU,BM_SETIMAGE,IMAGE_ICON,(WPARAM)ImageList_GetIcon(hIml,1,ILD_NORMAL)); - SendDlgItemMessage(hwndDlg,IDC_SENDMSG,BM_SETIMAGE,IMAGE_ICON,(WPARAM)ImageList_GetIcon(hIml,2,ILD_NORMAL)); - } - - //set-up tooltips - { - HWND hwndDlgToolTips; - TOOLINFO ti; - - hwndDlgToolTips = CreateWindowEx(WS_EX_TOPMOST,TOOLTIPS_CLASS,"",WS_POPUP,0,0,0,0,NULL,NULL,GetModuleHandle(NULL),NULL); - ZeroMemory(&ti,sizeof(ti)); - ti.cbSize=sizeof(ti); - ti.uFlags=TTF_IDISHWND|TTF_SUBCLASS; - ti.uId=(UINT)GetDlgItem(hwndDlg,IDC_USERMENU); - ti.lpszText=Translate("User Menu"); - SendMessage(hwndDlgToolTips,TTM_ADDTOOL,0,(LPARAM)&ti); - ti.uId=(UINT)GetDlgItem(hwndDlg,IDC_DETAILS); - ti.lpszText=Translate("View User's Details"); - SendMessage(hwndDlgToolTips,TTM_ADDTOOL,0,(LPARAM)&ti); - ti.uId=(UINT)GetDlgItem(hwndDlg,IDC_SENDMSG); - ti.lpszText=Translate("Send Instant Message"); - SendMessage(hwndDlgToolTips,TTM_ADDTOOL,0,(LPARAM)&ti); - } - - - Utils_RestoreWindowPositionNoMove(hwndDlg,NULL,S_MOD,"History_"); - ShowWindow(hwndDlg, SW_SHOW); - break; - - case WM_MEASUREITEM: - return CallService(MS_CLIST_MENUMEASUREITEM,wparam,lparam); - case WM_DRAWITEM: - return CallService(MS_CLIST_MENUDRAWITEM,wparam,lparam); - case WM_COMMAND: - hContact=(HANDLE)GetWindowLongPtr(hwndDlg,GWLP_USERDATA); - if(CallService(MS_CLIST_MENUPROCESSCOMMAND,MAKEWPARAM(LOWORD(wparam),MPCF_CONTACTMENU),(LPARAM)hContact)) - break; - switch(LOWORD(wparam)) - { - case IDCANCEL: - SendMessage(hwndDlg, WM_CLOSE, 0, 0); - break; - case IDOK: - if (SendDlgItemMessage(hwndDlg, IDC_STATUSCHANGE, BM_GETCHECK, 0, 0) == BST_CHECKED) - DBWriteContactSettingByte(hContact,S_MOD,"OnlineAlert",1); - else - DBWriteContactSettingByte(hContact,S_MOD,"OnlineAlert",0); - SendMessage(hwndDlg, WM_CLOSE, 0, 0); - break; - case IDC_USERMENU: - { - RECT rc; - HMENU hMenu=(HMENU)CallService(MS_CLIST_MENUBUILDCONTACT,(WPARAM)hContact,0); - GetWindowRect(GetDlgItem(hwndDlg,IDC_USERMENU),&rc); - TrackPopupMenu(hMenu,0,rc.left,rc.bottom,0,hwndDlg,NULL); - DestroyMenu(hMenu); - } - break; - case IDC_DETAILS: - CallService(MS_USERINFO_SHOWDIALOG,(WPARAM)hContact,0); - break; - case IDC_SENDMSG: - CallService(MS_MSG_SENDMESSAGE,(WPARAM)hContact,0); - break; - case IDC_TEST: - debug(ParseString("Date: %d.%m.%y(%Y) \n Date desc: %W - %w - %E - %e \n Time: %H:%M:%S (%h-%p) \n user: %n - %u \n Status: %s \n IP: %i - %r",hContact,0)); - break; - } - break; - case WM_SIZE: - { - int dx, dy; - HDWP hDwp; - - hDwp = BeginDeferWindowPos(6); - MyResizeGetOffset(hwndDlg, GetDlgItem(hwndDlg, IDC_HISTORYLIST), - LOWORD(lparam)-15, HIWORD(lparam)-99, &dx, &dy); - hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_USERMENU), - dx, 0, 0, 0); - hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_DETAILS), - dx, 0, 0, 0); - hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_SENDMSG), - dx, 0, 0, 0); - hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_HISTORYLIST), - 0, 0, dx, dy); - hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_STATUSCHANGE), - 0, dy, dx, 0); - hDwp = MyHorizCenterWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDOK), - LOWORD(lparam), dy, 0); - EndDeferWindowPos(hDwp); - } - break; - case WM_GETMINMAXINFO: - { - MINMAXINFO mmi; - CopyMemory (&mmi, (LPMINMAXINFO) lparam, sizeof (MINMAXINFO)); - - /* The minimum width in points*/ - mmi.ptMinTrackSize.x = 200; - /* The minimum height in points*/ - mmi.ptMinTrackSize.y = 190; - - CopyMemory ((LPMINMAXINFO) lparam, &mmi, sizeof (MINMAXINFO)); - } - break; - - case WM_CLOSE: - DestroyWindow(hwndDlg); - WindowList_Remove(hWindowList,hwndDlg); - break; - case WM_DESTROY: - Utils_SaveWindowPosition(hwndDlg,NULL,S_MOD,"History_"); - ImageList_Destroy(hIml); - break; - default: - return FALSE; - } - return TRUE; -} - -void ShowHistory(HANDLE hContact, BYTE isAlert) -{ - HWND hHistoryDlg; - - hHistoryDlg = WindowList_Find(hWindowList,hContact); - if (hHistoryDlg == NULL) - { - hHistoryDlg = CreateDialogParam(hInstance,MAKEINTRESOURCE(IDD_HISTORY),NULL,HistoryDlgProc,(LPARAM)hContact); - LoadHistoryList(hContact, hHistoryDlg, IDC_HISTORYLIST); - WindowList_Add(hWindowList,hHistoryDlg,hContact); - } - else - { - SetForegroundWindow(hHistoryDlg); - LoadHistoryList(hContact, hHistoryDlg, IDC_HISTORYLIST); - SetFocus(hHistoryDlg); - } - - if (isAlert) - { - SkinPlaySound("LastSeenTrackedStatusChange"); - } -} - - -void InitHistoryDialog(void) -{ - hWindowList=(HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST,0,0); -} diff --git a/plugins/SeenPlugin/main.cpp b/plugins/SeenPlugin/main.cpp deleted file mode 100644 index 68a774e435..0000000000 --- a/plugins/SeenPlugin/main.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* -"Last Seen mod" plugin for Miranda IM -Copyright ( C ) 2002-03 micron-x -Copyright ( C ) 2005-07 Y.B. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or ( at your option ) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/main.c $ -Revision : $Rev: 1571 $ -Last change on : $Date: 2007-12-30 04:55:51 +0300 (Р’СЃ, 30 дек 2007) $ -Last change by : $Author: y_b $ -*/ -#include "seen.h" - -HINSTANCE hInstance; -HANDLE ehdb = NULL, ehproto = NULL, ehmissed = NULL, ehuserinfo = NULL, ehmissed_proto = NULL, hOptInit = NULL, hMainInit = NULL; - -int hLangpack; - -PLUGININFOEX pluginInfo={ - sizeof(PLUGININFOEX), - "Last seen", - PLUGIN_MAKE_VERSION(5,0,4,7), - "Log when a user was last seen online and which users were online while you were away.", - "Heiko Schillinger, YB", - "y_b@saaplugin.no-ip.info", - "© 2001-2002 Heiko Schillinger, 2003 modified by Bruno Rino, 2005-7 Modified by YB", - "http://nightly.miranda.im/", - UNICODE_AWARE, - { 0x2d506d46,0xc94e,0x4ef8,{0x85, 0x37, 0xf1, 0x12, 0x33, 0xa8, 0x03, 0x81}}/* 2d506d46-c94e-4ef8-8537-f11233a80381 */ -}; - -#define TRANSNUMBER 2 -DBVTranslation idleTr[TRANSNUMBER]={ - {(TranslateFunc*)any_to_IdleNotidleUnknown, _T("Any to Idle/Not Idle/Unknown"),0}, - {(TranslateFunc*)any_to_Idle, _T("Any to /Idle or empty"),0} -}; - -BOOL includeIdle; -logthread_info **contactQueue = NULL; -int contactQueueSize = 0; - -int MainInit(WPARAM wparam,LPARAM lparam) -{ - contactQueueSize = 16*sizeof(logthread_info *); - contactQueue = (logthread_info **)malloc(contactQueueSize); - memset(&contactQueue[0], 0, contactQueueSize); - contactQueueSize = 16; - includeIdle = (BOOL )DBGetContactSettingByte(NULL,S_MOD,"IdleSupport",1); - hOptInit = HookEvent(ME_OPT_INITIALISE, OptionsInit); - - if(DBGetContactSettingByte(NULL,S_MOD,"MenuItem",1)) { - InitMenuitem(); - } - - if(DBGetContactSettingByte(NULL,S_MOD,"UserinfoTab",1)) - ehuserinfo = HookEvent(ME_USERINFO_INITIALISE,UserinfoInit); - - if(DBGetContactSettingByte(NULL,S_MOD,"FileOutput",0)) - InitFileOutput(); - - if(DBGetContactSettingByte(NULL,S_MOD,"MissedOnes",0)) - ehmissed_proto=HookEvent(ME_PROTO_ACK,ModeChange_mo); - - ehdb = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, UpdateValues); - ehproto = HookEvent(ME_PROTO_ACK,ModeChange); - - SkinAddNewSoundEx("LastSeenTrackedStatusChange", LPGEN("LastSeen"), LPGEN("User status change")); - SkinAddNewSoundEx("LastSeenTrackedStatusOnline", LPGEN("LastSeen"), LPGEN("Changed to Online")); - SkinAddNewSoundEx("LastSeenTrackedStatusOffline", LPGEN("LastSeen"), LPGEN("User Logged Off")); - SkinAddNewSoundEx("LastSeenTrackedStatusFromOffline", LPGEN("LastSeen"), LPGEN("User Logged In")); - - // known modules list - if (ServiceExists("DBEditorpp/RegisterSingleModule")) - CallService("DBEditorpp/RegisterSingleModule", (WPARAM)S_MOD, 0); - DBWriteContactSettingString(NULL,"Uninstall",Translate("Last seen"),S_MOD); - - - if ( ServiceExists(MS_TIPPER_ADDTRANSLATION)) { - int i; - for (i=0; i < TRANSNUMBER; i++) - CallService(MS_TIPPER_ADDTRANSLATION, 0, (LPARAM)&idleTr[i]); - } - - return 0; -} - -extern "C" __declspec(dllexport) PLUGININFOEX * MirandaPluginInfoEx(DWORD mirandaVersion) -{ - return &pluginInfo; -} - -extern "C" __declspec(dllexport) int Unload(void) -{ - UnhookEvent(ehdb); - if(ehmissed) UnhookEvent(ehmissed); - UnhookEvent(ehproto); - if(ehmissed_proto) UnhookEvent(ehmissed_proto); - UnhookEvent(hOptInit); - UnhookEvent(hMainInit); - if (ehuserinfo) UnhookEvent(ehuserinfo); - UninitMenuitem(); -// free(contactQueue); - return 0; -} - -BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID lpvReserved) -{ - hInstance=hinst; - return 1; -} - -extern "C" __declspec(dllexport) int Load(void) -{ - - mir_getLP(&pluginInfo); - // this isn't required for most events - // but the ME_USERINFO_INITIALISE - // I decided to hook all events after - // everything is loaded because it seems - // to be safer in my opinion - hMainInit = HookEvent(ME_SYSTEM_MODULESLOADED,MainInit); - return 0; -} \ No newline at end of file diff --git a/plugins/SeenPlugin/menu.cpp b/plugins/SeenPlugin/menu.cpp deleted file mode 100644 index 02f241b793..0000000000 --- a/plugins/SeenPlugin/menu.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* -"Last Seen mod" plugin for Miranda IM -Copyright ( C ) 2002-03 micron-x -Copyright ( C ) 2005-07 Y.B. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or ( at your option ) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/menu.c $ -Revision : $Rev: 1570 $ -Last change on : $Date: 2007-12-30 01:30:07 +0300 (Р’СЃ, 30 дек 2007) $ -Last change by : $Author: y_b $ -*/ -#include "seen.h" - -HANDLE hmenuitem=NULL, hLSUserDet = NULL, hBuildMenu = NULL; - -void ShowHistory(HANDLE hContact, BYTE isAlert); -void InitHistoryDialog(void); - -/* -Handles the messages sent by clicking the contact's menu item -*/ -INT_PTR MenuitemClicked(WPARAM wparam,LPARAM lparam) -{ - ShowHistory((HANDLE)wparam, 0); - return 0; -} - -int BuildContactMenu(WPARAM wparam,LPARAM lparam) -{ - CLISTMENUITEM cmi; - DBVARIANT dbv; - int id=-1,isetting; - HANDLE hContact; - char *szProto; - - hContact = (HANDLE)wparam; - szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0); - - ZeroMemory(&cmi,sizeof(cmi)); - cmi.cbSize=sizeof(cmi); - if (!IsWatchedProtocol(szProto) || !DBGetContactSettingByte(NULL,S_MOD,"MenuItem",1)) - { - cmi.flags=CMIM_FLAGS|CMIF_HIDDEN; - } - else - { - cmi.flags=CMIM_NAME|CMIM_FLAGS|CMIM_ICON; - cmi.hIcon=NULL; - cmi.pszName=ParseString(!DBGetContactSetting(NULL,S_MOD,"MenuStamp",&dbv)?dbv.pszVal:DEFAULT_MENUSTAMP,(HANDLE)wparam,0); - - if (!strcmp(cmi.pszName,Translate(""))) - { - if (IsWatchedProtocol(szProto)) - cmi.flags|=CMIF_GRAYED; - else - cmi.flags|=CMIF_HIDDEN; - } - else if(DBGetContactSettingByte(NULL,S_MOD,"ShowIcon",1)) - { - isetting=DBGetContactSettingWord((HANDLE)hContact,S_MOD,"StatusTriger",-1); - cmi.hIcon=LoadSkinnedProtoIcon(szProto,isetting|0x8000); - - } - } - - CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)hmenuitem,(LPARAM)&cmi); - DBFreeVariant(&dbv); - - return 0; -} - - - -void InitMenuitem() -{ - CLISTMENUITEM cmi; - - hLSUserDet = CreateServiceFunction("LastSeenUserDetails", MenuitemClicked); - - ZeroMemory(&cmi,sizeof(cmi)); - cmi.cbSize=sizeof(cmi); - cmi.flags=0; - cmi.hIcon=NULL; - cmi.hotKey=0; - cmi.position=-0x7FFFFFFF; - cmi.pszContactOwner=NULL; - cmi.pszName=""; - cmi.pszService="LastSeenUserDetails"; - hmenuitem = Menu_AddContactMenuItem(&cmi); - - hBuildMenu = HookEvent(ME_CLIST_PREBUILDCONTACTMENU,BuildContactMenu); - - InitHistoryDialog(); -} - -void UninitMenuitem() -{ - DestroyServiceFunction(hLSUserDet); - UnhookEvent(hBuildMenu); -} \ No newline at end of file diff --git a/plugins/SeenPlugin/missed.cpp b/plugins/SeenPlugin/missed.cpp deleted file mode 100644 index 179dd8ee4d..0000000000 --- a/plugins/SeenPlugin/missed.cpp +++ /dev/null @@ -1,301 +0,0 @@ -/* -"Last Seen mod" plugin for Miranda IM -Copyright ( C ) 2002-03 micron-x -Copyright ( C ) 2005-07 Y.B. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or ( at your option ) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/missed.c $ -Revision : $Rev: 1570 $ -Last change on : $Date: 2007-12-30 01:30:07 +0300 (Р’СЃ, 30 дек 2007) $ -Last change by : $Author: y_b $ -*/ -#include "seen.h" - -#include - - - -MISSEDCONTACTS mcs; -extern HANDLE ehmissed; -extern HINSTANCE hInstance; - - - -WPARAM IsUserMissed(WPARAM contact) -{ - int loop=0; - - for (;loopszSetting,"Status") || (strcmp(cws->szModule,"ICQ") && strcmp(cws->szModule,"MSN")) || (HANDLE)wparam==NULL) return 0; - - if(CallService(MS_IGNORE_ISIGNORED,wparam,IGNOREEVENT_USERONLINE)) - return 0; - - if(cws->value.wVal==ID_STATUS_OFFLINE) - { - if(DBGetContactSettingByte((HANDLE)wparam,S_MOD,"Missed",0)==1) - { - mcs.times[mcs.count]++; - mcs.wpcontact[mcs.count++]=wparam; - DBWriteContactSettingByte((HANDLE)wparam,S_MOD,"Missed",0); - } - - else if(DBGetContactSettingByte((HANDLE)wparam,S_MOD,"Missed",0)==3) - mcs.times[HIWORD(IsUserMissed(wparam))]++; - - return 0; - } - - wpvar=IsUserMissed(wparam); - if(LOWORD(wpvar)) - DBWriteContactSettingByte((HANDLE)wparam,S_MOD,"Missed",3); - - else - DBWriteContactSettingByte((HANDLE)wparam,S_MOD,"Missed",1); - - return 0; -} - -*/ - -int Test(WPARAM wparam,LPARAM lparam) -{ - if(lparamICON_INVIS) - return 0; - - if(CallService(MS_IGNORE_ISIGNORED,wparam,IGNOREEVENT_USERONLINE)) - return 0; - - if(DBGetContactSettingByte((HANDLE)wparam,S_MOD,"Missed",0)==2) - return 0; - - switch(lparam){ - - case ICON_OFFLINE: - if(DBGetContactSettingByte((HANDLE)wparam,S_MOD,"Missed",0)==1) - { - WORD missed=IsUserMissed(wparam); - - if (!LOWORD(missed)) - { - mcs.times[mcs.count]=1; - mcs.wpcontact[mcs.count++]=wparam; - } - else - mcs.times[HIWORD(missed)]++; - - DBWriteContactSettingByte((HANDLE)wparam,S_MOD,"Missed",0); - } - break; - - case ICON_ONLINE: - case ICON_AWAY: - case ICON_NA: - case ICON_OCC: - case ICON_DND: - case ICON_FREE: - case ICON_INVIS: - DBWriteContactSettingByte((HANDLE)wparam,S_MOD,"Missed",1); - break; - } - - return 0; -} - - - -int ModeChange_mo(WPARAM wparam,LPARAM lparam) -{ - ACKDATA *ack; - int isetting=0; - - ack=(ACKDATA *)lparam; - - if(ack->type!=ACKTYPE_STATUS || ack->result!=ACKRESULT_SUCCESS || ack->hContact!=NULL) return 0; - - isetting=CallProtoService(ack->szModule,PS_GETSTATUS,0,0); - - switch(isetting){ - - case ID_STATUS_AWAY: - case ID_STATUS_DND: - case ID_STATUS_NA: - if(ehmissed==NULL) - { - ZeroMemory(&mcs,sizeof(mcs)); - CheckIfOnline(); - //ehmissed=HookEvent(ME_DB_CONTACT_SETTINGCHANGED,LogStatus); - ehmissed=HookEvent(ME_CLIST_CONTACTICONCHANGED,Test); - } - break; - - default: - if(ehmissed!=NULL) - { - UnhookEvent(ehmissed); - ehmissed=NULL; - ShowMissed(); - ResetMissed(); - } - break; - } - - return 0; -} diff --git a/plugins/SeenPlugin/options.cpp b/plugins/SeenPlugin/options.cpp deleted file mode 100644 index daab1e8ee3..0000000000 --- a/plugins/SeenPlugin/options.cpp +++ /dev/null @@ -1,494 +0,0 @@ -/* -"Last Seen mod" plugin for Miranda IM -Copyright ( C ) 2002-03 micron-x -Copyright ( C ) 2005-07 Y.B. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or ( at your option ) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/options.c $ -Revision : $Rev: 1570 $ -Last change on : $Date: 2007-12-30 01:30:07 +0300 (Р’СЃ, 30 дек 2007) $ -Last change by : $Author: y_b $ -*/ -#include "seen.h" - - - -extern HINSTANCE hInstance; -extern HANDLE ehuserinfo,hmenuitem,ehmissed_proto; -void BuildInfo(char *,char *,char *); -int BuildContactMenu(WPARAM,LPARAM); -int UserinfoInit(WPARAM,LPARAM); -int InitFileOutput(void); -void ShutdownFileOutput(void); -void InitMenuitem(void); -int ModeChange_mo(WPARAM,LPARAM); -int CheckIfOnline(void); -int ResetMissed(void); -static BOOL (WINAPI *pfnEnableThemeDialogTexture)(HANDLE, DWORD) = 0; - -INT_PTR CALLBACK OptsPopUpsDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) -{ - DBVARIANT dbv; - int i; - char szstamp[256]; - BOOL hasPopups; - switch(msg) - { - case WM_INITDIALOG:{ - if (hasPopups = (ServiceExists(MS_POPUP_QUERY) != 0)) - hasPopups = CallService(MS_POPUP_QUERY,PUQS_GETSTATUS,0); - TranslateDialogDefault(hdlg); - ShowWindow(GetDlgItem(hdlg,IDC_MISSPOPUP),hasPopups?SW_HIDE:SW_SHOW); - ShowWindow(GetDlgItem(hdlg,IDC_POPUPS),hasPopups?SW_SHOW:SW_HIDE); - ShowWindow(GetDlgItem(hdlg,IDC_POPUPSTAMP),hasPopups?SW_SHOW:SW_HIDE); - ShowWindow(GetDlgItem(hdlg,IDC_LABTEXT),hasPopups?SW_SHOW:SW_HIDE); - ShowWindow(GetDlgItem(hdlg,IDC_LABTTITLE),hasPopups?SW_SHOW:SW_HIDE); - ShowWindow(GetDlgItem(hdlg,IDC_POPUPSTAMPTEXT),hasPopups?SW_SHOW:SW_HIDE); - CheckDlgButton(hdlg,IDC_POPUPS,DBGetContactSettingByte(NULL,S_MOD,"UsePopups",0)&hasPopups); - EnableWindow(GetDlgItem(hdlg,IDC_POPUPS),hasPopups); - hasPopups = IsDlgButtonChecked(hdlg,IDC_POPUPS); - EnableWindow(GetDlgItem(hdlg,IDC_POPUPSTAMP),hasPopups); - EnableWindow(GetDlgItem(hdlg,IDC_POPUPSTAMPTEXT),hasPopups); - for (i=ID_STATUS_OFFLINE;i<=ID_STATUS_OUTTOLUNCH;i++) { - DWORD sett; - COLORREF back, text; - sprintf(szstamp, "Col_%d",i-ID_STATUS_OFFLINE); - sett = DBGetContactSettingDword(NULL,S_MOD,szstamp,StatusColors15bits[i-ID_STATUS_OFFLINE]); - GetColorsFromDWord(&back, &text, sett); - SendDlgItemMessage(hdlg,i,CPM_SETCOLOUR,0,back); - SendDlgItemMessage(hdlg,i+20,CPM_SETCOLOUR,0,text); - EnableWindow(GetDlgItem(hdlg,i),hasPopups); - EnableWindow(GetDlgItem(hdlg,i+20),hasPopups); - } - - SetDlgItemText(hdlg,IDC_POPUPSTAMP,!DBGetContactSetting(NULL,S_MOD,"PopupStamp",&dbv)?dbv.pszVal:DEFAULT_POPUPSTAMP); - DBFreeVariant(&dbv); - SetDlgItemText(hdlg,IDC_POPUPSTAMPTEXT,!DBGetContactSetting(NULL,S_MOD,"PopupStampText",&dbv)?dbv.pszVal:DEFAULT_POPUPSTAMPTEXT); - DBFreeVariant(&dbv); - - } - break; //case WM_INITDIALOG - case WM_COMMAND: - if ((HIWORD(wparam)==BN_CLICKED || HIWORD(wparam)==EN_CHANGE) && GetFocus()==(HWND)lparam) - SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); - else if (HIWORD(wparam)==CPN_COLOURCHANGED){ - WORD idText, idBack; - POPUPDATAEX ppd = {0}; - DBVARIANT dbv = {0}; - DWORD temp; - if (LOWORD(wparam)>ID_STATUS_OUTTOLUNCH){ // we have clicked a text color - idText = wparam; idBack = wparam-20; - } else {idText = wparam+20; idBack = wparam;} - ppd.colorBack = SendDlgItemMessage(hdlg,idBack,CPM_GETCOLOUR,0,0); - ppd.colorText = SendDlgItemMessage(hdlg,idText,CPM_GETCOLOUR,0,0); - temp = GetDWordFromColors(ppd.colorBack,ppd.colorText); - GetColorsFromDWord(&ppd.colorBack,&ppd.colorText,temp); - SendDlgItemMessage(hdlg,idBack,CPM_SETCOLOUR,0,ppd.colorBack); - SendDlgItemMessage(hdlg,idText,CPM_SETCOLOUR,0,ppd.colorText); - ppd.lchIcon = LoadSkinnedProtoIcon(NULL, idBack); - GetDlgItemText(hdlg,IDC_POPUPSTAMP,szstamp,255); - strncpy(ppd.lpzContactName,ParseString(szstamp,NULL,0),MAX_CONTACTNAME); - GetDlgItemText(hdlg,IDC_POPUPSTAMPTEXT,szstamp,255); - strncpy(ppd.lpzText,ParseString(szstamp,NULL,0),MAX_SECONDLINE); - CallService(MS_POPUP_ADDPOPUPEX, (WPARAM)&ppd, 0); - - SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); - } - if(HIWORD(wparam)==BN_CLICKED) - { - switch(LOWORD(wparam)) { - case IDC_POPUPS: - hasPopups = IsDlgButtonChecked(hdlg,IDC_POPUPS); - EnableWindow(GetDlgItem(hdlg,IDC_POPUPSTAMP),hasPopups); - EnableWindow(GetDlgItem(hdlg,IDC_POPUPSTAMPTEXT),hasPopups); - for (i=ID_STATUS_OFFLINE;i<=ID_STATUS_OUTTOLUNCH;i++) { - EnableWindow(GetDlgItem(hdlg,i),hasPopups); - EnableWindow(GetDlgItem(hdlg,i+20),hasPopups); - } - break; - case IDC_DEFAULTCOL: - for (i=ID_STATUS_OFFLINE;i<=ID_STATUS_OUTTOLUNCH;i++) { - DWORD sett; - COLORREF back, text; - sprintf(szstamp, "Col_%d",i-ID_STATUS_OFFLINE); - sett = StatusColors15bits[i-ID_STATUS_OFFLINE]; - GetColorsFromDWord(&back, &text, sett); - SendDlgItemMessage(hdlg,i,CPM_SETCOLOUR,0,back); - SendDlgItemMessage(hdlg,i+20,CPM_SETCOLOUR,0,text); - } - break; - } - } - break; //case WM_COMMAND - - case WM_NOTIFY: - switch(((LPNMHDR)lparam)->idFrom) - { - case 0: - switch (((LPNMHDR)lparam)->code) - { - BYTE checkValue; - - case PSN_APPLY: - GetDlgItemText(hdlg,IDC_POPUPSTAMP,szstamp,256); - DBWriteContactSettingString(NULL,S_MOD,"PopupStamp",szstamp); - GetDlgItemText(hdlg,IDC_POPUPSTAMPTEXT,szstamp,256); - DBWriteContactSettingString(NULL,S_MOD,"PopupStampText",szstamp); - - checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_POPUPS); - if (DBGetContactSettingByte(NULL,S_MOD,"UsePopups",0) != checkValue) { - DBWriteContactSettingByte(NULL,S_MOD,"UsePopups",checkValue); - } - for (i=ID_STATUS_OFFLINE;i<=ID_STATUS_OUTTOLUNCH;i++) { - DWORD sett; - COLORREF back=0, text=0; - sprintf(szstamp, "Col_%d",i-ID_STATUS_OFFLINE); - back = SendDlgItemMessage(hdlg,i,CPM_GETCOLOUR,0,0); - text = SendDlgItemMessage(hdlg,i+20,CPM_GETCOLOUR,0,0); - sett=GetDWordFromColors(back,text); - if (sett!=StatusColors15bits[i-ID_STATUS_OFFLINE]) - DBWriteContactSettingDword(NULL,S_MOD,szstamp,sett); - else DBDeleteContactSetting(NULL,S_MOD,szstamp); - } - - break; //case PSN_APPLY - } - break; //case 0 - } - break;//case WM_NOTIFY - - } - - return 0; -} - -INT_PTR CALLBACK OptsSettingsDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) -{ - DBVARIANT dbv; - char szstamp[256]; - BYTE bchecked=0; - WPARAM wpsend=0; - - switch(msg) - { - case WM_INITDIALOG:{ - TranslateDialogDefault(hdlg); - - CheckDlgButton(hdlg,IDC_MENUITEM,DBGetContactSettingByte(NULL,S_MOD,"MenuItem",1)); - CheckDlgButton(hdlg,IDC_USERINFO,DBGetContactSettingByte(NULL,S_MOD,"UserinfoTab",1)); - CheckDlgButton(hdlg,IDC_FILE,DBGetContactSettingByte(NULL,S_MOD,"FileOutput",0)); - CheckDlgButton(hdlg,IDC_HISTORY,DBGetContactSettingByte(NULL,S_MOD,"KeepHistory",0)); - CheckDlgButton(hdlg,IDC_IGNOREOFFLINE,DBGetContactSettingByte(NULL,S_MOD,"IgnoreOffline",1)); - CheckDlgButton(hdlg,IDC_MISSEDONES,DBGetContactSettingByte(NULL,S_MOD,"MissedOnes",0)); - CheckDlgButton(hdlg,IDC_SHOWICON,DBGetContactSettingByte(NULL,S_MOD,"ShowIcon",1)); - CheckDlgButton(hdlg,IDC_COUNT,DBGetContactSettingByte(NULL,S_MOD,"MissedOnes_Count",0)); - CheckDlgButton(hdlg,IDC_IDLESUPPORT,DBGetContactSettingByte(NULL,S_MOD,"IdleSupport",1)); - - EnableWindow(GetDlgItem(hdlg,IDC_MENUSTAMP),IsDlgButtonChecked(hdlg,IDC_MENUITEM)); - EnableWindow(GetDlgItem(hdlg,IDC_SHOWICON),IsDlgButtonChecked(hdlg,IDC_MENUITEM)); - EnableWindow(GetDlgItem(hdlg,IDC_USERSTAMP),IsDlgButtonChecked(hdlg,IDC_USERINFO)); - EnableWindow(GetDlgItem(hdlg,IDC_FILESTAMP),IsDlgButtonChecked(hdlg,IDC_FILE)); - EnableWindow(GetDlgItem(hdlg,IDC_FILENAME),IsDlgButtonChecked(hdlg,IDC_FILE)); - EnableWindow(GetDlgItem(hdlg,IDC_HISTORYSIZE),IsDlgButtonChecked(hdlg,IDC_HISTORY)); - EnableWindow(GetDlgItem(hdlg,IDC_HISTORYSTAMP),IsDlgButtonChecked(hdlg,IDC_HISTORY)); - EnableWindow(GetDlgItem(hdlg,IDC_COUNT),IsDlgButtonChecked(hdlg,IDC_MISSEDONES)); - - SetDlgItemText(hdlg,IDC_MENUSTAMP,!DBGetContactSetting(NULL,S_MOD,"MenuStamp",&dbv)?dbv.pszVal:DEFAULT_MENUSTAMP); - DBFreeVariant(&dbv); - SetDlgItemText(hdlg,IDC_USERSTAMP,!DBGetContactSetting(NULL,S_MOD,"UserStamp",&dbv)?dbv.pszVal:DEFAULT_USERSTAMP); - DBFreeVariant(&dbv); - SetDlgItemText(hdlg,IDC_FILESTAMP,!DBGetContactSetting(NULL,S_MOD,"FileStamp",&dbv)?dbv.pszVal:DEFAULT_FILESTAMP); - DBFreeVariant(&dbv); - SetDlgItemText(hdlg,IDC_FILENAME,!DBGetContactSetting(NULL,S_MOD,"FileName",&dbv)?dbv.pszVal:DEFAULT_FILENAME); - DBFreeVariant(&dbv); - SetDlgItemInt(hdlg,IDC_HISTORYSIZE,DBGetContactSettingWord(NULL,S_MOD,"HistoryMax",10-1)-1,FALSE); - SetDlgItemText(hdlg,IDC_HISTORYSTAMP,!DBGetContactSetting(NULL,S_MOD,"HistoryStamp",&dbv)?dbv.pszVal:DEFAULT_HISTORYSTAMP); - DBFreeVariant(&dbv); - - // load protocol list - SetWindowLongPtr(GetDlgItem(hdlg,IDC_PROTOCOLLIST),GWL_STYLE,GetWindowLongPtr(GetDlgItem(hdlg,IDC_PROTOCOLLIST),GWL_STYLE)|TVS_CHECKBOXES); - { - TVINSERTSTRUCT tvis; - int numberOfProtocols,i; - PROTOCOLDESCRIPTOR** protos; - char *protoName; - char *protoLabel; - - tvis.hParent=NULL; - tvis.hInsertAfter=TVI_LAST; - tvis.item.mask=TVIF_TEXT | TVIF_HANDLE | TVIF_STATE | TVIF_PARAM; - tvis.item.stateMask = TVIS_STATEIMAGEMASK; - - CallService(MS_PROTO_ENUMPROTOCOLS,(WPARAM)&numberOfProtocols,(LPARAM)&protos); - for (i=0; itype!=PROTOTYPE_PROTOCOL || CallProtoService(protos[i]->szName,PS_GETCAPS,PFLAGNUM_2,0)==0) continue; - protoName = (char *)malloc(strlen(protos[i]->szName)+1); - strcpy(protoName,protos[i]->szName); -//debug(protoName); - protoLabel = (char *)malloc(MAXMODULELABELLENGTH+1); - CallProtoService(protoName,PS_GETNAME,MAXMODULELABELLENGTH,(LPARAM)protoLabel); -//debug(protoLabel); - tvis.item.pszText = protoLabel; - tvis.item.lParam = (LPARAM)protoName; - tvis.item.state = INDEXTOSTATEIMAGEMASK(IsWatchedProtocol(protoName)+1); - TreeView_InsertItem(GetDlgItem(hdlg,IDC_PROTOCOLLIST),&tvis); - free(protoLabel); - - } - } - } - break; //case WM_INITDIALOG - - case WM_COMMAND: - if ((HIWORD(wparam)==BN_CLICKED || HIWORD(wparam)==EN_CHANGE) && GetFocus()==(HWND)lparam) - if (LOWORD(wparam)!=IDC_VARIABLES)SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); - - if(HIWORD(wparam)==BN_CLICKED) - { - switch(LOWORD(wparam)) { - case IDC_MENUITEM: - EnableWindow(GetDlgItem(hdlg,IDC_MENUSTAMP),IsDlgButtonChecked(hdlg,IDC_MENUITEM)); - EnableWindow(GetDlgItem(hdlg,IDC_SHOWICON),IsDlgButtonChecked(hdlg,IDC_MENUITEM)); - break; - case IDC_USERINFO: - EnableWindow(GetDlgItem(hdlg,IDC_USERSTAMP),IsDlgButtonChecked(hdlg,IDC_USERINFO)); - break; - case IDC_FILE: - EnableWindow(GetDlgItem(hdlg,IDC_FILESTAMP),IsDlgButtonChecked(hdlg,IDC_FILE)); - EnableWindow(GetDlgItem(hdlg,IDC_FILENAME),IsDlgButtonChecked(hdlg,IDC_FILE)); - break; - case IDC_HISTORY: - EnableWindow(GetDlgItem(hdlg,IDC_HISTORYSTAMP),IsDlgButtonChecked(hdlg,IDC_HISTORY)); - EnableWindow(GetDlgItem(hdlg,IDC_HISTORYSIZE),IsDlgButtonChecked(hdlg,IDC_HISTORY)); - break; - case IDC_MISSEDONES: - EnableWindow(GetDlgItem(hdlg,IDC_COUNT),IsDlgButtonChecked(hdlg,IDC_MISSEDONES)); - break; - } - } - - if (LOWORD(wparam)==IDC_VARIABLES) - { - char szout[2048]=""; - wsprintf(szout,VARIABLE_LIST); - MessageBox(NULL,szout,Translate("Last Seen Variables"),MB_OK|MB_TOPMOST); - } - - break; //case WM_COMMAND - - case WM_NOTIFY: - switch(((LPNMHDR)lparam)->idFrom) - { - case 0: - switch (((LPNMHDR)lparam)->code) - { - BYTE checkValue; - - case PSN_APPLY: - - GetDlgItemText(hdlg,IDC_MENUSTAMP,szstamp,256); - DBWriteContactSettingString(NULL,S_MOD,"MenuStamp",szstamp); - - GetDlgItemText(hdlg,IDC_USERSTAMP,szstamp,256); - DBWriteContactSettingString(NULL,S_MOD,"UserStamp",szstamp); - - GetDlgItemText(hdlg,IDC_FILESTAMP,szstamp,256); - DBWriteContactSettingString(NULL,S_MOD,"FileStamp",szstamp); - - GetDlgItemText(hdlg,IDC_FILENAME,szstamp,256); - DBWriteContactSettingString(NULL,S_MOD,"FileName",szstamp); - - GetDlgItemText(hdlg,IDC_HISTORYSTAMP,szstamp,256); - DBWriteContactSettingString(NULL,S_MOD,"HistoryStamp",szstamp); - - DBWriteContactSettingWord(NULL,S_MOD,"HistoryMax",(WORD)(GetDlgItemInt(hdlg,IDC_HISTORYSIZE,NULL,FALSE)+1)); - - checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_MENUITEM); - if (DBGetContactSettingByte(NULL,S_MOD,"MenuItem",1) != checkValue) { - DBWriteContactSettingByte(NULL,S_MOD,"MenuItem",checkValue); - if(hmenuitem==NULL && checkValue) { - InitMenuitem(); - } - } - - checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_USERINFO); - if (DBGetContactSettingByte(NULL,S_MOD,"UserinfoTab",1) != checkValue) { - DBWriteContactSettingByte(NULL,S_MOD,"UserinfoTab",checkValue); - if(checkValue) { - ehuserinfo=HookEvent(ME_USERINFO_INITIALISE,UserinfoInit); - } else { - UnhookEvent(ehuserinfo); - } - } - - checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_FILE); - if (DBGetContactSettingByte(NULL,S_MOD,"FileOutput",0) != checkValue) { - DBWriteContactSettingByte(NULL,S_MOD,"FileOutput",checkValue); - if(checkValue) { - InitFileOutput(); - } - } - - checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_HISTORY); - if (DBGetContactSettingByte(NULL,S_MOD,"KeepHistory",0) != checkValue) { - DBWriteContactSettingByte(NULL,S_MOD,"KeepHistory",checkValue); - } - - checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_IGNOREOFFLINE); - if (DBGetContactSettingByte(NULL,S_MOD,"IgnoreOffline",1) != checkValue) { - DBWriteContactSettingByte(NULL,S_MOD,"IgnoreOffline",checkValue); - } - - checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_MISSEDONES); - if (DBGetContactSettingByte(NULL,S_MOD,"MissedOnes",0) != checkValue) { - DBWriteContactSettingByte(NULL,S_MOD,"MissedOnes",checkValue); - if(checkValue) { - ehmissed_proto=HookEvent(ME_PROTO_ACK,ModeChange_mo); - } else { - UnhookEvent(ehmissed_proto); - } - } - - checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_SHOWICON); - if (DBGetContactSettingByte(NULL,S_MOD,"ShowIcon",1) != checkValue) { - DBWriteContactSettingByte(NULL,S_MOD,"ShowIcon",checkValue); - } - - checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_COUNT); - if (DBGetContactSettingByte(NULL,S_MOD,"MissedOnes_Count",0) != checkValue) { - DBWriteContactSettingByte(NULL,S_MOD,"MissedOnes_Count",checkValue); - } - - includeIdle = (BYTE)IsDlgButtonChecked(hdlg,IDC_IDLESUPPORT); - if (DBGetContactSettingByte(NULL,S_MOD,"IdleSupport",1) != includeIdle) { - DBWriteContactSettingByte(NULL,S_MOD,"IdleSupport",(BYTE)includeIdle); - } - - // save protocol list - { - HWND hwndTreeView = GetDlgItem(hdlg,IDC_PROTOCOLLIST); - HTREEITEM hItem; - TVITEM tvItem; - char *watchedProtocols; - char *protocol; - int size=1; - - watchedProtocols = (char *)malloc(sizeof(char)); - *watchedProtocols = '\0'; - hItem = TreeView_GetRoot(hwndTreeView); - tvItem.mask = TVIF_HANDLE | TVIF_STATE | TVIF_PARAM; - tvItem.stateMask = TVIS_STATEIMAGEMASK; - - while (hItem != NULL) { - tvItem.hItem = hItem; - TreeView_GetItem(hwndTreeView, &tvItem); - protocol = (char*)tvItem.lParam; - if ((BOOL)(tvItem.state >> 12) -1) { - size = (size + (int)_tcslen(protocol)+2) * sizeof(char); - watchedProtocols = (char *)realloc(watchedProtocols, size); - strcat(watchedProtocols, protocol); - strcat(watchedProtocols, " "); - } - hItem = TreeView_GetNextSibling(hwndTreeView, hItem); - } - DBWriteContactSettingString(NULL,S_MOD,"WatchedProtocols",watchedProtocols); - free(watchedProtocols); - } - - break; //case PSN_APPLY - } - break; //case 0 - - case IDC_PROTOCOLLIST: - switch (((LPNMHDR)lparam)->code) - { - case NM_CLICK: - { - HWND hTree=((LPNMHDR)lparam)->hwndFrom; - TVHITTESTINFO hti; - HTREEITEM hItem; - - hti.pt.x=(short)LOWORD(GetMessagePos()); - hti.pt.y=(short)HIWORD(GetMessagePos()); - ScreenToClient(hTree,&hti.pt); - if(hItem=TreeView_HitTest(hTree,&hti)) - { - if (hti.flags & TVHT_ONITEM) - TreeView_SelectItem(hTree,hItem); - if (hti.flags & TVHT_ONITEMSTATEICON) - SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); - - } - } - break; - } - break; //case IDC_PROTOCOLLIST - } - break;//case WM_NOTIFY - - case WM_DESTROY: - // free protocol list - { - HWND hwndTreeView = GetDlgItem(hdlg,IDC_PROTOCOLLIST); - HTREEITEM hItem; - TVITEM tvItem; - - hItem = TreeView_GetRoot(hwndTreeView); - tvItem.mask = TVIF_HANDLE | TVIF_PARAM; - - while (hItem != NULL) { - tvItem.hItem = hItem; - TreeView_GetItem(hwndTreeView, &tvItem); - free((void *)tvItem.lParam); - hItem = TreeView_GetNextSibling(hwndTreeView, hItem); - } - } - break; - - } - - return 0; -} - -int OptionsInit(WPARAM wparam,LPARAM lparam) -{ - OPTIONSDIALOGPAGE odp = { 0 }; - - if(IsWinVerXPPlus()) { - HMODULE hUxTheme = GetModuleHandle(_T("uxtheme.dll")); - if (hUxTheme) - pfnEnableThemeDialogTexture = (BOOL (WINAPI *)(HANDLE, DWORD))GetProcAddress(hUxTheme, "EnableThemeDialogTexture"); - } - - odp.cbSize = sizeof(odp); - odp.position = 100000000; - odp.hInstance = hInstance; - odp.flags = ODPF_BOLDGROUPS; - odp.pszTemplate = MAKEINTRESOURCE(IDD_SETTINGS); - odp.pszGroup = LPGEN("Services"); - odp.pszTitle = LPGEN("Last seen"); - odp.pfnDlgProc = OptsSettingsDlgProc; - Options_AddPage(wparam,&odp); - - if (ServiceExists(MS_POPUP_ADDPOPUP)) { - odp.pszTemplate = MAKEINTRESOURCE(IDD_POPUPS); - odp.pszGroup = LPGEN("PopUps"); - odp.pszTitle = LPGEN("Last seen"); - odp.pfnDlgProc = OptsPopUpsDlgProc; - Options_AddPage(wparam,&odp); - } - return 0; -} diff --git a/plugins/SeenPlugin/readme_src.txt b/plugins/SeenPlugin/readme_src.txt deleted file mode 100644 index 0769b49b03..0000000000 --- a/plugins/SeenPlugin/readme_src.txt +++ /dev/null @@ -1,23 +0,0 @@ -This source code is licensed under the GPL (http://www.gnu.org/copyleft/gpl.html) - -Please notify me of any changes that improve the plugin or add -new features. - -If you have any questions on the code, feel free to contact me at -UIN: 46955367 or -eMail: micron@nexgo.de -Visit http://home.nexgo.de/micron/miranda for the latest source files - -micron-x - - - -Rebase information -****************** -enotify.dll 0x67700000 -dbviewer.dll 0x67600000 -hotkey.dll 0x67500000 -pluginsweeper.dll 0x67400000 -seenplugin.dll 0x67300000 -tipinfo.dll 0x67200000 -visibility.dll 0x67100000 \ No newline at end of file diff --git a/plugins/SeenPlugin/res/resource.rc b/plugins/SeenPlugin/res/resource.rc new file mode 100644 index 0000000000..4f93191aca --- /dev/null +++ b/plugins/SeenPlugin/res/resource.rc @@ -0,0 +1,280 @@ +//Microsoft Developer Studio generated resource script. +// +#include "..\src\resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// German (Germany) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) +#ifdef _WIN32 +LANGUAGE LANG_GERMAN, SUBLANG_GERMAN +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "..\\src\\resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include \0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_SETTINGS DIALOGEX 0, 0, 300, 228 +STYLE DS_3DLOOK | DS_FIXEDSYS | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + GROUPBOX "Last seen options",IDC_MAINGROUP,0,0,299,226,WS_GROUP + CONTROL "Last seen menuitem",IDC_MENUITEM,"Button", + BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,6,12,132,10 + CONTROL "Show icon",IDC_SHOWICON,"Button",BS_AUTOCHECKBOX | + WS_GROUP | WS_TABSTOP,141,12,69,10 + EDITTEXT IDC_MENUSTAMP,18,23,120,12,ES_AUTOHSCROLL | WS_GROUP + CONTROL "Userinfo tab",IDC_USERINFO,"Button",BS_AUTOCHECKBOX | + WS_GROUP | WS_TABSTOP,6,42,140,10 + EDITTEXT IDC_USERSTAMP,18,52,275,12,ES_AUTOHSCROLL | WS_GROUP + CONTROL "Log to file",IDC_FILE,"Button",BS_AUTOCHECKBOX | + WS_GROUP | WS_TABSTOP,6,72,132,10 + EDITTEXT IDC_FILENAME,149,69,144,12,ES_AUTOHSCROLL + EDITTEXT IDC_FILESTAMP,18,83,275,12,ES_AUTOHSCROLL | WS_GROUP + CONTROL "Log to history",IDC_HISTORY,"Button",BS_AUTOCHECKBOX | + WS_GROUP | WS_TABSTOP,7,104,131,10 + LTEXT "Maximum size",IDC_STATIC,183,102,51,9 + EDITTEXT IDC_HISTORYSIZE,149,100,30,12,ES_AUTOHSCROLL | ES_NUMBER + EDITTEXT IDC_HISTORYSTAMP,18,114,275,12,ES_AUTOHSCROLL | WS_GROUP + PUSHBUTTON "Variable list",IDC_VARIABLES,47,137,50,13 + CONTROL "Enable Idle support",IDC_IDLESUPPORT,"Button", + BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,7,158,135,10 + CONTROL "Ignore contacts going offline",IDC_IGNOREOFFLINE,"Button", + BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,7,174,135,10 + CONTROL "Enable 'Missed Ones' feature",IDC_MISSEDONES,"Button", + BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,7,190,135,10 + CONTROL "Count times",IDC_COUNT,"Button",BS_AUTOCHECKBOX | + WS_GROUP | WS_TABSTOP,18,202,100,10 + LTEXT "Protocols to watch:",IDC_MAINGROUP,149,130,114,9 + CONTROL "Tree1",IDC_PROTOCOLLIST,"SysTreeView32",TVS_NOTOOLTIPS | + WS_BORDER | WS_TABSTOP,149,140,144,81 +END + +IDD_POPUPS DIALOGEX 0, 0, 280, 208 +STYLE DS_3DLOOK | DS_FIXEDSYS | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + GROUPBOX "",IDC_STATIC,0,0,280,26,WS_GROUP + CTEXT "Popup interoperability missing or disabled. You need Popups plugin",IDC_MISSPOPUP,1,11,280,10,NOT WS_VISIBLE + CONTROL "Use popups",IDC_POPUPS,"Button",BS_AUTOCHECKBOX | + WS_GROUP | WS_TABSTOP,3,10,50,10 + RTEXT "Title",IDC_LABTEXT,57,11,40,10 + EDITTEXT IDC_POPUPSTAMP,100,9,50,12,ES_AUTOHSCROLL | WS_GROUP + RTEXT "Text",IDC_LABTTITLE,155,11,25,10 + EDITTEXT IDC_POPUPSTAMPTEXT,185,9,88,12,ES_AUTOHSCROLL | + WS_GROUP + GROUPBOX "PopUp Colors",IDC_STATIC,0,30,280,136,WS_GROUP + RTEXT "Online",IDC_STATIC,10,43,60,10 + CONTROL "",ID_STATUS_ONLINE,"ColourPicker",WS_TABSTOP,80,40,20,14 + CONTROL "",ID_STATUS_ONLINE+20,"ColourPicker",WS_TABSTOP,105,40,20,14 + RTEXT "Away",IDC_STATIC,10,63,60,10 + CONTROL "",ID_STATUS_AWAY,"ColourPicker",WS_TABSTOP,80,60,20,14 + CONTROL "",ID_STATUS_AWAY+20,"ColourPicker",WS_TABSTOP,105,60,20,14 + RTEXT "N/A",IDC_STATIC,10,83,60,10 + CONTROL "",ID_STATUS_NA,"ColourPicker",WS_TABSTOP,80,80,20,14 + CONTROL "",ID_STATUS_NA+20,"ColourPicker",WS_TABSTOP,105,80,20,14 + RTEXT "Occupied",IDC_STATIC,10,103,60,10 + CONTROL "",ID_STATUS_OCCUPIED,"ColourPicker",WS_TABSTOP,80,100,20,14 + CONTROL "",ID_STATUS_OCCUPIED+20,"ColourPicker",WS_TABSTOP,105,100,20,14 + RTEXT "DND",IDC_STATIC,10,123,60,10 + CONTROL "",ID_STATUS_DND,"ColourPicker",WS_TABSTOP,80,120,20,14 + CONTROL "",ID_STATUS_DND+20,"ColourPicker",WS_TABSTOP,105,120,20,14 + + RTEXT "On the phone",IDC_STATIC,140,43,60,10 + CONTROL "",ID_STATUS_ONTHEPHONE,"ColourPicker",WS_TABSTOP,210,40,20,14 + CONTROL "",ID_STATUS_ONTHEPHONE+20,"ColourPicker",WS_TABSTOP,235,40,20,14 + RTEXT "Out to lunch",IDC_STATIC,140,63,60,10 + CONTROL "",ID_STATUS_OUTTOLUNCH,"ColourPicker",WS_TABSTOP,210,60,20,14 + CONTROL "",ID_STATUS_OUTTOLUNCH+20,"ColourPicker",WS_TABSTOP,235,60,20,14 + RTEXT "Free for chat",IDC_STATIC,140,83,60,10 + CONTROL "",ID_STATUS_FREECHAT,"ColourPicker",WS_TABSTOP,210,80,20,14 + CONTROL "",ID_STATUS_FREECHAT+20,"ColourPicker",WS_TABSTOP,235,80,20,14 + RTEXT "Invisible",IDC_STATIC,140,103,60,10 + CONTROL "",ID_STATUS_INVISIBLE,"ColourPicker",WS_TABSTOP,210,100,20,14 + CONTROL "",ID_STATUS_INVISIBLE+20,"ColourPicker",WS_TABSTOP,235,100,20,14 + RTEXT "Offline",IDC_STATIC,140,123,60,10 + CONTROL "",ID_STATUS_OFFLINE,"ColourPicker",WS_TABSTOP,210,120,20,14 + CONTROL "",ID_STATUS_OFFLINE+20,"ColourPicker",WS_TABSTOP,235,120,20,14 + PUSHBUTTON "Reset colors",IDC_DEFAULTCOL,115,145,50,13 +END + +IDD_USERINFO DIALOGEX 0, 0, 222, 132 +STYLE DS_3DLOOK | DS_FIXEDSYS | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + EDITTEXT IDC_INFOTEXT,6,6,210,122,ES_MULTILINE | ES_NOHIDESEL | + ES_READONLY | NOT WS_BORDER +END + +IDD_MISSED DIALOGEX 0, 0, 160, 71 +STYLE DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | + WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_CONTROLPARENT +CAPTION "Last seen plugin" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + DEFPUSHBUTTON "OK",IDOK,55,48,50,14 + LTEXT "You missed following contacts:",IDC_TEXT,6,6,148,10 + CTEXT "Test\nTest",IDC_CONTACTS,6,22,148,16 +END + +IDD_HISTORY DIALOGEX 0, 0, 200, 120 +STYLE DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | + WS_CAPTION | WS_SYSMENU | WS_THICKFRAME +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN +// PUSHBUTTON "Variablestest",IDC_TEST,5,5,52,13,NOT WS_VISIBLE + DEFPUSHBUTTON "OK",IDOK,75,101,50,14 + PUSHBUTTON "",IDC_USERMENU,146,5,15,13,BS_ICON | WS_TABSTOP + PUSHBUTTON "",IDC_DETAILS,163,5,15,13,BS_ICON | WS_TABSTOP + PUSHBUTTON "",IDC_SENDMSG,180,5,15,13,BS_ICON | WS_TABSTOP + LISTBOX IDC_HISTORYLIST,5,20,190,59,LBS_NOINTEGRALHEIGHT | + WS_VSCROLL | WS_TABSTOP + CONTROL "Alert when user status changes",IDC_STATUSCHANGE,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,5,86,190,8 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO DISCARDABLE +BEGIN + IDD_OPTIONS, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 293 + VERTGUIDE, 18 + VERTGUIDE, 149 + VERTGUIDE, 161 + TOPMARGIN, 7 + BOTTOMMARGIN, 225 + HORZGUIDE, 22 + END + + IDD_USERINFO, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 215 + TOPMARGIN, 7 + BOTTOMMARGIN, 125 + END + + IDD_MISSED, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 153 + TOPMARGIN, 7 + BOTTOMMARGIN, 64 + END + + IDD_HISTORY, DIALOG + BEGIN + LEFTMARGIN, 5 + RIGHTMARGIN, 195 + TOPMARGIN, 5 + BOTTOMMARGIN, 115 + END +END +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 5,0,4,7 + PRODUCTVERSION 5,0,4,7 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "Comments", "Last Seen Mod Plugin for Miranda IM\0" + VALUE "CompanyName", "Heiko Schillinger, YB\0" + VALUE "FileDescription", "Last Seen Plugin (NSN Compatible)\0" + VALUE "FileVersion", "5.0.4.7\0" + VALUE "InternalName", "Last Seen\0" + VALUE "LegalCopyright", "© 2001-2002 by Heiko Schillinger, 2003 by Bruno Rino, 2006 by YB\0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename", "seenplugin.dll\0" + VALUE "PrivateBuild", "\0" + VALUE "ProductName", " Last Seen Plugin Mod\0" + VALUE "ProductVersion", "5.0.4.7\0" + VALUE "SpecialBuild", "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END + +#endif // German (Germany) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/SeenPlugin/resource.h b/plugins/SeenPlugin/resource.h deleted file mode 100644 index 110639bb3b..0000000000 --- a/plugins/SeenPlugin/resource.h +++ /dev/null @@ -1,93 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by resource.rc -// - -#ifndef TVS_NOTOOLTIPS -#define TVS_NOTOOLTIPS 0x0080 -#endif - -#define ID_STATUS_OFFLINE 40071 -#define ID_STATUS_ONLINE 40072 -#define ID_STATUS_AWAY 40073 -#define ID_STATUS_DND 40074 -#define ID_STATUS_NA 40075 -#define ID_STATUS_OCCUPIED 40076 -#define ID_STATUS_FREECHAT 40077 -#define ID_STATUS_INVISIBLE 40078 -#define ID_STATUS_ONTHEPHONE 40079 -#define ID_STATUS_OUTTOLUNCH 40080 -#define ID_STATUS_IDLE 40081 /* do not use as a status */ - - -#define IDD_SETTINGS 101 -#define IDD_USERINFO 102 -#define IDD_MISSED 103 -#define IDD_USERDETAILS 104 -#define IDD_HISTORY 105 -#define IDD_POPUPS 106 -#define IDC_SEENMENUITEM 1000 -#define IDC_MENUITEM 1001 -#define IDC_UINFOTAB 1002 -#define IDC_USERINFO 1003 -#define IDC_USERTIME 1004 -#define IDC_HISTORY 1005 -#define IDC_FILE 1006 -#define IDC_FILEGROUP 1007 -#define IDC_POPUPS 1008 -#define IDC_TIME 1009 -#define IDC_OWNSTATUS 1010 -#define IDC_TIMESTAMPGROUP 1011 -#define IDC_EDIT1 1012 -#define IDC_TIMESTAMP 1013 -#define IDC_FILESTAMP 1014 -#define IDC_CONTACTS 1015 -#define IDC_INFOTEXT 1016 -#define IDC_TIMESTAMPHELP 1017 -#define IDC_USERSTAMP 1018 -#define IDC_DELCHAR 1019 -#define IDC_HISTORYSTAMP 1020 -#define IDC_DELCHARHELP 1021 -#define IDC_POPUPSTAMP 1022 -#define IDC_MENUGROUP 1023 -#define IDC_POPUPSTAMPTEXT 1023 -#define IDC_MENUTIME 1024 -#define IDC_MENUSTATUS 1025 -#define IDC_MENUSTAMP 1026 -#define IDC_LABTEXT 1027 -#define IDC_MISSPOPUP 1028 -#define IDC_DEFAULTCOL 1029 -#define IDC_FILENAME 1030 -#define IDC_IGNOREOFFLINE 1031 -#define IDC_MISSEDONES 1032 -#define IDC_SHOWICON 1033 -#define IDC_COUNT 1034 -#define IDC_FILENAME2 1035 -#define IDC_HISTORYSIZE 1036 -#define IDC_LASTSEENLIST 1037 -#define IDC_HISTORYLIST 1038 -#define IDC_STATUSCHANGE 1039 -#define IDC_VARIABLES 1040 -#define IDC_PROTOCOLLIST 1041 -#define IDC_USERMENU 1042 -#define IDC_TEST 1043 -#define IDC_DETAILS 1044 -#define IDC_SENDMSG 1045 -#define IDC_LABTTITLE 1046 -#define IDC_OPTIONSTAB 1047 -#define IDC_IDLESUPPORT 1050 -#define IDC_MAINGROUP -1 -#define IDC_INFO -1 -#define IDC_TEXT -1 -#define IDC_STATIC -1 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 107 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1051 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/plugins/SeenPlugin/resource.rc b/plugins/SeenPlugin/resource.rc deleted file mode 100644 index d813b69be3..0000000000 --- a/plugins/SeenPlugin/resource.rc +++ /dev/null @@ -1,284 +0,0 @@ -//Microsoft Developer Studio generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// German (Germany) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) -#ifdef _WIN32 -LANGUAGE LANG_GERMAN, SUBLANG_GERMAN -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include \0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_SETTINGS DIALOGEX 0, 0, 300, 228 -STYLE DS_3DLOOK | DS_FIXEDSYS | WS_CHILD -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - GROUPBOX "Last seen options",IDC_MAINGROUP,0,0,299,226,WS_GROUP - CONTROL "Last seen menuitem",IDC_MENUITEM,"Button", - BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,6,12,132,10 - CONTROL "Show icon",IDC_SHOWICON,"Button",BS_AUTOCHECKBOX | - WS_GROUP | WS_TABSTOP,141,12,69,10 - EDITTEXT IDC_MENUSTAMP,18,23,120,12,ES_AUTOHSCROLL | WS_GROUP - CONTROL "Userinfo tab",IDC_USERINFO,"Button",BS_AUTOCHECKBOX | - WS_GROUP | WS_TABSTOP,6,42,140,10 - EDITTEXT IDC_USERSTAMP,18,52,275,12,ES_AUTOHSCROLL | WS_GROUP - CONTROL "Log to file",IDC_FILE,"Button",BS_AUTOCHECKBOX | - WS_GROUP | WS_TABSTOP,6,72,132,10 - EDITTEXT IDC_FILENAME,149,69,144,12,ES_AUTOHSCROLL - EDITTEXT IDC_FILESTAMP,18,83,275,12,ES_AUTOHSCROLL | WS_GROUP - CONTROL "Log to history",IDC_HISTORY,"Button",BS_AUTOCHECKBOX | - WS_GROUP | WS_TABSTOP,7,104,131,10 - LTEXT "Maximum size",IDC_STATIC,183,102,51,9 - EDITTEXT IDC_HISTORYSIZE,149,100,30,12,ES_AUTOHSCROLL | ES_NUMBER - EDITTEXT IDC_HISTORYSTAMP,18,114,275,12,ES_AUTOHSCROLL | WS_GROUP - PUSHBUTTON "Variable list",IDC_VARIABLES,47,137,50,13 - CONTROL "Enable Idle support",IDC_IDLESUPPORT,"Button", - BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,7,158,135,10 - CONTROL "Ignore contacts going offline",IDC_IGNOREOFFLINE,"Button", - BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,7,174,135,10 - CONTROL "Enable 'Missed Ones' feature",IDC_MISSEDONES,"Button", - BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,7,190,135,10 - CONTROL "Count times",IDC_COUNT,"Button",BS_AUTOCHECKBOX | - WS_GROUP | WS_TABSTOP,18,202,100,10 - LTEXT "Protocols to watch:",IDC_MAINGROUP,149,130,114,9 - CONTROL "Tree1",IDC_PROTOCOLLIST,"SysTreeView32",TVS_NOTOOLTIPS | - WS_BORDER | WS_TABSTOP,149,140,144,81 -END - -IDD_POPUPS DIALOGEX 0, 0, 280, 208 -STYLE DS_3DLOOK | DS_FIXEDSYS | WS_CHILD -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - GROUPBOX "",IDC_STATIC,0,0,280,26,WS_GROUP - CTEXT "Popup interoperability missing or disabled. You need Popups plugin",IDC_MISSPOPUP,1,11,280,10,NOT WS_VISIBLE - CONTROL "Use popups",IDC_POPUPS,"Button",BS_AUTOCHECKBOX | - WS_GROUP | WS_TABSTOP,3,10,50,10 - RTEXT "Title",IDC_LABTEXT,57,11,40,10 - EDITTEXT IDC_POPUPSTAMP,100,9,50,12,ES_AUTOHSCROLL | WS_GROUP - RTEXT "Text",IDC_LABTTITLE,155,11,25,10 - EDITTEXT IDC_POPUPSTAMPTEXT,185,9,88,12,ES_AUTOHSCROLL | - WS_GROUP - GROUPBOX "PopUp Colors",IDC_STATIC,0,30,280,136,WS_GROUP - RTEXT "Online",IDC_STATIC,10,43,60,10 - CONTROL "",ID_STATUS_ONLINE,"ColourPicker",WS_TABSTOP,80,40,20,14 - CONTROL "",ID_STATUS_ONLINE+20,"ColourPicker",WS_TABSTOP,105,40,20,14 - RTEXT "Away",IDC_STATIC,10,63,60,10 - CONTROL "",ID_STATUS_AWAY,"ColourPicker",WS_TABSTOP,80,60,20,14 - CONTROL "",ID_STATUS_AWAY+20,"ColourPicker",WS_TABSTOP,105,60,20,14 - RTEXT "N/A",IDC_STATIC,10,83,60,10 - CONTROL "",ID_STATUS_NA,"ColourPicker",WS_TABSTOP,80,80,20,14 - CONTROL "",ID_STATUS_NA+20,"ColourPicker",WS_TABSTOP,105,80,20,14 - RTEXT "Occupied",IDC_STATIC,10,103,60,10 - CONTROL "",ID_STATUS_OCCUPIED,"ColourPicker",WS_TABSTOP,80,100,20,14 - CONTROL "",ID_STATUS_OCCUPIED+20,"ColourPicker",WS_TABSTOP,105,100,20,14 - RTEXT "DND",IDC_STATIC,10,123,60,10 - CONTROL "",ID_STATUS_DND,"ColourPicker",WS_TABSTOP,80,120,20,14 - CONTROL "",ID_STATUS_DND+20,"ColourPicker",WS_TABSTOP,105,120,20,14 - - RTEXT "On the phone",IDC_STATIC,140,43,60,10 - CONTROL "",ID_STATUS_ONTHEPHONE,"ColourPicker",WS_TABSTOP,210,40,20,14 - CONTROL "",ID_STATUS_ONTHEPHONE+20,"ColourPicker",WS_TABSTOP,235,40,20,14 - RTEXT "Out to lunch",IDC_STATIC,140,63,60,10 - CONTROL "",ID_STATUS_OUTTOLUNCH,"ColourPicker",WS_TABSTOP,210,60,20,14 - CONTROL "",ID_STATUS_OUTTOLUNCH+20,"ColourPicker",WS_TABSTOP,235,60,20,14 - RTEXT "Free for chat",IDC_STATIC,140,83,60,10 - CONTROL "",ID_STATUS_FREECHAT,"ColourPicker",WS_TABSTOP,210,80,20,14 - CONTROL "",ID_STATUS_FREECHAT+20,"ColourPicker",WS_TABSTOP,235,80,20,14 - RTEXT "Invisible",IDC_STATIC,140,103,60,10 - CONTROL "",ID_STATUS_INVISIBLE,"ColourPicker",WS_TABSTOP,210,100,20,14 - CONTROL "",ID_STATUS_INVISIBLE+20,"ColourPicker",WS_TABSTOP,235,100,20,14 - RTEXT "Offline",IDC_STATIC,140,123,60,10 - CONTROL "",ID_STATUS_OFFLINE,"ColourPicker",WS_TABSTOP,210,120,20,14 - CONTROL "",ID_STATUS_OFFLINE+20,"ColourPicker",WS_TABSTOP,235,120,20,14 - PUSHBUTTON "Reset colors",IDC_DEFAULTCOL,115,145,50,13 -END - -IDD_USERINFO DIALOGEX 0, 0, 222, 132 -STYLE DS_3DLOOK | DS_FIXEDSYS | WS_CHILD -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - EDITTEXT IDC_INFOTEXT,6,6,210,122,ES_MULTILINE | ES_NOHIDESEL | - ES_READONLY | NOT WS_BORDER -END - -IDD_MISSED DIALOGEX 0, 0, 160, 71 -STYLE DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | - WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_CONTROLPARENT -CAPTION "Last seen plugin" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - DEFPUSHBUTTON "OK",IDOK,55,48,50,14 - LTEXT "You missed following contacts:",IDC_TEXT,6,6,148,10 - CTEXT "Test\nTest",IDC_CONTACTS,6,22,148,16 -END - -IDD_HISTORY DIALOGEX 0, 0, 200, 120 -STYLE DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | - WS_CAPTION | WS_SYSMENU | WS_THICKFRAME -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN -// PUSHBUTTON "Variablestest",IDC_TEST,5,5,52,13,NOT WS_VISIBLE - DEFPUSHBUTTON "OK",IDOK,75,101,50,14 - PUSHBUTTON "",IDC_USERMENU,146,5,15,13,BS_ICON | WS_TABSTOP - PUSHBUTTON "",IDC_DETAILS,163,5,15,13,BS_ICON | WS_TABSTOP - PUSHBUTTON "",IDC_SENDMSG,180,5,15,13,BS_ICON | WS_TABSTOP - LISTBOX IDC_HISTORYLIST,5,20,190,59,LBS_NOINTEGRALHEIGHT | - WS_VSCROLL | WS_TABSTOP - CONTROL "Alert when user status changes",IDC_STATUSCHANGE,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,5,86,190,8 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE -BEGIN - IDD_OPTIONS, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 293 - VERTGUIDE, 18 - VERTGUIDE, 149 - VERTGUIDE, 161 - TOPMARGIN, 7 - BOTTOMMARGIN, 225 - HORZGUIDE, 22 - END - - IDD_USERINFO, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 215 - TOPMARGIN, 7 - BOTTOMMARGIN, 125 - END - - IDD_MISSED, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 153 - TOPMARGIN, 7 - BOTTOMMARGIN, 64 - END - - IDD_HISTORY, DIALOG - BEGIN - LEFTMARGIN, 5 - RIGHTMARGIN, 195 - TOPMARGIN, 5 - BOTTOMMARGIN, 115 - END -END -#endif // APSTUDIO_INVOKED - - -#ifndef _MAC -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 5,0,4,7 - PRODUCTVERSION 5,0,4,7 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "Comments", "Last Seen Mod Plugin for Miranda IM\0" - VALUE "CompanyName", "Heiko Schillinger, YB\0" - VALUE "FileDescription", "Last Seen Plugin (NSN Compatible)\0" - VALUE "FileVersion", "5.0.4.7\0" - VALUE "InternalName", "Last Seen\0" - VALUE "LegalCopyright", "© 2001-2002 by Heiko Schillinger, 2003 by Bruno Rino, 2006 by YB\0" - VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", "seenplugin.dll\0" - VALUE "PrivateBuild", "\0" - VALUE "ProductName", " Last Seen Plugin Mod\0" - VALUE "ProductVersion", "5.0.4.7\0" - VALUE "SpecialBuild", "\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0, 1200 - END -END - -#endif // !_MAC - -#endif // German (Germany) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/plugins/SeenPlugin/seen.h b/plugins/SeenPlugin/seen.h deleted file mode 100644 index ba2b13a6c2..0000000000 --- a/plugins/SeenPlugin/seen.h +++ /dev/null @@ -1,134 +0,0 @@ -/* -"Last Seen mod" plugin for Miranda IM -Copyright ( C ) 2002-03 micron-x -Copyright ( C ) 2005-07 Y.B. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or ( at your option ) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/seen.h $ -Revision : $Rev: 1570 $ -Last change on : $Date: 2007-12-30 01:30:07 +0300 (Р’СЃ, 30 дек 2007) $ -Last change by : $Author: y_b $ -*/ -#ifndef _WIN32_IE -#define _WIN32_IE 0x0300 -#endif -#define ETDT_ENABLE 0x00000002 -#define ETDT_USETABTEXTURE 0x00000004 -#define ETDT_ENABLETAB (ETDT_ENABLE | ETDT_USETABTEXTURE) -#define MIRANDA_VER 0x0A00 - -#include -#include -#include -#include -#include - -#include "resource.h" -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "m_tipper.h" -WCHAR *any_to_IdleNotidleUnknown(HANDLE hContact, const char *module_name, const char *setting_name, WCHAR *buff, int bufflen); -WCHAR *any_to_Idle(HANDLE hContact, const char *module_name, const char *setting_name, WCHAR *buff, int bufflen); - -#ifdef __GNUC__ -#define NUM100NANOSEC 116444736000000000ULL -#else -#define NUM100NANOSEC 116444736000000000 -#endif - -#define S_MOD "SeenModule" - -//#define UM_CHECKHOOKS (WM_USER+1) - -#define debug(a) MessageBox(NULL,a,"Debug",MB_OK) - -#define IDI_USERDETAILS 160 -#define IDI_DOWNARROW 264 -#define IDI_RECVMSG 136 - -#define ICON_OFFLINE 13 -#define ICON_ONLINE 14 -#define ICON_AWAY 15 -#define ICON_NA 16 -#define ICON_OCC 17 -#define ICON_DND 18 -#define ICON_FREE 19 -#define ICON_INVIS 20 - -#define DEFAULT_MENUSTAMP "%d.%m.%Y - %H:%M [%s]" -#define DEFAULT_POPUPSTAMP Translate("%n is %s (%u)") -#define DEFAULT_POPUPSTAMPTEXT Translate("%i(%r)%bWas %o") -#define DEFAULT_USERSTAMP Translate("Name:%t%N%bStatus:%t%s%bDay:%t%d.%m.%Y%bTime:%t%H:%M:%S%bPrevious Status:%t%o%b%b%P ID:%t%u%bExternal IP:%t%i%bInternal IP:%t%r%bClientID: %t%C%b%bStatus Message:%t%T") -#define DEFAULT_FILESTAMP "%d.%m.%Y %H:%M:%S%t%n%t%s%t%u%t%r | %i%t%N" -#define DEFAULT_FILENAME "logs\\%P.txt" -#define DEFAULT_HISTORYSTAMP "%d.%m.%Y - %H:%M [%s]" -#define DEFAULT_WATCHEDPROTOCOLS "" - -#define VARIABLE_LIST "%s \n%%Y: \t %s \n%%y: \t %s \n%%m: \t %s \n%%E: \t %s \n%%e: \t %s \n%%d: \t %s \n%%W: \t %s \n%%w: \t %s \n\n%s \n%%H: \t %s \n%%h: \t %s \n%%p: \t %s \n%%M: \t %s \n%%S: \t %s \n\n%s \n%%n: \t %s \n%%N: \t %s \n%%u: \t %s \n%%G: \t %s \n%%s: \t %s \n%%T: \t %s \n%%o: \t %s \n%%i: \t %s \n%%r: \t %s \n%%C: \t %s \n%%P: \t %s \n\n%s \n%%t: \t %s \n%%b: \t %s\n\n%s\t%s \"#\" %s\n\t%s %s", Translate("-- Date --"), Translate("year (4 digits)"), Translate("year (2 digits)"), Translate("month"), Translate("name of month"), Translate("short name of month"), Translate("day"), Translate("weekday (full)"), Translate("weekday (abbreviated)"), Translate("-- Time --"), Translate("hours (24)"), Translate("hours (12)"), Translate("AM/PM"), Translate("minutes"), Translate("seconds"), Translate("-- User --"), Translate("username"), Translate("nick"), Translate("UIN/handle"), Translate("Group"), Translate("Status"), Translate("Status message"), Translate("Old status"), Translate("external IP"), Translate("internal IP"),Translate("Client info"),Translate("Protocol"), Translate("-- Format --"), Translate("tabulator"), Translate("line break"), Translate("Note:"),Translate("Use"),Translate("for empty string"),Translate("instead of"),Translate("") - -#ifndef LPCOLORREF -typedef DWORD *LPCOLORREF; -#endif - -typedef struct{ - int count; - WPARAM wpcontact[1024]; - BYTE times[1024]; -} MISSEDCONTACTS; - -int IsWatchedProtocol(const char* szProto); -char *ParseString(char *,HANDLE,BYTE); -extern DWORD StatusColors15bits[]; -void GetColorsFromDWord(LPCOLORREF First, LPCOLORREF Second, DWORD colDword); -DWORD GetDWordFromColors(COLORREF First, COLORREF Second); -int OptionsInit(WPARAM,LPARAM); -int UserinfoInit(WPARAM,LPARAM); -int InitFileOutput(void); -void InitMenuitem(void); -int UpdateValues(WPARAM, LPARAM); -int ModeChange(WPARAM,LPARAM); -void SetOffline(void); -int ModeChange_mo(WPARAM,LPARAM); -int CheckIfOnline(void); -void UninitMenuitem(); - -extern BOOL includeIdle; -typedef struct logthread_info { - char sProtoName[MAXMODULELABELLENGTH]; - HANDLE hContact; - WORD courStatus; - int queueIndex; -} logthread_info; - -extern logthread_info **contactQueue; -extern int contactQueueSize; - diff --git a/plugins/SeenPlugin/seen_info.txt b/plugins/SeenPlugin/seen_info.txt deleted file mode 100644 index 5ba87f079a..0000000000 --- a/plugins/SeenPlugin/seen_info.txt +++ /dev/null @@ -1,216 +0,0 @@ -Last Seen plugin -**************** -This plugin logs when a contact was last seen online. -You can choose between contactmenu item, userinfo page and file output. -Second feature is to show which users were online while you were away. - -micron-x - -Questions and comments to: -micron@nexgo.de - -Last Seen Mod -************* -I did some (quick'n'dirty) modifications to LastSeen plugin to fit better to my taste: - - 1. ICQ IPs are logged correctly; - 2. Variables can be used in the log filename. You could have separate files for different protocols/contacts or create new file each month; - 3. Rewritten "Protocols to watch". Now selecting/deselecting protocols is easy ;) - 4. Solved enable/disable file logging bug - 5. Introduced 6 new variables: - * %P - protocol name (ICQ, ICQ1, MSN...); - * %N - nick on the server; - * %C - Client Info; - * %G - Group; - * %o - Old status; - * %T - Status message - 6. Option to use # instead of % to get empty strings instead of - 7. extended support of multiple yahoo protocols(not tested); - 8. extended support for jabber/s. - 9. popup support - 10. delayed logging to wait for the protocols to update all the settings - 11. option to track idle statuses - -Y.B. -http://saaplugin.no-ip.info/ -http://forums.miranda-im.org/showthread.php?t=2822 - - -Langpack strings -**************** - -see seen_langpack.txt - - - -Version history -*************** - -Last Seen Mod -************* - * v. 5.0.4.7 - o Added special sound for "Uses Logged In" - o Used the core service MS_SYSTEM_FORK_THREAD_EX - - * v. 5.0.4.3 - o Included seenTS DB setting - o "suppress online notification" affects only sounds and popups - o Sounds are working now. Two new are added. - * v. 5.0.4.2 - o Implemented Idle support (Will include "/Idle" to the status if contact is idle) - * v. 5.0.4.1 - o Enabled 32bit icons in lastseen history dialog (fixes the "transperancy bug") - o New variable: %T: Status Message - o Parser rewritten to be safer - o Click on popup will open message window - * v. 5.0.4.0 - o Small memory leak in user info dialog fixed (thanks Tio Duke) - o Increased the delay to check offline contacts 2->10 seconds - o If the contact's status changer while we have been offline the time we went offline will be logged (not the current time) - o Fixed visual glitch in the "last seen history" dialog - o Suppress the DEFMOD_RNDUSERONLINE core functionality - LastSeenMod is not compatible with NewStatusNotify anylonger - o Option to enable clist online notify - * v. 5.0.3.2 - o Better protocol type guessing (based on PFLAG_UNIQUEIDSETTING) - o Popups colors are configurable - o Tabbed interface of the option page - * v. 5.0.3.1 (never released) - o Avoid multiple popups on login - only those for contacts with different status before logoff - o implemented delayed logging of the status changes using thread - o Doesn't show popups is the contact is "hidden" - o Better tracking if the contact went offline while we were offline - o %i and %r are replaced by "resource" and "system" for Jabber/JGmail - * v. 5.0.3.0 - o Enhanced PopUp support: - + separated fields for PopUp title and text - + Correct icon is chosen according to the protocol and status - o New Variable %o - "Old Status" - o JGmail is recognised as Jabber - * v. 5.0.2.6 - o Basic PopUp support - * v. 5.0.2.5 - o Added %G standing for "Group" - o Using variables in the path of the log file(s) is possible now - * v. 5.0.2.4 - o Updated MSN capability bits according to this post - * v. 5.0.2.3 - o Solved enable/disable file logging bug (hopefully) - o Option to use # instead of % to get empty strings instead of - * v. 5.0.2.2 - o Added %C (Client/version for ICQ; ClientID flags for MSN); - o Better support for multiple instances of same protocol; - o Logging contacts of protocol logon/off is back; - * v. 5.0.2.1 - o Updated plugin info - -Last Seen plugin -**************** -5.0.1.1: - - FIX: The protocol list now uses more uuser friendly names - - FIX: The "Missed Ones" feature options weren't saved correctly - - FIX: The "Offline" setting was added even to contacts whose protocol wasn't "watched" - - FIX: Minor cosmetics (icons and tooltips) - - UPDATE: seen_langpack.txt -5.0.1.0: - - FIX: Some protocols added an offline entry for every contact when the user logoff the network - - FIX: An extra character (0 or 1) was added to each line of the file log. - - UPDATE: seen_langpack.txt now contains the strings added on version 5.0.0.0 -5.0.0.1: - - FIX: Removed some code that flooded the network with requests (see http://miranda-icq.sourceforge.net/forums/viewtopic.php?t=11579) - - CHANGE: History now defaults to a "pretier" format. -5.0.0.0: - - FIX: Last statusmode icon displayed according to the contact's protocol - - NEW: Support for all protocols (user selectable) - - NEW: Added dialog showing the recent "seen history" of an user - - NEW: Added option to display an alert when a specified user changes its status - -4.1.6.2: - prevent plugin not loading & new base address - -4.1.6.1: - Silly bug with 4.1.6.0 fixed - -4.1.6.0: - Directory access fix - -4.1.5.0: - fixed 0AM/PM bug - - 'Missed Ones' window doesn't steal focus anymore - - 'Missed Ones' bugfixes - -4.1.4.0: - removed Miranda 0.1.2.0 support - -4.1.3.0: - 'Missed Ones' dismisses ignored contacts (online notification) - - reduced file size - -4.1.2.0: - Added support for Plugin sweeper - -4.1.1.0: - New option: count times a user was online while you were away - - Bug crashing Miranda on open userdetails fixed - -4.1.0.0: - 'Missed Ones' should finally work now - -4.0.9.0: - works now with Miranda v0.1.2.0 - - unknown values grayed out - -4.0.8.0: - fixed bug crashing miranda on status change - -4.0.7.0: - two new variables: %E - name of month and %e abrreviated name of month - - empty userinfo page fixed - -4.0.6.0: - attempted fix for bad userinfo page - - two new variables: %W - weekday and %w - abbr. weekday - -4.0.5.0: - Two new variables: %h - 12 hour time and %p - AM/PM - - New 'Missed Ones' popup (Dialog instead of MessageBox) - -4.0.4.0: - Option to show last statusmode icon - -4.0.3.0: - 'Missed Ones' feature reimplemented - - Miranda crashing on close fixed - -4.0.2.0: - Option to keep track of contacts going offline - - fixed crashing when %u was used - - file output implemented - - one new langpack string - -4.0.1.0: - IP/RealIP variables working now - -4.0.0.0: - Initial release of the totally rewritten version - Please mail me any bug reports - - - -Rebase information -****************** -seenplugin.dll 0x67300000 - -enotify.dll 0x67700000 -dbviewer.dll 0x67600000 -hotkey.dll 0x67500000 -pluginsweeper.dll 0x67400000 -tipinfo.dll 0x67200000 -visibility.dll 0x67100000 - - - -====================================== -"Last Seen mod" plugin for Miranda IM -Copyright ( C ) 2002-03 micron-x -Copyright ( C ) 2005-06 Y.B. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or ( at your option ) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/seen_info.txt $ -Revision : $Rev: 1570 $ -Last change on : $Date: 2007-12-30 01:30:07 +0300 (Р’СЃ, 30 дек 2007) $ -Last change by : $Author: y_b $ - diff --git a/plugins/SeenPlugin/seenplugin-translation.txt b/plugins/SeenPlugin/seenplugin-translation.txt deleted file mode 100644 index 67bbc30ebf..0000000000 --- a/plugins/SeenPlugin/seenplugin-translation.txt +++ /dev/null @@ -1,101 +0,0 @@ -; Common strings that belong to many files -;[] -;[Last seen] - -; ../../plugins/SeenPlugin/history.cpp -;[Send Instant Message] -;[User Menu] -;[View User's Details] -;[last seen history] - -; ../../plugins/SeenPlugin/main.cpp -;[Changed to Online] -;[LastSeen] -;[User Logged In] -;[User Logged Off] -;[User status change] - -; ../../plugins/SeenPlugin/options.cpp -;[Last Seen Variables] -;[PopUps] -;[Services] - -; ../../plugins/SeenPlugin/resource.rc -;[Alert when user status changes] -;[Away] -;[Count times] -;[DND] -;[Enable 'Missed Ones' feature] -;[Enable Idle support] -;[Free for chat] -;[Ignore contacts going offline] -;[Invisible] -;[Last seen menuitem] -;[Last seen options] -;[Last seen plugin] -;[Log to file] -;[Log to history] -;[Maximum size] -;[N/A] -;[OK] -;[Occupied] -;[Offline] -;[On the phone] -;[Online] -;[Out to lunch] -;[PopUp Colors] -;[Popup interoperability missing or disabled. You need Popups plugin] -;[Protocols to watch:] -;[Reset colors] -;[Show icon] -;[Test\nTest] -;[Text] -;[Title] -;[Use popups] -;[Userinfo tab] -;[Variable list] -;[Variablestest] -;[You missed following contacts:] - -; ../../plugins/SeenPlugin/seen.h -;[%i(%r)%bWas %o] -;[%n is %s (%u)] -;[-- Date --] -;[-- Format --] -;[-- Time --] -;[-- User --] -;[AM/PM] -;[Client info] -;[Group] -;[Name:%t%N%bStatus:%t%s%bDay:%t%d.%m.%Y%bTime:%t%H:%M:%S%bPrevious Status:%t%o%b%b%P ID:%t%u%bExternal IP:%t%i%bInternal IP:%t%r%bClientID: %t%C%b%bStatus Message:%t%T] -;[Note:] -;[Old status] -;[Protocol] -;[Status] -;[Status message] -;[UIN/handle] -;[Use] -;[day] -;[external IP] -;[for empty string] -;[hours (12)] -;[hours (24)] -;[instead of] -;[internal IP] -;[line break] -;[minutes] -;[month] -;[name of month] -;[nick] -;[seconds] -;[short name of month] -;[tabulator] -;[username] -;[weekday (abbreviated)] -;[weekday (full)] -;[year (2 digits)] -;[year (4 digits)] - -; ../../plugins/SeenPlugin/utils.cpp -;[] -;[Idle] diff --git a/plugins/SeenPlugin/seenplugin_10.vcxproj b/plugins/SeenPlugin/seenplugin_10.vcxproj index 29b4004f10..4e83e465ef 100644 --- a/plugins/SeenPlugin/seenplugin_10.vcxproj +++ b/plugins/SeenPlugin/seenplugin_10.vcxproj @@ -75,11 +75,10 @@ OnlyExplicitInline Size ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;PERMITNSN;NDEBUG;_WINDOWS;_USRDLL;MP_SEEN_EXPORTS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) true true Level3 - 4996;%(DisableSpecificWarnings) NDEBUG;%(PreprocessorDefinitions) @@ -103,11 +102,10 @@ OnlyExplicitInline Size ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN64;PERMITNSN;NDEBUG;_WINDOWS;_USRDLL;MP_SEEN_EXPORTS;%(PreprocessorDefinitions) + WIN64;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) true true Level3 - 4996;%(DisableSpecificWarnings) NDEBUG;%(PreprocessorDefinitions) @@ -129,13 +127,12 @@ Disabled ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;PERMITNSN;_DEBUG;_WINDOWS;_USRDLL;MP_SEEN_EXPORTS;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL Level3 EditAndContinue - 4996;%(DisableSpecificWarnings) _DEBUG;%(PreprocessorDefinitions) @@ -155,11 +152,10 @@ Disabled ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN64;PERMITNSN;_DEBUG;_WINDOWS;_USRDLL;MP_SEEN_EXPORTS;%(PreprocessorDefinitions) + WIN64;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL Level3 - 4996;%(DisableSpecificWarnings) _DEBUG;%(PreprocessorDefinitions) @@ -176,25 +172,21 @@ - - - - - - - - + + + + + + + + - - + + - - - - - + diff --git a/plugins/SeenPlugin/seenplugin_10.vcxproj.filters b/plugins/SeenPlugin/seenplugin_10.vcxproj.filters index 01ad56020d..77ba5eda3f 100644 --- a/plugins/SeenPlugin/seenplugin_10.vcxproj.filters +++ b/plugins/SeenPlugin/seenplugin_10.vcxproj.filters @@ -15,46 +15,42 @@ - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Header Files - + Header Files - + Resource Files - - - - \ No newline at end of file diff --git a/plugins/SeenPlugin/src/file.cpp b/plugins/SeenPlugin/src/file.cpp new file mode 100644 index 0000000000..cac37f8c30 --- /dev/null +++ b/plugins/SeenPlugin/src/file.cpp @@ -0,0 +1,119 @@ +/* +"Last Seen mod" plugin for Miranda IM +Copyright ( C ) 2002-03 micron-x +Copyright ( C ) 2005-07 Y.B. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or ( at your option ) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/file.c $ +Revision : $Rev: 1570 $ +Last change on : $Date: 2007-12-30 01:30:07 +0300 (Р’СЃ, 30 дек 2007) $ +Last change by : $Author: y_b $ +*/ + +#include "seen.h" +/* +Prepares the log file: +- calculates the absolute path (and store it in the db) +- creates the directory + +*/ +int InitFileOutput(void) +{ + char szfpath[256]="",szmpath[256]="",*str; + DBVARIANT dbv; + + GetModuleFileName(NULL,szmpath,MAX_PATH); + strcpy(szfpath,!DBGetContactSetting(NULL,S_MOD,"FileName",&dbv)?dbv.pszVal:DEFAULT_FILENAME); + + DBFreeVariant(&dbv); + + if(szfpath[0]=='\\') + strcpy(szfpath,szfpath+1); + + str=strrchr(szmpath,'\\'); + if(str!=NULL) + *++str=0; + + strcat(szmpath,szfpath); + + strcpy(szfpath,szmpath); + + str=strrchr(szmpath,'\\'); + if(str!=NULL) + *++str=0; +/* +//we dont need this anylonger. the directory is created in filewrite + if (!CreateDirectory(szmpath,NULL)) + { + if (!(GetFileAttributes(szmpath) & FILE_ATTRIBUTE_DIRECTORY)) + { + MessageBox(NULL,"Directory could not be created\nPlease choose another!","Last seen plugin",MB_OK|MB_ICONERROR); + DBWriteContactSettingByte(NULL,S_MOD,"FileOutput",0); + return 0; + } + } +*/ + DBWriteContactSettingString(NULL,S_MOD,"PathToFile",szfpath); + + return 0; +} + +//borrowed from netliblog.c +static void CreateDirectoryTree(char *szDir) +{ + DWORD dwAttributes; + char *pszLastBackslash,szTestDir[MAX_PATH]; + + lstrcpynA(szTestDir,szDir,sizeof(szTestDir)); + if ((dwAttributes=GetFileAttributesA(szTestDir))!=0xffffffff && dwAttributes&FILE_ATTRIBUTE_DIRECTORY) return; + pszLastBackslash=strrchr(szTestDir,'\\'); + if(pszLastBackslash==NULL) return; + *pszLastBackslash='\0'; + CreateDirectoryTree(szTestDir); + CreateDirectoryA(szTestDir,NULL); +} + +/* +Writes a line into the log. +*/ +void FileWrite(HANDLE hcontact) +{ + HANDLE fhout; + DWORD byteswritten; + char szout[1024],sznl[3]="\r\n"; + DBVARIANT dbv; + + DBGetContactSetting(NULL,S_MOD,"PathToFile",&dbv); + strcpy(szout,ParseString(dbv.pszVal,hcontact,1)); + fhout=CreateFile(szout,GENERIC_WRITE,0,NULL,OPEN_ALWAYS,0,NULL); + if (fhout==INVALID_HANDLE_VALUE){ + CreateDirectoryTree(szout); + fhout=CreateFile(szout,GENERIC_WRITE,0,NULL,OPEN_ALWAYS,0,NULL); + if (fhout==INVALID_HANDLE_VALUE) return; + } + DBFreeVariant(&dbv); + SetFilePointer(fhout,0,0,FILE_END); + + strcpy(szout,ParseString(!DBGetContactSetting(NULL,S_MOD,"FileStamp",&dbv)?dbv.pszVal:DEFAULT_FILESTAMP,hcontact,1)); + DBFreeVariant(&dbv); + + WriteFile(fhout,szout, (DWORD)_tcslen(szout),&byteswritten,NULL); + WriteFile(fhout,sznl, (DWORD)_tcslen(sznl),&byteswritten,NULL); + + CloseHandle(fhout); + + +} diff --git a/plugins/SeenPlugin/src/history.cpp b/plugins/SeenPlugin/src/history.cpp new file mode 100644 index 0000000000..724cfd5612 --- /dev/null +++ b/plugins/SeenPlugin/src/history.cpp @@ -0,0 +1,347 @@ +/* +"Last Seen mod" plugin for Miranda IM +Copyright ( C ) 2002-03 micron-x +Copyright ( C ) 2005-06 Y.B. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or ( at your option ) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/history.c $ +Revision : $Rev: 1056 $ +Last change on : $Date: 2006-10-30 06:22:07 +0300 (РџРЅ, 30 РѕРєС‚ 2006) $ +Last change by : $Author: y_b $ +*/ +#include "seen.h" + + +extern HINSTANCE hInstance; + +static HANDLE hWindowList; + +char* BuildSetting(int historyLast) { + static char setting[15]; + static char sztemp[15]; + *setting = '\0'; + strcat(setting, "History_"); + strcat(setting, itoa(historyLast, sztemp, 10)); + return setting; +} + +void HistoryWrite(HANDLE hContact) +{ + short historyFirst, historyLast, historyMax; + DBVARIANT dbv; + + historyMax = DBGetContactSettingWord(NULL,S_MOD,"HistoryMax",10); + if (historyMax < 0) historyMax=0; else if (historyMax > 99) historyMax = 99; + if (historyMax == 0) return; + historyFirst = DBGetContactSettingWord(hContact,S_MOD,"HistoryFirst",0); + if (historyFirst >= historyMax) historyFirst = 0; + historyLast = DBGetContactSettingWord(hContact,S_MOD,"HistoryLast",0); + if (historyLast >= historyMax) historyLast = historyMax-1; + + DBWriteContactSettingString(hContact,S_MOD,BuildSetting(historyLast), + ParseString(!DBGetContactSetting(NULL,S_MOD,"HistoryStamp",&dbv)?dbv.pszVal:DEFAULT_HISTORYSTAMP,hContact,0)); + DBFreeVariant(&dbv); + + historyLast = (historyLast+1) % historyMax; + DBWriteContactSettingWord(hContact,S_MOD,"HistoryLast",historyLast); + if (historyLast == historyFirst) { + DBWriteContactSettingWord(hContact,S_MOD,"HistoryFirst",(short) ((historyFirst+1) % historyMax)); + } + +} + +void LoadHistoryList(HANDLE hContact, HWND hwnd, int nList) { + short historyFirst, historyLast, historyMax; + short i; + DBVARIANT dbv; + + + SendDlgItemMessage(hwnd, nList, LB_RESETCONTENT, 0, 0); + historyMax = DBGetContactSettingWord(NULL,S_MOD,"HistoryMax",10); + if (historyMax < 0) historyMax = 0; else if (historyMax > 99) historyMax = 99; + if (historyMax == 0) return; + historyFirst = DBGetContactSettingWord(hContact,S_MOD,"HistoryFirst",0); + if (historyFirst >= historyMax) historyFirst = 0; + historyLast = DBGetContactSettingWord(hContact,S_MOD,"HistoryLast",0); + if (historyLast >= historyMax) historyLast = historyMax-1; + + i = historyLast; + while (i != historyFirst) { + i = (i-1+historyMax) % historyMax; + SendDlgItemMessage(hwnd, nList, LB_ADDSTRING, 0, + (LPARAM)(!DBGetContactSetting(hContact,S_MOD,BuildSetting(i),&dbv)?dbv.pszVal:"")); + DBFreeVariant(&dbv); + } + +} + + +HDWP MyResizeWindow (HDWP hDwp, HWND hwndDlg, HWND hwndControl, + int nHorizontalOffset, int nVerticalOffset, + int nWidthOffset, int nHeightOffset) +{ + POINT pt; + RECT rcinit; + + // get current bounding rectangle + GetWindowRect(hwndControl, &rcinit); + + // get current top left point + pt.x = rcinit.left; + pt.y = rcinit.top; + ScreenToClient(hwndDlg, &pt); + + // resize control +/* MoveWindow(hwndControl, + pt.x + nHorizontalOffset, + pt.y + nVerticalOffset, + rcinit.right - rcinit.left + nWidthOffset, + rcinit.bottom - rcinit.top + nHeightOffset, + FALSE); +*/ + return DeferWindowPos(hDwp, hwndControl, NULL, + pt.x + nHorizontalOffset, + pt.y + nVerticalOffset, + rcinit.right - rcinit.left + nWidthOffset, + rcinit.bottom - rcinit.top + nHeightOffset, + SWP_NOZORDER); + + +} + +HDWP MyHorizCenterWindow (HDWP hDwp, HWND hwndDlg, HWND hwndControl, + int nClientWidth, int nVerticalOffset, + int nHeightOffset) +{ + POINT pt; + RECT rcinit; + + // get current bounding rectangle + GetWindowRect(hwndControl, &rcinit); + + // get current top left point + pt.x = rcinit.left; + pt.y = rcinit.top; + ScreenToClient(hwndDlg, &pt); + + // resize control +/* MoveWindow(hwndControl, + (int) ((nClientWidth - (rcinit.right - rcinit.left))/2), + pt.y + nVerticalOffset, + rcinit.right - rcinit.left, + rcinit.bottom - rcinit.top + nHeightOffset, + TRUE); +*/ + return DeferWindowPos(hDwp, hwndControl, NULL, + (int) ((nClientWidth - (rcinit.right - rcinit.left))/2), + pt.y + nVerticalOffset, + rcinit.right - rcinit.left, + rcinit.bottom - rcinit.top + nHeightOffset, + SWP_NOZORDER); + +} +void MyResizeGetOffset (HWND hwndDlg, HWND hwndControl, + int nWidth, int nHeight, + int* nDx, int* nDy) +{ + RECT rcinit; + + // get current bounding rectangle + GetWindowRect(hwndControl, &rcinit); + + // calculate offsets + *nDx = nWidth - (rcinit.right - rcinit.left); + *nDy = nHeight - (rcinit.bottom - rcinit.top); +} + +INT_PTR CALLBACK HistoryDlgProc(HWND hwndDlg, UINT Message, WPARAM wparam, LPARAM lparam) +{ + HANDLE hContact; + char sztemp[1024]=""; + static HIMAGELIST hIml=NULL; + + switch(Message) + { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + hContact = (HANDLE)lparam; + SetWindowLongPtr(hwndDlg,GWLP_USERDATA,lparam); + strcpy(sztemp,(char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,0)); + strcat(sztemp, ": "); + strcat(sztemp, Translate("last seen history")); + SendMessage(hwndDlg, WM_SETTEXT, 0, (LPARAM)sztemp); + SendMessage(hwndDlg, WM_SETICON, (WPARAM) ICON_BIG, (LPARAM) LoadSkinnedIcon(SKINICON_OTHER_MIRANDA)); + SendMessage(hwndDlg, WM_SETICON, (WPARAM) ICON_SMALL, (LPARAM) LoadSkinnedIcon(SKINICON_OTHER_MIRANDA)); + +// LoadHistoryList(hContact, hwndDlg, IDC_HISTORYLIST); + + if (DBGetContactSettingByte(hContact,S_MOD,"OnlineAlert",0)) + SendDlgItemMessage(hwndDlg, IDC_STATUSCHANGE, BM_SETCHECK, (WPARAM)BST_CHECKED, 0); + { + hIml=ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),ILC_COLOR32|ILC_MASK,3,3); + ImageList_AddIcon(hIml,LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_USERDETAILS))); + ImageList_AddIcon(hIml,LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_DOWNARROW))); + ImageList_AddIcon(hIml,LoadSkinnedIcon(SKINICON_EVENT_MESSAGE)); + SendDlgItemMessage(hwndDlg,IDC_DETAILS,BM_SETIMAGE,IMAGE_ICON,(WPARAM)ImageList_GetIcon(hIml,0,ILD_NORMAL)); + SendDlgItemMessage(hwndDlg,IDC_USERMENU,BM_SETIMAGE,IMAGE_ICON,(WPARAM)ImageList_GetIcon(hIml,1,ILD_NORMAL)); + SendDlgItemMessage(hwndDlg,IDC_SENDMSG,BM_SETIMAGE,IMAGE_ICON,(WPARAM)ImageList_GetIcon(hIml,2,ILD_NORMAL)); + } + + //set-up tooltips + { + HWND hwndDlgToolTips; + TOOLINFO ti; + + hwndDlgToolTips = CreateWindowEx(WS_EX_TOPMOST,TOOLTIPS_CLASS,"",WS_POPUP,0,0,0,0,NULL,NULL,GetModuleHandle(NULL),NULL); + ZeroMemory(&ti,sizeof(ti)); + ti.cbSize=sizeof(ti); + ti.uFlags=TTF_IDISHWND|TTF_SUBCLASS; + ti.uId=(UINT)GetDlgItem(hwndDlg,IDC_USERMENU); + ti.lpszText=Translate("User Menu"); + SendMessage(hwndDlgToolTips,TTM_ADDTOOL,0,(LPARAM)&ti); + ti.uId=(UINT)GetDlgItem(hwndDlg,IDC_DETAILS); + ti.lpszText=Translate("View User's Details"); + SendMessage(hwndDlgToolTips,TTM_ADDTOOL,0,(LPARAM)&ti); + ti.uId=(UINT)GetDlgItem(hwndDlg,IDC_SENDMSG); + ti.lpszText=Translate("Send Instant Message"); + SendMessage(hwndDlgToolTips,TTM_ADDTOOL,0,(LPARAM)&ti); + } + + + Utils_RestoreWindowPositionNoMove(hwndDlg,NULL,S_MOD,"History_"); + ShowWindow(hwndDlg, SW_SHOW); + break; + + case WM_MEASUREITEM: + return CallService(MS_CLIST_MENUMEASUREITEM,wparam,lparam); + case WM_DRAWITEM: + return CallService(MS_CLIST_MENUDRAWITEM,wparam,lparam); + case WM_COMMAND: + hContact=(HANDLE)GetWindowLongPtr(hwndDlg,GWLP_USERDATA); + if(CallService(MS_CLIST_MENUPROCESSCOMMAND,MAKEWPARAM(LOWORD(wparam),MPCF_CONTACTMENU),(LPARAM)hContact)) + break; + switch(LOWORD(wparam)) + { + case IDCANCEL: + SendMessage(hwndDlg, WM_CLOSE, 0, 0); + break; + case IDOK: + if (SendDlgItemMessage(hwndDlg, IDC_STATUSCHANGE, BM_GETCHECK, 0, 0) == BST_CHECKED) + DBWriteContactSettingByte(hContact,S_MOD,"OnlineAlert",1); + else + DBWriteContactSettingByte(hContact,S_MOD,"OnlineAlert",0); + SendMessage(hwndDlg, WM_CLOSE, 0, 0); + break; + case IDC_USERMENU: + { + RECT rc; + HMENU hMenu=(HMENU)CallService(MS_CLIST_MENUBUILDCONTACT,(WPARAM)hContact,0); + GetWindowRect(GetDlgItem(hwndDlg,IDC_USERMENU),&rc); + TrackPopupMenu(hMenu,0,rc.left,rc.bottom,0,hwndDlg,NULL); + DestroyMenu(hMenu); + } + break; + case IDC_DETAILS: + CallService(MS_USERINFO_SHOWDIALOG,(WPARAM)hContact,0); + break; + case IDC_SENDMSG: + CallService(MS_MSG_SENDMESSAGE,(WPARAM)hContact,0); + break; + case IDC_TEST: + debug(ParseString("Date: %d.%m.%y(%Y) \n Date desc: %W - %w - %E - %e \n Time: %H:%M:%S (%h-%p) \n user: %n - %u \n Status: %s \n IP: %i - %r",hContact,0)); + break; + } + break; + case WM_SIZE: + { + int dx, dy; + HDWP hDwp; + + hDwp = BeginDeferWindowPos(6); + MyResizeGetOffset(hwndDlg, GetDlgItem(hwndDlg, IDC_HISTORYLIST), + LOWORD(lparam)-15, HIWORD(lparam)-99, &dx, &dy); + hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_USERMENU), + dx, 0, 0, 0); + hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_DETAILS), + dx, 0, 0, 0); + hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_SENDMSG), + dx, 0, 0, 0); + hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_HISTORYLIST), + 0, 0, dx, dy); + hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_STATUSCHANGE), + 0, dy, dx, 0); + hDwp = MyHorizCenterWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDOK), + LOWORD(lparam), dy, 0); + EndDeferWindowPos(hDwp); + } + break; + case WM_GETMINMAXINFO: + { + MINMAXINFO mmi; + CopyMemory (&mmi, (LPMINMAXINFO) lparam, sizeof (MINMAXINFO)); + + /* The minimum width in points*/ + mmi.ptMinTrackSize.x = 200; + /* The minimum height in points*/ + mmi.ptMinTrackSize.y = 190; + + CopyMemory ((LPMINMAXINFO) lparam, &mmi, sizeof (MINMAXINFO)); + } + break; + + case WM_CLOSE: + DestroyWindow(hwndDlg); + WindowList_Remove(hWindowList,hwndDlg); + break; + case WM_DESTROY: + Utils_SaveWindowPosition(hwndDlg,NULL,S_MOD,"History_"); + ImageList_Destroy(hIml); + break; + default: + return FALSE; + } + return TRUE; +} + +void ShowHistory(HANDLE hContact, BYTE isAlert) +{ + HWND hHistoryDlg; + + hHistoryDlg = WindowList_Find(hWindowList,hContact); + if (hHistoryDlg == NULL) + { + hHistoryDlg = CreateDialogParam(hInstance,MAKEINTRESOURCE(IDD_HISTORY),NULL,HistoryDlgProc,(LPARAM)hContact); + LoadHistoryList(hContact, hHistoryDlg, IDC_HISTORYLIST); + WindowList_Add(hWindowList,hHistoryDlg,hContact); + } + else + { + SetForegroundWindow(hHistoryDlg); + LoadHistoryList(hContact, hHistoryDlg, IDC_HISTORYLIST); + SetFocus(hHistoryDlg); + } + + if (isAlert) + { + SkinPlaySound("LastSeenTrackedStatusChange"); + } +} + + +void InitHistoryDialog(void) +{ + hWindowList=(HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST,0,0); +} diff --git a/plugins/SeenPlugin/src/main.cpp b/plugins/SeenPlugin/src/main.cpp new file mode 100644 index 0000000000..68a774e435 --- /dev/null +++ b/plugins/SeenPlugin/src/main.cpp @@ -0,0 +1,136 @@ +/* +"Last Seen mod" plugin for Miranda IM +Copyright ( C ) 2002-03 micron-x +Copyright ( C ) 2005-07 Y.B. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or ( at your option ) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/main.c $ +Revision : $Rev: 1571 $ +Last change on : $Date: 2007-12-30 04:55:51 +0300 (Р’СЃ, 30 дек 2007) $ +Last change by : $Author: y_b $ +*/ +#include "seen.h" + +HINSTANCE hInstance; +HANDLE ehdb = NULL, ehproto = NULL, ehmissed = NULL, ehuserinfo = NULL, ehmissed_proto = NULL, hOptInit = NULL, hMainInit = NULL; + +int hLangpack; + +PLUGININFOEX pluginInfo={ + sizeof(PLUGININFOEX), + "Last seen", + PLUGIN_MAKE_VERSION(5,0,4,7), + "Log when a user was last seen online and which users were online while you were away.", + "Heiko Schillinger, YB", + "y_b@saaplugin.no-ip.info", + "© 2001-2002 Heiko Schillinger, 2003 modified by Bruno Rino, 2005-7 Modified by YB", + "http://nightly.miranda.im/", + UNICODE_AWARE, + { 0x2d506d46,0xc94e,0x4ef8,{0x85, 0x37, 0xf1, 0x12, 0x33, 0xa8, 0x03, 0x81}}/* 2d506d46-c94e-4ef8-8537-f11233a80381 */ +}; + +#define TRANSNUMBER 2 +DBVTranslation idleTr[TRANSNUMBER]={ + {(TranslateFunc*)any_to_IdleNotidleUnknown, _T("Any to Idle/Not Idle/Unknown"),0}, + {(TranslateFunc*)any_to_Idle, _T("Any to /Idle or empty"),0} +}; + +BOOL includeIdle; +logthread_info **contactQueue = NULL; +int contactQueueSize = 0; + +int MainInit(WPARAM wparam,LPARAM lparam) +{ + contactQueueSize = 16*sizeof(logthread_info *); + contactQueue = (logthread_info **)malloc(contactQueueSize); + memset(&contactQueue[0], 0, contactQueueSize); + contactQueueSize = 16; + includeIdle = (BOOL )DBGetContactSettingByte(NULL,S_MOD,"IdleSupport",1); + hOptInit = HookEvent(ME_OPT_INITIALISE, OptionsInit); + + if(DBGetContactSettingByte(NULL,S_MOD,"MenuItem",1)) { + InitMenuitem(); + } + + if(DBGetContactSettingByte(NULL,S_MOD,"UserinfoTab",1)) + ehuserinfo = HookEvent(ME_USERINFO_INITIALISE,UserinfoInit); + + if(DBGetContactSettingByte(NULL,S_MOD,"FileOutput",0)) + InitFileOutput(); + + if(DBGetContactSettingByte(NULL,S_MOD,"MissedOnes",0)) + ehmissed_proto=HookEvent(ME_PROTO_ACK,ModeChange_mo); + + ehdb = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, UpdateValues); + ehproto = HookEvent(ME_PROTO_ACK,ModeChange); + + SkinAddNewSoundEx("LastSeenTrackedStatusChange", LPGEN("LastSeen"), LPGEN("User status change")); + SkinAddNewSoundEx("LastSeenTrackedStatusOnline", LPGEN("LastSeen"), LPGEN("Changed to Online")); + SkinAddNewSoundEx("LastSeenTrackedStatusOffline", LPGEN("LastSeen"), LPGEN("User Logged Off")); + SkinAddNewSoundEx("LastSeenTrackedStatusFromOffline", LPGEN("LastSeen"), LPGEN("User Logged In")); + + // known modules list + if (ServiceExists("DBEditorpp/RegisterSingleModule")) + CallService("DBEditorpp/RegisterSingleModule", (WPARAM)S_MOD, 0); + DBWriteContactSettingString(NULL,"Uninstall",Translate("Last seen"),S_MOD); + + + if ( ServiceExists(MS_TIPPER_ADDTRANSLATION)) { + int i; + for (i=0; i < TRANSNUMBER; i++) + CallService(MS_TIPPER_ADDTRANSLATION, 0, (LPARAM)&idleTr[i]); + } + + return 0; +} + +extern "C" __declspec(dllexport) PLUGININFOEX * MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +extern "C" __declspec(dllexport) int Unload(void) +{ + UnhookEvent(ehdb); + if(ehmissed) UnhookEvent(ehmissed); + UnhookEvent(ehproto); + if(ehmissed_proto) UnhookEvent(ehmissed_proto); + UnhookEvent(hOptInit); + UnhookEvent(hMainInit); + if (ehuserinfo) UnhookEvent(ehuserinfo); + UninitMenuitem(); +// free(contactQueue); + return 0; +} + +BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID lpvReserved) +{ + hInstance=hinst; + return 1; +} + +extern "C" __declspec(dllexport) int Load(void) +{ + + mir_getLP(&pluginInfo); + // this isn't required for most events + // but the ME_USERINFO_INITIALISE + // I decided to hook all events after + // everything is loaded because it seems + // to be safer in my opinion + hMainInit = HookEvent(ME_SYSTEM_MODULESLOADED,MainInit); + return 0; +} \ No newline at end of file diff --git a/plugins/SeenPlugin/src/menu.cpp b/plugins/SeenPlugin/src/menu.cpp new file mode 100644 index 0000000000..02f241b793 --- /dev/null +++ b/plugins/SeenPlugin/src/menu.cpp @@ -0,0 +1,113 @@ +/* +"Last Seen mod" plugin for Miranda IM +Copyright ( C ) 2002-03 micron-x +Copyright ( C ) 2005-07 Y.B. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or ( at your option ) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/menu.c $ +Revision : $Rev: 1570 $ +Last change on : $Date: 2007-12-30 01:30:07 +0300 (Р’СЃ, 30 дек 2007) $ +Last change by : $Author: y_b $ +*/ +#include "seen.h" + +HANDLE hmenuitem=NULL, hLSUserDet = NULL, hBuildMenu = NULL; + +void ShowHistory(HANDLE hContact, BYTE isAlert); +void InitHistoryDialog(void); + +/* +Handles the messages sent by clicking the contact's menu item +*/ +INT_PTR MenuitemClicked(WPARAM wparam,LPARAM lparam) +{ + ShowHistory((HANDLE)wparam, 0); + return 0; +} + +int BuildContactMenu(WPARAM wparam,LPARAM lparam) +{ + CLISTMENUITEM cmi; + DBVARIANT dbv; + int id=-1,isetting; + HANDLE hContact; + char *szProto; + + hContact = (HANDLE)wparam; + szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0); + + ZeroMemory(&cmi,sizeof(cmi)); + cmi.cbSize=sizeof(cmi); + if (!IsWatchedProtocol(szProto) || !DBGetContactSettingByte(NULL,S_MOD,"MenuItem",1)) + { + cmi.flags=CMIM_FLAGS|CMIF_HIDDEN; + } + else + { + cmi.flags=CMIM_NAME|CMIM_FLAGS|CMIM_ICON; + cmi.hIcon=NULL; + cmi.pszName=ParseString(!DBGetContactSetting(NULL,S_MOD,"MenuStamp",&dbv)?dbv.pszVal:DEFAULT_MENUSTAMP,(HANDLE)wparam,0); + + if (!strcmp(cmi.pszName,Translate(""))) + { + if (IsWatchedProtocol(szProto)) + cmi.flags|=CMIF_GRAYED; + else + cmi.flags|=CMIF_HIDDEN; + } + else if(DBGetContactSettingByte(NULL,S_MOD,"ShowIcon",1)) + { + isetting=DBGetContactSettingWord((HANDLE)hContact,S_MOD,"StatusTriger",-1); + cmi.hIcon=LoadSkinnedProtoIcon(szProto,isetting|0x8000); + + } + } + + CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)hmenuitem,(LPARAM)&cmi); + DBFreeVariant(&dbv); + + return 0; +} + + + +void InitMenuitem() +{ + CLISTMENUITEM cmi; + + hLSUserDet = CreateServiceFunction("LastSeenUserDetails", MenuitemClicked); + + ZeroMemory(&cmi,sizeof(cmi)); + cmi.cbSize=sizeof(cmi); + cmi.flags=0; + cmi.hIcon=NULL; + cmi.hotKey=0; + cmi.position=-0x7FFFFFFF; + cmi.pszContactOwner=NULL; + cmi.pszName=""; + cmi.pszService="LastSeenUserDetails"; + hmenuitem = Menu_AddContactMenuItem(&cmi); + + hBuildMenu = HookEvent(ME_CLIST_PREBUILDCONTACTMENU,BuildContactMenu); + + InitHistoryDialog(); +} + +void UninitMenuitem() +{ + DestroyServiceFunction(hLSUserDet); + UnhookEvent(hBuildMenu); +} \ No newline at end of file diff --git a/plugins/SeenPlugin/src/missed.cpp b/plugins/SeenPlugin/src/missed.cpp new file mode 100644 index 0000000000..179dd8ee4d --- /dev/null +++ b/plugins/SeenPlugin/src/missed.cpp @@ -0,0 +1,301 @@ +/* +"Last Seen mod" plugin for Miranda IM +Copyright ( C ) 2002-03 micron-x +Copyright ( C ) 2005-07 Y.B. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or ( at your option ) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/missed.c $ +Revision : $Rev: 1570 $ +Last change on : $Date: 2007-12-30 01:30:07 +0300 (Р’СЃ, 30 дек 2007) $ +Last change by : $Author: y_b $ +*/ +#include "seen.h" + +#include + + + +MISSEDCONTACTS mcs; +extern HANDLE ehmissed; +extern HINSTANCE hInstance; + + + +WPARAM IsUserMissed(WPARAM contact) +{ + int loop=0; + + for (;loopszSetting,"Status") || (strcmp(cws->szModule,"ICQ") && strcmp(cws->szModule,"MSN")) || (HANDLE)wparam==NULL) return 0; + + if(CallService(MS_IGNORE_ISIGNORED,wparam,IGNOREEVENT_USERONLINE)) + return 0; + + if(cws->value.wVal==ID_STATUS_OFFLINE) + { + if(DBGetContactSettingByte((HANDLE)wparam,S_MOD,"Missed",0)==1) + { + mcs.times[mcs.count]++; + mcs.wpcontact[mcs.count++]=wparam; + DBWriteContactSettingByte((HANDLE)wparam,S_MOD,"Missed",0); + } + + else if(DBGetContactSettingByte((HANDLE)wparam,S_MOD,"Missed",0)==3) + mcs.times[HIWORD(IsUserMissed(wparam))]++; + + return 0; + } + + wpvar=IsUserMissed(wparam); + if(LOWORD(wpvar)) + DBWriteContactSettingByte((HANDLE)wparam,S_MOD,"Missed",3); + + else + DBWriteContactSettingByte((HANDLE)wparam,S_MOD,"Missed",1); + + return 0; +} + +*/ + +int Test(WPARAM wparam,LPARAM lparam) +{ + if(lparamICON_INVIS) + return 0; + + if(CallService(MS_IGNORE_ISIGNORED,wparam,IGNOREEVENT_USERONLINE)) + return 0; + + if(DBGetContactSettingByte((HANDLE)wparam,S_MOD,"Missed",0)==2) + return 0; + + switch(lparam){ + + case ICON_OFFLINE: + if(DBGetContactSettingByte((HANDLE)wparam,S_MOD,"Missed",0)==1) + { + WORD missed=IsUserMissed(wparam); + + if (!LOWORD(missed)) + { + mcs.times[mcs.count]=1; + mcs.wpcontact[mcs.count++]=wparam; + } + else + mcs.times[HIWORD(missed)]++; + + DBWriteContactSettingByte((HANDLE)wparam,S_MOD,"Missed",0); + } + break; + + case ICON_ONLINE: + case ICON_AWAY: + case ICON_NA: + case ICON_OCC: + case ICON_DND: + case ICON_FREE: + case ICON_INVIS: + DBWriteContactSettingByte((HANDLE)wparam,S_MOD,"Missed",1); + break; + } + + return 0; +} + + + +int ModeChange_mo(WPARAM wparam,LPARAM lparam) +{ + ACKDATA *ack; + int isetting=0; + + ack=(ACKDATA *)lparam; + + if(ack->type!=ACKTYPE_STATUS || ack->result!=ACKRESULT_SUCCESS || ack->hContact!=NULL) return 0; + + isetting=CallProtoService(ack->szModule,PS_GETSTATUS,0,0); + + switch(isetting){ + + case ID_STATUS_AWAY: + case ID_STATUS_DND: + case ID_STATUS_NA: + if(ehmissed==NULL) + { + ZeroMemory(&mcs,sizeof(mcs)); + CheckIfOnline(); + //ehmissed=HookEvent(ME_DB_CONTACT_SETTINGCHANGED,LogStatus); + ehmissed=HookEvent(ME_CLIST_CONTACTICONCHANGED,Test); + } + break; + + default: + if(ehmissed!=NULL) + { + UnhookEvent(ehmissed); + ehmissed=NULL; + ShowMissed(); + ResetMissed(); + } + break; + } + + return 0; +} diff --git a/plugins/SeenPlugin/src/options.cpp b/plugins/SeenPlugin/src/options.cpp new file mode 100644 index 0000000000..daab1e8ee3 --- /dev/null +++ b/plugins/SeenPlugin/src/options.cpp @@ -0,0 +1,494 @@ +/* +"Last Seen mod" plugin for Miranda IM +Copyright ( C ) 2002-03 micron-x +Copyright ( C ) 2005-07 Y.B. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or ( at your option ) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/options.c $ +Revision : $Rev: 1570 $ +Last change on : $Date: 2007-12-30 01:30:07 +0300 (Р’СЃ, 30 дек 2007) $ +Last change by : $Author: y_b $ +*/ +#include "seen.h" + + + +extern HINSTANCE hInstance; +extern HANDLE ehuserinfo,hmenuitem,ehmissed_proto; +void BuildInfo(char *,char *,char *); +int BuildContactMenu(WPARAM,LPARAM); +int UserinfoInit(WPARAM,LPARAM); +int InitFileOutput(void); +void ShutdownFileOutput(void); +void InitMenuitem(void); +int ModeChange_mo(WPARAM,LPARAM); +int CheckIfOnline(void); +int ResetMissed(void); +static BOOL (WINAPI *pfnEnableThemeDialogTexture)(HANDLE, DWORD) = 0; + +INT_PTR CALLBACK OptsPopUpsDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) +{ + DBVARIANT dbv; + int i; + char szstamp[256]; + BOOL hasPopups; + switch(msg) + { + case WM_INITDIALOG:{ + if (hasPopups = (ServiceExists(MS_POPUP_QUERY) != 0)) + hasPopups = CallService(MS_POPUP_QUERY,PUQS_GETSTATUS,0); + TranslateDialogDefault(hdlg); + ShowWindow(GetDlgItem(hdlg,IDC_MISSPOPUP),hasPopups?SW_HIDE:SW_SHOW); + ShowWindow(GetDlgItem(hdlg,IDC_POPUPS),hasPopups?SW_SHOW:SW_HIDE); + ShowWindow(GetDlgItem(hdlg,IDC_POPUPSTAMP),hasPopups?SW_SHOW:SW_HIDE); + ShowWindow(GetDlgItem(hdlg,IDC_LABTEXT),hasPopups?SW_SHOW:SW_HIDE); + ShowWindow(GetDlgItem(hdlg,IDC_LABTTITLE),hasPopups?SW_SHOW:SW_HIDE); + ShowWindow(GetDlgItem(hdlg,IDC_POPUPSTAMPTEXT),hasPopups?SW_SHOW:SW_HIDE); + CheckDlgButton(hdlg,IDC_POPUPS,DBGetContactSettingByte(NULL,S_MOD,"UsePopups",0)&hasPopups); + EnableWindow(GetDlgItem(hdlg,IDC_POPUPS),hasPopups); + hasPopups = IsDlgButtonChecked(hdlg,IDC_POPUPS); + EnableWindow(GetDlgItem(hdlg,IDC_POPUPSTAMP),hasPopups); + EnableWindow(GetDlgItem(hdlg,IDC_POPUPSTAMPTEXT),hasPopups); + for (i=ID_STATUS_OFFLINE;i<=ID_STATUS_OUTTOLUNCH;i++) { + DWORD sett; + COLORREF back, text; + sprintf(szstamp, "Col_%d",i-ID_STATUS_OFFLINE); + sett = DBGetContactSettingDword(NULL,S_MOD,szstamp,StatusColors15bits[i-ID_STATUS_OFFLINE]); + GetColorsFromDWord(&back, &text, sett); + SendDlgItemMessage(hdlg,i,CPM_SETCOLOUR,0,back); + SendDlgItemMessage(hdlg,i+20,CPM_SETCOLOUR,0,text); + EnableWindow(GetDlgItem(hdlg,i),hasPopups); + EnableWindow(GetDlgItem(hdlg,i+20),hasPopups); + } + + SetDlgItemText(hdlg,IDC_POPUPSTAMP,!DBGetContactSetting(NULL,S_MOD,"PopupStamp",&dbv)?dbv.pszVal:DEFAULT_POPUPSTAMP); + DBFreeVariant(&dbv); + SetDlgItemText(hdlg,IDC_POPUPSTAMPTEXT,!DBGetContactSetting(NULL,S_MOD,"PopupStampText",&dbv)?dbv.pszVal:DEFAULT_POPUPSTAMPTEXT); + DBFreeVariant(&dbv); + + } + break; //case WM_INITDIALOG + case WM_COMMAND: + if ((HIWORD(wparam)==BN_CLICKED || HIWORD(wparam)==EN_CHANGE) && GetFocus()==(HWND)lparam) + SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); + else if (HIWORD(wparam)==CPN_COLOURCHANGED){ + WORD idText, idBack; + POPUPDATAEX ppd = {0}; + DBVARIANT dbv = {0}; + DWORD temp; + if (LOWORD(wparam)>ID_STATUS_OUTTOLUNCH){ // we have clicked a text color + idText = wparam; idBack = wparam-20; + } else {idText = wparam+20; idBack = wparam;} + ppd.colorBack = SendDlgItemMessage(hdlg,idBack,CPM_GETCOLOUR,0,0); + ppd.colorText = SendDlgItemMessage(hdlg,idText,CPM_GETCOLOUR,0,0); + temp = GetDWordFromColors(ppd.colorBack,ppd.colorText); + GetColorsFromDWord(&ppd.colorBack,&ppd.colorText,temp); + SendDlgItemMessage(hdlg,idBack,CPM_SETCOLOUR,0,ppd.colorBack); + SendDlgItemMessage(hdlg,idText,CPM_SETCOLOUR,0,ppd.colorText); + ppd.lchIcon = LoadSkinnedProtoIcon(NULL, idBack); + GetDlgItemText(hdlg,IDC_POPUPSTAMP,szstamp,255); + strncpy(ppd.lpzContactName,ParseString(szstamp,NULL,0),MAX_CONTACTNAME); + GetDlgItemText(hdlg,IDC_POPUPSTAMPTEXT,szstamp,255); + strncpy(ppd.lpzText,ParseString(szstamp,NULL,0),MAX_SECONDLINE); + CallService(MS_POPUP_ADDPOPUPEX, (WPARAM)&ppd, 0); + + SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); + } + if(HIWORD(wparam)==BN_CLICKED) + { + switch(LOWORD(wparam)) { + case IDC_POPUPS: + hasPopups = IsDlgButtonChecked(hdlg,IDC_POPUPS); + EnableWindow(GetDlgItem(hdlg,IDC_POPUPSTAMP),hasPopups); + EnableWindow(GetDlgItem(hdlg,IDC_POPUPSTAMPTEXT),hasPopups); + for (i=ID_STATUS_OFFLINE;i<=ID_STATUS_OUTTOLUNCH;i++) { + EnableWindow(GetDlgItem(hdlg,i),hasPopups); + EnableWindow(GetDlgItem(hdlg,i+20),hasPopups); + } + break; + case IDC_DEFAULTCOL: + for (i=ID_STATUS_OFFLINE;i<=ID_STATUS_OUTTOLUNCH;i++) { + DWORD sett; + COLORREF back, text; + sprintf(szstamp, "Col_%d",i-ID_STATUS_OFFLINE); + sett = StatusColors15bits[i-ID_STATUS_OFFLINE]; + GetColorsFromDWord(&back, &text, sett); + SendDlgItemMessage(hdlg,i,CPM_SETCOLOUR,0,back); + SendDlgItemMessage(hdlg,i+20,CPM_SETCOLOUR,0,text); + } + break; + } + } + break; //case WM_COMMAND + + case WM_NOTIFY: + switch(((LPNMHDR)lparam)->idFrom) + { + case 0: + switch (((LPNMHDR)lparam)->code) + { + BYTE checkValue; + + case PSN_APPLY: + GetDlgItemText(hdlg,IDC_POPUPSTAMP,szstamp,256); + DBWriteContactSettingString(NULL,S_MOD,"PopupStamp",szstamp); + GetDlgItemText(hdlg,IDC_POPUPSTAMPTEXT,szstamp,256); + DBWriteContactSettingString(NULL,S_MOD,"PopupStampText",szstamp); + + checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_POPUPS); + if (DBGetContactSettingByte(NULL,S_MOD,"UsePopups",0) != checkValue) { + DBWriteContactSettingByte(NULL,S_MOD,"UsePopups",checkValue); + } + for (i=ID_STATUS_OFFLINE;i<=ID_STATUS_OUTTOLUNCH;i++) { + DWORD sett; + COLORREF back=0, text=0; + sprintf(szstamp, "Col_%d",i-ID_STATUS_OFFLINE); + back = SendDlgItemMessage(hdlg,i,CPM_GETCOLOUR,0,0); + text = SendDlgItemMessage(hdlg,i+20,CPM_GETCOLOUR,0,0); + sett=GetDWordFromColors(back,text); + if (sett!=StatusColors15bits[i-ID_STATUS_OFFLINE]) + DBWriteContactSettingDword(NULL,S_MOD,szstamp,sett); + else DBDeleteContactSetting(NULL,S_MOD,szstamp); + } + + break; //case PSN_APPLY + } + break; //case 0 + } + break;//case WM_NOTIFY + + } + + return 0; +} + +INT_PTR CALLBACK OptsSettingsDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) +{ + DBVARIANT dbv; + char szstamp[256]; + BYTE bchecked=0; + WPARAM wpsend=0; + + switch(msg) + { + case WM_INITDIALOG:{ + TranslateDialogDefault(hdlg); + + CheckDlgButton(hdlg,IDC_MENUITEM,DBGetContactSettingByte(NULL,S_MOD,"MenuItem",1)); + CheckDlgButton(hdlg,IDC_USERINFO,DBGetContactSettingByte(NULL,S_MOD,"UserinfoTab",1)); + CheckDlgButton(hdlg,IDC_FILE,DBGetContactSettingByte(NULL,S_MOD,"FileOutput",0)); + CheckDlgButton(hdlg,IDC_HISTORY,DBGetContactSettingByte(NULL,S_MOD,"KeepHistory",0)); + CheckDlgButton(hdlg,IDC_IGNOREOFFLINE,DBGetContactSettingByte(NULL,S_MOD,"IgnoreOffline",1)); + CheckDlgButton(hdlg,IDC_MISSEDONES,DBGetContactSettingByte(NULL,S_MOD,"MissedOnes",0)); + CheckDlgButton(hdlg,IDC_SHOWICON,DBGetContactSettingByte(NULL,S_MOD,"ShowIcon",1)); + CheckDlgButton(hdlg,IDC_COUNT,DBGetContactSettingByte(NULL,S_MOD,"MissedOnes_Count",0)); + CheckDlgButton(hdlg,IDC_IDLESUPPORT,DBGetContactSettingByte(NULL,S_MOD,"IdleSupport",1)); + + EnableWindow(GetDlgItem(hdlg,IDC_MENUSTAMP),IsDlgButtonChecked(hdlg,IDC_MENUITEM)); + EnableWindow(GetDlgItem(hdlg,IDC_SHOWICON),IsDlgButtonChecked(hdlg,IDC_MENUITEM)); + EnableWindow(GetDlgItem(hdlg,IDC_USERSTAMP),IsDlgButtonChecked(hdlg,IDC_USERINFO)); + EnableWindow(GetDlgItem(hdlg,IDC_FILESTAMP),IsDlgButtonChecked(hdlg,IDC_FILE)); + EnableWindow(GetDlgItem(hdlg,IDC_FILENAME),IsDlgButtonChecked(hdlg,IDC_FILE)); + EnableWindow(GetDlgItem(hdlg,IDC_HISTORYSIZE),IsDlgButtonChecked(hdlg,IDC_HISTORY)); + EnableWindow(GetDlgItem(hdlg,IDC_HISTORYSTAMP),IsDlgButtonChecked(hdlg,IDC_HISTORY)); + EnableWindow(GetDlgItem(hdlg,IDC_COUNT),IsDlgButtonChecked(hdlg,IDC_MISSEDONES)); + + SetDlgItemText(hdlg,IDC_MENUSTAMP,!DBGetContactSetting(NULL,S_MOD,"MenuStamp",&dbv)?dbv.pszVal:DEFAULT_MENUSTAMP); + DBFreeVariant(&dbv); + SetDlgItemText(hdlg,IDC_USERSTAMP,!DBGetContactSetting(NULL,S_MOD,"UserStamp",&dbv)?dbv.pszVal:DEFAULT_USERSTAMP); + DBFreeVariant(&dbv); + SetDlgItemText(hdlg,IDC_FILESTAMP,!DBGetContactSetting(NULL,S_MOD,"FileStamp",&dbv)?dbv.pszVal:DEFAULT_FILESTAMP); + DBFreeVariant(&dbv); + SetDlgItemText(hdlg,IDC_FILENAME,!DBGetContactSetting(NULL,S_MOD,"FileName",&dbv)?dbv.pszVal:DEFAULT_FILENAME); + DBFreeVariant(&dbv); + SetDlgItemInt(hdlg,IDC_HISTORYSIZE,DBGetContactSettingWord(NULL,S_MOD,"HistoryMax",10-1)-1,FALSE); + SetDlgItemText(hdlg,IDC_HISTORYSTAMP,!DBGetContactSetting(NULL,S_MOD,"HistoryStamp",&dbv)?dbv.pszVal:DEFAULT_HISTORYSTAMP); + DBFreeVariant(&dbv); + + // load protocol list + SetWindowLongPtr(GetDlgItem(hdlg,IDC_PROTOCOLLIST),GWL_STYLE,GetWindowLongPtr(GetDlgItem(hdlg,IDC_PROTOCOLLIST),GWL_STYLE)|TVS_CHECKBOXES); + { + TVINSERTSTRUCT tvis; + int numberOfProtocols,i; + PROTOCOLDESCRIPTOR** protos; + char *protoName; + char *protoLabel; + + tvis.hParent=NULL; + tvis.hInsertAfter=TVI_LAST; + tvis.item.mask=TVIF_TEXT | TVIF_HANDLE | TVIF_STATE | TVIF_PARAM; + tvis.item.stateMask = TVIS_STATEIMAGEMASK; + + CallService(MS_PROTO_ENUMPROTOCOLS,(WPARAM)&numberOfProtocols,(LPARAM)&protos); + for (i=0; itype!=PROTOTYPE_PROTOCOL || CallProtoService(protos[i]->szName,PS_GETCAPS,PFLAGNUM_2,0)==0) continue; + protoName = (char *)malloc(strlen(protos[i]->szName)+1); + strcpy(protoName,protos[i]->szName); +//debug(protoName); + protoLabel = (char *)malloc(MAXMODULELABELLENGTH+1); + CallProtoService(protoName,PS_GETNAME,MAXMODULELABELLENGTH,(LPARAM)protoLabel); +//debug(protoLabel); + tvis.item.pszText = protoLabel; + tvis.item.lParam = (LPARAM)protoName; + tvis.item.state = INDEXTOSTATEIMAGEMASK(IsWatchedProtocol(protoName)+1); + TreeView_InsertItem(GetDlgItem(hdlg,IDC_PROTOCOLLIST),&tvis); + free(protoLabel); + + } + } + } + break; //case WM_INITDIALOG + + case WM_COMMAND: + if ((HIWORD(wparam)==BN_CLICKED || HIWORD(wparam)==EN_CHANGE) && GetFocus()==(HWND)lparam) + if (LOWORD(wparam)!=IDC_VARIABLES)SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); + + if(HIWORD(wparam)==BN_CLICKED) + { + switch(LOWORD(wparam)) { + case IDC_MENUITEM: + EnableWindow(GetDlgItem(hdlg,IDC_MENUSTAMP),IsDlgButtonChecked(hdlg,IDC_MENUITEM)); + EnableWindow(GetDlgItem(hdlg,IDC_SHOWICON),IsDlgButtonChecked(hdlg,IDC_MENUITEM)); + break; + case IDC_USERINFO: + EnableWindow(GetDlgItem(hdlg,IDC_USERSTAMP),IsDlgButtonChecked(hdlg,IDC_USERINFO)); + break; + case IDC_FILE: + EnableWindow(GetDlgItem(hdlg,IDC_FILESTAMP),IsDlgButtonChecked(hdlg,IDC_FILE)); + EnableWindow(GetDlgItem(hdlg,IDC_FILENAME),IsDlgButtonChecked(hdlg,IDC_FILE)); + break; + case IDC_HISTORY: + EnableWindow(GetDlgItem(hdlg,IDC_HISTORYSTAMP),IsDlgButtonChecked(hdlg,IDC_HISTORY)); + EnableWindow(GetDlgItem(hdlg,IDC_HISTORYSIZE),IsDlgButtonChecked(hdlg,IDC_HISTORY)); + break; + case IDC_MISSEDONES: + EnableWindow(GetDlgItem(hdlg,IDC_COUNT),IsDlgButtonChecked(hdlg,IDC_MISSEDONES)); + break; + } + } + + if (LOWORD(wparam)==IDC_VARIABLES) + { + char szout[2048]=""; + wsprintf(szout,VARIABLE_LIST); + MessageBox(NULL,szout,Translate("Last Seen Variables"),MB_OK|MB_TOPMOST); + } + + break; //case WM_COMMAND + + case WM_NOTIFY: + switch(((LPNMHDR)lparam)->idFrom) + { + case 0: + switch (((LPNMHDR)lparam)->code) + { + BYTE checkValue; + + case PSN_APPLY: + + GetDlgItemText(hdlg,IDC_MENUSTAMP,szstamp,256); + DBWriteContactSettingString(NULL,S_MOD,"MenuStamp",szstamp); + + GetDlgItemText(hdlg,IDC_USERSTAMP,szstamp,256); + DBWriteContactSettingString(NULL,S_MOD,"UserStamp",szstamp); + + GetDlgItemText(hdlg,IDC_FILESTAMP,szstamp,256); + DBWriteContactSettingString(NULL,S_MOD,"FileStamp",szstamp); + + GetDlgItemText(hdlg,IDC_FILENAME,szstamp,256); + DBWriteContactSettingString(NULL,S_MOD,"FileName",szstamp); + + GetDlgItemText(hdlg,IDC_HISTORYSTAMP,szstamp,256); + DBWriteContactSettingString(NULL,S_MOD,"HistoryStamp",szstamp); + + DBWriteContactSettingWord(NULL,S_MOD,"HistoryMax",(WORD)(GetDlgItemInt(hdlg,IDC_HISTORYSIZE,NULL,FALSE)+1)); + + checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_MENUITEM); + if (DBGetContactSettingByte(NULL,S_MOD,"MenuItem",1) != checkValue) { + DBWriteContactSettingByte(NULL,S_MOD,"MenuItem",checkValue); + if(hmenuitem==NULL && checkValue) { + InitMenuitem(); + } + } + + checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_USERINFO); + if (DBGetContactSettingByte(NULL,S_MOD,"UserinfoTab",1) != checkValue) { + DBWriteContactSettingByte(NULL,S_MOD,"UserinfoTab",checkValue); + if(checkValue) { + ehuserinfo=HookEvent(ME_USERINFO_INITIALISE,UserinfoInit); + } else { + UnhookEvent(ehuserinfo); + } + } + + checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_FILE); + if (DBGetContactSettingByte(NULL,S_MOD,"FileOutput",0) != checkValue) { + DBWriteContactSettingByte(NULL,S_MOD,"FileOutput",checkValue); + if(checkValue) { + InitFileOutput(); + } + } + + checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_HISTORY); + if (DBGetContactSettingByte(NULL,S_MOD,"KeepHistory",0) != checkValue) { + DBWriteContactSettingByte(NULL,S_MOD,"KeepHistory",checkValue); + } + + checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_IGNOREOFFLINE); + if (DBGetContactSettingByte(NULL,S_MOD,"IgnoreOffline",1) != checkValue) { + DBWriteContactSettingByte(NULL,S_MOD,"IgnoreOffline",checkValue); + } + + checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_MISSEDONES); + if (DBGetContactSettingByte(NULL,S_MOD,"MissedOnes",0) != checkValue) { + DBWriteContactSettingByte(NULL,S_MOD,"MissedOnes",checkValue); + if(checkValue) { + ehmissed_proto=HookEvent(ME_PROTO_ACK,ModeChange_mo); + } else { + UnhookEvent(ehmissed_proto); + } + } + + checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_SHOWICON); + if (DBGetContactSettingByte(NULL,S_MOD,"ShowIcon",1) != checkValue) { + DBWriteContactSettingByte(NULL,S_MOD,"ShowIcon",checkValue); + } + + checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_COUNT); + if (DBGetContactSettingByte(NULL,S_MOD,"MissedOnes_Count",0) != checkValue) { + DBWriteContactSettingByte(NULL,S_MOD,"MissedOnes_Count",checkValue); + } + + includeIdle = (BYTE)IsDlgButtonChecked(hdlg,IDC_IDLESUPPORT); + if (DBGetContactSettingByte(NULL,S_MOD,"IdleSupport",1) != includeIdle) { + DBWriteContactSettingByte(NULL,S_MOD,"IdleSupport",(BYTE)includeIdle); + } + + // save protocol list + { + HWND hwndTreeView = GetDlgItem(hdlg,IDC_PROTOCOLLIST); + HTREEITEM hItem; + TVITEM tvItem; + char *watchedProtocols; + char *protocol; + int size=1; + + watchedProtocols = (char *)malloc(sizeof(char)); + *watchedProtocols = '\0'; + hItem = TreeView_GetRoot(hwndTreeView); + tvItem.mask = TVIF_HANDLE | TVIF_STATE | TVIF_PARAM; + tvItem.stateMask = TVIS_STATEIMAGEMASK; + + while (hItem != NULL) { + tvItem.hItem = hItem; + TreeView_GetItem(hwndTreeView, &tvItem); + protocol = (char*)tvItem.lParam; + if ((BOOL)(tvItem.state >> 12) -1) { + size = (size + (int)_tcslen(protocol)+2) * sizeof(char); + watchedProtocols = (char *)realloc(watchedProtocols, size); + strcat(watchedProtocols, protocol); + strcat(watchedProtocols, " "); + } + hItem = TreeView_GetNextSibling(hwndTreeView, hItem); + } + DBWriteContactSettingString(NULL,S_MOD,"WatchedProtocols",watchedProtocols); + free(watchedProtocols); + } + + break; //case PSN_APPLY + } + break; //case 0 + + case IDC_PROTOCOLLIST: + switch (((LPNMHDR)lparam)->code) + { + case NM_CLICK: + { + HWND hTree=((LPNMHDR)lparam)->hwndFrom; + TVHITTESTINFO hti; + HTREEITEM hItem; + + hti.pt.x=(short)LOWORD(GetMessagePos()); + hti.pt.y=(short)HIWORD(GetMessagePos()); + ScreenToClient(hTree,&hti.pt); + if(hItem=TreeView_HitTest(hTree,&hti)) + { + if (hti.flags & TVHT_ONITEM) + TreeView_SelectItem(hTree,hItem); + if (hti.flags & TVHT_ONITEMSTATEICON) + SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); + + } + } + break; + } + break; //case IDC_PROTOCOLLIST + } + break;//case WM_NOTIFY + + case WM_DESTROY: + // free protocol list + { + HWND hwndTreeView = GetDlgItem(hdlg,IDC_PROTOCOLLIST); + HTREEITEM hItem; + TVITEM tvItem; + + hItem = TreeView_GetRoot(hwndTreeView); + tvItem.mask = TVIF_HANDLE | TVIF_PARAM; + + while (hItem != NULL) { + tvItem.hItem = hItem; + TreeView_GetItem(hwndTreeView, &tvItem); + free((void *)tvItem.lParam); + hItem = TreeView_GetNextSibling(hwndTreeView, hItem); + } + } + break; + + } + + return 0; +} + +int OptionsInit(WPARAM wparam,LPARAM lparam) +{ + OPTIONSDIALOGPAGE odp = { 0 }; + + if(IsWinVerXPPlus()) { + HMODULE hUxTheme = GetModuleHandle(_T("uxtheme.dll")); + if (hUxTheme) + pfnEnableThemeDialogTexture = (BOOL (WINAPI *)(HANDLE, DWORD))GetProcAddress(hUxTheme, "EnableThemeDialogTexture"); + } + + odp.cbSize = sizeof(odp); + odp.position = 100000000; + odp.hInstance = hInstance; + odp.flags = ODPF_BOLDGROUPS; + odp.pszTemplate = MAKEINTRESOURCE(IDD_SETTINGS); + odp.pszGroup = LPGEN("Services"); + odp.pszTitle = LPGEN("Last seen"); + odp.pfnDlgProc = OptsSettingsDlgProc; + Options_AddPage(wparam,&odp); + + if (ServiceExists(MS_POPUP_ADDPOPUP)) { + odp.pszTemplate = MAKEINTRESOURCE(IDD_POPUPS); + odp.pszGroup = LPGEN("PopUps"); + odp.pszTitle = LPGEN("Last seen"); + odp.pfnDlgProc = OptsPopUpsDlgProc; + Options_AddPage(wparam,&odp); + } + return 0; +} diff --git a/plugins/SeenPlugin/src/resource.h b/plugins/SeenPlugin/src/resource.h new file mode 100644 index 0000000000..110639bb3b --- /dev/null +++ b/plugins/SeenPlugin/src/resource.h @@ -0,0 +1,93 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by resource.rc +// + +#ifndef TVS_NOTOOLTIPS +#define TVS_NOTOOLTIPS 0x0080 +#endif + +#define ID_STATUS_OFFLINE 40071 +#define ID_STATUS_ONLINE 40072 +#define ID_STATUS_AWAY 40073 +#define ID_STATUS_DND 40074 +#define ID_STATUS_NA 40075 +#define ID_STATUS_OCCUPIED 40076 +#define ID_STATUS_FREECHAT 40077 +#define ID_STATUS_INVISIBLE 40078 +#define ID_STATUS_ONTHEPHONE 40079 +#define ID_STATUS_OUTTOLUNCH 40080 +#define ID_STATUS_IDLE 40081 /* do not use as a status */ + + +#define IDD_SETTINGS 101 +#define IDD_USERINFO 102 +#define IDD_MISSED 103 +#define IDD_USERDETAILS 104 +#define IDD_HISTORY 105 +#define IDD_POPUPS 106 +#define IDC_SEENMENUITEM 1000 +#define IDC_MENUITEM 1001 +#define IDC_UINFOTAB 1002 +#define IDC_USERINFO 1003 +#define IDC_USERTIME 1004 +#define IDC_HISTORY 1005 +#define IDC_FILE 1006 +#define IDC_FILEGROUP 1007 +#define IDC_POPUPS 1008 +#define IDC_TIME 1009 +#define IDC_OWNSTATUS 1010 +#define IDC_TIMESTAMPGROUP 1011 +#define IDC_EDIT1 1012 +#define IDC_TIMESTAMP 1013 +#define IDC_FILESTAMP 1014 +#define IDC_CONTACTS 1015 +#define IDC_INFOTEXT 1016 +#define IDC_TIMESTAMPHELP 1017 +#define IDC_USERSTAMP 1018 +#define IDC_DELCHAR 1019 +#define IDC_HISTORYSTAMP 1020 +#define IDC_DELCHARHELP 1021 +#define IDC_POPUPSTAMP 1022 +#define IDC_MENUGROUP 1023 +#define IDC_POPUPSTAMPTEXT 1023 +#define IDC_MENUTIME 1024 +#define IDC_MENUSTATUS 1025 +#define IDC_MENUSTAMP 1026 +#define IDC_LABTEXT 1027 +#define IDC_MISSPOPUP 1028 +#define IDC_DEFAULTCOL 1029 +#define IDC_FILENAME 1030 +#define IDC_IGNOREOFFLINE 1031 +#define IDC_MISSEDONES 1032 +#define IDC_SHOWICON 1033 +#define IDC_COUNT 1034 +#define IDC_FILENAME2 1035 +#define IDC_HISTORYSIZE 1036 +#define IDC_LASTSEENLIST 1037 +#define IDC_HISTORYLIST 1038 +#define IDC_STATUSCHANGE 1039 +#define IDC_VARIABLES 1040 +#define IDC_PROTOCOLLIST 1041 +#define IDC_USERMENU 1042 +#define IDC_TEST 1043 +#define IDC_DETAILS 1044 +#define IDC_SENDMSG 1045 +#define IDC_LABTTITLE 1046 +#define IDC_OPTIONSTAB 1047 +#define IDC_IDLESUPPORT 1050 +#define IDC_MAINGROUP -1 +#define IDC_INFO -1 +#define IDC_TEXT -1 +#define IDC_STATIC -1 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 107 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1051 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/plugins/SeenPlugin/src/seen.h b/plugins/SeenPlugin/src/seen.h new file mode 100644 index 0000000000..ba2b13a6c2 --- /dev/null +++ b/plugins/SeenPlugin/src/seen.h @@ -0,0 +1,134 @@ +/* +"Last Seen mod" plugin for Miranda IM +Copyright ( C ) 2002-03 micron-x +Copyright ( C ) 2005-07 Y.B. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or ( at your option ) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/seen.h $ +Revision : $Rev: 1570 $ +Last change on : $Date: 2007-12-30 01:30:07 +0300 (Р’СЃ, 30 дек 2007) $ +Last change by : $Author: y_b $ +*/ +#ifndef _WIN32_IE +#define _WIN32_IE 0x0300 +#endif +#define ETDT_ENABLE 0x00000002 +#define ETDT_USETABTEXTURE 0x00000004 +#define ETDT_ENABLETAB (ETDT_ENABLE | ETDT_USETABTEXTURE) +#define MIRANDA_VER 0x0A00 + +#include +#include +#include +#include +#include + +#include "resource.h" +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "m_tipper.h" +WCHAR *any_to_IdleNotidleUnknown(HANDLE hContact, const char *module_name, const char *setting_name, WCHAR *buff, int bufflen); +WCHAR *any_to_Idle(HANDLE hContact, const char *module_name, const char *setting_name, WCHAR *buff, int bufflen); + +#ifdef __GNUC__ +#define NUM100NANOSEC 116444736000000000ULL +#else +#define NUM100NANOSEC 116444736000000000 +#endif + +#define S_MOD "SeenModule" + +//#define UM_CHECKHOOKS (WM_USER+1) + +#define debug(a) MessageBox(NULL,a,"Debug",MB_OK) + +#define IDI_USERDETAILS 160 +#define IDI_DOWNARROW 264 +#define IDI_RECVMSG 136 + +#define ICON_OFFLINE 13 +#define ICON_ONLINE 14 +#define ICON_AWAY 15 +#define ICON_NA 16 +#define ICON_OCC 17 +#define ICON_DND 18 +#define ICON_FREE 19 +#define ICON_INVIS 20 + +#define DEFAULT_MENUSTAMP "%d.%m.%Y - %H:%M [%s]" +#define DEFAULT_POPUPSTAMP Translate("%n is %s (%u)") +#define DEFAULT_POPUPSTAMPTEXT Translate("%i(%r)%bWas %o") +#define DEFAULT_USERSTAMP Translate("Name:%t%N%bStatus:%t%s%bDay:%t%d.%m.%Y%bTime:%t%H:%M:%S%bPrevious Status:%t%o%b%b%P ID:%t%u%bExternal IP:%t%i%bInternal IP:%t%r%bClientID: %t%C%b%bStatus Message:%t%T") +#define DEFAULT_FILESTAMP "%d.%m.%Y %H:%M:%S%t%n%t%s%t%u%t%r | %i%t%N" +#define DEFAULT_FILENAME "logs\\%P.txt" +#define DEFAULT_HISTORYSTAMP "%d.%m.%Y - %H:%M [%s]" +#define DEFAULT_WATCHEDPROTOCOLS "" + +#define VARIABLE_LIST "%s \n%%Y: \t %s \n%%y: \t %s \n%%m: \t %s \n%%E: \t %s \n%%e: \t %s \n%%d: \t %s \n%%W: \t %s \n%%w: \t %s \n\n%s \n%%H: \t %s \n%%h: \t %s \n%%p: \t %s \n%%M: \t %s \n%%S: \t %s \n\n%s \n%%n: \t %s \n%%N: \t %s \n%%u: \t %s \n%%G: \t %s \n%%s: \t %s \n%%T: \t %s \n%%o: \t %s \n%%i: \t %s \n%%r: \t %s \n%%C: \t %s \n%%P: \t %s \n\n%s \n%%t: \t %s \n%%b: \t %s\n\n%s\t%s \"#\" %s\n\t%s %s", Translate("-- Date --"), Translate("year (4 digits)"), Translate("year (2 digits)"), Translate("month"), Translate("name of month"), Translate("short name of month"), Translate("day"), Translate("weekday (full)"), Translate("weekday (abbreviated)"), Translate("-- Time --"), Translate("hours (24)"), Translate("hours (12)"), Translate("AM/PM"), Translate("minutes"), Translate("seconds"), Translate("-- User --"), Translate("username"), Translate("nick"), Translate("UIN/handle"), Translate("Group"), Translate("Status"), Translate("Status message"), Translate("Old status"), Translate("external IP"), Translate("internal IP"),Translate("Client info"),Translate("Protocol"), Translate("-- Format --"), Translate("tabulator"), Translate("line break"), Translate("Note:"),Translate("Use"),Translate("for empty string"),Translate("instead of"),Translate("") + +#ifndef LPCOLORREF +typedef DWORD *LPCOLORREF; +#endif + +typedef struct{ + int count; + WPARAM wpcontact[1024]; + BYTE times[1024]; +} MISSEDCONTACTS; + +int IsWatchedProtocol(const char* szProto); +char *ParseString(char *,HANDLE,BYTE); +extern DWORD StatusColors15bits[]; +void GetColorsFromDWord(LPCOLORREF First, LPCOLORREF Second, DWORD colDword); +DWORD GetDWordFromColors(COLORREF First, COLORREF Second); +int OptionsInit(WPARAM,LPARAM); +int UserinfoInit(WPARAM,LPARAM); +int InitFileOutput(void); +void InitMenuitem(void); +int UpdateValues(WPARAM, LPARAM); +int ModeChange(WPARAM,LPARAM); +void SetOffline(void); +int ModeChange_mo(WPARAM,LPARAM); +int CheckIfOnline(void); +void UninitMenuitem(); + +extern BOOL includeIdle; +typedef struct logthread_info { + char sProtoName[MAXMODULELABELLENGTH]; + HANDLE hContact; + WORD courStatus; + int queueIndex; +} logthread_info; + +extern logthread_info **contactQueue; +extern int contactQueueSize; + diff --git a/plugins/SeenPlugin/src/userinfo.cpp b/plugins/SeenPlugin/src/userinfo.cpp new file mode 100644 index 0000000000..442860bb86 --- /dev/null +++ b/plugins/SeenPlugin/src/userinfo.cpp @@ -0,0 +1,95 @@ +/* +"Last Seen mod" plugin for Miranda IM +Copyright ( C ) 2002-03 micron-x +Copyright ( C ) 2005-07 Y.B. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or ( at your option ) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/userinfo.c $ +Revision : $Rev: 1570 $ +Last change on : $Date: 2007-12-30 01:30:07 +0300 (Р’СЃ, 30 дек 2007) $ +Last change by : $Author: y_b $ +*/ +#include "seen.h" + + + +WNDPROC MainProc; + + + +extern HINSTANCE hInstance; +extern DWORD dwmirver; + + + +BOOL CALLBACK EditProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) +{ + switch(msg){ + case WM_SETCURSOR: + SetCursor(LoadCursor(NULL,IDC_ARROW)); + return 1; + + default: + break; + } + return CallWindowProc(MainProc,hdlg,msg,wparam,lparam); +} + + + +INT_PTR CALLBACK UserinfoDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) +{ + char *szout; + DBVARIANT dbv; + + switch(msg){ + + case WM_INITDIALOG: + MainProc=(WNDPROC)SetWindowLongPtr(GetDlgItem(hdlg,IDC_INFOTEXT),GWLP_WNDPROC,(LONG)EditProc); + szout=strdup(ParseString((!DBGetContactSetting(NULL,S_MOD,"UserStamp",&dbv)?dbv.pszVal:DEFAULT_USERSTAMP),(HANDLE)lparam,0)); + SetDlgItemText(hdlg,IDC_INFOTEXT,szout); + if (!strcmp(szout,Translate(""))) + EnableWindow(GetDlgItem(hdlg,IDC_INFOTEXT),FALSE); + free(szout); + DBFreeVariant(&dbv); + break; + + case WM_COMMAND: + if(HIWORD(wparam)==EN_SETFOCUS) + SetFocus(GetParent(hdlg)); + break; + } + + return 0; +} + + + +int UserinfoInit(WPARAM wparam,LPARAM lparam) +{ + char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,lparam,0); + if (IsWatchedProtocol(proto)) { + OPTIONSDIALOGPAGE uip; + ZeroMemory(&uip,sizeof(uip)); + uip.cbSize=sizeof(uip); + uip.hInstance=hInstance; + uip.pszTemplate=MAKEINTRESOURCE(IDD_USERINFO); + uip.pszTitle="Last seen"; + uip.pfnDlgProc=UserinfoDlgProc; + UserInfo_AddPage(wparam, &uip); + } + return 0; +} diff --git a/plugins/SeenPlugin/src/utils.cpp b/plugins/SeenPlugin/src/utils.cpp new file mode 100644 index 0000000000..d989f9e999 --- /dev/null +++ b/plugins/SeenPlugin/src/utils.cpp @@ -0,0 +1,878 @@ +/* +"Last Seen mod" plugin for Miranda IM +Copyright ( C ) 2002-03 micron-x +Copyright ( C ) 2005-07 Y.B. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or ( at your option ) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/utils.c $ +Revision : $Rev: 1570 $ +Last change on : $Date: 2007-12-30 01:30:07 +0300 (Р’СЃ, 30 дек 2007) $ +Last change by : $Author: y_b $ +*/ +#include "seen.h" +#include +#include + + +void FileWrite(HANDLE); +void HistoryWrite(HANDLE hcontact); +//void SetOffline(void); +void ShowHistory(HANDLE hContact, BYTE isAlert); + +char * courProtoName = 0; + +//copied from ..\..\miranda32\protocols\protocols\protocols.c +PROTOCOLDESCRIPTOR* Proto_IsProtocolLoaded(const char* szProto) +{ + return (PROTOCOLDESCRIPTOR*) CallService(MS_PROTO_ISPROTOCOLLOADED, 0, (LPARAM)szProto); +} + + +/* +Returns true if the protocols is to be monitored +*/ +int IsWatchedProtocol(const char* szProto) +{ + DBVARIANT dbv; + char *szProtoPointer, *szWatched; + int iProtoLen, iWatchedLen; + int retval = 0; + PROTOCOLDESCRIPTOR *pd; + + if (szProto == NULL) + return 0; + + pd=Proto_IsProtocolLoaded(szProto); + if (pd==NULL || pd->type!=PROTOTYPE_PROTOCOL || CallProtoService(pd->szName,PS_GETCAPS,PFLAGNUM_2,0)==0) + return 0; + + iProtoLen = (int)_tcslen(szProto); + if(DBGetContactSetting(NULL, S_MOD, "WatchedProtocols", &dbv)) + szWatched = DEFAULT_WATCHEDPROTOCOLS; + else + szWatched = dbv.pszVal; + iWatchedLen = (int)_tcslen(szWatched); + + if (*szWatched == '\0') + { + retval=1; //empty string: all protocols are watched + } + else + { + char sTemp [MAXMODULELABELLENGTH+1]=""; + strcat(sTemp,szProto); + strcat(sTemp," "); + szProtoPointer = strstr(szWatched, sTemp); + if (szProtoPointer == NULL) + retval=0; + else + retval=1; + } + + DBFreeVariant(&dbv); + return retval; +} + +BOOL isYahoo(char * protoname){ + if (protoname) { + char *pszUniqueSetting = (char*)CallProtoService(protoname, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); + if (pszUniqueSetting){ + return (!strcmp(pszUniqueSetting,"yahoo_id")); + } } + return FALSE; +} +BOOL isJabber(char * protoname){ + if (protoname) { + char *pszUniqueSetting = (char*)CallProtoService(protoname, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); + if (pszUniqueSetting){ + return (!strcmp(pszUniqueSetting,"jid")); + } } + return FALSE; +} +BOOL isICQ(char * protoname){ + if (protoname) { + char *pszUniqueSetting = (char*)CallProtoService(protoname, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); + if (pszUniqueSetting){ + return (!strcmp(pszUniqueSetting,"UIN")); + } } + return FALSE; +} +BOOL isMSN(char * protoname){ + if (protoname) { + char *pszUniqueSetting = (char*)CallProtoService(protoname, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); + if (pszUniqueSetting){ + return (!strcmp(pszUniqueSetting,"e-mail")); + } } + return FALSE; +} + +DWORD isSeen(HANDLE hcontact, SYSTEMTIME *st){ + DWORD res = 0; + FILETIME ft; + ULONGLONG ll; + res = DBGetContactSettingDword(hcontact,S_MOD,"seenTS",0); + if (res){ + if (st) { + ll = UInt32x32To64(CallService(MS_DB_TIME_TIMESTAMPTOLOCAL,res,0), 10000000) + NUM100NANOSEC; + ft.dwLowDateTime = (DWORD)ll; + ft.dwHighDateTime = (DWORD)(ll >> 32); + FileTimeToSystemTime(&ft, st); + } + return res; + } else { + SYSTEMTIME lst; + ZeroMemory(&lst,sizeof(lst)); + if (lst.wYear = DBGetContactSettingWord(hcontact,S_MOD,"Year",0)) { + if (lst.wMonth = DBGetContactSettingWord(hcontact,S_MOD,"Month",0)) { + if (lst.wDay = DBGetContactSettingWord(hcontact,S_MOD,"Day",0)) { + lst.wDayOfWeek = DBGetContactSettingWord(hcontact,S_MOD,"WeekDay",0); + lst.wHour = DBGetContactSettingWord(hcontact,S_MOD,"Hours",0); + lst.wMinute = DBGetContactSettingWord(hcontact,S_MOD,"Minutes",0); + lst.wSecond = DBGetContactSettingWord(hcontact,S_MOD,"Seconds",0); + if (SystemTimeToFileTime(&lst,&ft)) { + ll = ((LONGLONG)ft.dwHighDateTime<<32)|((LONGLONG)ft.dwLowDateTime); + ll -= NUM100NANOSEC; + ll /= 10000000; + //perform LOCALTOTIMESTAMP + res = (DWORD)ll - CallService(MS_DB_TIME_TIMESTAMPTOLOCAL,0,0); + //nevel look for Year/Month/Day/Hour/Minute/Second again + DBWriteContactSettingDword(hcontact,S_MOD,"seenTS",res); + } + } } } + if (st) CopyMemory (st, &lst, sizeof (SYSTEMTIME)); + } + return res; +} + +char *ParseString(char *szstring,HANDLE hcontact,BYTE isfile) +{ +#define MAXSIZE 1024 + static char sztemp[MAXSIZE+1]; + int sztemplen = 0; + char szdbsetting[128]=""; + char *charPtr; + UINT loop=0; + int isetting=0; + DWORD dwsetting=0; + struct in_addr ia; + char *weekdays[]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}; + char *wdays_short[]={"Sun.","Mon.","Tue.","Wed.","Thu.","Fri.","Sat."}; + char *monthnames[]={"January","February","March","April","May","June","July","August","September","October","November","December"}; + char *mnames_short[]={"Jan.","Feb.","Mar.","Apr.","May","Jun.","Jul.","Aug.","Sep.","Oct.","Nov.","Dec."}; + CONTACTINFO ci; + BOOL wantempty; + SYSTEMTIME st; + + sztemp[0] = '\0'; + if (!isSeen(hcontact,&st)) { + strcat(sztemp,Translate("")); + return sztemp; + } + + ci.cbSize=sizeof(CONTACTINFO); + ci.hContact=hcontact; + ci.szProto=hcontact?(char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hcontact,0):courProtoName; + for (;loop"); + goto LBL_charPtr; + } + charPtr = Translate(weekdays[isetting]); +LBL_charPtr: + sztemplen += mir_snprintf(sztemp+sztemplen,MAXSIZE-sztemplen,"%s",charPtr); + break; + + case 'w': + isetting=st.wDayOfWeek; + if(isetting==-1)goto LBL_noData; + charPtr = Translate(wdays_short[isetting]); + goto LBL_charPtr; + + case 'E': + if (!(isetting=st.wMonth))goto LBL_noData; + charPtr = Translate(monthnames[isetting-1]); + goto LBL_charPtr; + + case 'e': + if (!(isetting=st.wMonth))goto LBL_noData; + charPtr = Translate(mnames_short[isetting-1]); + goto LBL_charPtr; + + case 'H': + if ((isetting=st.wHour)==-1)goto LBL_noData; + goto LBL_2DigNum; + + case 'h': + if ((isetting=st.wHour)==-1)goto LBL_noData; + if (!isetting) isetting=12; + isetting = isetting-((isetting>12)?12:0); + goto LBL_2DigNum; + + case 'p': + if ((isetting=st.wHour)==-1)goto LBL_noData; + charPtr = (isetting>=12)?"PM":"AM"; + goto LBL_charPtr; + + case 'M': + if ((isetting=st.wMinute)==-1)goto LBL_noData; + goto LBL_2DigNum; + + case 'S': + if ((isetting=st.wHour)==-1)goto LBL_noData; + goto LBL_2DigNum; + + case 'n': + charPtr = hcontact?(char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hcontact,0):(wantempty?"":"---"); + goto LBL_charPtr; + case 'N': + ci.dwFlag=CNF_NICK; + if (!CallService(MS_CONTACT_GETCONTACTINFO,(WPARAM)0,(LPARAM)&ci)) { + charPtr = ci.pszVal; + } else goto LBL_noData; + goto LBL_charPtr; + case 'G': + { + DBVARIANT dbv; + if (!DBGetContactSetting(hcontact,"CList","Group",&dbv)) { + strcpy(szdbsetting,dbv.pszVal); + DBFreeVariant(&dbv); + charPtr = szdbsetting; + goto LBL_charPtr; + } else; //do nothing + } + break; + + case 'u': + ci.dwFlag=CNF_UNIQUEID; + if (!CallService(MS_CONTACT_GETCONTACTINFO,(WPARAM)0,(LPARAM)&ci)) + { + switch(ci.type) + { + case CNFT_BYTE: + ltoa(ci.bVal,szdbsetting,10); + break; + case CNFT_WORD: + ltoa(ci.wVal,szdbsetting,10); + break; + case CNFT_DWORD: + ltoa(ci.dVal,szdbsetting,10); + break; + case CNFT_ASCIIZ: + strcpy(szdbsetting,ci.pszVal); + break; + } + + } + else if (ci.szProto != NULL) + { + if (isYahoo(ci.szProto)) // YAHOO support + { + DBVARIANT dbv; + DBGetContactSetting(hcontact,ci.szProto,"id",&dbv); + strcpy(szdbsetting,dbv.pszVal); + DBFreeVariant(&dbv); + } + else if (isJabber(ci.szProto)) // JABBER support + { + DBVARIANT dbv; + if (DBGetContactSetting(hcontact,ci.szProto,"LoginName",&dbv)) goto LBL_noData; + strcpy(szdbsetting,dbv.pszVal); + DBFreeVariant(&dbv); + DBGetContactSetting(hcontact,ci.szProto,"LoginServer",&dbv); + strcat(szdbsetting,"@"); + strcat(szdbsetting,dbv.pszVal); + DBFreeVariant(&dbv); + } else goto LBL_noData; + } + else goto LBL_noData; + charPtr = szdbsetting; + goto LBL_charPtr; + + case 's': + if (isetting=DBGetContactSettingWord(hcontact,S_MOD,hcontact?"StatusTriger":courProtoName,0)) { + strcpy(szdbsetting,Translate((const char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,(WPARAM)(isetting|0x8000),0))); + if (!(isetting&0x8000)) { + strcat(szdbsetting,"/"); + strcat(szdbsetting,Translate("Idle")); + } + charPtr = szdbsetting; + } else goto LBL_noData; + goto LBL_charPtr; + case 'T': + { + DBVARIANT dbv; + if (!DBGetContactSetting(hcontact,"CList","StatusMsg",&dbv)) { + sztemplen += mir_snprintf(sztemp+sztemplen,MAXSIZE-sztemplen,"%s",dbv.pszVal); + DBFreeVariant(&dbv); + } else goto LBL_noData; + } + break; + case 'o': + if (isetting=DBGetContactSettingWord(hcontact,S_MOD,hcontact?"OldStatus":courProtoName,0)) { + strcpy(szdbsetting,Translate((const char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,(WPARAM)isetting,0))); + if (includeIdle) if (hcontact) if (DBGetContactSettingByte(hcontact,S_MOD,"OldIdle",0)) { + strcat(szdbsetting,"/"); + strcat(szdbsetting,Translate("Idle")); + } + charPtr = szdbsetting; + } else goto LBL_noData; + goto LBL_charPtr; + + case 'i': + case 'r': if (isJabber(ci.szProto)) { + DBVARIANT dbv; + if (!DBGetContactSetting(hcontact,ci.szProto,szstring[loop]=='i'?"Resource":"System",&dbv)) { + strcpy(szdbsetting,dbv.pszVal); + DBFreeVariant(&dbv); + charPtr = szdbsetting; + } else goto LBL_noData; + } else { + dwsetting=DBGetContactSettingDword(hcontact,ci.szProto,szstring[loop]=='i'?"IP":"RealIP",0); + if(dwsetting){ + ia.S_un.S_addr=htonl(dwsetting); + charPtr = inet_ntoa(ia); + } else goto LBL_noData; + } + goto LBL_charPtr; + case 'P':if (ci.szProto) charPtr = ci.szProto; else charPtr = wantempty?"":"ProtoUnknown"; + goto LBL_charPtr; + case 'b': + charPtr = /*"\n"*/"\x0D\x0A"; + goto LBL_charPtr; + case 'C': // Get Client Info + if (isMSN(ci.szProto)) { + if (hcontact) { + dwsetting = (int)DBGetContactSettingDword(hcontact,ci.szProto,"FlagBits",0); + wsprintf(szdbsetting,"MSNC%i",(dwsetting&0x70000000)>>28); + if (dwsetting & 0x00000001) strcat(szdbsetting," MobD"); //Mobile Device + if (dwsetting & 0x00000004) strcat(szdbsetting," InkG"); //GIF Ink Send/Receive + if (dwsetting & 0x00000008) strcat(szdbsetting," InkI"); //ISF Ink Send/Receive + if (dwsetting & 0x00000010) strcat(szdbsetting," WCam"); //Webcam + if (dwsetting & 0x00000020) strcat(szdbsetting," MPkt"); //Multi packet messages + if (dwsetting & 0x00000040) strcat(szdbsetting," SMSr"); //Paging + if (dwsetting & 0x00000080) strcat(szdbsetting," DSMS"); //Using MSN Direct + if (dwsetting & 0x00000200) strcat(szdbsetting," WebM"); //WebMessenger + if (dwsetting & 0x00001000) strcat(szdbsetting," MS7+"); //Unknown (Msgr 7 always[?] sets it) + if (dwsetting & 0x00004000) strcat(szdbsetting," DirM"); //DirectIM + if (dwsetting & 0x00008000) strcat(szdbsetting," Wink"); //Send/Receive Winks + if (dwsetting & 0x00010000) strcat(szdbsetting," MSrc"); //MSN Search ?? + if (dwsetting & 0x00040000) strcat(szdbsetting," VoiC"); //Voice Clips + } else strcpy(szdbsetting,"Miranda"); + } else { + DBVARIANT dbv; + if (!DBGetContactSetting(hcontact,ci.szProto,"MirVer",&dbv)) { + strcpy(szdbsetting,dbv.pszVal); + DBFreeVariant(&dbv); + } else goto LBL_noData; + } + charPtr = szdbsetting; + goto LBL_charPtr; + case 't': + charPtr = "\t"; + goto LBL_charPtr; + + default: + strncpy(szdbsetting,szstring+loop-1,2); + goto LBL_charPtr; + } + } + } + + return sztemp; +} + + + +void _DBWriteTime(SYSTEMTIME *st,HANDLE hcontact) +{ + DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Day",st->wDay); + DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Month",st->wMonth); + DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Year",st->wYear); + DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Hours",st->wHour); + DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Minutes",st->wMinute); + DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Seconds",st->wSecond); + DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"WeekDay",st->wDayOfWeek); + +} + +void DBWriteTimeTS(DWORD t, HANDLE hcontact){ + SYSTEMTIME st; + FILETIME ft; + ULONGLONG ll = UInt32x32To64(CallService(MS_DB_TIME_TIMESTAMPTOLOCAL,t,0), 10000000) + NUM100NANOSEC; + ft.dwLowDateTime = (DWORD)ll; + ft.dwHighDateTime = (DWORD)(ll >> 32); + FileTimeToSystemTime(&ft, &st); + DBWriteContactSettingDword(hcontact,S_MOD,"seenTS",t); + _DBWriteTime(&st, hcontact); +} +void GetColorsFromDWord(LPCOLORREF First, LPCOLORREF Second, DWORD colDword){ + WORD temp; + COLORREF res=0; + temp = (WORD)(colDword>>16); + res |= ((temp & 0x1F) <<3); + res |= ((temp & 0x3E0) <<6); + res |= ((temp & 0x7C00) <<9); + if (First) *First = res; + res = 0; + temp = (WORD)colDword; + res |= ((temp & 0x1F) <<3); + res |= ((temp & 0x3E0) <<6); + res |= ((temp & 0x7C00) <<9); + if (Second) *Second = res; +} + +DWORD StatusColors15bits[] = { + 0x63180000, // 0x00C0C0C0, 0x00000000, Offline - LightGray + 0x7B350000, // 0x00F0C8A8, 0x00000000, Online - LightBlue + 0x33fe0000, // 0x0070E0E0, 0x00000000, Away -LightOrange + 0x295C0000, // 0x005050E0, 0x00000000, DND -DarkRed + 0x5EFD0000, // 0x00B8B8E8, 0x00000000, NA -LightRed + 0x295C0000, // 0x005050E0, 0x00000000, Occupied + 0x43900000, // 0x0080E080, 0x00000000, Free for chat - LightGreen + 0x76AF0000, // 0x00E8A878, 0x00000000, Invisible + 0x431C0000, // 0x0080C0E0, 0x00000000, On the phone + 0x5EFD0000, // 0x00B8B8E8, 0x00000000, Out to lunch +}; + +DWORD GetDWordFromColors(COLORREF First, COLORREF Second){ + DWORD res = 0; + res |= (First&0xF8)>>3; + res |= (First&0xF800)>>6; + res |= (First&0xF80000)>>9; + res <<= 16; + res |= (Second&0xF8)>>3; + res |= (Second&0xF800)>>6; + res |= (Second&0xF80000)>>9; + return res; +} + +LRESULT CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { + + switch(message) { + case WM_COMMAND: + if (HIWORD(wParam) == STN_CLICKED){ + HANDLE hContact = PUGetContact(hwnd); + if (hContact > 0) CallService(MS_MSG_SENDMESSAGE,(WPARAM)hContact,0); + } + case WM_CONTEXTMENU: + PUDeletePopUp(hwnd); + break; + case UM_INITPOPUP: return 0; + } + return DefWindowProc(hwnd, message, wParam, lParam); +}; + +void ShowPopup(HANDLE hcontact, const char * lpzProto, int newStatus){ + if(CallService(MS_IGNORE_ISIGNORED,(WPARAM)hcontact,IGNOREEVENT_USERONLINE)) return; + if (ServiceExists(MS_POPUP_QUERY)) { + if (DBGetContactSettingByte(NULL,S_MOD,"UsePopups",0)) { + if (!DBGetContactSettingByte(hcontact,"CList","Hidden",0)) { + POPUPDATAEX ppd = {0}; + DBVARIANT dbv = {0}; + char szstamp[10]; + DWORD sett; + sprintf(szstamp, "Col_%d",newStatus-ID_STATUS_OFFLINE); + sett = DBGetContactSettingDword(NULL,S_MOD,szstamp,StatusColors15bits[newStatus-ID_STATUS_OFFLINE]); + GetColorsFromDWord(&ppd.colorBack,&ppd.colorText,sett); + ppd.lchContact = hcontact; + ppd.lchIcon = LoadSkinnedProtoIcon(lpzProto, newStatus); + strncpy(ppd.lpzContactName,ParseString(!DBGetContactSetting(NULL,S_MOD,"PopupStamp",&dbv)?dbv.pszVal:DEFAULT_POPUPSTAMP,hcontact,0),MAX_CONTACTNAME); + DBFreeVariant(&dbv); + strncpy(ppd.lpzText,ParseString(!DBGetContactSetting(NULL,S_MOD,"PopupStampText",&dbv)?dbv.pszVal:DEFAULT_POPUPSTAMPTEXT,hcontact,0),MAX_SECONDLINE); + DBFreeVariant(&dbv); + ppd.PluginWindowProc = (WNDPROC)PopupDlgProc; + CallService(MS_POPUP_ADDPOPUPEX, (WPARAM)&ppd, 0); + } + } + } +} + +void myPlaySound(HANDLE hcontact, WORD newStatus, WORD oldStatus){ + if(CallService(MS_IGNORE_ISIGNORED,(WPARAM)hcontact,IGNOREEVENT_USERONLINE)) return; + //oldStatus and hcontact are not used yet + if (DBGetContactSettingByte(NULL,"Skin","UseSound",1)) { + char * soundname=0; + if ((newStatus==ID_STATUS_ONLINE) || (newStatus==ID_STATUS_FREECHAT)) soundname = "LastSeenTrackedStatusOnline"; + else if (newStatus==ID_STATUS_OFFLINE) soundname = "LastSeenTrackedStatusOffline"; + else if (oldStatus==ID_STATUS_OFFLINE) soundname = "LastSeenTrackedStatusFromOffline"; + else soundname = "LastSeenTrackedStatusChange"; + if (!DBGetContactSettingByte(NULL,"SkinSoundsOff",soundname,0)) { + DBVARIANT dbv; + if (!DBGetContactSetting(NULL,"SkinSounds",soundname,&dbv)) { + PlaySoundA(dbv.pszVal, NULL, SND_ASYNC | SND_FILENAME | SND_NOWAIT); + DBFreeVariant(&dbv); +} } } } + +//will give hContact position or zero +int isContactQueueActive(HANDLE hContact){ + int i = 0; + if (!hContact) { +// MessageBox(0,"Is myself in the queue: never","LastSeen-Mod",0); + return 0; + } + for (i=1;ihContact==hContact) return i; + } + return 0; +} + +//will add hContact to queue and will return position; +int addContactToQueue(HANDLE hContact){ + int i = 0; + if (!hContact) { +// MessageBox(0,"Adding myself to queue","LastSeen-Mod",0); + return 0; + } + for (i=1;iqueueIndex = i; + contactQueue[i]->hContact = hContact; + return i; + } + } + //no free space. Create some + //MessageBox(0,"Creating more space","LastSeen-Mod",0); + contactQueue = (logthread_info **)realloc(contactQueue,(contactQueueSize+16)*sizeof(logthread_info *)); + memset(&contactQueue[contactQueueSize],0, 16*sizeof(logthread_info *)); + i = contactQueueSize; + contactQueue[i] = (logthread_info *)malloc(sizeof(logthread_info)); + contactQueue[i]->queueIndex = i; + contactQueue[i]->hContact = hContact; + contactQueueSize += 16; + return i; +} + +static DWORD __stdcall waitThread(logthread_info* infoParam) +{ + WORD prevStatus = DBGetContactSettingWord(infoParam->hContact,S_MOD,"StatusTriger",ID_STATUS_OFFLINE); + Sleep(1500); // I hope in 1.5 second all the needed info will be set + if (includeIdle) + if (DBGetContactSettingDword(infoParam->hContact,infoParam->sProtoName,"IdleTS",0)) + infoParam->courStatus &=0x7FFF; + + if (infoParam->courStatus != prevStatus){ + DBWriteContactSettingWord(infoParam->hContact,S_MOD,"OldStatus",(WORD)(prevStatus|0x8000)); + if (includeIdle) + DBWriteContactSettingByte(infoParam->hContact,S_MOD,"OldIdle",(BYTE)((prevStatus&0x8000)==0)); + + DBWriteContactSettingWord(infoParam->hContact,S_MOD,"StatusTriger",infoParam->courStatus); + } + + contactQueue[infoParam->queueIndex] = 0; + free(infoParam); + return 0; +} + + + +int UpdateValues(WPARAM wparam,LPARAM lparam) +{ + DBCONTACTWRITESETTING *cws; + BOOL isIdleEvent; + // to make this code faster + if (!wparam) return 0; + cws=(DBCONTACTWRITESETTING *)lparam; + //if(CallService(MS_IGNORE_ISIGNORED,(WPARAM)hContact,IGNOREEVENT_USERONLINE)) return 0; + isIdleEvent = includeIdle?(strcmp(cws->szSetting,"IdleTS")==0):0; + if (strcmp(cws->szSetting,"Status") && strcmp(cws->szSetting,"StatusTriger") && (isIdleEvent==0)) return 0; + if (!strcmp(cws->szModule,S_MOD)) { + //here we will come when Settings/SeenModule/StatusTriger is changed + WORD prevStatus=DBGetContactSettingWord((HANDLE)wparam, S_MOD, "OldStatus", ID_STATUS_OFFLINE); + if (includeIdle){ + if (DBGetContactSettingByte((HANDLE)wparam, S_MOD, "OldIdle", 0)) prevStatus &= 0x7FFF; + else prevStatus |= 0x8000; + } + if ((cws->value.wVal|0x8000)<=ID_STATUS_OFFLINE) + { + char * proto; + // avoid repeating the offline status + if ((prevStatus|0x8000)<=ID_STATUS_OFFLINE) + return 0; + proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wparam, 0); + DBWriteContactSettingByte((HANDLE)wparam, S_MOD, "Offline", 1); + { + DWORD t; + char *str = (char *)malloc(MAXMODULELABELLENGTH+9); + mir_snprintf(str,MAXMODULELABELLENGTH+8,"OffTime-%s",proto); + t = DBGetContactSettingDword(NULL,S_MOD,str,0); + if (!t) t = time(NULL); + free(str); + DBWriteTimeTS(t, (HANDLE)wparam); + } + + if (!DBGetContactSettingByte(NULL,S_MOD,"IgnoreOffline",1)) + { + char * sProto; + if(DBGetContactSettingByte(NULL,S_MOD,"FileOutput",0)) + FileWrite((HANDLE)wparam); + + if (CallProtoService(sProto = + (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wparam, 0), + PS_GETSTATUS,0,0 + )>ID_STATUS_OFFLINE) { + myPlaySound((HANDLE)wparam, ID_STATUS_OFFLINE, prevStatus); + if(DBGetContactSettingByte(NULL, S_MOD, "UsePopups", 0)) { + ShowPopup((HANDLE)wparam, sProto, ID_STATUS_OFFLINE); + } } + + if(DBGetContactSettingByte(NULL, S_MOD, "KeepHistory", 0)) + HistoryWrite((HANDLE)wparam); + + if(DBGetContactSettingByte((HANDLE)wparam, S_MOD, "OnlineAlert", 0)) + ShowHistory((HANDLE)wparam, 1); + } + + } else { + + if(cws->value.wVal==prevStatus && !DBGetContactSettingByte((HANDLE)wparam, S_MOD, "Offline", 0)) + return 0; + + DBWriteTimeTS(time(NULL), (HANDLE)wparam); + + //DBWriteContactSettingWord(hContact,S_MOD,"StatusTriger",(WORD)cws->value.wVal); + + if(DBGetContactSettingByte(NULL, S_MOD, "FileOutput", 0)) FileWrite((HANDLE)wparam); + if (prevStatus != cws->value.wVal) myPlaySound((HANDLE)wparam, cws->value.wVal, prevStatus); + if(DBGetContactSettingByte(NULL, S_MOD, "UsePopups", 0)) + if (prevStatus != cws->value.wVal) ShowPopup((HANDLE)wparam, (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wparam, 0), cws->value.wVal|0x8000); + + if(DBGetContactSettingByte(NULL, S_MOD, "KeepHistory", 0)) HistoryWrite((HANDLE)wparam); + if(DBGetContactSettingByte((HANDLE)wparam, S_MOD, "OnlineAlert", 0)) ShowHistory((HANDLE)wparam, 1); + DBWriteContactSettingByte((HANDLE)wparam, S_MOD, "Offline", 0); + } + } else if (IsWatchedProtocol(cws->szModule)) { + //here we will come when //Status is changed or it is idle event and if is watched + if (CallProtoService(cws->szModule,PS_GETSTATUS,0,0)>ID_STATUS_OFFLINE){ + int index; + if (!(index = isContactQueueActive((HANDLE)wparam))) { + index = addContactToQueue((HANDLE)wparam); + strncpy(contactQueue[index]->sProtoName,cws->szModule,MAXMODULELABELLENGTH); + + unsigned int dwThreadId; + mir_forkthreadex((pThreadFuncEx)waitThread, contactQueue[index], &dwThreadId); + } + contactQueue[index]->courStatus = isIdleEvent ? DBGetContactSettingWord((HANDLE)wparam, cws->szModule, "Status", ID_STATUS_OFFLINE) : cws->value.wVal; + } } + + return 0; +} + +static DWORD __stdcall cleanThread(logthread_info* infoParam) +{ + Sleep(10000); // I hope in 10 secons all logged-in contacts will be listed + + HANDLE hcontact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0); + while(hcontact != NULL) { + char *contactProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hcontact,0); + if (contactProto) { + if ( !strncmp(infoParam->sProtoName, contactProto, MAXMODULELABELLENGTH)) { + WORD oldStatus = DBGetContactSettingWord(hcontact,S_MOD,"StatusTriger",ID_STATUS_OFFLINE) | 0x8000; + if (oldStatus > ID_STATUS_OFFLINE) { + if (DBGetContactSettingWord(hcontact,contactProto,"Status",ID_STATUS_OFFLINE)==ID_STATUS_OFFLINE){ + DBWriteContactSettingWord(hcontact,S_MOD,"OldStatus",(WORD)(oldStatus|0x8000)); + if (includeIdle)DBWriteContactSettingByte(hcontact,S_MOD,"OldIdle",(BYTE)((oldStatus&0x8000)?0:1)); + DBWriteContactSettingWord(hcontact,S_MOD,"StatusTriger",ID_STATUS_OFFLINE); + } + } + } + } + hcontact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hcontact,0); + } + + char *str = (char *)malloc(MAXMODULELABELLENGTH+9); + mir_snprintf(str,MAXMODULELABELLENGTH+8,"OffTime-%s",infoParam->sProtoName); + DBDeleteContactSetting(NULL,S_MOD,str); + free(str); + + free(infoParam); + return 0; +} + + +int ModeChange(WPARAM wparam,LPARAM lparam) +{ + ACKDATA *ack; + WORD isetting=0; + + ack=(ACKDATA *)lparam; + + if(ack->type!=ACKTYPE_STATUS || ack->result!=ACKRESULT_SUCCESS || ack->hContact!=NULL) return 0; + courProtoName = (char *)ack->szModule; + if (!IsWatchedProtocol(courProtoName) && strncmp(courProtoName,"MetaContacts",12)) + { + //MessageBox(NULL,"Protocol not watched",courProtoName,0); + return 0; + } + + DBWriteTimeTS(time(NULL),NULL); + +// isetting=CallProtoService(ack->szModule,PS_GETSTATUS,0,0); + isetting=(WORD)ack->lParam; + if (isettingID_STATUS_OFFLINE)&&((WORD)ack->hProcess<=ID_STATUS_OFFLINE)) { + //we have just loged-in + db_dword_set(NULL, "UserOnline", ack->szModule, GetTickCount()); + if (IsWatchedProtocol(ack->szModule)) { + logthread_info *info; + info = (logthread_info *)malloc(sizeof(logthread_info)); + strncpy(info->sProtoName,courProtoName,MAXMODULELABELLENGTH); + info->hContact = 0; + info->courStatus = 0; + + unsigned int dwThreadId; + CloseHandle( mir_forkthreadex((pThreadFuncEx)cleanThread, info, &dwThreadId)); + } + } else if ((isetting==ID_STATUS_OFFLINE)&&((WORD)ack->hProcess>ID_STATUS_OFFLINE)) { + //we have just loged-off + if (IsWatchedProtocol(ack->szModule)) { + char *str = (char *)malloc(MAXMODULELABELLENGTH+9); + time_t t; + time(&t); + mir_snprintf(str,MAXMODULELABELLENGTH+8,"OffTime-%s",ack->szModule); + DBWriteContactSettingDword(NULL,S_MOD,str,t); + free(str); + } } + if (isetting==DBGetContactSettingWord(NULL,S_MOD,courProtoName,ID_STATUS_OFFLINE)) return 0; + DBWriteContactSettingWord(NULL,S_MOD,courProtoName,isetting); + + // log "myself" + if(DBGetContactSettingByte(NULL,S_MOD,"FileOutput",0)) + FileWrite(NULL); + +// if(isetting==ID_STATUS_OFFLINE) //this is removed 'cause I want other contacts to be logged only if the status changed while I was offline +// SetOffline(); + + courProtoName = NULL; + + return 0; +} + +short int isDbZero(HANDLE hContact, const char *module_name, const char *setting_name){ + DBVARIANT dbv; + if (!DBGetContactSetting(hContact, module_name, setting_name, &dbv)) { + short int res = 0; + switch (dbv.type) { + case DBVT_BYTE: res=dbv.bVal==0; break; + case DBVT_WORD: res=dbv.wVal==0; break; + case DBVT_DWORD: res=dbv.dVal==0; break; + case DBVT_BLOB: res=dbv.cpbVal==0; break; + default: res=dbv.pszVal[0]==0; break; + } + DBFreeVariant(&dbv); + return res; + } else return -1; +} + +WCHAR *any_to_IdleNotidleUnknown(HANDLE hContact, const char *module_name, const char *setting_name, WCHAR *buff, int bufflen) { + short int r = isDbZero(hContact, module_name, setting_name); + if (r==-1){ + wcsncpy(buff, TranslateW(L"Unknown"), bufflen); + } else { + wcsncpy(buff, TranslateW(r?L"Not Idle":L"Idle"), bufflen); + }; + buff[bufflen - 1] = 0; + return buff; +} +WCHAR *any_to_Idle(HANDLE hContact, const char *module_name, const char *setting_name, WCHAR *buff, int bufflen) { + if(isDbZero(hContact, module_name, setting_name)==0) { //DB setting is NOT zero and exists + buff[0] = L'/'; + wcsncpy((WCHAR *)&buff[1], TranslateW(L"Idle"), bufflen-1); + } else buff[0] = 0; + buff[bufflen - 1] = 0; + return buff; +} + + +/*int GetInfoAck(WPARAM wparam,LPARAM lparam) +{ + ACKDATA *ack; + DWORD dwsetting=0; + + ack=(ACKDATA *)lparam; + + if(ack->type!=ACKTYPE_GETINFO || ack->hContact==NULL) return 0; + if (((int)ack->hProcess-1)!=(int)ack->lParam) return 0; + + dwsetting=DBGetContactSettingDword(ack->hContact,ack->szModule,"IP",0); + if(dwsetting) + DBWriteContactSettingDword(ack->hContact,S_MOD,"IP",dwsetting); + + dwsetting=DBGetContactSettingDword(ack->hContact,ack->szModule,"RealIP",0); + if(dwsetting) + DBWriteContactSettingDword(ack->hContact,S_MOD,"RealIP",dwsetting); + + return 0; +}*/ + + + +/*void SetOffline(void) +{ + HANDLE hcontact=NULL; + char * szProto; + + hcontact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0); + while(hcontact!=NULL) + { + szProto=(char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hcontact,0); + if (szProto != NULL && IsWatchedProtocol(szProto)) { + DBWriteContactSettingByte(hcontact,S_MOD,"Offline",1); + } + hcontact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hcontact,0); + } +}*/ + + + diff --git a/plugins/SeenPlugin/userinfo.cpp b/plugins/SeenPlugin/userinfo.cpp deleted file mode 100644 index 442860bb86..0000000000 --- a/plugins/SeenPlugin/userinfo.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* -"Last Seen mod" plugin for Miranda IM -Copyright ( C ) 2002-03 micron-x -Copyright ( C ) 2005-07 Y.B. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or ( at your option ) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/userinfo.c $ -Revision : $Rev: 1570 $ -Last change on : $Date: 2007-12-30 01:30:07 +0300 (Р’СЃ, 30 дек 2007) $ -Last change by : $Author: y_b $ -*/ -#include "seen.h" - - - -WNDPROC MainProc; - - - -extern HINSTANCE hInstance; -extern DWORD dwmirver; - - - -BOOL CALLBACK EditProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) -{ - switch(msg){ - case WM_SETCURSOR: - SetCursor(LoadCursor(NULL,IDC_ARROW)); - return 1; - - default: - break; - } - return CallWindowProc(MainProc,hdlg,msg,wparam,lparam); -} - - - -INT_PTR CALLBACK UserinfoDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) -{ - char *szout; - DBVARIANT dbv; - - switch(msg){ - - case WM_INITDIALOG: - MainProc=(WNDPROC)SetWindowLongPtr(GetDlgItem(hdlg,IDC_INFOTEXT),GWLP_WNDPROC,(LONG)EditProc); - szout=strdup(ParseString((!DBGetContactSetting(NULL,S_MOD,"UserStamp",&dbv)?dbv.pszVal:DEFAULT_USERSTAMP),(HANDLE)lparam,0)); - SetDlgItemText(hdlg,IDC_INFOTEXT,szout); - if (!strcmp(szout,Translate(""))) - EnableWindow(GetDlgItem(hdlg,IDC_INFOTEXT),FALSE); - free(szout); - DBFreeVariant(&dbv); - break; - - case WM_COMMAND: - if(HIWORD(wparam)==EN_SETFOCUS) - SetFocus(GetParent(hdlg)); - break; - } - - return 0; -} - - - -int UserinfoInit(WPARAM wparam,LPARAM lparam) -{ - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,lparam,0); - if (IsWatchedProtocol(proto)) { - OPTIONSDIALOGPAGE uip; - ZeroMemory(&uip,sizeof(uip)); - uip.cbSize=sizeof(uip); - uip.hInstance=hInstance; - uip.pszTemplate=MAKEINTRESOURCE(IDD_USERINFO); - uip.pszTitle="Last seen"; - uip.pfnDlgProc=UserinfoDlgProc; - UserInfo_AddPage(wparam, &uip); - } - return 0; -} diff --git a/plugins/SeenPlugin/utils.cpp b/plugins/SeenPlugin/utils.cpp deleted file mode 100644 index d989f9e999..0000000000 --- a/plugins/SeenPlugin/utils.cpp +++ /dev/null @@ -1,878 +0,0 @@ -/* -"Last Seen mod" plugin for Miranda IM -Copyright ( C ) 2002-03 micron-x -Copyright ( C ) 2005-07 Y.B. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or ( at your option ) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/utils.c $ -Revision : $Rev: 1570 $ -Last change on : $Date: 2007-12-30 01:30:07 +0300 (Р’СЃ, 30 дек 2007) $ -Last change by : $Author: y_b $ -*/ -#include "seen.h" -#include -#include - - -void FileWrite(HANDLE); -void HistoryWrite(HANDLE hcontact); -//void SetOffline(void); -void ShowHistory(HANDLE hContact, BYTE isAlert); - -char * courProtoName = 0; - -//copied from ..\..\miranda32\protocols\protocols\protocols.c -PROTOCOLDESCRIPTOR* Proto_IsProtocolLoaded(const char* szProto) -{ - return (PROTOCOLDESCRIPTOR*) CallService(MS_PROTO_ISPROTOCOLLOADED, 0, (LPARAM)szProto); -} - - -/* -Returns true if the protocols is to be monitored -*/ -int IsWatchedProtocol(const char* szProto) -{ - DBVARIANT dbv; - char *szProtoPointer, *szWatched; - int iProtoLen, iWatchedLen; - int retval = 0; - PROTOCOLDESCRIPTOR *pd; - - if (szProto == NULL) - return 0; - - pd=Proto_IsProtocolLoaded(szProto); - if (pd==NULL || pd->type!=PROTOTYPE_PROTOCOL || CallProtoService(pd->szName,PS_GETCAPS,PFLAGNUM_2,0)==0) - return 0; - - iProtoLen = (int)_tcslen(szProto); - if(DBGetContactSetting(NULL, S_MOD, "WatchedProtocols", &dbv)) - szWatched = DEFAULT_WATCHEDPROTOCOLS; - else - szWatched = dbv.pszVal; - iWatchedLen = (int)_tcslen(szWatched); - - if (*szWatched == '\0') - { - retval=1; //empty string: all protocols are watched - } - else - { - char sTemp [MAXMODULELABELLENGTH+1]=""; - strcat(sTemp,szProto); - strcat(sTemp," "); - szProtoPointer = strstr(szWatched, sTemp); - if (szProtoPointer == NULL) - retval=0; - else - retval=1; - } - - DBFreeVariant(&dbv); - return retval; -} - -BOOL isYahoo(char * protoname){ - if (protoname) { - char *pszUniqueSetting = (char*)CallProtoService(protoname, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); - if (pszUniqueSetting){ - return (!strcmp(pszUniqueSetting,"yahoo_id")); - } } - return FALSE; -} -BOOL isJabber(char * protoname){ - if (protoname) { - char *pszUniqueSetting = (char*)CallProtoService(protoname, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); - if (pszUniqueSetting){ - return (!strcmp(pszUniqueSetting,"jid")); - } } - return FALSE; -} -BOOL isICQ(char * protoname){ - if (protoname) { - char *pszUniqueSetting = (char*)CallProtoService(protoname, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); - if (pszUniqueSetting){ - return (!strcmp(pszUniqueSetting,"UIN")); - } } - return FALSE; -} -BOOL isMSN(char * protoname){ - if (protoname) { - char *pszUniqueSetting = (char*)CallProtoService(protoname, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); - if (pszUniqueSetting){ - return (!strcmp(pszUniqueSetting,"e-mail")); - } } - return FALSE; -} - -DWORD isSeen(HANDLE hcontact, SYSTEMTIME *st){ - DWORD res = 0; - FILETIME ft; - ULONGLONG ll; - res = DBGetContactSettingDword(hcontact,S_MOD,"seenTS",0); - if (res){ - if (st) { - ll = UInt32x32To64(CallService(MS_DB_TIME_TIMESTAMPTOLOCAL,res,0), 10000000) + NUM100NANOSEC; - ft.dwLowDateTime = (DWORD)ll; - ft.dwHighDateTime = (DWORD)(ll >> 32); - FileTimeToSystemTime(&ft, st); - } - return res; - } else { - SYSTEMTIME lst; - ZeroMemory(&lst,sizeof(lst)); - if (lst.wYear = DBGetContactSettingWord(hcontact,S_MOD,"Year",0)) { - if (lst.wMonth = DBGetContactSettingWord(hcontact,S_MOD,"Month",0)) { - if (lst.wDay = DBGetContactSettingWord(hcontact,S_MOD,"Day",0)) { - lst.wDayOfWeek = DBGetContactSettingWord(hcontact,S_MOD,"WeekDay",0); - lst.wHour = DBGetContactSettingWord(hcontact,S_MOD,"Hours",0); - lst.wMinute = DBGetContactSettingWord(hcontact,S_MOD,"Minutes",0); - lst.wSecond = DBGetContactSettingWord(hcontact,S_MOD,"Seconds",0); - if (SystemTimeToFileTime(&lst,&ft)) { - ll = ((LONGLONG)ft.dwHighDateTime<<32)|((LONGLONG)ft.dwLowDateTime); - ll -= NUM100NANOSEC; - ll /= 10000000; - //perform LOCALTOTIMESTAMP - res = (DWORD)ll - CallService(MS_DB_TIME_TIMESTAMPTOLOCAL,0,0); - //nevel look for Year/Month/Day/Hour/Minute/Second again - DBWriteContactSettingDword(hcontact,S_MOD,"seenTS",res); - } - } } } - if (st) CopyMemory (st, &lst, sizeof (SYSTEMTIME)); - } - return res; -} - -char *ParseString(char *szstring,HANDLE hcontact,BYTE isfile) -{ -#define MAXSIZE 1024 - static char sztemp[MAXSIZE+1]; - int sztemplen = 0; - char szdbsetting[128]=""; - char *charPtr; - UINT loop=0; - int isetting=0; - DWORD dwsetting=0; - struct in_addr ia; - char *weekdays[]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}; - char *wdays_short[]={"Sun.","Mon.","Tue.","Wed.","Thu.","Fri.","Sat."}; - char *monthnames[]={"January","February","March","April","May","June","July","August","September","October","November","December"}; - char *mnames_short[]={"Jan.","Feb.","Mar.","Apr.","May","Jun.","Jul.","Aug.","Sep.","Oct.","Nov.","Dec."}; - CONTACTINFO ci; - BOOL wantempty; - SYSTEMTIME st; - - sztemp[0] = '\0'; - if (!isSeen(hcontact,&st)) { - strcat(sztemp,Translate("")); - return sztemp; - } - - ci.cbSize=sizeof(CONTACTINFO); - ci.hContact=hcontact; - ci.szProto=hcontact?(char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hcontact,0):courProtoName; - for (;loop"); - goto LBL_charPtr; - } - charPtr = Translate(weekdays[isetting]); -LBL_charPtr: - sztemplen += mir_snprintf(sztemp+sztemplen,MAXSIZE-sztemplen,"%s",charPtr); - break; - - case 'w': - isetting=st.wDayOfWeek; - if(isetting==-1)goto LBL_noData; - charPtr = Translate(wdays_short[isetting]); - goto LBL_charPtr; - - case 'E': - if (!(isetting=st.wMonth))goto LBL_noData; - charPtr = Translate(monthnames[isetting-1]); - goto LBL_charPtr; - - case 'e': - if (!(isetting=st.wMonth))goto LBL_noData; - charPtr = Translate(mnames_short[isetting-1]); - goto LBL_charPtr; - - case 'H': - if ((isetting=st.wHour)==-1)goto LBL_noData; - goto LBL_2DigNum; - - case 'h': - if ((isetting=st.wHour)==-1)goto LBL_noData; - if (!isetting) isetting=12; - isetting = isetting-((isetting>12)?12:0); - goto LBL_2DigNum; - - case 'p': - if ((isetting=st.wHour)==-1)goto LBL_noData; - charPtr = (isetting>=12)?"PM":"AM"; - goto LBL_charPtr; - - case 'M': - if ((isetting=st.wMinute)==-1)goto LBL_noData; - goto LBL_2DigNum; - - case 'S': - if ((isetting=st.wHour)==-1)goto LBL_noData; - goto LBL_2DigNum; - - case 'n': - charPtr = hcontact?(char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hcontact,0):(wantempty?"":"---"); - goto LBL_charPtr; - case 'N': - ci.dwFlag=CNF_NICK; - if (!CallService(MS_CONTACT_GETCONTACTINFO,(WPARAM)0,(LPARAM)&ci)) { - charPtr = ci.pszVal; - } else goto LBL_noData; - goto LBL_charPtr; - case 'G': - { - DBVARIANT dbv; - if (!DBGetContactSetting(hcontact,"CList","Group",&dbv)) { - strcpy(szdbsetting,dbv.pszVal); - DBFreeVariant(&dbv); - charPtr = szdbsetting; - goto LBL_charPtr; - } else; //do nothing - } - break; - - case 'u': - ci.dwFlag=CNF_UNIQUEID; - if (!CallService(MS_CONTACT_GETCONTACTINFO,(WPARAM)0,(LPARAM)&ci)) - { - switch(ci.type) - { - case CNFT_BYTE: - ltoa(ci.bVal,szdbsetting,10); - break; - case CNFT_WORD: - ltoa(ci.wVal,szdbsetting,10); - break; - case CNFT_DWORD: - ltoa(ci.dVal,szdbsetting,10); - break; - case CNFT_ASCIIZ: - strcpy(szdbsetting,ci.pszVal); - break; - } - - } - else if (ci.szProto != NULL) - { - if (isYahoo(ci.szProto)) // YAHOO support - { - DBVARIANT dbv; - DBGetContactSetting(hcontact,ci.szProto,"id",&dbv); - strcpy(szdbsetting,dbv.pszVal); - DBFreeVariant(&dbv); - } - else if (isJabber(ci.szProto)) // JABBER support - { - DBVARIANT dbv; - if (DBGetContactSetting(hcontact,ci.szProto,"LoginName",&dbv)) goto LBL_noData; - strcpy(szdbsetting,dbv.pszVal); - DBFreeVariant(&dbv); - DBGetContactSetting(hcontact,ci.szProto,"LoginServer",&dbv); - strcat(szdbsetting,"@"); - strcat(szdbsetting,dbv.pszVal); - DBFreeVariant(&dbv); - } else goto LBL_noData; - } - else goto LBL_noData; - charPtr = szdbsetting; - goto LBL_charPtr; - - case 's': - if (isetting=DBGetContactSettingWord(hcontact,S_MOD,hcontact?"StatusTriger":courProtoName,0)) { - strcpy(szdbsetting,Translate((const char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,(WPARAM)(isetting|0x8000),0))); - if (!(isetting&0x8000)) { - strcat(szdbsetting,"/"); - strcat(szdbsetting,Translate("Idle")); - } - charPtr = szdbsetting; - } else goto LBL_noData; - goto LBL_charPtr; - case 'T': - { - DBVARIANT dbv; - if (!DBGetContactSetting(hcontact,"CList","StatusMsg",&dbv)) { - sztemplen += mir_snprintf(sztemp+sztemplen,MAXSIZE-sztemplen,"%s",dbv.pszVal); - DBFreeVariant(&dbv); - } else goto LBL_noData; - } - break; - case 'o': - if (isetting=DBGetContactSettingWord(hcontact,S_MOD,hcontact?"OldStatus":courProtoName,0)) { - strcpy(szdbsetting,Translate((const char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,(WPARAM)isetting,0))); - if (includeIdle) if (hcontact) if (DBGetContactSettingByte(hcontact,S_MOD,"OldIdle",0)) { - strcat(szdbsetting,"/"); - strcat(szdbsetting,Translate("Idle")); - } - charPtr = szdbsetting; - } else goto LBL_noData; - goto LBL_charPtr; - - case 'i': - case 'r': if (isJabber(ci.szProto)) { - DBVARIANT dbv; - if (!DBGetContactSetting(hcontact,ci.szProto,szstring[loop]=='i'?"Resource":"System",&dbv)) { - strcpy(szdbsetting,dbv.pszVal); - DBFreeVariant(&dbv); - charPtr = szdbsetting; - } else goto LBL_noData; - } else { - dwsetting=DBGetContactSettingDword(hcontact,ci.szProto,szstring[loop]=='i'?"IP":"RealIP",0); - if(dwsetting){ - ia.S_un.S_addr=htonl(dwsetting); - charPtr = inet_ntoa(ia); - } else goto LBL_noData; - } - goto LBL_charPtr; - case 'P':if (ci.szProto) charPtr = ci.szProto; else charPtr = wantempty?"":"ProtoUnknown"; - goto LBL_charPtr; - case 'b': - charPtr = /*"\n"*/"\x0D\x0A"; - goto LBL_charPtr; - case 'C': // Get Client Info - if (isMSN(ci.szProto)) { - if (hcontact) { - dwsetting = (int)DBGetContactSettingDword(hcontact,ci.szProto,"FlagBits",0); - wsprintf(szdbsetting,"MSNC%i",(dwsetting&0x70000000)>>28); - if (dwsetting & 0x00000001) strcat(szdbsetting," MobD"); //Mobile Device - if (dwsetting & 0x00000004) strcat(szdbsetting," InkG"); //GIF Ink Send/Receive - if (dwsetting & 0x00000008) strcat(szdbsetting," InkI"); //ISF Ink Send/Receive - if (dwsetting & 0x00000010) strcat(szdbsetting," WCam"); //Webcam - if (dwsetting & 0x00000020) strcat(szdbsetting," MPkt"); //Multi packet messages - if (dwsetting & 0x00000040) strcat(szdbsetting," SMSr"); //Paging - if (dwsetting & 0x00000080) strcat(szdbsetting," DSMS"); //Using MSN Direct - if (dwsetting & 0x00000200) strcat(szdbsetting," WebM"); //WebMessenger - if (dwsetting & 0x00001000) strcat(szdbsetting," MS7+"); //Unknown (Msgr 7 always[?] sets it) - if (dwsetting & 0x00004000) strcat(szdbsetting," DirM"); //DirectIM - if (dwsetting & 0x00008000) strcat(szdbsetting," Wink"); //Send/Receive Winks - if (dwsetting & 0x00010000) strcat(szdbsetting," MSrc"); //MSN Search ?? - if (dwsetting & 0x00040000) strcat(szdbsetting," VoiC"); //Voice Clips - } else strcpy(szdbsetting,"Miranda"); - } else { - DBVARIANT dbv; - if (!DBGetContactSetting(hcontact,ci.szProto,"MirVer",&dbv)) { - strcpy(szdbsetting,dbv.pszVal); - DBFreeVariant(&dbv); - } else goto LBL_noData; - } - charPtr = szdbsetting; - goto LBL_charPtr; - case 't': - charPtr = "\t"; - goto LBL_charPtr; - - default: - strncpy(szdbsetting,szstring+loop-1,2); - goto LBL_charPtr; - } - } - } - - return sztemp; -} - - - -void _DBWriteTime(SYSTEMTIME *st,HANDLE hcontact) -{ - DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Day",st->wDay); - DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Month",st->wMonth); - DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Year",st->wYear); - DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Hours",st->wHour); - DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Minutes",st->wMinute); - DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Seconds",st->wSecond); - DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"WeekDay",st->wDayOfWeek); - -} - -void DBWriteTimeTS(DWORD t, HANDLE hcontact){ - SYSTEMTIME st; - FILETIME ft; - ULONGLONG ll = UInt32x32To64(CallService(MS_DB_TIME_TIMESTAMPTOLOCAL,t,0), 10000000) + NUM100NANOSEC; - ft.dwLowDateTime = (DWORD)ll; - ft.dwHighDateTime = (DWORD)(ll >> 32); - FileTimeToSystemTime(&ft, &st); - DBWriteContactSettingDword(hcontact,S_MOD,"seenTS",t); - _DBWriteTime(&st, hcontact); -} -void GetColorsFromDWord(LPCOLORREF First, LPCOLORREF Second, DWORD colDword){ - WORD temp; - COLORREF res=0; - temp = (WORD)(colDword>>16); - res |= ((temp & 0x1F) <<3); - res |= ((temp & 0x3E0) <<6); - res |= ((temp & 0x7C00) <<9); - if (First) *First = res; - res = 0; - temp = (WORD)colDword; - res |= ((temp & 0x1F) <<3); - res |= ((temp & 0x3E0) <<6); - res |= ((temp & 0x7C00) <<9); - if (Second) *Second = res; -} - -DWORD StatusColors15bits[] = { - 0x63180000, // 0x00C0C0C0, 0x00000000, Offline - LightGray - 0x7B350000, // 0x00F0C8A8, 0x00000000, Online - LightBlue - 0x33fe0000, // 0x0070E0E0, 0x00000000, Away -LightOrange - 0x295C0000, // 0x005050E0, 0x00000000, DND -DarkRed - 0x5EFD0000, // 0x00B8B8E8, 0x00000000, NA -LightRed - 0x295C0000, // 0x005050E0, 0x00000000, Occupied - 0x43900000, // 0x0080E080, 0x00000000, Free for chat - LightGreen - 0x76AF0000, // 0x00E8A878, 0x00000000, Invisible - 0x431C0000, // 0x0080C0E0, 0x00000000, On the phone - 0x5EFD0000, // 0x00B8B8E8, 0x00000000, Out to lunch -}; - -DWORD GetDWordFromColors(COLORREF First, COLORREF Second){ - DWORD res = 0; - res |= (First&0xF8)>>3; - res |= (First&0xF800)>>6; - res |= (First&0xF80000)>>9; - res <<= 16; - res |= (Second&0xF8)>>3; - res |= (Second&0xF800)>>6; - res |= (Second&0xF80000)>>9; - return res; -} - -LRESULT CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - - switch(message) { - case WM_COMMAND: - if (HIWORD(wParam) == STN_CLICKED){ - HANDLE hContact = PUGetContact(hwnd); - if (hContact > 0) CallService(MS_MSG_SENDMESSAGE,(WPARAM)hContact,0); - } - case WM_CONTEXTMENU: - PUDeletePopUp(hwnd); - break; - case UM_INITPOPUP: return 0; - } - return DefWindowProc(hwnd, message, wParam, lParam); -}; - -void ShowPopup(HANDLE hcontact, const char * lpzProto, int newStatus){ - if(CallService(MS_IGNORE_ISIGNORED,(WPARAM)hcontact,IGNOREEVENT_USERONLINE)) return; - if (ServiceExists(MS_POPUP_QUERY)) { - if (DBGetContactSettingByte(NULL,S_MOD,"UsePopups",0)) { - if (!DBGetContactSettingByte(hcontact,"CList","Hidden",0)) { - POPUPDATAEX ppd = {0}; - DBVARIANT dbv = {0}; - char szstamp[10]; - DWORD sett; - sprintf(szstamp, "Col_%d",newStatus-ID_STATUS_OFFLINE); - sett = DBGetContactSettingDword(NULL,S_MOD,szstamp,StatusColors15bits[newStatus-ID_STATUS_OFFLINE]); - GetColorsFromDWord(&ppd.colorBack,&ppd.colorText,sett); - ppd.lchContact = hcontact; - ppd.lchIcon = LoadSkinnedProtoIcon(lpzProto, newStatus); - strncpy(ppd.lpzContactName,ParseString(!DBGetContactSetting(NULL,S_MOD,"PopupStamp",&dbv)?dbv.pszVal:DEFAULT_POPUPSTAMP,hcontact,0),MAX_CONTACTNAME); - DBFreeVariant(&dbv); - strncpy(ppd.lpzText,ParseString(!DBGetContactSetting(NULL,S_MOD,"PopupStampText",&dbv)?dbv.pszVal:DEFAULT_POPUPSTAMPTEXT,hcontact,0),MAX_SECONDLINE); - DBFreeVariant(&dbv); - ppd.PluginWindowProc = (WNDPROC)PopupDlgProc; - CallService(MS_POPUP_ADDPOPUPEX, (WPARAM)&ppd, 0); - } - } - } -} - -void myPlaySound(HANDLE hcontact, WORD newStatus, WORD oldStatus){ - if(CallService(MS_IGNORE_ISIGNORED,(WPARAM)hcontact,IGNOREEVENT_USERONLINE)) return; - //oldStatus and hcontact are not used yet - if (DBGetContactSettingByte(NULL,"Skin","UseSound",1)) { - char * soundname=0; - if ((newStatus==ID_STATUS_ONLINE) || (newStatus==ID_STATUS_FREECHAT)) soundname = "LastSeenTrackedStatusOnline"; - else if (newStatus==ID_STATUS_OFFLINE) soundname = "LastSeenTrackedStatusOffline"; - else if (oldStatus==ID_STATUS_OFFLINE) soundname = "LastSeenTrackedStatusFromOffline"; - else soundname = "LastSeenTrackedStatusChange"; - if (!DBGetContactSettingByte(NULL,"SkinSoundsOff",soundname,0)) { - DBVARIANT dbv; - if (!DBGetContactSetting(NULL,"SkinSounds",soundname,&dbv)) { - PlaySoundA(dbv.pszVal, NULL, SND_ASYNC | SND_FILENAME | SND_NOWAIT); - DBFreeVariant(&dbv); -} } } } - -//will give hContact position or zero -int isContactQueueActive(HANDLE hContact){ - int i = 0; - if (!hContact) { -// MessageBox(0,"Is myself in the queue: never","LastSeen-Mod",0); - return 0; - } - for (i=1;ihContact==hContact) return i; - } - return 0; -} - -//will add hContact to queue and will return position; -int addContactToQueue(HANDLE hContact){ - int i = 0; - if (!hContact) { -// MessageBox(0,"Adding myself to queue","LastSeen-Mod",0); - return 0; - } - for (i=1;iqueueIndex = i; - contactQueue[i]->hContact = hContact; - return i; - } - } - //no free space. Create some - //MessageBox(0,"Creating more space","LastSeen-Mod",0); - contactQueue = (logthread_info **)realloc(contactQueue,(contactQueueSize+16)*sizeof(logthread_info *)); - memset(&contactQueue[contactQueueSize],0, 16*sizeof(logthread_info *)); - i = contactQueueSize; - contactQueue[i] = (logthread_info *)malloc(sizeof(logthread_info)); - contactQueue[i]->queueIndex = i; - contactQueue[i]->hContact = hContact; - contactQueueSize += 16; - return i; -} - -static DWORD __stdcall waitThread(logthread_info* infoParam) -{ - WORD prevStatus = DBGetContactSettingWord(infoParam->hContact,S_MOD,"StatusTriger",ID_STATUS_OFFLINE); - Sleep(1500); // I hope in 1.5 second all the needed info will be set - if (includeIdle) - if (DBGetContactSettingDword(infoParam->hContact,infoParam->sProtoName,"IdleTS",0)) - infoParam->courStatus &=0x7FFF; - - if (infoParam->courStatus != prevStatus){ - DBWriteContactSettingWord(infoParam->hContact,S_MOD,"OldStatus",(WORD)(prevStatus|0x8000)); - if (includeIdle) - DBWriteContactSettingByte(infoParam->hContact,S_MOD,"OldIdle",(BYTE)((prevStatus&0x8000)==0)); - - DBWriteContactSettingWord(infoParam->hContact,S_MOD,"StatusTriger",infoParam->courStatus); - } - - contactQueue[infoParam->queueIndex] = 0; - free(infoParam); - return 0; -} - - - -int UpdateValues(WPARAM wparam,LPARAM lparam) -{ - DBCONTACTWRITESETTING *cws; - BOOL isIdleEvent; - // to make this code faster - if (!wparam) return 0; - cws=(DBCONTACTWRITESETTING *)lparam; - //if(CallService(MS_IGNORE_ISIGNORED,(WPARAM)hContact,IGNOREEVENT_USERONLINE)) return 0; - isIdleEvent = includeIdle?(strcmp(cws->szSetting,"IdleTS")==0):0; - if (strcmp(cws->szSetting,"Status") && strcmp(cws->szSetting,"StatusTriger") && (isIdleEvent==0)) return 0; - if (!strcmp(cws->szModule,S_MOD)) { - //here we will come when Settings/SeenModule/StatusTriger is changed - WORD prevStatus=DBGetContactSettingWord((HANDLE)wparam, S_MOD, "OldStatus", ID_STATUS_OFFLINE); - if (includeIdle){ - if (DBGetContactSettingByte((HANDLE)wparam, S_MOD, "OldIdle", 0)) prevStatus &= 0x7FFF; - else prevStatus |= 0x8000; - } - if ((cws->value.wVal|0x8000)<=ID_STATUS_OFFLINE) - { - char * proto; - // avoid repeating the offline status - if ((prevStatus|0x8000)<=ID_STATUS_OFFLINE) - return 0; - proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wparam, 0); - DBWriteContactSettingByte((HANDLE)wparam, S_MOD, "Offline", 1); - { - DWORD t; - char *str = (char *)malloc(MAXMODULELABELLENGTH+9); - mir_snprintf(str,MAXMODULELABELLENGTH+8,"OffTime-%s",proto); - t = DBGetContactSettingDword(NULL,S_MOD,str,0); - if (!t) t = time(NULL); - free(str); - DBWriteTimeTS(t, (HANDLE)wparam); - } - - if (!DBGetContactSettingByte(NULL,S_MOD,"IgnoreOffline",1)) - { - char * sProto; - if(DBGetContactSettingByte(NULL,S_MOD,"FileOutput",0)) - FileWrite((HANDLE)wparam); - - if (CallProtoService(sProto = - (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wparam, 0), - PS_GETSTATUS,0,0 - )>ID_STATUS_OFFLINE) { - myPlaySound((HANDLE)wparam, ID_STATUS_OFFLINE, prevStatus); - if(DBGetContactSettingByte(NULL, S_MOD, "UsePopups", 0)) { - ShowPopup((HANDLE)wparam, sProto, ID_STATUS_OFFLINE); - } } - - if(DBGetContactSettingByte(NULL, S_MOD, "KeepHistory", 0)) - HistoryWrite((HANDLE)wparam); - - if(DBGetContactSettingByte((HANDLE)wparam, S_MOD, "OnlineAlert", 0)) - ShowHistory((HANDLE)wparam, 1); - } - - } else { - - if(cws->value.wVal==prevStatus && !DBGetContactSettingByte((HANDLE)wparam, S_MOD, "Offline", 0)) - return 0; - - DBWriteTimeTS(time(NULL), (HANDLE)wparam); - - //DBWriteContactSettingWord(hContact,S_MOD,"StatusTriger",(WORD)cws->value.wVal); - - if(DBGetContactSettingByte(NULL, S_MOD, "FileOutput", 0)) FileWrite((HANDLE)wparam); - if (prevStatus != cws->value.wVal) myPlaySound((HANDLE)wparam, cws->value.wVal, prevStatus); - if(DBGetContactSettingByte(NULL, S_MOD, "UsePopups", 0)) - if (prevStatus != cws->value.wVal) ShowPopup((HANDLE)wparam, (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wparam, 0), cws->value.wVal|0x8000); - - if(DBGetContactSettingByte(NULL, S_MOD, "KeepHistory", 0)) HistoryWrite((HANDLE)wparam); - if(DBGetContactSettingByte((HANDLE)wparam, S_MOD, "OnlineAlert", 0)) ShowHistory((HANDLE)wparam, 1); - DBWriteContactSettingByte((HANDLE)wparam, S_MOD, "Offline", 0); - } - } else if (IsWatchedProtocol(cws->szModule)) { - //here we will come when //Status is changed or it is idle event and if is watched - if (CallProtoService(cws->szModule,PS_GETSTATUS,0,0)>ID_STATUS_OFFLINE){ - int index; - if (!(index = isContactQueueActive((HANDLE)wparam))) { - index = addContactToQueue((HANDLE)wparam); - strncpy(contactQueue[index]->sProtoName,cws->szModule,MAXMODULELABELLENGTH); - - unsigned int dwThreadId; - mir_forkthreadex((pThreadFuncEx)waitThread, contactQueue[index], &dwThreadId); - } - contactQueue[index]->courStatus = isIdleEvent ? DBGetContactSettingWord((HANDLE)wparam, cws->szModule, "Status", ID_STATUS_OFFLINE) : cws->value.wVal; - } } - - return 0; -} - -static DWORD __stdcall cleanThread(logthread_info* infoParam) -{ - Sleep(10000); // I hope in 10 secons all logged-in contacts will be listed - - HANDLE hcontact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0); - while(hcontact != NULL) { - char *contactProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hcontact,0); - if (contactProto) { - if ( !strncmp(infoParam->sProtoName, contactProto, MAXMODULELABELLENGTH)) { - WORD oldStatus = DBGetContactSettingWord(hcontact,S_MOD,"StatusTriger",ID_STATUS_OFFLINE) | 0x8000; - if (oldStatus > ID_STATUS_OFFLINE) { - if (DBGetContactSettingWord(hcontact,contactProto,"Status",ID_STATUS_OFFLINE)==ID_STATUS_OFFLINE){ - DBWriteContactSettingWord(hcontact,S_MOD,"OldStatus",(WORD)(oldStatus|0x8000)); - if (includeIdle)DBWriteContactSettingByte(hcontact,S_MOD,"OldIdle",(BYTE)((oldStatus&0x8000)?0:1)); - DBWriteContactSettingWord(hcontact,S_MOD,"StatusTriger",ID_STATUS_OFFLINE); - } - } - } - } - hcontact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hcontact,0); - } - - char *str = (char *)malloc(MAXMODULELABELLENGTH+9); - mir_snprintf(str,MAXMODULELABELLENGTH+8,"OffTime-%s",infoParam->sProtoName); - DBDeleteContactSetting(NULL,S_MOD,str); - free(str); - - free(infoParam); - return 0; -} - - -int ModeChange(WPARAM wparam,LPARAM lparam) -{ - ACKDATA *ack; - WORD isetting=0; - - ack=(ACKDATA *)lparam; - - if(ack->type!=ACKTYPE_STATUS || ack->result!=ACKRESULT_SUCCESS || ack->hContact!=NULL) return 0; - courProtoName = (char *)ack->szModule; - if (!IsWatchedProtocol(courProtoName) && strncmp(courProtoName,"MetaContacts",12)) - { - //MessageBox(NULL,"Protocol not watched",courProtoName,0); - return 0; - } - - DBWriteTimeTS(time(NULL),NULL); - -// isetting=CallProtoService(ack->szModule,PS_GETSTATUS,0,0); - isetting=(WORD)ack->lParam; - if (isettingID_STATUS_OFFLINE)&&((WORD)ack->hProcess<=ID_STATUS_OFFLINE)) { - //we have just loged-in - db_dword_set(NULL, "UserOnline", ack->szModule, GetTickCount()); - if (IsWatchedProtocol(ack->szModule)) { - logthread_info *info; - info = (logthread_info *)malloc(sizeof(logthread_info)); - strncpy(info->sProtoName,courProtoName,MAXMODULELABELLENGTH); - info->hContact = 0; - info->courStatus = 0; - - unsigned int dwThreadId; - CloseHandle( mir_forkthreadex((pThreadFuncEx)cleanThread, info, &dwThreadId)); - } - } else if ((isetting==ID_STATUS_OFFLINE)&&((WORD)ack->hProcess>ID_STATUS_OFFLINE)) { - //we have just loged-off - if (IsWatchedProtocol(ack->szModule)) { - char *str = (char *)malloc(MAXMODULELABELLENGTH+9); - time_t t; - time(&t); - mir_snprintf(str,MAXMODULELABELLENGTH+8,"OffTime-%s",ack->szModule); - DBWriteContactSettingDword(NULL,S_MOD,str,t); - free(str); - } } - if (isetting==DBGetContactSettingWord(NULL,S_MOD,courProtoName,ID_STATUS_OFFLINE)) return 0; - DBWriteContactSettingWord(NULL,S_MOD,courProtoName,isetting); - - // log "myself" - if(DBGetContactSettingByte(NULL,S_MOD,"FileOutput",0)) - FileWrite(NULL); - -// if(isetting==ID_STATUS_OFFLINE) //this is removed 'cause I want other contacts to be logged only if the status changed while I was offline -// SetOffline(); - - courProtoName = NULL; - - return 0; -} - -short int isDbZero(HANDLE hContact, const char *module_name, const char *setting_name){ - DBVARIANT dbv; - if (!DBGetContactSetting(hContact, module_name, setting_name, &dbv)) { - short int res = 0; - switch (dbv.type) { - case DBVT_BYTE: res=dbv.bVal==0; break; - case DBVT_WORD: res=dbv.wVal==0; break; - case DBVT_DWORD: res=dbv.dVal==0; break; - case DBVT_BLOB: res=dbv.cpbVal==0; break; - default: res=dbv.pszVal[0]==0; break; - } - DBFreeVariant(&dbv); - return res; - } else return -1; -} - -WCHAR *any_to_IdleNotidleUnknown(HANDLE hContact, const char *module_name, const char *setting_name, WCHAR *buff, int bufflen) { - short int r = isDbZero(hContact, module_name, setting_name); - if (r==-1){ - wcsncpy(buff, TranslateW(L"Unknown"), bufflen); - } else { - wcsncpy(buff, TranslateW(r?L"Not Idle":L"Idle"), bufflen); - }; - buff[bufflen - 1] = 0; - return buff; -} -WCHAR *any_to_Idle(HANDLE hContact, const char *module_name, const char *setting_name, WCHAR *buff, int bufflen) { - if(isDbZero(hContact, module_name, setting_name)==0) { //DB setting is NOT zero and exists - buff[0] = L'/'; - wcsncpy((WCHAR *)&buff[1], TranslateW(L"Idle"), bufflen-1); - } else buff[0] = 0; - buff[bufflen - 1] = 0; - return buff; -} - - -/*int GetInfoAck(WPARAM wparam,LPARAM lparam) -{ - ACKDATA *ack; - DWORD dwsetting=0; - - ack=(ACKDATA *)lparam; - - if(ack->type!=ACKTYPE_GETINFO || ack->hContact==NULL) return 0; - if (((int)ack->hProcess-1)!=(int)ack->lParam) return 0; - - dwsetting=DBGetContactSettingDword(ack->hContact,ack->szModule,"IP",0); - if(dwsetting) - DBWriteContactSettingDword(ack->hContact,S_MOD,"IP",dwsetting); - - dwsetting=DBGetContactSettingDword(ack->hContact,ack->szModule,"RealIP",0); - if(dwsetting) - DBWriteContactSettingDword(ack->hContact,S_MOD,"RealIP",dwsetting); - - return 0; -}*/ - - - -/*void SetOffline(void) -{ - HANDLE hcontact=NULL; - char * szProto; - - hcontact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0); - while(hcontact!=NULL) - { - szProto=(char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hcontact,0); - if (szProto != NULL && IsWatchedProtocol(szProto)) { - DBWriteContactSettingByte(hcontact,S_MOD,"Offline",1); - } - hcontact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hcontact,0); - } -}*/ - - - diff --git a/plugins/SendScreenshotPlus/CSend.cpp b/plugins/SendScreenshotPlus/CSend.cpp deleted file mode 100644 index 4e48ecb2b4..0000000000 --- a/plugins/SendScreenshotPlus/CSend.cpp +++ /dev/null @@ -1,416 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2009 Miranda ICQ/IM project, - -This file is part of Send Screenshot Plus, a Miranda IM plugin. -Copyright (c) 2010 Ing.U.Horn - -Parts of this file based on original sorce code -(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/CSend.cpp $ -Revision : $Revision: 19 $ -Last change on : $Date: 2010-04-09 03:24:04 +0400 (РџС‚, 09 апр 2010) $ -Last change by : $Author: ing.u.horn $ - -*/ - -#include "CSend.h" - -//--------------------------------------------------------------------------- -CSend::CSend(HWND Owner, HANDLE hContact, bool bFreeOnExit) { - m_hWndO = Owner; - m_bFreeOnExit = bFreeOnExit; - m_pszFile = NULL; - m_pszFileDesc = NULL; - m_pszProto = NULL; - m_ChatRoom = NULL; - m_PFflag = NULL; - m_hContact = NULL; - if (hContact) SetContact(hContact); - m_hOnSend = NULL; - m_szEventMsg = NULL; - m_szEventMsgT = NULL; - m_pszSendTyp = NULL; - - m_ErrorMsg = NULL; - m_ErrorTitle = NULL; -} - -CSend::~CSend(){ - mir_free(m_pszFile); - mir_free(m_pszFileDesc); - mir_free(m_szEventMsg); - mir_free(m_szEventMsgT); - mir_free(m_ErrorMsg); - mir_free(m_ErrorTitle); - if (m_hOnSend) UnhookEvent(m_hOnSend); -} - -//--------------------------------------------------------------------------- -void CSend::SetContact(HANDLE hContact) { - m_hContact = hContact; - m_pszProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0); - m_ChatRoom = DBGetContactSettingByte(hContact, m_pszProto, "ChatRoom", 0); - m_PFflag = hasCap(PF1_URLSEND); - m_PFflag = hasCap(PF1_CHAT); - m_PFflag = hasCap(PF1_IMSEND); -} - -//--------------------------------------------------------------------------- -bool CSend::hasCap(unsigned int Flag) { - return (Flag & CallContactService(m_hContact, PS_GETCAPS, (WPARAM)PFLAGNUM_1, NULL)) == Flag; -} - -//--------------------------------------------------------------------------- -void CSend::svcSendMsg(const char* szMessage) { - mir_freeAndNil(m_szEventMsg); - m_cbEventMsg=lstrlenA(szMessage)+1; - m_szEventMsg=(char*)mir_realloc(m_szEventMsg, sizeof(char)*m_cbEventMsg); - ZeroMemory(m_szEventMsg, m_cbEventMsg); - lstrcpyA(m_szEventMsg,szMessage); - if (m_pszFileDesc && m_pszFileDesc[0] != NULL) { - char *temp = mir_t2a(m_pszFileDesc); - mir_stradd(m_szEventMsg, "\r\n"); - mir_stradd(m_szEventMsg, temp); - m_cbEventMsg = lstrlenA(m_szEventMsg)+1; - mir_free(temp); - } - //create a HookEventObj on ME_PROTO_ACK - if (!m_hOnSend) { - int (__cdecl CSend::*hookProc)(WPARAM, LPARAM); - hookProc = &CSend::OnSend; - m_hOnSend = HookEventObj(ME_PROTO_ACK, (MIRANDAHOOKOBJ)*(void **)&hookProc, this); - } - //start PSS_MESSAGE service - m_hSend = (HANDLE)CallContactService(m_hContact, PSS_MESSAGE, NULL, (LPARAM)m_szEventMsg); - // check we actually got an ft handle back from the protocol - if (!m_hSend) { - Unhook(); - Error(SS_ERR_INIT, m_pszSendTyp); - Exit(ACKRESULT_FAILED); - } -} - -void CSend::svcSendUrl(const char* url) { -//szMessage should be encoded as the URL followed by the description, the -//separator being a single nul (\0). If there is no description, do not forget -//to end the URL with two nuls. - mir_freeAndNil(m_szEventMsg) - m_cbEventMsg=lstrlenA(url)+2; - m_szEventMsg=(char*)mir_realloc(m_szEventMsg, m_cbEventMsg); - ZeroMemory(m_szEventMsg, m_cbEventMsg); - lstrcpyA(m_szEventMsg,url); - if (m_pszFileDesc && m_pszFileDesc[0] != NULL) { - char *temp = mir_t2a(m_pszFileDesc); - m_cbEventMsg += lstrlenA(temp); - m_szEventMsg=(char*)mir_realloc(m_szEventMsg, sizeof(char)*m_cbEventMsg); - lstrcpyA(m_szEventMsg+lstrlenA(url)+1,temp); - m_szEventMsg[m_cbEventMsg-1] = 0; - mir_free(temp); - } - //create a HookEventObj on ME_PROTO_ACK - if (!m_hOnSend) { - int (__cdecl CSend::*hookProc)(WPARAM, LPARAM); - hookProc = &CSend::OnSend; - m_hOnSend = HookEventObj(ME_PROTO_ACK, (MIRANDAHOOKOBJ)*(void **)&hookProc, this); - } - //start PSS_URL service - m_hSend = (HANDLE)CallContactService(m_hContact, PSS_URL, NULL, (LPARAM)m_szEventMsg); - // check we actually got an ft handle back from the protocol - if (!m_hSend) { - //SetFtStatus(hwndDlg, LPGENT("Unable to initiate transfer."), FTS_TEXT); - //dat->waitingForAcceptance=0; - Unhook(); - } -} - -void CSend::svcSendChat() { - LPTSTR dirtyFix = NULL; - GC_INFO gci = {0}; - GCDEST gcd = {0}; - GCEVENT gce = {0}; - int res = GC_RESULT_NOSESSION; - int cnt = (int)CallService(MS_GC_GETSESSIONCOUNT, 0, (LPARAM)m_pszProto); - - //loop on all gc session to get the right (save) ptszID for the chatroom from m_hContact - gci.pszModule = m_pszProto; - for (int i = 0; i < cnt ; i++ ) { - gci.iItem = i; - gci.Flags = BYINDEX | HCONTACT | ID; //need dirty fix - CallService(MS_GC_GETINFO, 0, (LPARAM)(GC_INFO *) &gci); - if (gci.hContact == m_hContact) { - gcd.pszModule = m_pszProto; - gcd.iType = GC_EVENT_SENDMESSAGE; //GC_EVENT_MESSAGE ???; -#ifdef _UNICODE - gcd.ptszID = gci.pszID; -#else //dirty fix coz MS_GC_GETINFO dont know if caller is ansi or unicode. - //result from MS_GC_GETINFO only depend on type of chat.dll and not of caller type - if (mir_is_unicode()) { - dirtyFix = mir_u2t((wchar_t*)gci.pszID); - } - else { - dirtyFix = mir_tstrdup(gci.pszID); - } - gcd.ptszID = dirtyFix; //fixed gci.pszID; -#endif - gce.cbSize = sizeof(GCEVENT); - gce.pDest = &gcd; - gce.bIsMe = TRUE; - gce.dwFlags = GC_TCHAR|GCEF_ADDTOLOG; - gce.ptszText = m_szEventMsgT; - gce.time = time(NULL); - - //* returns 0 on success or error code on failure - res = 200 + (int)CallService(MS_GC_EVENT, 0, (LPARAM)(GCEVENT *) &gce); - mir_freeAndNil(dirtyFix); - break; - } - } - Exit(res); -} - -void CSend::svcSendChat(const char* szMessage) { - if (!m_ChatRoom) { - svcSendMsg(szMessage); - return; - } - mir_freeAndNil(m_szEventMsgT); - m_szEventMsgT = mir_a2t(szMessage); - if (m_pszFileDesc) { - mir_tcsadd(m_szEventMsgT, _T("\r\n")); - mir_tcsadd(m_szEventMsgT, m_pszFileDesc); - } - svcSendChat(); -} - -void CSend::svcSendFile() { -//szMessage should be encoded as the File followed by the description, the -//separator being a single nul (\0). If there is no description, do not forget -//to end the File with two nuls. - mir_freeAndNil(m_szEventMsg) - char *szFile = mir_t2a(m_pszFile); - m_cbEventMsg=lstrlenA(szFile)+2; - m_szEventMsg=(char*)mir_realloc(m_szEventMsg, sizeof(char)*m_cbEventMsg); - ZeroMemory(m_szEventMsg, m_cbEventMsg); - lstrcpyA(m_szEventMsg,szFile); - if (m_pszFileDesc && m_pszFileDesc[0] != NULL) { - char* temp = mir_t2a(m_pszFileDesc); - m_cbEventMsg += lstrlenA(temp); - m_szEventMsg=(char*)mir_realloc(m_szEventMsg, sizeof(char)*m_cbEventMsg); - lstrcpyA(m_szEventMsg+lstrlenA(szFile)+1,temp); - m_szEventMsg[m_cbEventMsg-1] = 0; - mir_freeAndNil(temp); - } - mir_freeAndNil(szFile); - - //create a HookEventObj on ME_PROTO_ACK - if (!m_hOnSend) { - int (__cdecl CSend::*hookProc)(WPARAM, LPARAM); - hookProc = &CSend::OnSend; - m_hOnSend = HookEventObj(ME_PROTO_ACK, (MIRANDAHOOKOBJ)*(void **)&hookProc, this); - } - // Start miranda PSS_FILE based on mir ver (T) - if ((CallService(MS_SYSTEM_GETVERSION,0,0) >= 0x090000) && mir_is_unicode()) { - TCHAR *ppFile[2]={0,0}; - TCHAR *pDesc = mir_tstrdup(m_pszFileDesc); - ppFile[0] = mir_tstrdup (m_pszFile); -/* #if defined( _UNICODE ) - TCHAR *ppFile[2]={0,0}; - TCHAR *pDesc = mir_tstrdup(m_pszFileDesc); - ppFile[0] = mir_tstrdup (m_pszFile); - #else - wchar_t *ppFile[2]={0,0}; - wchar_t *pDesc = mir_t2u (m_pszFileDesc); - ppFile[0] = mir_t2u (m_pszFile); - #endif */ - ppFile[1] = NULL; - m_hSend = (HANDLE)CallContactService(m_hContact, PSS_FILET, (WPARAM)pDesc, (LPARAM)ppFile); - mir_free(pDesc); - mir_free(ppFile[0]); - } - else { - char *pDesc = mir_t2a(m_pszFileDesc); - char *ppFile[2]={0}; - ppFile[0] = mir_t2a(m_pszFile); - ppFile[1] = NULL; - m_hSend = (HANDLE)CallContactService(m_hContact, PSS_FILE, (WPARAM)pDesc, (LPARAM)ppFile); - mir_free(pDesc); - mir_free(ppFile[0]); - } - // check we actually got an ft handle back from the protocol - if (!m_hSend) { - Unhook(); - Error(SS_ERR_INIT, m_pszSendTyp); - Exit(ACKRESULT_FAILED); - } -} - -//--------------------------------------------------------------------------- -int __cdecl CSend::OnSend(WPARAM wParam, LPARAM lParam){ - ACKDATA *ack=(ACKDATA*)lParam; - if(ack->hProcess!= m_hSend) return 0; - /* if(dat->waitingForAcceptance) { - SetTimer(hwndDlg,1,1000,NULL); - dat->waitingForAcceptance=0; - } - */ - - switch(ack->result) { - case ACKRESULT_INITIALISING: //SetFtStatus(hwndDlg, LPGENT("Initialising..."), FTS_TEXT); break; - case ACKRESULT_CONNECTING: //SetFtStatus(hwndDlg, LPGENT("Connecting..."), FTS_TEXT); break; - case ACKRESULT_CONNECTPROXY: //SetFtStatus(hwndDlg, LPGENT("Connecting to proxy..."), FTS_TEXT); break; - case ACKRESULT_LISTENING: //SetFtStatus(hwndDlg, LPGENT("Waiting for connection..."), FTS_TEXT); break; - case ACKRESULT_CONNECTED: //SetFtStatus(hwndDlg, LPGENT("Connected"), FTS_TEXT); break; - case ACKRESULT_SENTREQUEST: //SetFtStatus(hwndDlg, LPGENT("Decision sent"), FTS_TEXT); break; - case ACKRESULT_NEXTFILE: //SetFtStatus(hwndDlg, LPGENT("Moving to next file..."), FTS_TEXT); - case ACKRESULT_FILERESUME: // - case ACKRESULT_DATA: //transfer is on progress - break; - case ACKRESULT_DENIED: - Unhook(); - Exit(ack->result); - break; - case ACKRESULT_FAILED: - Unhook(); - Exit(ack->result); - //type=ACKTYPE_MESSAGE, result=success/failure, (char*)lParam=error message or NULL. - //type=ACKTYPE_URL, result=success/failure, (char*)lParam=error message or NULL. - //type=ACKTYPE_FILE, result=ACKRESULT_FAILED then lParam=(LPARAM)(const char*)szReason - break; - case ACKRESULT_SUCCESS: - Unhook(); - switch(ack->type) { - case ACKTYPE_CHAT: - break; - case ACKTYPE_MESSAGE: - DB_EventAdd((WORD)EVENTTYPE_MESSAGE); - break; - case ACKTYPE_URL: - DB_EventAdd((WORD)EVENTTYPE_URL); - break; - case ACKTYPE_FILE: - //MS_DB_EVENT_ADD need 4byte extra at the beginning of m_szEventMsg for ACKTYPE_FILE - m_szEventMsg = (char*) mir_realloc(m_szEventMsg, sizeof(DWORD) + m_cbEventMsg); - //memmove_s(m_szEventMsg+sizeof(DWORD), m_cbEventMsg, m_szEventMsg, m_cbEventMsg); - memmove(m_szEventMsg+sizeof(DWORD), m_szEventMsg, m_cbEventMsg); - m_cbEventMsg += sizeof(DWORD); - DB_EventAdd((WORD)EVENTTYPE_FILE); - break; - default: - break; - } - Exit(ack->result); - break; - default: - return 0; - break; - } - return 0; -} - -void CSend::DB_EventAdd(WORD EventType) { - DBEVENTINFO dbei={0}; - dbei.cbSize = sizeof(dbei); - dbei.szModule = m_pszProto; - dbei.eventType = EventType; - dbei.flags = DBEF_SENT; - dbei.timestamp = time(NULL); - #if defined( _UNICODE ) - dbei.flags |= DBEF_UTF; - #endif - dbei.cbBlob= m_cbEventMsg; - dbei.pBlob=(PBYTE)m_szEventMsg; - - CallService(MS_DB_EVENT_ADD,(WPARAM)m_hContact,(LPARAM)&dbei); -} - -//--------------------------------------------------------------------------- -void CSend::AfterSendDelete() { - if (m_pszFile && m_bDeleteAfterSend && (m_EnableItem & SS_DLG_DELETEAFTERSSEND) == SS_DLG_DELETEAFTERSSEND) { - DeleteFile(m_pszFile); - } -} - -//--------------------------------------------------------------------------- -void CSend::Exit(unsigned int Result) { - bool err = true; - if (m_hWndO && IsWindow(m_hWndO)){ - ; - } - switch(Result) { - case ACKRESULT_SUCCESS: - case GC_RESULT_SUCCESS: - SkinPlaySound("FileDone"); - err = false; - break; - case ACKRESULT_DENIED: - SkinPlaySound("FileDenied"); - Error(_T("%s (%i):\nFile transfer denied."),TranslateTS(m_pszSendTyp),Result); - MsgBoxService(NULL, (LPARAM)&m_box); - err = false; - break; - case GC_RESULT_WRONGVER: //.You appear to be using the wrong version of GC API. - Error(_T("%s (%i):\nYou appear to be using the wrong version of GC API"),TranslateT("GCHAT error"),Result); - break; - case GC_RESULT_ERROR: // An internal GC error occurred. - Error(_T("%s (%i):\nAn internal GC error occurred."),TranslateT("GCHAT error"),Result); - break; - case GC_RESULT_NOSESSION: // contact has no open GC session - Error(_T("%s (%i):\nContact has no open GC session."),TranslateT("GCHAT error"),Result); - break; - case ACKRESULT_FAILED: - default: - break; - } - if (err){ - SkinPlaySound("FileFailed"); - if(m_ErrorMsg && m_ErrorMsg[0] != 0) MsgBoxService(NULL, (LPARAM)&m_box); - else MsgErr(NULL, LPGENT("An unknown error has occured.")); - } - - AfterSendDelete(); - if(m_bFreeOnExit) delete this; -} - -void CSend::Error(LPCTSTR pszFormat, ...) { - if(!pszFormat) return; - - TCHAR tszTemp[MAX_SECONDLINE]; - va_list vl; - - mir_sntprintf(tszTemp, SIZEOF(tszTemp),_T("%s - %s") ,_T(MODNAME), TranslateT("Error")); - mir_freeAndNil(m_ErrorTitle); - m_ErrorTitle = mir_tstrdup(tszTemp); - - va_start(vl, pszFormat); - mir_vsntprintf(tszTemp, SIZEOF(tszTemp), TranslateTS(pszFormat), vl); - va_end(vl); - mir_freeAndNil(m_ErrorMsg); - m_ErrorMsg = mir_tstrdup(tszTemp); - - ZeroMemory(&m_box, sizeof(m_box)); - m_box.cbSize = sizeof(MSGBOX); - m_box.hParent = NULL; - m_box.hiLogo = IcoLib_GetIcon(ICO_PLUG_SSWINDOW1); - m_box.hiMsg = NULL; - m_box.ptszTitle = m_ErrorTitle; - m_box.ptszMsg = m_ErrorMsg; - m_box.uType = MB_OK|MB_ICON_ERROR; -} - diff --git a/plugins/SendScreenshotPlus/CSend.h b/plugins/SendScreenshotPlus/CSend.h deleted file mode 100644 index 082f3e961a..0000000000 --- a/plugins/SendScreenshotPlus/CSend.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2009 Miranda ICQ/IM project, - -This file is part of Send Screenshot Plus, a Miranda IM plugin. -Copyright (c) 2010 Ing.U.Horn - -Parts of this file based on original sorce code -(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/CSend.h $ -Revision : $Revision: 17 $ -Last change on : $Date: 2010-04-03 18:01:11 +0400 (РЎР±, 03 апр 2010) $ -Last change by : $Author: ing.u.horn $ - -*/ - -#ifndef _CSEND_H -#define _CSEND_H - -//--------------------------------------------------------------------------- -#include "global.h" -#include "Utils.h" -#include "dlg_msgbox.h" - - -//--------------------------------------------------------------------------- -#define SS_AUTOSEND 1 -#define SS_DELETEAFTERSSEND 2 - -#define SS_DLG_AUTOSEND 1 //Button_Enable(GetDlgItem(Owner, ID_chkEmulateClick), TRUE); -#define SS_DLG_DELETEAFTERSSEND 2 //Button_Enable(GetDlgItem(Owner, ID_btnDeleteAfterSend), TRUE); -#define SS_DLG_DESCRIPTION 4 //Button_Enable(GetDlgItem(Owner, ID_btnDesc), TRUE); - -#define GC_RESULT_SUCCESS 200 -#define GC_RESULT_WRONGVER 201 -#define GC_RESULT_ERROR 202 -#define GC_RESULT_NOSESSION 209 - -#define SS_ERR_INIT _T("Unable to initiate %s.") -#define SS_ERR_MAPI _T("MAPI error (%i):\n%s.") - -//--------------------------------------------------------------------------- -class CSend { - public: - CSend(HWND Owner, HANDLE hContact, bool bFreeOnExit); // oder (TfrmMain & Owner) - virtual ~CSend(); - - virtual void Send() = 0; - void SendSync(bool Sync) {m_SendSync = Sync;}; - bool m_bFreeOnExit; // need to "delete object;" on exit ? - void SetContact(HANDLE hContact); - BYTE GetEnableItem() {return m_EnableItem;}; - LPTSTR GetErrorMsg() {return m_ErrorMsg;}; - - LPTSTR m_pszFile; - LPTSTR m_pszFileDesc; - - BOOL m_bDeleteAfterSend; - - private: - - protected: - LPTSTR m_pszSendTyp; //hold string for error mess - HWND m_hWndO; //window handle of caller - HANDLE m_hContact; //Contact handle - char* m_pszProto; //Contact Proto Modul - BYTE m_EnableItem; //hold flag for send type - void AfterSendDelete(); - BYTE m_ChatRoom; //is Contact chatroom - bool m_SendSync; //send sync / async - - bool hasCap(unsigned int Flag); - unsigned int m_PFflag; - - void svcSendFile(); - void svcSendUrl (const char* url); - void svcSendMsg (const char* szMessage); - void svcSendChat(); //main GC service - void svcSendChat(const char* szMessage); //GC ansi wrapper - - DWORD m_cbEventMsg; //sizeof EventMsg(T) buffer - char* m_szEventMsg; //EventMsg char* - LPTSTR m_szEventMsgT; //EventMsg TCHAR* - HANDLE m_hSend; //protocol send handle - HANDLE m_hOnSend; //HookEventObj on ME_PROTO_ACK - int __cdecl OnSend(WPARAM wParam, LPARAM lParam); - void Unhook(){if(m_hOnSend) {UnhookEvent(m_hOnSend);m_hOnSend = NULL;}} - void DB_EventAdd(WORD EventType); - void Exit(unsigned int Result); - - MSGBOX m_box; - LPTSTR m_ErrorMsg; - LPTSTR m_ErrorTitle; - void Error(LPCTSTR pszFormat, ...); -}; - -#endif diff --git a/plugins/SendScreenshotPlus/CSendEmail.cpp b/plugins/SendScreenshotPlus/CSendEmail.cpp deleted file mode 100644 index 14e539ea0d..0000000000 --- a/plugins/SendScreenshotPlus/CSendEmail.cpp +++ /dev/null @@ -1,221 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2009 Miranda ICQ/IM project, - -This file is part of Send Screenshot Plus, a Miranda IM plugin. -Copyright (c) 2010 Ing.U.Horn - -Parts of this file based on original sorce code -(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/CSendEmail.cpp $ -Revision : $Revision: 13 $ -Last change on : $Date: 2010-04-02 02:54:30 +0400 (РџС‚, 02 апр 2010) $ -Last change by : $Author: ing.u.horn $ - -*/ - -//--------------------------------------------------------------------------- -#include "CSendEmail.h" - -//--------------------------------------------------------------------------- -CSendEmail::CSendEmail(HWND Owner, HANDLE hContact, bool bFreeOnExit) -: CSend(Owner, hContact, bFreeOnExit){ - m_EnableItem = SS_DLG_DELETEAFTERSSEND | SS_DLG_DESCRIPTION; // SS_DLG_AUTOSEND | ; - m_pszSendTyp = _T("Email transfer"); - m_pszFileA = NULL; - m_pszFileName = NULL; - m_Email = NULL; - m_FriendlyName = NULL; - m_Subject = NULL; -} - -CSendEmail::~CSendEmail(){ - mir_free(m_pszFileA); - mir_free(m_pszFileName); - mir_free(m_Email); - mir_free(m_FriendlyName); - mir_free(m_Subject); -} - -//--------------------------------------------------------------------------- -void CSendEmail::Send() { - - mir_freeAndNil(m_pszFileName); - m_pszFileName = (LPSTR)GetFileName(m_pszFile, DBVT_ASCIIZ); - - mir_freeAndNil(m_pszFileA); - m_pszFileA = mir_t2a(m_pszFile); - - -// AnsiString Email, Subject, FriendlyName; - CONTACTINFO ci={0}; - ci.cbSize = sizeof(ci); - ci.hContact = m_hContact; - ci.szProto = m_pszProto; - //ci.dwFlag = CNF_TCHAR; - - ci.dwFlag = CNF_EMAIL | CNF_TCHAR; - CallService(MS_CONTACT_GETCONTACTINFO,(WPARAM)0,(LPARAM)&ci); - m_Email = mir_t2a(ci.pszVal); - - ci.dwFlag = CNF_DISPLAY | CNF_TCHAR; - CallService(MS_CONTACT_GETCONTACTINFO,(WPARAM)0,(LPARAM)&ci); - m_FriendlyName = mir_t2a(ci.pszVal); - - mir_free(ci.pszVal); - - m_Subject = mir_t2a(m_pszFileDesc); - - //SendByEmail(m_pszFileA, "", m_FriendlyName, m_Email, m_Subject); - - //start Send thread - m_bFreeOnExit = TRUE; - mir_forkthread(&CSendEmail::SendThreadWrapper, this); -} - -void CSendEmail::SendThread() { - //This code based on SentTo.exe application. - //The default mail client for Simple MAPI or MAPI calls is defined by the - //HKLM\Software\Clients\Mail::(default) registry value. - - LPTSTR err = NULL; - MapiFileDesc arrfileDesc[1]; - - typedef ULONG (FAR PASCAL *MAPIFUNC)(LHANDLE,ULONG,lpMapiMessage,FLAGS,ULONG); - MapiMessage Msg; - MAPIFUNC lpMAPISendMail; - - HINSTANCE hMAPILib = ::LoadLibrary(_T("MAPI32.DLL")); - if (hMAPILib == NULL) { - //return -1; - Error(SS_ERR_INIT, m_pszSendTyp); - Exit(ACKRESULT_FAILED); - } - - lpMAPISendMail = (MAPIFUNC)GetProcAddress(hMAPILib, "MAPISendMail"); - if (lpMAPISendMail == NULL) { - ::FreeLibrary(hMAPILib); - //return -2; - Error(SS_ERR_INIT, m_pszSendTyp); - Exit(ACKRESULT_FAILED); - } - - memset(&Msg, 0, sizeof(Msg)); - - arrfileDesc[0].ulReserved = 0; - arrfileDesc[0].flFlags = 0; - arrfileDesc[0].lpFileType = NULL; - arrfileDesc[0].nPosition = -1; - arrfileDesc[0].lpszPathName = m_pszFileA; - arrfileDesc[0].lpszFileName = NULL; - - Msg.nFileCount = 1; - Msg.lpFiles = arrfileDesc; - Msg.lpszNoteText = ""; //body - Msg.lpszSubject = m_Subject; //subject - - Msg.nRecipCount = 1; - MapiRecipDesc recip; - recip.ulReserved = 0; - recip.ulRecipClass = MAPI_TO; - - if (m_FriendlyName && m_FriendlyName[0]!= NULL) { - recip.lpszName = m_FriendlyName; //friendly name set to contact's name - } - else { - recip.lpszName = m_Email; //friendly name set to contact's email - } - - recip.lpszAddress = m_Email; //email - recip.ulEIDSize = 0; - recip.lpEntryID = NULL; - Msg.lpRecips = &recip; - - try { - int res = lpMAPISendMail(NULL, NULL, &Msg, MAPI_LOGON_UI|MAPI_DIALOG, 0); - ::FreeLibrary(hMAPILib); - - switch (res) { - case SUCCESS_SUCCESS: - //The call succeeded and the message was sent. - Exit(ACKRESULT_SUCCESS); - return; - - // No message was sent - case MAPI_E_AMBIGUOUS_RECIPIENT: - err = _T("A recipient matched more than one of the recipient descriptor structures and MAPI_DIALOG was not set"); - break; - case MAPI_E_ATTACHMENT_NOT_FOUND: - err = _T("The specified attachment was not found"); - break; - case MAPI_E_ATTACHMENT_OPEN_FAILURE: - err = _T("The specified attachment could not be opened"); - break; - case MAPI_E_BAD_RECIPTYPE: - err = _T("The type of a recipient was not MAPI_TO, MAPI_CC, or MAPI_BCC"); - break; - case MAPI_E_FAILURE: - err = _T("One or more unspecified errors occurred"); - break; - case MAPI_E_INSUFFICIENT_MEMORY: - err = _T("There was insufficient memory to proceed"); - break; - case MAPI_E_INVALID_RECIPS: - err = _T("One or more recipients were invalid or did not resolve to any address"); - break; - case MAPI_E_LOGIN_FAILURE: - err = _T("There was no default logon, and the user failed to log on successfully when the logon dialog box was displayed"); - break; - case MAPI_E_TEXT_TOO_LARGE: - err = _T("The text in the message was too large"); - break; - case MAPI_E_TOO_MANY_FILES: - err = _T("There were too many file attachments"); - break; - case MAPI_E_TOO_MANY_RECIPIENTS: - err = _T("There were too many recipients"); - break; - case MAPI_E_UNKNOWN_RECIPIENT: - err = _T("A recipient did not appear in the address list"); - break; - case MAPI_E_USER_ABORT: - err = _T("The user canceled one of the dialog boxes"); - break; - default: - err = _T("Unknown Error"); - break; - } - Error(SS_ERR_MAPI, res, err); - Exit(ACKRESULT_FAILED); - - } catch (...) { - ::FreeLibrary(hMAPILib); - Error(SS_ERR_INIT, m_pszSendTyp); - Exit(ACKRESULT_FAILED); - //return -3; - return; - } -} - -void CSendEmail::SendThreadWrapper(void * Obj) { - reinterpret_cast(Obj)->SendThread(); -} - -//--------------------------------------------------------------------------- - diff --git a/plugins/SendScreenshotPlus/CSendEmail.h b/plugins/SendScreenshotPlus/CSendEmail.h deleted file mode 100644 index 940558b0d6..0000000000 --- a/plugins/SendScreenshotPlus/CSendEmail.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2009 Miranda ICQ/IM project, - -This file is part of Send Screenshot Plus, a Miranda IM plugin. -Copyright (c) 2010 Ing.U.Horn - -Parts of this file based on original sorce code -(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/CSendEmail.h $ -Revision : $Revision: 13 $ -Last change on : $Date: 2010-04-02 02:54:30 +0400 (РџС‚, 02 апр 2010) $ -Last change by : $Author: ing.u.horn $ - -*/ - -#ifndef _CSEND_EMAIL_H -#define _CSEND_EMAIL_H - -//--------------------------------------------------------------------------- -#include "global.h" -#include "CSend.h" -#include - -//--------------------------------------------------------------------------- -class CSendEmail : public CSend { - public: - // Deklaration Standardkonstruktor/Standarddestructor - CSendEmail(HWND Owner, HANDLE hContact, bool bFreeOnExit); - ~CSendEmail(); - - void Send(); - - protected: - LPSTR m_pszFileA; - LPSTR m_pszFileName; - LPSTR m_Email; - LPSTR m_FriendlyName; - LPSTR m_Subject; - void SendThread(); - static void SendThreadWrapper(void * Obj); - -}; - -//--------------------------------------------------------------------------- - -#endif diff --git a/plugins/SendScreenshotPlus/CSendFTPFile.cpp b/plugins/SendScreenshotPlus/CSendFTPFile.cpp deleted file mode 100644 index d7512d2fe6..0000000000 --- a/plugins/SendScreenshotPlus/CSendFTPFile.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2009 Miranda ICQ/IM project, - -This file is part of Send Screenshot Plus, a Miranda IM plugin. -Copyright (c) 2010 Ing.U.Horn - -Parts of this file based on original sorce code -(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/CSendFTPFile.cpp $ -Revision : $Revision: 13 $ -Last change on : $Date: 2010-04-02 02:54:30 +0400 (РџС‚, 02 апр 2010) $ -Last change by : $Author: ing.u.horn $ - -*/ - -//--------------------------------------------------------------------------- -#include "CSendFTPFile.h" - - -//--------------------------------------------------------------------------- -CSendFTPFile::CSendFTPFile(HWND Owner, HANDLE hContact, bool bFreeOnExit) -: CSend(Owner, hContact, bFreeOnExit){ - m_EnableItem = NULL ; //SS_DLG_DESCRIPTION| SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND; - m_pszSendTyp = _T("FTPFile transfer"); - m_pszFileName = NULL; - m_URL = NULL; -} - -CSendFTPFile::~CSendFTPFile(){ - mir_free(m_pszFileName); - mir_free(m_URL); -} - -//--------------------------------------------------------------------------- -void CSendFTPFile::Send() { - - /********************************************************************************************* - * Send file (files) to the FTP server and copy file URL - * to message log or clipboard (according to plugin setting) - * wParam = (HANDLE)hContact - * lParam = (char *)filename - * Filename format is same as GetOpenFileName (OPENFILENAME.lpstrFile) returns, - * see http://msdn2.microsoft.com/en-us/library/ms646839.aspx - * Returns 0 on success or nonzero on failure - * if (!wParam || !lParam) return 1 - ********************************************************************************************/ - mir_freeAndNil(m_pszFileName); - m_pszFileName = (LPSTR)GetFileName(m_pszFile, DBVT_ASCIIZ); - size_t size = sizeof(char)*(strlen(m_pszFileName)+2); - m_pszFileName = (LPSTR) mir_realloc(m_pszFileName, size); - m_pszFileName[size-1] = NULL; - - //start Send thread - m_bFreeOnExit = TRUE; - mir_forkthread(&CSendFTPFile::SendThreadWrapper, this); -} - -void CSendFTPFile::SendThread() { - int ret; - mir_freeAndNil(m_URL); - - ret = (int)CallService(MS_FTPFILE_SHAREFILE, (WPARAM)m_hContact, (LPARAM)m_pszFileName); - if (ret != 0) { - Error(_T("%s (%i):\nCould not add a share to the FTP File plugin."),TranslateTS(m_pszSendTyp),ret); - Exit(ret); - } - - //Can't delete the file since FTP File plugin will use it - m_bDeleteAfterSend = false; - - if (m_URL && m_URL[0]!= NULL) { - m_ChatRoom ? svcSendChat(m_URL) : svcSendMsg(m_URL); - return; - } -} - -void CSendFTPFile::SendThreadWrapper(void * Obj) { - reinterpret_cast(Obj)->SendThread(); -} - -//--------------------------------------------------------------------------- - diff --git a/plugins/SendScreenshotPlus/CSendFTPFile.h b/plugins/SendScreenshotPlus/CSendFTPFile.h deleted file mode 100644 index 6012f76232..0000000000 --- a/plugins/SendScreenshotPlus/CSendFTPFile.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2009 Miranda ICQ/IM project, - -This file is part of Send Screenshot Plus, a Miranda IM plugin. -Copyright (c) 2010 Ing.U.Horn - -Parts of this file based on original sorce code -(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/CSendFTPFile.h $ -Revision : $Revision: 13 $ -Last change on : $Date: 2010-04-02 02:54:30 +0400 (РџС‚, 02 апр 2010) $ -Last change by : $Author: ing.u.horn $ - -*/ - -#ifndef _CSEND_FTP_FILE_H -#define _CSEND_FTP_FILE_H - -//--------------------------------------------------------------------------- -#include "global.h" -#include "CSend.h" - -//--------------------------------------------------------------------------- -class CSendFTPFile : public CSend { - public: - // Deklaration Standardkonstruktor/Standarddestructor - CSendFTPFile(HWND Owner, HANDLE hContact, bool bFreeOnExit); - ~CSendFTPFile(); - - void Send(); - - protected: - LPSTR m_pszFileName; - LPSTR m_URL; - void SendThread(); - static void SendThreadWrapper(void * Obj); - -}; - -//--------------------------------------------------------------------------- - -#endif diff --git a/plugins/SendScreenshotPlus/CSendFile.cpp b/plugins/SendScreenshotPlus/CSendFile.cpp deleted file mode 100644 index 1884c8307f..0000000000 --- a/plugins/SendScreenshotPlus/CSendFile.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2009 Miranda ICQ/IM project, - -This file is part of Send Screenshot Plus, a Miranda IM plugin. -Copyright (c) 2010 Ing.U.Horn - -Parts of this file based on original sorce code -(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/CSendFile.cpp $ -Revision : $Revision: 13 $ -Last change on : $Date: 2010-04-02 02:54:30 +0400 (РџС‚, 02 апр 2010) $ -Last change by : $Author: ing.u.horn $ - -*/ - -//--------------------------------------------------------------------------- -#include "CSendFile.h" - -//--------------------------------------------------------------------------- -CSendFile::CSendFile(HWND Owner, HANDLE hContact, bool bFreeOnExit) -: CSend(Owner, hContact, bFreeOnExit){ - m_EnableItem = SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND | SS_DLG_DESCRIPTION; - m_pszSendTyp = _T("File transfer"); -} - -CSendFile::~CSendFile(){ - ; -} - -//--------------------------------------------------------------------------- -void CSendFile::Send() { - m_bFreeOnExit = TRUE; - svcSendFile(); -} - -//--------------------------------------------------------------------------- diff --git a/plugins/SendScreenshotPlus/CSendFile.h b/plugins/SendScreenshotPlus/CSendFile.h deleted file mode 100644 index edbb49822d..0000000000 --- a/plugins/SendScreenshotPlus/CSendFile.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2009 Miranda ICQ/IM project, - -This file is part of Send Screenshot Plus, a Miranda IM plugin. -Copyright (c) 2010 Ing.U.Horn - -Parts of this file based on original sorce code -(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/CSendFile.h $ -Revision : $Revision: 13 $ -Last change on : $Date: 2010-04-02 02:54:30 +0400 (РџС‚, 02 апр 2010) $ -Last change by : $Author: ing.u.horn $ - -*/ - -#ifndef _CSEND_FILE_H -#define _CSEND_FILE_H - -//--------------------------------------------------------------------------- -#include "global.h" -#include "CSend.h" - -//--------------------------------------------------------------------------- -class CSendFile : public CSend { - public: - // Deklaration Standardkonstruktor/Standarddestructor - CSendFile(HWND Owner, HANDLE hContact, bool bFreeOnExit); - ~CSendFile(); - - void Send(); - - protected: - -}; - -//---------------------------------------------------------------------------*/ - -#endif diff --git a/plugins/SendScreenshotPlus/CSendHTTPServer.cpp b/plugins/SendScreenshotPlus/CSendHTTPServer.cpp deleted file mode 100644 index 788ebca4d1..0000000000 --- a/plugins/SendScreenshotPlus/CSendHTTPServer.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2009 Miranda ICQ/IM project, - -This file is part of Send Screenshot Plus, a Miranda IM plugin. -Copyright (c) 2010 Ing.U.Horn - -Parts of this file based on original sorce code -(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/CSendHTTPServer.cpp $ -Revision : $Revision: 13 $ -Last change on : $Date: 2010-04-02 02:54:30 +0400 (РџС‚, 02 апр 2010) $ -Last change by : $Author: ing.u.horn $ - -*/ - -//--------------------------------------------------------------------------- -#include "CSendHTTPServer.h" -INT_PTR (*g_MirCallService)(const char *, WPARAM, LPARAM)=NULL; -//INT_PTR (*CallService)(const char *,WPARAM,LPARAM); - - -//--------------------------------------------------------------------------- -CSendHTTPServer::CSendHTTPServer(HWND Owner, HANDLE hContact, bool bFreeOnExit) -: CSend(Owner, hContact, bFreeOnExit){ - m_EnableItem = SS_DLG_DESCRIPTION ; //| SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND; - m_pszSendTyp = _T("HTTPServer transfer"); - m_pszFileName = NULL; - m_URL = NULL; - m_fsi_pszSrvPath = NULL; - m_fsi_pszRealPath = NULL; -} - -CSendHTTPServer::~CSendHTTPServer(){ - mir_free(m_pszFileName); - mir_free(m_URL); - mir_free(m_fsi_pszSrvPath); - mir_free(m_fsi_pszRealPath); -} - -//--------------------------------------------------------------------------- -void CSendHTTPServer::Send() { - - if (CallService(MS_HTTP_ACCEPT_CONNECTIONS, (WPARAM)true, (LPARAM)0) != 0) { - Error(NULL, _T("Could not start the HTTP Server plugin.")); - return; - } - - if (!m_pszFileName) { - m_pszFileName = (LPSTR)GetFileName(m_pszFile, DBVT_ASCIIZ); - } - mir_freeAndNil(m_fsi_pszSrvPath); - mir_stradd(m_fsi_pszSrvPath, "/"); - mir_stradd(m_fsi_pszSrvPath, m_pszFileName); - - mir_freeAndNil(m_fsi_pszRealPath); - m_fsi_pszRealPath = mir_t2a(m_pszFile); - - ZeroMemory(&m_fsi, sizeof(m_fsi)); - m_fsi.lStructSize = sizeof(STFileShareInfo); - m_fsi.pszSrvPath = m_fsi_pszSrvPath; - m_fsi.nMaxDownloads = -1; // -1 = infinite - m_fsi.pszRealPath = m_fsi_pszRealPath; - //m_fsi.dwOptions = NULL; //OPT_SEND_LINK only work on single chat; - - //start Send thread - m_bFreeOnExit = TRUE; - mir_forkthread(&CSendHTTPServer::SendThreadWrapper, this); -} - -void CSendHTTPServer::SendThread() { - int ret; - mir_freeAndNil(m_URL); - - if (ServiceExists(MS_HTTP_GET_LINK)) { - //patched plugin version - ret = (int)CallService(MS_HTTP_ADD_CHANGE_REMOVE, (WPARAM)m_hContact, (LPARAM)&m_fsi); - if (!ret) { - m_URL = (LPSTR)CallService(MS_HTTP_GET_LINK, (WPARAM)m_fsi.pszSrvPath, NULL); - } - } - else { - //original plugin - m_fsi.dwOptions = OPT_SEND_LINK; - - //send DATA and wait for reply - ret = (int)CallService(MS_HTTP_ADD_CHANGE_REMOVE, (WPARAM)m_hContact, (LPARAM)&m_fsi); - } - - if (ret != 0) { - Error(_T("%s (%i):\nCould not add a share to the HTTP Server plugin."),TranslateTS(m_pszSendTyp),ret); - Exit(ret); - } - - //Share the file by HTTP Server plugin, SendSS does not own the file anymore = auto-delete won't work - m_bDeleteAfterSend = false; - - if (m_URL && m_URL[0]!= NULL) { - m_ChatRoom ? svcSendChat(m_URL) : svcSendMsg(m_URL); - return; - } - Exit(ACKRESULT_FAILED); -} - -void CSendHTTPServer::SendThreadWrapper(void * Obj) { - reinterpret_cast(Obj)->SendThread(); -} - -//--------------------------------------------------------------------------- -CSendHTTPServer::CContactMapping CSendHTTPServer::_CContactMapping; - -INT_PTR CSendHTTPServer::MyCallService(const char *name, WPARAM wParam, LPARAM lParam) { - CContactMapping::iterator Contact(_CContactMapping.end()); -/* - if ( wParam == m_hContact && ( - (strcmp(name, MS_MSG_SENDMESSAGE)== 0) || - (strcmp(name, "SRMsg/LaunchMessageWindow")== 0) )) - { - m_URL= mir_strdup((char*)lParam); - return 0; - }*/ - return g_MirCallService(name, wParam, lParam); -} - diff --git a/plugins/SendScreenshotPlus/CSendHTTPServer.h b/plugins/SendScreenshotPlus/CSendHTTPServer.h deleted file mode 100644 index 129153e0c6..0000000000 --- a/plugins/SendScreenshotPlus/CSendHTTPServer.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2009 Miranda ICQ/IM project, - -This file is part of Send Screenshot Plus, a Miranda IM plugin. -Copyright (c) 2010 Ing.U.Horn - -Parts of this file based on original sorce code -(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/CSendHTTPServer.h $ -Revision : $Revision: 13 $ -Last change on : $Date: 2010-04-02 02:54:30 +0400 (РџС‚, 02 апр 2010) $ -Last change by : $Author: ing.u.horn $ - -*/ - -#ifndef _CSEND_HTTP_SERVER_H -#define _CSEND_HTTP_SERVER_H - -//--------------------------------------------------------------------------- -#include "global.h" -#include "CSend.h" - -//--------------------------------------------------------------------------- -class CSendHTTPServer : public CSend { - public: - // Deklaration Standardkonstruktor/Standarddestructor - CSendHTTPServer(HWND Owner, HANDLE hContact, bool bFreeOnExit); - ~CSendHTTPServer(); - - void Send(); - - protected: - LPSTR m_pszFileName; - LPSTR m_URL; - STFileShareInfo m_fsi; - LPSTR m_fsi_pszSrvPath; - LPSTR m_fsi_pszRealPath; - void SendThread(); - static void SendThreadWrapper(void * Obj); - - typedef std::map CContactMapping; - static CContactMapping _CContactMapping; - - static INT_PTR MyCallService(const char *name, WPARAM wParam, LPARAM lParam); - -}; - -//--------------------------------------------------------------------------- - -#endif diff --git a/plugins/SendScreenshotPlus/CSendImageShack.cpp b/plugins/SendScreenshotPlus/CSendImageShack.cpp deleted file mode 100644 index a27b4f5273..0000000000 --- a/plugins/SendScreenshotPlus/CSendImageShack.cpp +++ /dev/null @@ -1,299 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2009 Miranda ICQ/IM project, - -This file is part of Send Screenshot Plus, a Miranda IM plugin. -Copyright (c) 2010 Ing.U.Horn - -Parts of this file based on original sorce code -(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/CSendImageShack.cpp $ -Revision : $Revision: 13 $ -Last change on : $Date: 2010-04-02 02:54:30 +0400 (РџС‚, 02 апр 2010) $ -Last change by : $Author: ing.u.horn $ - -*/ - -//--------------------------------------------------------------------------- -#include -#include -#include - -#include "CSendImageShack.h" -#include "DevKey.h" - -//--------------------------------------------------------------------------- -CSendImageShack::CSendImageShack(HWND Owner, HANDLE hContact, bool bFreeOnExit) -: CSend(Owner, hContact, bFreeOnExit) { - m_EnableItem = SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND | SS_DLG_DESCRIPTION; - m_pszSendTyp = _T("Image upload"); - m_pszFileName = NULL; - m_pszContentType = NULL; - m_MFDRboundary = NULL; - m_nlreply = NULL; - m_SendSync = false; - m_Url = NULL; -} - -CSendImageShack::~CSendImageShack(){ - mir_free(m_pszFileName); - mir_free(m_MFDRboundary); - // FREEHTTPREQUESTSTRUCT* - if (m_nlreply) CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM) m_nlreply); - mir_free(m_Url); -}; - -//--------------------------------------------------------------------------- -void CSendImageShack::Send() { - // check Netlib - if( !hNetlibUser ) { - //PrintError(1,TRUE); - return; - } - if (!m_pszFileName) { - m_pszFileName = (LPSTR)GetFileName(m_pszFile, DBVT_ASCIIZ); - } - if (!m_pszContentType) GetContentType(); - - // create new boundary - MFDR_Reset(); - - // initialize the netlib request - ZeroMemory(&m_nlhr, sizeof(m_nlhr)); - m_nlhr.cbSize = sizeof(m_nlhr); - m_nlhr.requestType = REQUEST_POST; - m_nlhr.flags = NLHRF_HTTP11; //NLHRF_DUMPASTEXT; - m_nlhr.szUrl = "http://www.imageshack.us/upload_api.php"; - m_nlhr.headersCount = 6; - { //NETLIBHTTPHEADER start - m_nlhr.headers=(NETLIBHTTPHEADER*)mir_alloc(sizeof(NETLIBHTTPHEADER)*m_nlhr.headersCount); - m_nlhr.headers[0].szName = "Referer"; - m_nlhr.headers[0].szValue = "http://www.imageshack.us/upload_api.php"; - m_nlhr.headers[1].szName = "Connection"; - m_nlhr.headers[1].szValue = "Keep-alive"; - m_nlhr.headers[2].szName = "AcceptLanguage"; - m_nlhr.headers[2].szValue = "en-us, pt-br"; - m_nlhr.headers[3].szName = "Host"; - m_nlhr.headers[3].szValue = "imageshack.us"; - m_nlhr.headers[4].szName = "User-Agent"; - m_nlhr.headers[4].szValue = __USER_AGENT_STRING; //szAgent; /; - //nlhr.headers[x].szName = "Authorization"; - //nlhr.headers[x].szValue = auth; //Basic base-64-authorization - - //$header .= "Content-type: multipart/form-data; boundary=" . part::getBoundary() . "\r\n"; - sprintf(m_nlheader_ContentType, "multipart/form-data; boundary=%s", m_MFDRboundary); - m_nlhr.headers[m_nlhr.headersCount-1].szName = "Content-Type"; - m_nlhr.headers[m_nlhr.headersCount-1].szValue = m_nlheader_ContentType; - } //NETLIBHTTPHEADER end - -//POST DATA file-header, init DATA with MultipartFormDataRequest - //$params[] = new filepart('fileupload', $file, basename($file), $contentType, 'iso-8859-1'); - //($this->sendStart($h);) - AppendToData("--"); - AppendToData(m_MFDRboundary); - AppendToData("\r\n"); - //($this->sendDispositionHeader($h);) - AppendToData("Content-Disposition: form-data; name=\""); - AppendToData("fileupload"); - AppendToData("\"; filename=\""); - AppendToData(m_pszFileName); - AppendToData("\""); - AppendToData("\r\n"); - //($this->sendContentTypeHeader($h);) - AppendToData("Content-Type: "); - AppendToData(m_pszContentType); - AppendToData("; charset="); - AppendToData("iso-8859-1"); - //($this->sendEndOfHeader($h);) - AppendToData("\r\n"); - AppendToData("\r\n"); - //Now we add the file binary ($this->sendData($h)) - FILE * fileId = _tfsopen(m_pszFile, _T("rb"), _SH_DENYWR ); - if( !fileId) { - //PrintError(1,TRUE); - return; - } - fseek(fileId, NULL, SEEK_END); - size_t lenFile = ftell(fileId); - size_t sizeDest = sizeof(char)*(m_nlhr.dataLength + lenFile + 1); - m_nlhr.pData = (char *) mir_realloc(m_nlhr.pData, sizeDest); - fseek(fileId, NULL, SEEK_SET ); - int i; - int ch = fgetc( fileId ); - for( i=0; (i < (int)lenFile ) && ( feof( fileId ) == 0 ); i++ ) { - m_nlhr.pData[m_nlhr.dataLength+i] = (char)ch; - ch = fgetc( fileId ); - } - m_nlhr.pData[sizeDest-1] = 0; //NULL Termination for binary data - m_nlhr.dataLength = (int)sizeDest - 1; - fclose(fileId); - //($this->sendEnd($h);) - AppendToData("\r\n"); - -//POST DATA footer (for "optimage", 1) -//POST DATA footer (for "optsize", optsize) - -//POST DATA footer (for "tags", tags) -//POST DATA footer (for "rembar", "yes" : "no") -//POST DATA footer (for "public", "yes" : "no") -//POST DATA footer (for "cookie", cookie) - -//POST DATA footer (for "key", DEVKEY_IMAGESHACK) - //($this->sendStart($h);) - AppendToData("--"); - AppendToData(m_MFDRboundary); - AppendToData("\r\n"); - //($this->sendDispositionHeader($h);) - AppendToData("Content-Disposition: form-data; name=\""); - AppendToData("key"); - AppendToData("\""); - //($this->sendTransferEncodingHeader($h); ) - AppendToData("\r\n"); - AppendToData("Content-Transfer-Encoding: "); - AppendToData("8bit"); //??"binary" - //($this->sendEndOfHeader($h);) - AppendToData("\r\n"); - AppendToData("\r\n"); - //($this->sendData($h);) - AppendToData(DEVKEY_IMAGESHACK); - //($this->sendEnd($h);) - AppendToData("\r\n"); - -//POST DATA Exit - //$postdata = "--" . part::getBoundary() . "--\r\n"; - AppendToData("--"); - AppendToData(m_MFDRboundary); - AppendToData("--\r\n"); - -//start upload thread - if (m_SendSync) { - m_bFreeOnExit = FALSE; - SendThread(); - return; - } - m_bFreeOnExit = TRUE; - mir_forkthread(&CSendImageShack::SendThreadWrapper, this); -} - -void CSendImageShack::SendThread() { - //send DATA and wait for m_nlreply - m_nlreply = (NETLIBHTTPREQUEST *) CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM) hNetlibUser, (LPARAM) &m_nlhr); - mir_freeAndNil(m_nlhr.pData); - mir_freeAndNil(m_nlhr.headers); - if(m_nlreply){ - if( m_nlreply->resultCode >= 200 && m_nlreply->resultCode < 300 ){ - m_nlreply->pData[m_nlreply->dataLength] = 0;// make sure its null terminated - const char* URL = NULL; - LPTSTR err = NULL; - URL = GetTagContent(m_nlreply->pData, "", ""); - if (URL && URL[0]!= NULL) { - m_Url = mir_strdup(URL); - if(m_SendSync) { - Exit(ACKRESULT_SUCCESS); - return; - } - m_ChatRoom ? svcSendChat(URL) : svcSendMsg(URL); - return; - } - else{ //check error mess from server - err = mir_a2t(GetTagContent(m_nlreply->pData, "")); - if (err && err[0]!= NULL) { //parsed err messege - Error(NULL, err); - } - else{ //fallback to server response mess - mir_freeAndNil(err); - err = mir_a2t(m_nlreply->pData); - } - mir_free(err); - } - } - else { - Error(NULL, _T("Upload server did not respond timely.")); - } - CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM) m_nlreply); - m_nlreply = NULL; - } - else { - Error(SS_ERR_INIT, m_pszSendTyp); - } - Exit(ACKRESULT_FAILED); -} - -void CSendImageShack::SendThreadWrapper(void * Obj) { - reinterpret_cast(Obj)->SendThread(); -} - -//--------------------------------------------------------------------------- -void CSendImageShack::MFDR_Reset() { - char Temp[64]; - DWORD dwBoundaryRand1 = GetTickCount(); - DWORD dwBoundaryRand2 = rand(); - - mir_freeAndNil(m_MFDRboundary); - sprintf(Temp, "B-O-U-N-D-A-R-Y%u%u", dwBoundaryRand1, dwBoundaryRand2); - mir_stradd(m_MFDRboundary,Temp); -} - -void CSendImageShack::GetContentType() { - if (m_pszContentType) mir_freeAndNil(m_pszContentType); - LPSTR FileExtension = (LPSTR)GetFileExt(m_pszFile, DBVT_ASCIIZ); - - if ((strcmp(FileExtension, ".jpeg")==0) || (strcmp(FileExtension, ".jpe")==0) || (strcmp(FileExtension ,".jpg")==0)) - m_pszContentType="image/jpeg"; - else if (strcmp(FileExtension, ".bmp")==0) - m_pszContentType="image/bmp"; - else if (strcmp(FileExtension, ".png")==0) - m_pszContentType="image/png"; - else if (strcmp(FileExtension, ".gif")==0) - m_pszContentType="image/gif"; - else if ((strcmp(FileExtension, ".tif")==0) || (strcmp(FileExtension, ".tiff")==0)) - m_pszContentType="image/tiff"; - else - m_pszContentType="application/octet-stream"; - - mir_free(FileExtension); - return; -} - -void CSendImageShack::AppendToData(const char *pszVal) { - if (!m_nlhr.pData) { - m_nlhr.pData = mir_strdup(pszVal); - m_nlhr.dataLength = (int)strlen(pszVal); - } - else { - size_t lenVal = strlen(pszVal); - size_t sizeNew = sizeof(char)*(m_nlhr.dataLength + lenVal + 1); - m_nlhr.pData = (char*) mir_realloc(m_nlhr.pData, sizeNew); - - strcpy(m_nlhr.pData + sizeof(char)*m_nlhr.dataLength, pszVal); - m_nlhr.pData[sizeNew-1] = 0; - m_nlhr.dataLength = (int)sizeNew -1; - } -} - -//--------------------------------------------------------------------------- -const char * CSendImageShack::GetTagContent(char * pszSource, const char * pszTagStart, const char * pszTagEnd) { - char * b = strstr(pszSource, pszTagStart); - if (!b) return NULL; - b += strlen(pszTagStart); - char * e = strstr(b, pszTagEnd); - if (e) *e = 0; - return b; -} - diff --git a/plugins/SendScreenshotPlus/CSendImageShack.h b/plugins/SendScreenshotPlus/CSendImageShack.h deleted file mode 100644 index eae406aca9..0000000000 --- a/plugins/SendScreenshotPlus/CSendImageShack.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2009 Miranda ICQ/IM project, - -This file is part of Send Screenshot Plus, a Miranda IM plugin. -Copyright (c) 2010 Ing.U.Horn - -Parts of this file based on original sorce code -(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/CSendImageShack.h $ -Revision : $Revision: 13 $ -Last change on : $Date: 2010-04-02 02:54:30 +0400 (РџС‚, 02 апр 2010) $ -Last change by : $Author: ing.u.horn $ - -*/ - -#ifndef _CSEND_IMAGESHACK_H -#define _CSEND_IMAGESHACK_H - -//--------------------------------------------------------------------------- -#include "global.h" -#include "Utils.h" -#include "CSend.h" - -//--------------------------------------------------------------------------- -class CSendImageShack : public CSend { - public: - // Deklaration Standardkonstruktor/Standarddestructor - CSendImageShack(HWND Owner, HANDLE hContact, bool bFreeOnExit); - ~CSendImageShack(); - - void Send(); - void SendSync(bool Sync) {m_SendSync = Sync;}; - LPSTR GetURL(){return m_Url;}; - LPSTR GetError(){return mir_t2a(m_ErrorMsg);}; - - protected: - LPSTR m_pszFileName; - NETLIBHTTPREQUEST m_nlhr; - NETLIBHTTPREQUEST* m_nlreply; - NETLIBHTTPHEADER* m_nlheader; - char m_nlheader_ContentType[64]; - LPSTR m_Url; - - void AppendToData(const char *pszVal); //append to netlib DATA - LPSTR m_pszContentType; //hold mimeType (does not need free) - void GetContentType(); //get mimeType - const char * GetTagContent(char * pszSource, const char * pszTagStart, const char * pszTagEnd); - - char* m_MFDRboundary; - void MFDR_Reset(); - - bool m_SendSync; - void SendThread(); - static void SendThreadWrapper(void * Obj); - -}; - -//--------------------------------------------------------------------------- - -#endif diff --git a/plugins/SendScreenshotPlus/Main.cpp b/plugins/SendScreenshotPlus/Main.cpp deleted file mode 100644 index 75e5655ac5..0000000000 --- a/plugins/SendScreenshotPlus/Main.cpp +++ /dev/null @@ -1,364 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2009 Miranda ICQ/IM project, - -This file is part of Send Screenshot Plus, a Miranda IM plugin. -Copyright (c) 2010 Ing.U.Horn - -Parts of this file based on original sorce code -(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/Main.cpp $ -Revision : $Revision: 22 $ -Last change on : $Date: 2010-05-02 21:25:02 +0400 (Р’СЃ, 02 май 2010) $ -Last change by : $Author: ing.u.horn $ - -*/ - -//--------------------------------------------------------------------------- -#include "main.h" - -// Prototypes /////////////////////////////////////////////////////////////////////////// -//LIST_INTERFACE li; -FI_INTERFACE *FIP = 0; -HINSTANCE hInst; //!< Global reference to the application -MGLOBAL myGlobals; -int hLangpack; - - -//Information gathered by Miranda, displayed in the plugin pane of the Option Dialog -PLUGININFOEX pluginInfo={ - sizeof(PLUGININFOEX), - __PLUGIN_NAME, // altered here and on file listing, so as not to match original - PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), - __DESC, - __AUTHOR, - __AUTHOREMAIL, - __COPYRIGHT, - __AUTHORWEB, - UNICODE_AWARE, //doesn't replace anything built-in - MIID_PLUGIN -}; - -//static char szSendSS[]=SZ_SENDSS; - -HANDLE hsvc_SendScreenshot=0; -HANDLE hsvc_SendDesktop=0; -HANDLE hsvc_EditBitmap=0; -HANDLE hsvc_Send2ImageShack=0; - -HANDLE hNetlibUser = 0; //!< Netlib Register User -HANDLE hFolderScreenshot=0; - -HANDLE hhook_ModulesLoad=0; -HANDLE hhook_SystemPShutdown=0; - - -// Functions //////////////////////////////////////////////////////////////////////////// - -/*--------------------------------------------------------------------------- -* DLL entry point - Required to store the instance handle -*/ -extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { - hInst = hinstDLL; - // Freeing some unneeded resources - DisableThreadLibraryCalls(GetModuleHandle(_T("sendss.dll"))); - - return TRUE; -} - -/*--------------------------------------------------------------------------- -* Called by Miranda to get the information associated to this plugin. -* It only returns the PLUGININFO structure, without any test on the version -* @param mirandaVersion The version of the application calling this function -*/ -extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) { - pluginInfo.cbSize = sizeof(PLUGININFOEX); - myGlobals.mirandaVersion = mirandaVersion; - return &pluginInfo; -} - -extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PLUGIN, MIID_LAST }; - -/*--------------------------------------------------------------------------- -* Initializes the services provided and the link to those needed -* Called when the plugin is loaded into Miranda -*/ -extern "C" int __declspec(dllexport) Load(void) { - mir_getLP(&pluginInfo); - INT_PTR result = CALLSERVICE_NOTFOUND; - - if(ServiceExists(MS_IMG_GETINTERFACE)) - result = CallService(MS_IMG_GETINTERFACE, FI_IF_VERSION, (LPARAM)&FIP); - - if(FIP == NULL || result != S_OK) { - MessageBoxEx(NULL, TranslateT("Fatal error, image services not found. Send Screenshot will be disabled."), _T("Error"), MB_OK | MB_ICONERROR | MB_APPLMODAL, 0); - return 1; - } - - // load icon library (use UserInfoEx icon Pack) - IcoLib_LoadModule(); - - hhook_ModulesLoad = HookEvent(ME_SYSTEM_MODULESLOADED, hook_ModulesLoaded); - //hhook_options_init = HookEvent(ME_OPT_INITIALISE, hook_options_init); - //hhook_OkToExit = HookEvent(ME_SYSTEM_OKTOEXIT, hook_OkToExit); - hhook_SystemPShutdown = HookEvent(ME_SYSTEM_PRESHUTDOWN, hook_SystemPShutdown); - - AddMenuItems(); - RegisterServices(); - - return 0; -} - -int hook_ModulesLoaded(WPARAM, LPARAM) { - - myGlobals.PopUpExist = ServiceExists(MS_POPUP_ADDPOPUP); - myGlobals.PopUpActionsExist = ServiceExists(MS_POPUP_REGISTERACTIONS); - myGlobals.PluginHTTPExist = ServiceExists(MS_HTTP_ACCEPT_CONNECTIONS); - myGlobals.PluginFTPExist = ServiceExists(MS_FTPFILE_SHAREFILE); -// myGlobals.PluginUserinfoEx = ServiceExists(MS_USERINFO_VCARD_EXPORT); - - // Netlib register - if (!NetlibInit()){ - ; - } - - // load my button class - if(!ServiceExists("UserInfo/vCard/Export")) { - CtrlButtonLoadModule(); - } - - // Folders plugin support - if (ServiceExists(MS_FOLDERS_REGISTER_PATH)) { - hFolderScreenshot = (HANDLE) FoldersRegisterCustomPathT("SendSS", "Screenshots", - _T(PROFILE_PATH)_T("\\")_T(CURRENT_PROFILE)_T("\\Screenshots")); - } - - return 0; -} - -/*--------------------------------------------------------------------------- -* Prepare the plugin to stop -* Called by Miranda when it will exit or when the plugin gets deselected -*/ -extern "C" int __declspec(dllexport) Unload(void) { - UnhookEvent(hhook_SystemPShutdown); - - DestroyServiceFunction(MS_SENDSS_OPENDIALOG); - DestroyServiceFunction(MS_SENDSS_EDITBITMAP); - DestroyServiceFunction(MS_SENDSS_SENDDESKTOP); - DestroyServiceFunction(MS_SENDSS_SEND2IMAGESHACK); - return 0; -} - -int hook_SystemPShutdown(WPARAM wParam, LPARAM lParam) { - UnhookEvent(hhook_ModulesLoad); - - // Netlib unregister - NetlibClose(); - - // uninitialize classes - CtrlButtonUnloadModule(); - - return 0; -} - -//--------------------------------------------------------------------------- -// Netlib -HANDLE NetlibInit(void) { - NETLIBUSER nlu = {0}; - nlu.cbSize = sizeof(nlu); - nlu.szSettingsModule = (char*)PLUGNAME; - nlu.szDescriptiveName = Translate("SendSS HTTP connections"); - nlu.flags = NUF_OUTGOING|NUF_HTTPCONNS; //|NUF_NOHTTPSOPTION; - hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu); - return hNetlibUser; -} - -void NetlibClose(void) { - Netlib_CloseHandle(hNetlibUser); -} - - -//--------------------------------------------------------------------------- -// Callback function of service -// 1. Send a screenshot of the desktop to the selected contact -// wParam = contact handle -// lParam = 0 -// 2. Open the capture dialog in take screenshot only mode (it will not be sent) -// wParam = 0 -// lParam = anything but 0 -INT_PTR service_CaptureAndSendDesktop(WPARAM wParam, LPARAM lParam) { - LPTSTR pszPath = NULL; - LPSTR pszProto = NULL; - bool bChatRoom; - - TfrmMain *frmMain=new TfrmMain(); - if (!frmMain) { - MessageBoxEx(NULL, TranslateT("Could not create main dialog."), TranslateT("Error"), MB_OK | MB_ICONERROR | MB_APPLMODAL, 0); - return -1; - } - pszPath = GetCustomPath(); - - pszProto = (LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0); - bChatRoom = DBGetContactSettingByte((HANDLE)wParam, pszProto, "ChatRoom", 0) != 0; - frmMain->m_opt_chkTimed = false; - frmMain->m_opt_tabCapture = 1; - frmMain->m_opt_cboxDesktop = 0; - frmMain->m_opt_chkEditor = false; - frmMain->m_opt_cboxSendBy = bChatRoom ? SS_IMAGESHACK:SS_FILESEND; - frmMain->Init(pszPath, (HANDLE)wParam); // this method create the window hidden. - frmMain->btnCaptureClick(); // this method will call Close() - mir_free(pszPath); - return 0; -} - -//--------------------------------------------------------------------------- -// Callback function of service for contact menu and main menu -// wParam = contact handle -// lParam = 0 -INT_PTR service_OpenCaptureDialog(WPARAM wParam, LPARAM lParam) { - LPTSTR pszPath = NULL; - - TfrmMain *frmMain=new TfrmMain(); - if (!frmMain) { - MessageBoxEx(NULL, TranslateT("Could not create main dialog."), TranslateT("Error"), MB_OK | MB_ICONERROR | MB_APPLMODAL, 0); - return -1; - } - - pszPath = GetCustomPath(); - frmMain->Init(pszPath, (HANDLE)wParam); - mir_free(pszPath); - frmMain->Show(); - return 0; -} - -//--------------------------------------------------------------------------- -// Edit a in-memory bitmap on the edit window -// wParam = (SENDSSCB) callback function address to call when editing is done -// lParam = (HBITMAP) bitmap handle, a copy is made so the calling function can free this handle after the service function returns -// Returns: -INT_PTR service_EditBitmap(WPARAM wParam, LPARAM lParam) { -/* TfrmEdit *frmEdit=new TfrmEdit(NULL); - if (!frmEdit) - return -1; - - Graphics::TBitmap *bitmap=new Graphics::TBitmap(); - if (!bitmap) - return -2; - - bitmap->Handle = (void*)lParam; - frmEdit->InitEditor(bitmap); // a copy of the bitmap is made inside this function - frmEdit->Show(); - delete bitmap; -*/ - return 0; -} - -//--------------------------------------------------------------------------- -// Callback function of service for sending image to imageshack.us -// wParam = (char*)filename -// lParam = (HANDLE)contact (can be null) -INT_PTR service_Send2ImageShack(WPARAM wParam, LPARAM lParam) { - LPSTR result = NULL; - CSendImageShack* cSend = new CSendImageShack(NULL, (HANDLE)lParam, false); - cSend->m_pszFile = mir_a2t((char*)wParam); - cSend->m_bDeleteAfterSend = FALSE; - if (lParam != NULL) { - cSend->Send(); - return 0; - } - cSend->SendSync(TRUE); - cSend->Send(); - if (cSend->GetURL()) { - result = mir_strdup(cSend->GetURL()); - } - else { - result = cSend->GetError(); - } - delete cSend; - return (INT_PTR)result; -} - -//--------------------------------------------------------------------------- -// Add SendSS menu item in contact menu -void AddMenuItems(void) { - CLISTMENUITEM mi={0}; - - // Common - mi.cbSize = sizeof(mi); - // support new genmenu style - mi.flags = CMIF_ROOTHANDLE|CMIF_UNICODE; - mi.hParentMenu = HGENMENU_ROOT; - - // Add item to contact menu - mi.position = 1000000; - mi.ptszName = LPGENT("Send Screenshot"); - mi.hIcon = IcoLib_GetIcon(ICO_PLUG_SSWINDOW2); - mi.pszService = MS_SENDSS_OPENDIALOG; - Menu_AddContactMenuItem(&mi); - - // Add item to contact menu - mi.position = 1000001; - mi.ptszName = LPGENT("Send desktop screenshot"); - mi.hIcon = IcoLib_GetIcon(ICO_PLUG_SSWINDOW2); - mi.pszService = MS_SENDSS_SENDDESKTOP; - Menu_AddContactMenuItem(&mi); - - // Add item to main menu - mi.position = 1000001; - mi.ptszName = LPGENT("Take a screenshot"); - mi.hIcon = IcoLib_GetIcon(ICO_PLUG_SSWINDOW2); - mi.pszService = MS_SENDSS_OPENDIALOG; - Menu_AddMainMenuItem(&mi); -} - -//--------------------------------------------------------------------------- -// Register Send screenshot services -int RegisterServices(void) { - hsvc_SendScreenshot = CreateServiceFunction(MS_SENDSS_OPENDIALOG, service_OpenCaptureDialog); - if (!hsvc_SendScreenshot) - MessageBoxEx(NULL, TranslateT("Could not register miranda service."), _T("MS_SENDSS_OPENDIALOG"), MB_OK | MB_ICONERROR | MB_APPLMODAL, 0); - - hsvc_SendDesktop = CreateServiceFunction(MS_SENDSS_SENDDESKTOP, service_CaptureAndSendDesktop); - if (!hsvc_SendDesktop) - MessageBoxEx(NULL, TranslateT("Could not register miranda service."), _T("MS_SENDSS_SENDDESKTOP"), MB_OK | MB_ICONERROR | MB_APPLMODAL, 0); - - hsvc_EditBitmap = CreateServiceFunction(MS_SENDSS_EDITBITMAP, service_EditBitmap); - if (!hsvc_EditBitmap) - MessageBoxEx(NULL, TranslateT("Could not register miranda service."), _T("MS_SENDSS_EDITBITMAP"), MB_OK | MB_ICONERROR | MB_APPLMODAL, 0); - - hsvc_Send2ImageShack = CreateServiceFunction(MS_SENDSS_SEND2IMAGESHACK, service_Send2ImageShack); - if (!hsvc_Send2ImageShack) - MessageBoxEx(NULL, TranslateT("Could not register miranda service."), _T("MS_SENDSS_SEND2IMAGESHACK"), MB_OK | MB_ICONERROR | MB_APPLMODAL, 0); - - return 0; -} - -//--------------------------------------------------------------------------- -LPTSTR GetCustomPath() { - LPTSTR pszPath = NULL; - pszPath = Utils_ReplaceVarsT(_T("%miranda_userdata%\\Screenshots")); - if (hFolderScreenshot) { - TCHAR szPath[1024] = {'\0'}; - FoldersGetCustomPathT(hFolderScreenshot, szPath, 1024, pszPath); - mir_freeAndNil(pszPath); - pszPath = mir_tstrdup(szPath); - } - return pszPath; -} diff --git a/plugins/SendScreenshotPlus/Main.h b/plugins/SendScreenshotPlus/Main.h deleted file mode 100644 index 67059fb73c..0000000000 --- a/plugins/SendScreenshotPlus/Main.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2009 Miranda ICQ/IM project, - -This file is part of Send Screenshot Plus, a Miranda IM plugin. -Copyright (c) 2010 Ing.U.Horn - -Parts of this file based on original sorce code -(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/Main.h $ -Revision : $Revision: 22 $ -Last change on : $Date: 2010-05-02 21:25:02 +0400 (Р’СЃ, 02 май 2010) $ -Last change by : $Author: ing.u.horn $ - -*/ - -#ifndef MainH -#define MainH - -//--------------------------------------------------------------------------- -#include "global.h" -#include "UMainForm.h" -//#include "UEditForm.h" - -extern HANDLE hNetlibUser; - -//--------------------------------------------------------------------------- - -HANDLE NetlibInit(void); -void NetlibClose(void); - -void IcoLib_LoadModule(void); -void AddMenuItems(void); -int RegisterServices(void); - -int hook_ModulesLoaded(WPARAM, LPARAM); -int hook_SystemPShutdown(WPARAM wParam, LPARAM lParam); - -INT_PTR service_CaptureAndSendDesktop(WPARAM wParam, LPARAM lParam); -INT_PTR service_OpenCaptureDialog(WPARAM wParam, LPARAM lParam); -INT_PTR service_EditBitmap(WPARAM wParam, LPARAM lParam); -INT_PTR service_Send2ImageShack(WPARAM wParam, LPARAM lParam); - -int OnSendScreenShot(WPARAM wParam, LPARAM lParam); - -LPTSTR GetCustomPath(); - -//--------------------------------------------------------------------------- -#endif diff --git a/plugins/SendScreenshotPlus/SendSS_10.vcxproj b/plugins/SendScreenshotPlus/SendSS_10.vcxproj index d58df0064f..cd757979d6 100644 --- a/plugins/SendScreenshotPlus/SendSS_10.vcxproj +++ b/plugins/SendScreenshotPlus/SendSS_10.vcxproj @@ -73,7 +73,7 @@ - sdk;..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) Level3 Full @@ -97,7 +97,7 @@ Disabled - sdk;..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) MultiThreadedDebugDLL Level3 @@ -118,7 +118,7 @@ - sdk;..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) WIN64;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) Level3 Full @@ -142,7 +142,7 @@ Disabled - sdk;..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) WIN64;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) MultiThreadedDebugDLL Level3 @@ -161,69 +161,43 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + diff --git a/plugins/SendScreenshotPlus/SendSS_10.vcxproj.filters b/plugins/SendScreenshotPlus/SendSS_10.vcxproj.filters index 1c963f799a..3747d35c3d 100644 --- a/plugins/SendScreenshotPlus/SendSS_10.vcxproj.filters +++ b/plugins/SendScreenshotPlus/SendSS_10.vcxproj.filters @@ -18,181 +18,107 @@ - + Class Form - + Class Form - + Helper - + Helper - + Helper - + Helper - + Helper - + Class Send - + Class Send - + Class Send - + Class Send - + Class Send - + Class Send - + Class Form - + Class Form - + Class Form - + Helper - + Helper - + Helper - + Helper - + Helper - + Resource Files - + Class Send - + Class Send - + Class Send - + Class Send - + Class Send - + Class Send - + Helper - + Helper - + Helper - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - - + Resource Files - + Resource Files diff --git a/plugins/SendScreenshotPlus/UAboutForm.cpp b/plugins/SendScreenshotPlus/UAboutForm.cpp deleted file mode 100644 index f4ea2b6bc2..0000000000 --- a/plugins/SendScreenshotPlus/UAboutForm.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2009 Miranda ICQ/IM project, - -This file is part of Send Screenshot Plus, a Miranda IM plugin. -Copyright (c) 2010 Ing.U.Horn - -Parts of this file based on original sorce code -(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/UAboutForm.cpp $ -Revision : $Revision: 22 $ -Last change on : $Date: 2010-05-02 21:25:02 +0400 (Р’СЃ, 02 май 2010) $ -Last change by : $Author: ing.u.horn $ - -*/ - -#include "UAboutForm.h" - -//--------------------------------------------------------------------------- -TfrmAbout::CHandleMapping TfrmAbout::_HandleMapping; - -LRESULT CALLBACK TfrmAbout::DlgTfrmAbout(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - if (msg == WM_CTLCOLOREDIT || msg == WM_CTLCOLORSTATIC) { - switch ( GetWindowLongPtr(( HWND )lParam, GWL_ID )) { - case IDC_WHITERECT: - case IDC_BUILDTIME: - case IDC_CREDIT: - case IDC_LICENSE: - SetTextColor((HDC)wParam,GetSysColor(COLOR_WINDOWTEXT)); - break; - default: - return FALSE; - } - SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); - return (LRESULT)GetStockObject(WHITE_BRUSH); //GetSysColorBrush(COLOR_WINDOW); - } - - CHandleMapping::iterator wnd(_HandleMapping.end()); - if (msg == WM_INITDIALOG) { - wnd = _HandleMapping.insert(CHandleMapping::value_type(hWnd, reinterpret_cast(lParam))).first; - reinterpret_cast(lParam)->m_hWnd = hWnd; - return wnd->second->wmInitdialog(wParam, lParam); - } - else { - wnd = _HandleMapping.find(hWnd); - } - if (wnd == _HandleMapping.end()) { // something screwed up - return FALSE; //dialog! do not use ::DefWindowProc(hWnd, msg, wParam, lParam); - } - - switch (msg) - { - // case WM_INITDIALOG: done on top - case WM_COMMAND: - return wnd->second->wmCommand(wParam, lParam); - break; - case WM_CLOSE: - return wnd->second->wmClose(wParam, lParam); - break; - case WM_DESTROY: - delete wnd->second; - break; - } - return FALSE; -} - -//--------------------------------------------------------------------------- -//WM_INITDIALOG: -LRESULT TfrmAbout::wmInitdialog(WPARAM wParam, LPARAM lParam) { - char* pszMsg = NULL; - HRSRC hResInfo; - DWORD ResSize; - TCHAR oldTitle[256], newTitle[256]; - LPTSTR temp = NULL; - LPTSTR pszTitle = NULL; - // Headerbar - LPTSTR pszPlug = mir_a2t(__PLUGIN_NAME); - LPTSTR pszVer = mir_a2t(__VERSION_STRING_DOT); - GetDlgItemText( m_hWnd, IDC_HEADERBAR, oldTitle, SIZEOF( oldTitle )); - mir_sntprintf( newTitle, SIZEOF(newTitle), oldTitle, pszPlug, pszVer ); - mir_freeAndNil(pszPlug); - mir_freeAndNil(pszVer); - SetDlgItemText( m_hWnd, IDC_HEADERBAR, newTitle ); - SendMessage(GetDlgItem(m_hWnd, IDC_HEADERBAR), WM_SETICON, 0, (WPARAM)IcoLib_GetIcon(ICO_PLUG_SSWINDOW1, true)); - - //Buildtime - mir_sntprintf(newTitle,SIZEOF(newTitle),TranslateT("Built %s %s"),_T(__DATE__),_T(__TIME__)); - SetDlgItemText(m_hWnd,IDC_BUILDTIME,newTitle); - - //License - { mir_tcsadd(pszTitle ,_T(__COPYRIGHT)); - mir_tcsadd(pszTitle ,_T("\r\n\r\n")); - - hResInfo = FindResource(hInst,MAKEINTRESOURCE(IDR_LICENSE),_T("TEXT")); - ResSize = SizeofResource(hInst,hResInfo); - pszMsg = (char*)LockResource(LoadResource(hInst,hResInfo)); - temp = mir_a2t(pszMsg); - temp [ResSize] = 0; //LockResource is not NULL terminatet !! - mir_tcsadd(pszTitle ,temp); - mir_freeAndNil(temp); - SetDlgItemText(m_hWnd,IDC_LICENSE, pszTitle); - mir_freeAndNil(pszTitle); - } - - //Credit - { - hResInfo = FindResource(hInst,MAKEINTRESOURCE(IDR_CREDIT),_T("TEXT")); - ResSize = SizeofResource(hInst,hResInfo); - pszMsg = (char*)LockResource(LoadResource(hInst,hResInfo)); - temp = mir_a2t(pszMsg); - temp [ResSize] = 0; //LockResource is not NULL terminatet !! - mir_tcsadd(pszTitle ,temp); - mir_freeAndNil(temp); - SetDlgItemText(m_hWnd,IDC_CREDIT, pszTitle); - mir_freeAndNil(pszTitle); - } - - SendMessage(m_hWnd, WM_SETICON, ICON_BIG, (LPARAM)IcoLib_GetIcon(ICO_PLUG_SSWINDOW1, true)); - SendMessage(m_hWnd, WM_SETICON, ICON_SMALL, (LPARAM)IcoLib_GetIcon(ICO_PLUG_SSWINDOW2)); - - //init controls - btnPageClick(); - SendMessage(GetDlgItem(m_hWnd, IDA_CONTRIBLINK), BUTTONSETDEFAULT, (WPARAM)1, NULL); - - TranslateDialogDefault(m_hWnd); - return FALSE; -} - -//WM_COMMAND: -LRESULT TfrmAbout::wmCommand(WPARAM wParam, LPARAM lParam) { - //--------------------------------------------------------------------------- - if (HIWORD(wParam) == BN_CLICKED) { - int IDControl = LOWORD(wParam); - HWND hCtrl = (HWND)lParam; - switch(IDControl) { - case IDCANCEL: - case IDCLOSE: - break; - case IDA_btnClose: - Close(); - break; - case IDA_CONTRIBLINK: - m_Page = m_Page ? 0 : 1; - btnPageClick(); - break; - default: - break; - } - } - return FALSE; -} - -//WM_CLOSE: -LRESULT TfrmAbout::wmClose(WPARAM wParam, LPARAM lParam) { - SendMessage(m_hWndOwner,UM_CLOSING, (WPARAM)m_hWnd, (LPARAM)IDD_UAboutForm); - DestroyWindow(m_hWnd); - return FALSE; -} - -//--------------------------------------------------------------------------- -// Standard konstruktor/destruktor -TfrmAbout::TfrmAbout(HWND Owner) { - m_hWndOwner = Owner; - // create window - m_hWnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_UAboutForm),0, (DLGPROC)DlgTfrmAbout,(LPARAM)this); - //register object - _HandleMapping.insert(CHandleMapping::value_type(m_hWnd, this)); - //init page - m_Page = 1; -} - -TfrmAbout::~TfrmAbout() { - _HandleMapping.erase(m_hWnd); -} - -//--------------------------------------------------------------------------- -void TfrmAbout::btnPageClick() { - HWND hCtrl = GetDlgItem(m_hWnd, IDA_CONTRIBLINK); - if(!m_Page) { - ShowWindow(GetDlgItem(m_hWnd, IDC_CREDIT), SW_HIDE); - ShowWindow(GetDlgItem(m_hWnd, IDC_LICENSE), SW_SHOW); - SendDlgItemMessage(m_hWnd, IDA_CONTRIBLINK, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Credits >"), MBF_TCHAR); - HICON hIcon = IcoLib_GetIcon(ICO_PLUG_ARROWR); - SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); - SetWindowText(hCtrl, hIcon ? TranslateT("Credits") : TranslateT("Credits >")); - } - else { - ShowWindow(GetDlgItem(m_hWnd, IDC_CREDIT), SW_SHOW); - ShowWindow(GetDlgItem(m_hWnd, IDC_LICENSE), SW_HIDE); - SendDlgItemMessage(m_hWnd, IDA_CONTRIBLINK, BUTTONADDTOOLTIP, (WPARAM)TranslateT("< Copyright"), MBF_TCHAR); - HICON hIcon = IcoLib_GetIcon(ICO_PLUG_ARROWL); - SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); - SetWindowText(hCtrl, hIcon ? TranslateT("Copyright") : TranslateT("< Copyright")); - } -} diff --git a/plugins/SendScreenshotPlus/UAboutForm.h b/plugins/SendScreenshotPlus/UAboutForm.h deleted file mode 100644 index d9d598aeb6..0000000000 --- a/plugins/SendScreenshotPlus/UAboutForm.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2009 Miranda ICQ/IM project, - -This file is part of Send Screenshot Plus, a Miranda IM plugin. -Copyright (c) 2010 Ing.U.Horn - -Parts of this file based on original sorce code -(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/UAboutForm.h $ -Revision : $Revision: 19 $ -Last change on : $Date: 2010-04-09 03:24:04 +0400 (РџС‚, 09 апр 2010) $ -Last change by : $Author: ing.u.horn $ - -*/ - -#ifndef UAboutFormH -#define UAboutFormH -//--------------------------------------------------------------------------- -#include "global.h" - -//--------------------------------------------------------------------------- -class TfrmAbout{ - - public: - // Deklaration Standardkonstruktor/Standarddestructor - TfrmAbout(HWND Owner); - ~TfrmAbout(); - - HWND m_hWndOwner; - void Show(){ShowWindow(m_hWnd,SW_SHOW);} - void Hide(){ShowWindow(m_hWnd,SW_HIDE);} - void Close(){SendMessage(m_hWnd,WM_CLOSE,0,0);} - - private: - HWND m_hWnd; - - protected: - UINT m_Page; - typedef std::map CHandleMapping; - static CHandleMapping _HandleMapping; - static LRESULT CALLBACK DlgTfrmAbout(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); - - LRESULT wmInitdialog(WPARAM wParam, LPARAM lParam); - LRESULT wmCommand(WPARAM wParam, LPARAM lParam); - LRESULT wmClose(WPARAM wParam, LPARAM lParam); - - void btnPageClick(); - -}; - -//--------------------------------------------------------------------------- -#endif diff --git a/plugins/SendScreenshotPlus/UMainForm.cpp b/plugins/SendScreenshotPlus/UMainForm.cpp deleted file mode 100644 index 2061f80d83..0000000000 --- a/plugins/SendScreenshotPlus/UMainForm.cpp +++ /dev/null @@ -1,1180 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2009 Miranda ICQ/IM project, - -This file is part of Send Screenshot Plus, a Miranda IM plugin. -Copyright (c) 2010 Ing.U.Horn - -Parts of this file based on original sorce code -(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/UMainForm.cpp $ -Revision : $Revision: 22 $ -Last change on : $Date: 2010-05-02 21:25:02 +0400 (Р’СЃ, 02 май 2010) $ -Last change by : $Author: ing.u.horn $ - -*/ - -#include "UMainForm.h" -#include "UAboutForm.h" -//#include "UEditForm.h" - -//--------------------------------------------------------------------------- -INT_PTR CALLBACK TfrmMain::DlgProc_CaptureWindow(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { -// main message handling is done inside TfrmMain::DlgTfrmMain - switch (uMsg) { - case WM_INITDIALOG: - Static_SetIcon(GetDlgItem(hDlg, ID_imgTarget), IcoLib_GetIcon(ICO_PLUG_SSTARGET)); - SetDlgItemText(hDlg, ID_edtCaption, _T("Drag&&Drop the target on the desired window.")); - TranslateDialogDefault(hDlg); - break; - case WM_CTLCOLOREDIT: //ctrl is NOT read-only or disabled - case WM_CTLCOLORSTATIC: //ctrl is read-only or disabled - // make the rectangle on the top white - switch (GetWindowLongPtr((HWND)lParam, GWL_ID)) { - case IDC_WHITERECT: - case ID_chkClientArea: - case ID_lblDropInfo: - case ID_edtCaption: - case ID_edtCaptionLabel: - case ID_edtSize: - case ID_edtSizeLabel: - case ID_bvlTarget: - case ID_imgTarget: - SetBkColor((HDC)wParam,GetSysColor(COLOR_WINDOW)); - SetTextColor((HDC)wParam,GetSysColor(COLOR_WINDOWTEXT)); - - //SetBkMode((HDC)wParam,OPAQUE); - //return (INT_PTR)GetSysColorBrush(COLOR_WINDOW); - return (LRESULT)GetStockObject(WHITE_BRUSH); - break; - default: - SetBkMode((HDC)wParam, TRANSPARENT); - return (LRESULT)GetStockObject(NULL_BRUSH); - break; - } - break; //this return false - case WM_COMMAND: - SendMessage(GetParent(hDlg), uMsg, wParam, lParam); - break; - case WM_MOUSEMOVE: - SendMessage(GetParent(hDlg), UM_TAB1, uMsg, 0); - break; - case WM_NOTIFY: - SendMessage(GetParent(hDlg), uMsg, wParam, lParam); - break; - case WM_DESTROY: - break; - } - return FALSE; -} - -//--------------------------------------------------------------------------- -INT_PTR CALLBACK TfrmMain::DlgProc_CaptureDesktop(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { -// main message handling is done inside TfrmMain::DlgTfrmMain - switch (uMsg) { - case WM_INITDIALOG: - Static_SetIcon(GetDlgItem(hDlg, ID_imgTarget), IcoLib_GetIcon(ICO_PLUG_SSMONITOR)); - break; - case WM_CTLCOLOREDIT: - case WM_CTLCOLORSTATIC: - // make the rectangle on the top white - switch (GetWindowLongPtr((HWND)lParam, GWL_ID)) { - case IDC_WHITERECT: - case ID_lblDropInfo: - case ID_edtCaption: - case ID_edtCaptionLabel: - case ID_edtSize: - case ID_edtSizeLabel: - case ID_bvlTarget: - case ID_imgTarget: - SetBkColor((HDC)wParam,GetSysColor(COLOR_WINDOW)); - SetTextColor((HDC)wParam,GetSysColor(COLOR_WINDOWTEXT)); - return (LRESULT)GetStockObject(WHITE_BRUSH); - break; - default: - SetBkMode((HDC)wParam, TRANSPARENT); - return (LRESULT)GetStockObject(NULL_BRUSH); - break; - } - break; - case WM_COMMAND: - SendMessage(GetParent(hDlg), uMsg, wParam, lParam); - break; - case WM_NOTIFY: - SendMessage(GetParent(hDlg), uMsg, wParam, lParam); - break; - case WM_DESTROY: - break; - } - return FALSE; -} - -//--------------------------------------------------------------------------- - -TfrmMain::CHandleMapping TfrmMain::_HandleMapping; - -LRESULT CALLBACK TfrmMain::DlgTfrmMain(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - if (msg == WM_CTLCOLOREDIT || msg == WM_CTLCOLORSTATIC) { - switch ( GetWindowLongPtr(( HWND )lParam, GWL_ID )) { - /* case IDC_WHITERECT:*/ - case IDC_HEADERBAR: - SetTextColor((HDC)wParam,GetSysColor(COLOR_WINDOWTEXT)); - break; - default: - return FALSE; - } - SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); - return (LRESULT)GetStockObject(WHITE_BRUSH); //GetSysColorBrush(COLOR_WINDOW); - } - - CHandleMapping::iterator wnd(_HandleMapping.end()); - if (msg == WM_INITDIALOG) { - wnd = _HandleMapping.insert(CHandleMapping::value_type(hWnd, reinterpret_cast(lParam))).first; - reinterpret_cast(lParam)->m_hWnd = hWnd; - return wnd->second->wmInitdialog(wParam, lParam); - } - else { - wnd = _HandleMapping.find(hWnd); - } - if (wnd == _HandleMapping.end()) { // something screwed up - return FALSE; //dialog! do not use ::DefWindowProc(hWnd, msg, wParam, lParam); - } - - switch (msg) - { - // case WM_INITDIALOG: done on top - case WM_COMMAND: - return wnd->second->wmCommand(wParam, lParam); - break; - case WM_CLOSE: - return wnd->second->wmClose(wParam, lParam); - break; - case WM_DESTROY: - delete wnd->second; - break; - case UM_TAB1: - return wnd->second->UMTab1(wParam, lParam); - break; - case WM_NOTIFY: - return wnd->second->wmNotify(wParam, lParam); - break; - case WM_TIMER: - return wnd->second->wmTimer(wParam, lParam); - break; - case UM_CLOSING: - return wnd->second->UMClosing(wParam, lParam); - break; - case UM_EVENT: - return wnd->second->UMevent(wParam, lParam); - break; - } - return FALSE; -} - -//--------------------------------------------------------------------------- -//WM_INITDIALOG: -LRESULT TfrmMain::wmInitdialog(WPARAM wParam, LPARAM lParam) { - HWND hCtrl; - //Taskbar and Window icon - SendMessage(m_hWnd, WM_SETICON, ICON_BIG, (LPARAM)IcoLib_GetIcon(ICO_PLUG_SSWINDOW1, true)); - SendMessage(m_hWnd, WM_SETICON, ICON_SMALL, (LPARAM)IcoLib_GetIcon(ICO_PLUG_SSWINDOW2)); - LPTSTR pt = mir_a2t(__PLUGIN_NAME); - SetWindowText(m_hWnd, pt); - mir_freeAndNil(pt); - - // Headerbar - pt = mir_tstrdup((LPTSTR)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)m_hContact, (LPARAM)GCDNF_TCHAR)); - if (pt && (m_hContact != 0)) { - LPTSTR lptString = NULL; - mir_tcsadd(lptString , TranslateT("Send screenshot to\n")); - mir_tcsadd(lptString , pt); - SetDlgItemText(m_hWnd, IDC_HEADERBAR, lptString); - mir_free(lptString); - } - mir_freeAndNil(pt); - - SendMessage(GetDlgItem(m_hWnd, IDC_HEADERBAR), WM_SETICON, 0, (WPARAM)IcoLib_GetIcon(ICO_PLUG_SSWINDOW1, true)); - - //Timed controls - CheckDlgButton(m_hWnd,ID_chkTimed, m_opt_chkTimed ? BST_CHECKED : BST_UNCHECKED); - SetDlgItemInt (m_hWnd,ID_edtTimed, (UINT)m_opt_edtTimed, FALSE); - SendDlgItemMessage(m_hWnd, ID_upTimed, UDM_SETRANGE, 0, (LPARAM)MAKELONG(250, 1)); - chkTimedClick(); //enable disable Timed controls - - //create Image list for tab control - if(m_himlTab == 0){ - //m_himlTab = ImageList_Create(16, 16, PluginConfig.m_bIsXP ? ILC_COLOR32 | ILC_MASK : ILC_COLOR8 | ILC_MASK, 2, 0); - m_himlTab = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 2, 0); - ImageList_AddIcon(m_himlTab, IcoLib_GetIcon(ICO_PLUG_SSWINDOW2)); - ImageList_AddIcon(m_himlTab, IcoLib_GetIcon(ICO_PLUG_SSWINDOW2)); - } - - //create the tab control. - { - TAB_INFO itab; - RECT rcClient, rcTab; - m_hwndTab = GetDlgItem(m_hWnd, IDC_CAPTURETAB); - TabCtrl_SetItemExtra(m_hwndTab, sizeof(TAB_INFO) - sizeof(TCITEMHEADER)); - - ZeroMemory(&itab, sizeof(itab)); - itab.hwndMain = m_hWnd; - itab.hwndTab = m_hwndTab; - - GetWindowRect(m_hwndTab, &rcTab); - GetWindowRect(m_hWnd, &rcClient); - - TabCtrl_SetImageList(m_hwndTab, m_himlTab); - - // Add a tab for each of the three child dialog boxes. - itab.tcih.mask = TCIF_PARAM|TCIF_TEXT|TCIF_IMAGE; - - itab.tcih.pszText = TranslateT("Window"); - itab.tcih.iImage = 0; - itab.hwndTabPage = CreateDialog(hInst,MAKEINTRESOURCE(IDD_UMain_CaptureWindow), m_hWnd,(DLGPROC)DlgProc_CaptureWindow); - TabCtrl_InsertItem(m_hwndTab, 0, &itab); - MoveWindow(itab.hwndTabPage, (rcTab.left - rcClient.left)+2, (rcTab.top - rcClient.top), (rcTab.right - rcTab.left) - 2*5, (rcTab.bottom - rcTab.top) - 2*20, TRUE); - ShowWindow(itab.hwndTabPage, SW_HIDE); - CheckDlgButton(itab.hwndTabPage, ID_chkClientArea, m_opt_chkClientArea ? BST_CHECKED : BST_UNCHECKED); - - itab.tcih.pszText = TranslateT("Desktop"); - itab.tcih.iImage = 1; - itab.hwndTabPage = CreateDialog(hInst,MAKEINTRESOURCE(IDD_UMain_CaptureDesktop), m_hWnd, DlgProc_CaptureDesktop); - TabCtrl_InsertItem(m_hwndTab, 1, &itab); - MoveWindow(itab.hwndTabPage, (rcTab.left - rcClient.left)+2, (rcTab.top - rcClient.top), (rcTab.right - rcTab.left) - 2*5, (rcTab.bottom - rcTab.top) - 2*20, TRUE); - ShowWindow(itab.hwndTabPage, SW_HIDE); - - hCtrl = GetDlgItem(itab.hwndTabPage, ID_edtCaption); - ComboBox_ResetContent(hCtrl); - ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("")) ,(DWORD)0); - ComboBox_SetCurSel (hCtrl,0); - if(m_MonitorCount >1) { - TCHAR tszTemp[120]; - for (size_t i = 0; i < m_MonitorCount; ++i) { - mir_sntprintf(tszTemp, SIZEOF(tszTemp),_T("%i. %s%s"), - i+1, - TranslateT("Monitor"), - (m_Monitors[i].dwFlags & MONITORINFOF_PRIMARY) ? TranslateT(" (primary)") : _T("") - ); - ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, (LPCTSTR)tszTemp) , i+1); - } - ComboBox_SelectItemData (hCtrl, -1, m_opt_cboxDesktop); //use Workaround for MS bug ComboBox_SelectItemData - } - PostMessage(m_hWnd, WM_COMMAND, MAKEWPARAM(ID_edtCaption, CBN_SELCHANGE),(LPARAM)hCtrl); - - //select tab and set m_hwndTabPage - TabCtrl_SetCurSel(m_hwndTab, m_opt_tabCapture); - ZeroMemory(&itab, sizeof(itab)); - itab.tcih.mask = TCIF_PARAM; - TabCtrl_GetItem(m_hwndTab,TabCtrl_GetCurSel(m_hwndTab),&itab); - ShowWindow(itab.hwndTabPage,SW_SHOW); - m_hwndTabPage = itab.hwndTabPage; - } - //init Format combo box - { - hCtrl = GetDlgItem(m_hWnd, ID_cboxFormat); - ComboBox_ResetContent(hCtrl); - ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, _T("PNG")),0); - ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, _T("JPG")),1); - ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, _T("BMP")),2); - ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, _T("TIF")),3); - ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, _T("GIF")),4); - ComboBox_SelectItemData (hCtrl, -1, m_opt_cboxFormat); //use Workaround for MS bug ComboBox_SelectItemData - } - //init SendBy combo box - { - hCtrl = GetDlgItem(m_hWnd, ID_cboxSendBy); - ComboBox_ResetContent(hCtrl); - ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("")) ,SS_JUSTSAVE); - if (m_hContact) { - ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("File Transfer")),SS_FILESEND); - } - else if(m_opt_cboxSendBy == SS_FILESEND) { - m_opt_cboxSendBy = SS_IMAGESHACK; - } - ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("E-mail")) ,SS_EMAIL); - if (myGlobals.PluginHTTPExist) { - ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, _T("HTTP Server")) ,SS_HTTPSERVER); - } - else if(m_opt_cboxSendBy == SS_HTTPSERVER) { - m_opt_cboxSendBy = SS_IMAGESHACK; - } - if (myGlobals.PluginFTPExist) { - ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("FTP File")) ,SS_FTPFILE); - } - else if(m_opt_cboxSendBy == SS_FTPFILE) { - m_opt_cboxSendBy = SS_IMAGESHACK; - } - ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("ImageShack")) ,(BYTE)SS_IMAGESHACK); - ComboBox_SelectItemData (hCtrl, -1, m_opt_cboxSendBy); //use Workaround for MS bug ComboBox_SelectItemData - cboxSendByChange(); //enable disable controls - } - //init footer options - CheckDlgButton(m_hWnd,ID_chkOpenAgain, m_opt_chkOpenAgain ? BST_CHECKED : BST_UNCHECKED); - - if (hCtrl = GetDlgItem(m_hWnd, ID_btnAbout)) { - SendDlgItemMessage(m_hWnd, ID_btnAbout, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Information"), MBF_TCHAR); - HICON hIcon = IcoLib_GetIcon(ICO_PLUG_SSHELP); - SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); - SetWindowText(hCtrl, hIcon ? _T("") : _T("?")); - } - - if (hCtrl = GetDlgItem(m_hWnd, ID_btnExplore)) { - SendDlgItemMessage(m_hWnd, ID_btnExplore, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Open Folder"), MBF_TCHAR); - HICON hIcon = IcoLib_GetIcon(ICO_PLUG_SSFOLDERO); - SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); - SetWindowText(hCtrl, hIcon ? _T("") : _T("...")); - } - - if (hCtrl = GetDlgItem(m_hWnd, ID_btnDesc)) { - SendDlgItemMessage(m_hWnd, ID_btnDesc, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Fill description textbox."), MBF_TCHAR); - HICON hIcon = IcoLib_GetIcon(m_opt_btnDesc ? ICO_PLUG_SSDESKON : ICO_PLUG_SSDESKOFF); - SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); - SetWindowText(hCtrl, hIcon ? _T("") : _T("D")); - SendMessage(hCtrl, BM_SETCHECK, m_opt_btnDesc ? BST_CHECKED : BST_UNCHECKED, NULL); - } - - if (hCtrl = GetDlgItem(m_hWnd, ID_btnDeleteAfterSend)) { - SendDlgItemMessage(m_hWnd, ID_btnDeleteAfterSend, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Delete after send"), MBF_TCHAR); - HICON hIcon = IcoLib_GetIcon(m_opt_btnDeleteAfterSend ? ICO_PLUG_SSDELON : ICO_PLUG_SSDELOFF); - SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); - SetWindowText(hCtrl, hIcon ? _T("") : _T("X")); - SendMessage(hCtrl, BM_SETCHECK, m_opt_btnDeleteAfterSend ? BST_CHECKED : BST_UNCHECKED, NULL); - } - - if (hCtrl = GetDlgItem(m_hWnd, ID_btnCapture)) { - SendDlgItemMessage(m_hWnd, ID_btnCapture, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Capture"), MBF_TCHAR); - HICON hIcon = IcoLib_GetIcon(ICO_BTN_OK); - SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); - SetWindowText(hCtrl, TranslateT("&Capture")); - SendMessage(hCtrl, BUTTONSETDEFAULT, (WPARAM)1, NULL); - } - -// CheckDlgButton(m_hWnd,ID_chkEditor, m_opt_chkEditor ? BST_CHECKED : BST_UNCHECKED); - TranslateDialogDefault(m_hWnd); - return FALSE; -} - -//WM_COMMAND: -LRESULT TfrmMain::wmCommand(WPARAM wParam, LPARAM lParam) { - //--------------------------------------------------------------------------- - int IDControl = LOWORD(wParam); - switch (HIWORD(wParam)) { - case BN_CLICKED: //Button controls - switch(IDControl) { - case IDCANCEL: - case IDCLOSE: - break; - - case ID_chkTimed: - m_opt_chkTimed = (BYTE)Button_GetCheck((HWND)lParam); - TfrmMain::chkTimedClick(); - break; - case ID_chkClientArea: - m_opt_chkClientArea = (BYTE)Button_GetCheck((HWND)lParam); - if(m_hTargetWindow) - edtSizeUpdate(m_hTargetWindow, m_opt_chkClientArea, GetParent((HWND)lParam), ID_edtSize); - break; - case ID_chkOpenAgain: - m_opt_chkOpenAgain = (BYTE)Button_GetCheck((HWND)lParam); - break; - case ID_chkEditor: - m_opt_chkEditor = (BYTE)Button_GetCheck((HWND)lParam); - break; - - case ID_btnAbout: - TfrmMain::btnAboutClick(); - break; - case ID_btnExplore: - TfrmMain::btnExploreClick(); - break; - case ID_btnDesc: - { - m_opt_btnDesc = (m_opt_btnDesc == 0); - HICON hIcon = IcoLib_GetIcon(m_opt_btnDesc ? ICO_PLUG_SSDESKON : ICO_PLUG_SSDESKOFF); - SendMessage((HWND)lParam, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); - } - break; - case ID_btnDeleteAfterSend: - { - m_opt_btnDeleteAfterSend = (m_opt_btnDeleteAfterSend == 0); - HICON hIcon = IcoLib_GetIcon(m_opt_btnDeleteAfterSend ? ICO_PLUG_SSDELON : ICO_PLUG_SSDELOFF); - SendMessage((HWND)lParam, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); - if(m_cSend) m_cSend->m_bDeleteAfterSend = m_opt_btnDeleteAfterSend; - } - break; - case ID_btnCapture: - TfrmMain::btnCaptureClick(); - break; - default: - break; - } - break; - case CBN_SELCHANGE: //ComboBox controls - switch(IDControl) { - //lParam = Handle to the control - case ID_cboxFormat: //not finish - m_opt_cboxFormat = (BYTE)ComboBox_GetItemData((HWND)lParam, ComboBox_GetCurSel((HWND)lParam)); - break; - case ID_cboxSendBy: - m_opt_cboxSendBy = (BYTE)ComboBox_GetItemData((HWND)lParam, ComboBox_GetCurSel((HWND)lParam)); - cboxSendByChange(); - break; - case ID_edtCaption: //cboxDesktopChange - m_opt_cboxDesktop = (BYTE)ComboBox_GetItemData((HWND)lParam, ComboBox_GetCurSel((HWND)lParam)); - m_hTargetWindow = 0; - if (m_opt_cboxDesktop > 0) { - edtSizeUpdate(m_Monitors[m_opt_cboxDesktop-1].rcMonitor, GetParent((HWND)lParam), ID_edtSize); - } - else { - edtSizeUpdate(m_VirtualScreen, GetParent((HWND)lParam), ID_edtSize); - } - break; - default: - break; - } - break; - case EN_CHANGE: //Edit controls - switch(IDControl) { - //lParam = Handle to the control - case ID_edtQuality: - m_opt_edtQuality = (BYTE)GetDlgItemInt(m_hWnd, ID_edtQuality, NULL, FALSE); - break; - case ID_edtTimed: - m_opt_edtTimed = (BYTE)GetDlgItemInt(m_hWnd, ID_edtTimed, NULL, FALSE); - break; - default: - break; - } - break; - default: - break; - } - return FALSE; -} - -//WM_CLOSE: -LRESULT TfrmMain::wmClose(WPARAM wParam, LPARAM lParam) { - DestroyWindow(m_hWnd); - return FALSE; -} - -//WM_TIMER: -LRESULT TfrmMain::wmTimer(WPARAM wParam, LPARAM lParam) { - if (wParam == ID_bvlTarget) { // Timer for Target selector - if (m_hCursor) { //imgTarget is activ - //LmouseButton = false - if (!GetLmouse()) { - TfrmMain::imgTargetMouseUp(); - return FALSE; - } - //Timer action if LmouseButton = true - m_hLastWin = m_hTargetWindow; - POINT point={0}; - GetCursorPos(&point); - HWND hCurrentWin = WindowFromPoint(point); - while (GetParent(hCurrentWin)) { - hCurrentWin = GetParent(hCurrentWin); - } - if (m_hLastWin != hCurrentWin) { - LPTSTR lpTitle = NULL; - if (m_hLastWin) { - DrawBorderInverted(m_hLastWin); - } - int Count = GetWindowTextLength(hCurrentWin)+1; - if(Count > 1){ - lpTitle = (LPTSTR)mir_alloc(Count*sizeof(TCHAR)); - GetWindowText(hCurrentWin, lpTitle, Count); - } - else { - //no WindowText present, use WindowClass - lpTitle = (LPTSTR)mir_alloc(MAX_PATH*sizeof(TCHAR)); - RealGetWindowClass(hCurrentWin, lpTitle, MAX_PATH); - } - SetDlgItemText(m_hwndTabPage, ID_edtCaption, lpTitle); - mir_free(lpTitle); - edtSizeUpdate(hCurrentWin, m_opt_chkClientArea, m_hwndTabPage, ID_edtSize); - DrawBorderInverted(hCurrentWin); - m_hTargetWindow = hCurrentWin; - } - return FALSE; - } - //imgTarget is not activ (check if cursor is over ID_bvlTarget control) - RECT rc; - POINT pt; - GetWindowRect(GetDlgItem(m_hwndTabPage, wParam),&rc); - GetCursorPos(&pt); - //check Mouse cursor - if(!PtInRect(&rc,pt)) { // mouse must be gone, trigger mouse leave - //PostMessage(m_hWnd,WM_MOUSELEAVE,wParam,lParam); - KillTimer(m_hWnd,wParam); - } - else if (GetLmouse() && !m_hCursor) { //mouse hover + LButton - TfrmMain::imgTargetMouseDown(); - } - } - if (wParam == ID_chkTimed) { // Timer for Screenshot - #ifdef _DEBUG - OutputDebugStringA("SS Bitmap Timer Start\r\n" ); - #endif - if(!m_bCapture) { //only start once - if (m_Screenshot) { - FIP->FI_Unload(m_Screenshot); - m_Screenshot = NULL; - } - m_bCapture = true; - switch (m_opt_tabCapture) { - case 0: - m_Screenshot = CaptureWindow(m_hTargetWindow, (BOOL)m_opt_chkClientArea); - break; - case 1: - m_Screenshot = CaptureMonitor((m_opt_cboxDesktop > 0) ? m_Monitors[m_opt_cboxDesktop-1].szDevice : NULL); - break; - default: - KillTimer(m_hWnd,wParam); - m_bCapture = false; - #ifdef _DEBUG - OutputDebugStringA("SS Bitmap Timer Stop (no tabCapture)\r\n" ); - #endif - return FALSE; - } - if (!m_Screenshot) m_bCapture = false; - } - if (m_Screenshot) { - KillTimer(m_hWnd,wParam); - m_bCapture = false; - #ifdef _DEBUG - OutputDebugStringA("SS Bitmap Timer Stop (CaptureDone)\r\n" ); - #endif - SendMessage(m_hWnd,UM_EVENT, (WPARAM)0, (LPARAM)EVT_CaptureDone); - } - } - return FALSE; -} - -//WM_NOTIFY: -LRESULT TfrmMain::wmNotify(WPARAM wParam, LPARAM lParam) { - switch(((LPNMHDR)lParam)->idFrom) { - case IDC_CAPTURETAB: //TabControl IDC_CAPTURETAB - switch (((LPNMHDR)lParam)->code) { - // HWND hwndFrom; = member is handle to the tab control - // UINT_PTR idFrom; = member is the child window identifier of the tab control. - // UINT code; = member is TCN_SELCHANGE - case TCN_SELCHANGING: - { - TAB_INFO itab; - ZeroMemory(&itab, sizeof(itab)); - itab.tcih.mask = TCIF_PARAM; - TabCtrl_GetItem(m_hwndTab,TabCtrl_GetCurSel(m_hwndTab),&itab); - ShowWindow(itab.hwndTabPage,SW_HIDE); - m_hwndTabPage = NULL; - } - break; - - case TCN_SELCHANGE: - { - TAB_INFO itab; - ZeroMemory(&itab, sizeof(itab)); - itab.tcih.mask = TCIF_PARAM; - m_opt_tabCapture = TabCtrl_GetCurSel(m_hwndTab); - TabCtrl_GetItem(m_hwndTab, m_opt_tabCapture, &itab); - ShowWindow(itab.hwndTabPage, SW_SHOW); - m_hwndTabPage = itab.hwndTabPage; - } - break; - default: - break; - } - break; - default: - break; - } - return FALSE; -} - -//UM_CLOSING: -LRESULT TfrmMain::UMClosing(WPARAM wParam, LPARAM lParam) { - HWND hWnd = (HWND)wParam; - switch (lParam) { - case IDD_UAboutForm: - btnAboutOnCloseWindow(hWnd); - break; - case IDD_UEditForm: - ; - break; - default: - break; - } - return FALSE; -} - -//UM_TAB1: -LRESULT TfrmMain::UMTab1(WPARAM wParam, LPARAM lParam) { - switch (wParam) { - case WM_MOUSEMOVE: - if (m_opt_tabCapture == 0) { - // Call timer, used to start cheesy TrackMouseEvent faker - SetTimer(m_hWnd,ID_bvlTarget,BUTTON_POLLDELAY,NULL); - } - break; - default: - break; - } - return FALSE; -} - -//UM_EVENT: -LRESULT TfrmMain::UMevent(WPARAM wParam, LPARAM lParam) { - //HWND hWnd = (HWND)wParam; - switch (lParam) { - case EVT_CaptureDone: - if (!m_Screenshot) { - TCHAR *err = TranslateT("Cant create a Screenshot"); - MessageBox(m_hWnd,err,ERROR_TITLE,MB_OK|MB_ICONWARNING); - Show(); - return FALSE; - } - if (m_opt_chkEditor) { - /* TfrmEdit *frmEdit=new TfrmEdit(this); - m_bFormEdit = true; - - frmEdit->mniClose->Enabled = !chkJustSaveIt->Checked; - frmEdit->mniCloseSend->Enabled = frmEdit->mniClose->Enabled; - frmEdit->OnClose = OnCloseEditWindow; - frmEdit->InitEditor(Screenshot); // Screenshot is copied to another in-memory bitmap inside this method - frmEdit->Show(); - delete Screenshot; // This way we can delete it after the method returns - Screenshot = NULL; - */ - return FALSE; - } - else { - FormClose(); - } - break; - case EVT_SendFileDone: - break; - case EVT_CheckOpenAgain: - if (m_opt_chkOpenAgain) { - if (m_Screenshot) { - FIP->FI_Unload(m_Screenshot); - m_Screenshot = NULL; - } - m_hTargetWindow = m_hLastWin = NULL; - Show(); - } - else { - // Saving Options and close - SaveOptions(); - Close(); - } - break; - default: - break; - } - return FALSE; -} - -//--------------------------------------------------------------------------- -// Standard konstruktor/destruktor -TfrmMain::TfrmMain() { - m_hWnd = NULL; - m_hContact = NULL; - m_hTargetWindow = NULL; - m_hCursor = NULL; - m_Screenshot = NULL; - m_pszFile = m_pszFileDesc = m_FDestFolder = NULL; - m_bFormAbout = m_bFormEdit = m_bDeleteAfterSend = m_bSelectingWindow = false; - m_cSend = NULL; - m_bOnExitSave = TRUE; - LoadOptions(); - m_bCapture = false; - m_himlTab = NULL; - m_Monitors = NULL; - m_MonitorCount = MonitorInfoEnum(m_Monitors, m_VirtualScreen); - -} - -TfrmMain::~TfrmMain() { - _HandleMapping.erase(m_hWnd); - mir_free(m_pszFile); - mir_free(m_FDestFolder); - mir_free(m_pszFileDesc); - mir_free(m_Monitors); - if (m_Screenshot) FIP->FI_Unload(m_Screenshot); - if (m_cSend) delete m_cSend; -} - -//--------------------------------------------------------------------------- -// Load / Saving options from miranda's database -void TfrmMain::LoadOptions(void) { - DWORD rgb = DBGetContactSettingDword(NULL, SZ_SENDSS, "AlphaColor", 16777215); - m_AlphaColor.rgbRed = GetRValue(rgb); - m_AlphaColor.rgbGreen = GetGValue(rgb); - m_AlphaColor.rgbBlue = GetBValue(rgb); - m_AlphaColor.rgbReserved = 0; - -// m_opt_chkEmulateClick = DBGetContactSettingByte(NULL, SZ_SENDSS, "AutoSend", 1); - m_opt_edtQuality = DBGetContactSettingByte(NULL, SZ_SENDSS, "JpegQuality", 75); - - m_opt_tabCapture = DBGetContactSettingByte(NULL, SZ_SENDSS, "Capture", 0); - m_opt_chkClientArea = DBGetContactSettingByte(NULL, SZ_SENDSS, "ClientArea", 0); - m_opt_cboxDesktop = DBGetContactSettingByte(NULL, SZ_SENDSS, "Desktop", 0); - - m_opt_chkTimed = DBGetContactSettingByte(NULL, SZ_SENDSS, "TimedCap", 0); - m_opt_edtTimed = DBGetContactSettingByte(NULL, SZ_SENDSS, "CapTime", 3); - m_opt_cboxFormat = DBGetContactSettingByte(NULL, SZ_SENDSS, "OutputFormat", 3); - m_opt_cboxSendBy = DBGetContactSettingByte(NULL, SZ_SENDSS, "SendBy", 0); - - m_opt_chkEditor = DBGetContactSettingByte(NULL, SZ_SENDSS, "Preview", 0); - m_opt_btnDesc = DBGetContactSettingByte(NULL, SZ_SENDSS, "AutoDescription", 1); - m_opt_btnDeleteAfterSend = DBGetContactSettingByte(NULL, SZ_SENDSS, "DelAfterSend", 1); - m_opt_chkOpenAgain = DBGetContactSettingByte(NULL, SZ_SENDSS, "OpenAgain", 0); -} - -void TfrmMain::SaveOptions(void) { - if(m_bOnExitSave) { - DBWriteContactSettingDword(NULL, SZ_SENDSS, "AlphaColor", - (DWORD)RGB(m_AlphaColor.rgbRed, m_AlphaColor.rgbGreen, m_AlphaColor.rgbBlue)); - -// DBWriteContactSettingByte(NULL, SZ_SENDSS, "AutoSend", m_opt_chkEmulateClick); - DBWriteContactSettingByte(NULL, SZ_SENDSS, "JpegQuality", m_opt_edtQuality); - - DBWriteContactSettingByte(NULL, SZ_SENDSS, "Capture", m_opt_tabCapture); - DBWriteContactSettingByte(NULL, SZ_SENDSS, "ClientArea", m_opt_chkClientArea); - DBWriteContactSettingByte(NULL, SZ_SENDSS, "Desktop", m_opt_cboxDesktop); - - DBWriteContactSettingByte(NULL, SZ_SENDSS, "TimedCap", m_opt_chkTimed); - DBWriteContactSettingByte(NULL, SZ_SENDSS, "CapTime", m_opt_edtTimed); - DBWriteContactSettingByte(NULL, SZ_SENDSS, "OutputFormat", m_opt_cboxFormat); - DBWriteContactSettingByte(NULL, SZ_SENDSS, "SendBy", m_opt_cboxSendBy); - - DBWriteContactSettingByte(NULL, SZ_SENDSS, "AutoDescription", m_opt_btnDesc); - DBWriteContactSettingByte(NULL, SZ_SENDSS, "DelAfterSend", m_opt_btnDeleteAfterSend); - DBWriteContactSettingByte(NULL, SZ_SENDSS, "OpenAgain", m_opt_chkOpenAgain); - DBWriteContactSettingByte(NULL, SZ_SENDSS, "Preview", m_opt_chkEditor); - } -} - -//--------------------------------------------------------------------------- -void TfrmMain::Init(LPTSTR DestFolder, HANDLE Contact) { - m_FDestFolder = mir_tstrdup(DestFolder); - m_hContact = Contact; - if(!m_hContact) m_opt_cboxSendBy = SS_JUSTSAVE; - - // create window - m_hWnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_UMainForm),0, (DLGPROC)DlgTfrmMain,(LPARAM)this); - //register object - _HandleMapping.insert(CHandleMapping::value_type(m_hWnd, this)); - - //check Contact - if(m_cSend) m_cSend->SetContact(Contact); -} - -//--------------------------------------------------------------------------- -void TfrmMain::btnCaptureClick() { - m_bFormEdit = false; //until UEditForm is includet - - if (m_opt_tabCapture == 0 && m_hTargetWindow == 0) { - TCHAR *err = TranslateT("Select a target window."); - MessageBox(m_hWnd,err,ERROR_TITLE,MB_OK|MB_ICONWARNING); - return; - } - TfrmMain::Hide(); - - if (!m_hTargetWindow) m_hTargetWindow = GetDesktopWindow(); - - if (m_opt_chkTimed) { - SetTimer(m_hWnd, ID_chkTimed, m_opt_edtTimed ? m_opt_edtTimed*1000 : 500, NULL); - } - else if (m_opt_tabCapture == 1){ - //desktop need always time to update from TfrmMain::Hide() - SetTimer(m_hWnd, ID_chkTimed, 500, NULL); - } - else { - m_Screenshot = CaptureWindow(m_hTargetWindow, (BOOL)(m_opt_chkClientArea)); - SendMessage(m_hWnd,UM_EVENT, (WPARAM)0, (LPARAM)EVT_CaptureDone); - } -} - -//--------------------------------------------------------------------------- -void TfrmMain::chkTimedClick() { - Button_Enable(GetDlgItem(m_hWnd, ID_edtTimedLabel), (BOOL)m_opt_chkTimed); - Button_Enable(GetDlgItem(m_hWnd, ID_edtTimed), (BOOL)m_opt_chkTimed); - Button_Enable(GetDlgItem(m_hWnd, ID_upTimed), (BOOL)m_opt_chkTimed); -} - -//--------------------------------------------------------------------------- -void TfrmMain::imgTargetMouseDown() { - //if (Button != mbLeft) return; - m_hCursor = CopyCursor(GetCursor()); //backup cursor - //SetSystemCursor need a copy coz it destroy the handle - SetSystemCursor(CopyCursor(IcoLib_GetIcon(ICO_PLUG_SSTARGET)),OCR_NORMAL); - m_bSelectingWindow = true; - m_hTargetWindow = NULL; - Hide(); - SetCapture(m_hWnd); -} - -//--------------------------------------------------------------------------- -void TfrmMain::imgTargetMouseUp() { - //if (Button == mbLeft && m_bSelectingWindow && TimerCheckFocus->Enabled) - if (m_bSelectingWindow && m_hCursor) { - Show(); - ReleaseCapture(); - SetSystemCursor(m_hCursor, OCR_NORMAL); - m_hCursor = NULL; - if (m_hTargetWindow){ - DrawBorderInverted(m_hTargetWindow); - } - m_bSelectingWindow = false; - } -} - -//--------------------------------------------------------------------------- -void TfrmMain::cboxSendByChange() { - BOOL bState; - HICON hIcon; - BYTE itemFlag = SS_DLG_DESCRIPTION; //SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND | - if (m_cSend && !m_cSend->m_bFreeOnExit) { - delete m_cSend; - m_cSend = NULL; - } - switch(m_opt_cboxSendBy) { - case SS_FILESEND: //"File Transfer" - m_cSend = new CSendFile(m_hWnd, m_hContact, false); - break; - case SS_EMAIL: //"E-mail" - m_cSend = new CSendEmail(m_hWnd, m_hContact, false); - break; - case SS_HTTPSERVER: //"HTTP Server" - m_cSend = new CSendHTTPServer(m_hWnd, m_hContact, false); - break; - case SS_FTPFILE: //"FTP File" - m_cSend = new CSendFTPFile(m_hWnd, m_hContact, false); - break; - case SS_IMAGESHACK: //"ImageShack" - m_cSend = new CSendImageShack(m_hWnd, m_hContact, false); - break; - default: //SS_JUSTSAVE - "Just save it " - m_cSend = NULL; - break; - } - if(m_cSend){ - itemFlag = m_cSend->GetEnableItem(); - m_cSend->m_bDeleteAfterSend = m_opt_btnDeleteAfterSend; - } - bState = ((itemFlag & SS_DLG_DELETEAFTERSSEND) == SS_DLG_DELETEAFTERSSEND); - hIcon = IcoLib_GetIcon(m_opt_btnDeleteAfterSend ? ICO_PLUG_SSDELON : ICO_PLUG_SSDELOFF); - SendMessage(GetDlgItem(m_hWnd, ID_btnDeleteAfterSend), BM_SETIMAGE, IMAGE_ICON, (LPARAM)(bState ? hIcon : 0)); - Button_Enable(GetDlgItem(m_hWnd, ID_btnDeleteAfterSend), bState); - - bState = ((itemFlag & SS_DLG_DESCRIPTION) == SS_DLG_DESCRIPTION); - hIcon = IcoLib_GetIcon(m_opt_btnDesc ? ICO_PLUG_SSDESKON : ICO_PLUG_SSDESKOFF); - SendMessage(GetDlgItem(m_hWnd, ID_btnDesc), BM_SETIMAGE, IMAGE_ICON, (LPARAM)(bState ? hIcon : 0)); - Button_Enable(GetDlgItem(m_hWnd, ID_btnDesc), bState); -} - -//--------------------------------------------------------------------------- -void TfrmMain::btnAboutClick() { - if (m_bFormAbout) return; - - TfrmAbout *frmAbout=new TfrmAbout(m_hWnd); - frmAbout->Show(); - m_bFormAbout = true; -} - -// Edit window call this event before it closes -void TfrmMain::btnAboutOnCloseWindow(HWND hWnd) { - m_bFormAbout = false; -} - -//--------------------------------------------------------------------------- -void TfrmMain::btnExploreClick() { - if (m_FDestFolder) - ShellExecute(NULL, _T("explore"), m_FDestFolder, NULL, NULL, SW_SHOW); -} - -//--------------------------------------------------------------------------- -void TfrmMain::edtSizeUpdate(HWND hWnd, BOOL ClientArea, HWND hTarget, UINT Ctrl) { - // get window dimensions - RECT rect = {0}; - RECT cliRect = {0}; - TCHAR B[33], H[16]; - GetWindowRect(hWnd, &rect); - if (ClientArea) { - POINT pt = {0}; - GetClientRect(hWnd, &cliRect); - pt.x = cliRect.left; - pt.y = cliRect.top; - ClientToScreen(hWnd, &pt); - pt.x = pt.x - rect.left; //offset x for client area - pt.y = pt.y - rect.top; //offset y for client area - rect = cliRect; - } -// _itot_s(rect.right - rect.left, B, 33, 10); - _itot(rect.right - rect.left, B, 10); -// _itot_s(rect.bottom - rect.top, H, 16, 10); - _itot(rect.bottom - rect.top, H, 10); - mir_tcsncat(B, _T("x"), 33); - mir_tcsncat(B, H, 33); - SetDlgItemText(hTarget, Ctrl, B); -} - -void TfrmMain::edtSizeUpdate(RECT rect, HWND hTarget, UINT Ctrl) { - TCHAR B[33], H[16]; -// _itot_s(ABS(rect.right - rect.left), B, 33, 10); - _itot(ABS(rect.right - rect.left), B, 10); -// _itot_s(ABS(rect.bottom - rect.top), H, 16, 10); - _itot(ABS(rect.bottom - rect.top), H, 10); - mir_tcsncat(B, _T("x"), 33); - mir_tcsncat(B, H, 33); - SetDlgItemText(hTarget, Ctrl, B); -} - -//--------------------------------------------------------------------------- -INT_PTR TfrmMain::SaveScreenshot(FIBITMAP* dib) { - //generate File name - FREE_IMAGE_FORMAT fif = FIF_UNKNOWN; - LPTSTR ret = NULL; - LPTSTR path = NULL; - LPTSTR pszFilename = NULL; - LPTSTR pszFileDesc = NULL; - if (!dib) return 1; //error - - //Generate FileName - mir_tcsadd(path, m_FDestFolder); - if (path[_tcslen(path)-1] != _T('\\')) mir_tcsadd(path, _T("\\")); - mir_tcsadd(path, _T("shot%.5ld")); - int FileNumber=DBGetContactSettingDword(NULL, SZ_SENDSS, "FileNumber", 0) + 1; - // '00000'-'%.5ld'=0 (add more or less len if differ from 5 - size_t len = (_tcslen(path)+0+1); - pszFilename = (LPTSTR)mir_alloc(sizeof(TCHAR)*(len)); - mir_sntprintf(pszFilename, len, path, FileNumber); - mir_free(path); - - //Generate a description according to the screenshot - TCHAR winText[1024]; - mir_tcsadd(pszFileDesc, _T("Screenshot ")); - if (m_opt_tabCapture == 0 && m_opt_chkClientArea) { - mir_tcsadd(pszFileDesc, _T("for Client area ")); - } - mir_tcsadd(pszFileDesc, _T("of \"")); - GetDlgItemText(m_hwndTabPage, ID_edtCaption, winText, 1024); - mir_tcsadd(pszFileDesc, winText); - mir_tcsadd(pszFileDesc, _T("\" Window")); - - // convert to 32Bits (make shure it is 32bit) - FIBITMAP *dib_new = FIP->FI_ConvertTo32Bits(dib); - //RGBQUAD appColor = { 245, 0, 254, 0 }; //bgr0 schwarz - //FIP->FI_SetBackgroundColor(dib_new, &appColor); - FIP->FI_SetTransparent(dib_new,TRUE); - - // Investigates the color type of the bitmap (test for RGB or CMYK colour space) - switch (FREE_IMAGE_COLOR_TYPE ColTye=FIP->FI_GetColorType(dib_new)) { - case FIC_MINISBLACK: - //Monochrome bitmap (1-bit) : first palette entry is black. - //Palletised bitmap (4 or 8-bit) and single channel non standard bitmap: the bitmap has a greyscale palette - case FIC_MINISWHITE: - //Monochrome bitmap (1-bit) : first palette entry is white. - //Palletised bitmap (4 or 8-bit) : the bitmap has an inverted greyscale palette - case FIC_PALETTE: - //Palettized bitmap (1, 4 or 8 bit) - case FIC_RGB: - //High-color bitmap (16, 24 or 32 bit), RGB16 or RGBF - case FIC_RGBALPHA: - //High-color bitmap with an alpha channel (32 bit bitmap, RGBA16 or RGBAF) - case FIC_CMYK: - //CMYK bitmap (32 bit only) - default: - break; - } - - - if ((FIP->FI_GetICCProfile(dib_new)->flags & FIICC_COLOR_IS_CMYK) == FIICC_COLOR_IS_CMYK) { - // we are in CMYK colour space - bool bDummy = false; - } - else { - // we are in RGB colour space - bool bDummy = true; - } - - FIBITMAP *dib32 = NULL; - FIBITMAP *dib24 = NULL; - HWND hwndCombo = GetDlgItem(m_hWnd, ID_cboxFormat); - switch (ComboBox_GetItemData(hwndCombo, ComboBox_GetCurSel(hwndCombo))) { - case 0: //PNG - ret = SaveImage(fif,dib_new, pszFilename, _T("png")); - break; - - case 1: //JPG - /* - #define JPEG_QUALITYSUPERB 0x80 // save with superb quality (100:1) - #define JPEG_QUALITYGOOD 0x0100 // save with good quality (75:1) - #define JPEG_QUALITYNORMAL 0x0200 // save with normal quality (50:1) - #define JPEG_QUALITYAVERAGE 0x0400 // save with average quality (25:1) - #define JPEG_QUALITYBAD 0x0800 // save with bad quality (10:1) - #define JPEG_PROGRESSIVE 0x2000 // save as a progressive-JPEG (use | to combine with other save flags) - */ - dib32 = FIP->FI_Composite(dib_new,FALSE,&m_AlphaColor,NULL); - dib24 = FIP->FI_ConvertTo24Bits(dib32); - FIP->FI_Unload(dib32); dib32 = NULL; - ret = SaveImage(fif,dib24, pszFilename, _T("jpg")); - FIP->FI_Unload(dib24); dib24 = NULL; - break; - - case 2: //BMP - // ret = SaveImage(FIF_BMP,dib_new, pszFilename, _T("bmp")); //32bit alpha BMP - dib32 = FIP->FI_Composite(dib_new,FALSE,&m_AlphaColor,NULL); - dib24 = FIP->FI_ConvertTo24Bits(dib32); - FIP->FI_Unload(dib32); dib32 = NULL; - ret = SaveImage(FIF_BMP,dib24, pszFilename, _T("bmp")); - FIP->FI_Unload(dib24); dib24 = NULL; - break; - - case 3: //TIFF (miranda freeimage interface do not support save tiff, we udse GDI+) - { - LPTSTR pszFile = NULL; - mir_tcsadd(pszFile, pszFilename); - mir_tcsadd(pszFile, _T(".tif")); - - dib32 = FIP->FI_Composite(dib_new,FALSE,&m_AlphaColor,NULL); - dib24 = FIP->FI_ConvertTo24Bits(dib32); - FIP->FI_Unload(dib32); dib32 = NULL; - - HBITMAP hBmp = FIP->FI_CreateHBITMAPFromDIB(dib24); - FIP->FI_Unload(dib24); dib24 = NULL; - ret = SaveTIF(hBmp, pszFile) ? NULL : pszFile; - DeleteObject(hBmp); - } - break; - - case 4: //GIF - { - //dib24 = FIP->FI_ConvertTo8Bits(dib_new); - //ret = SaveImage(FIF_GIF,dib24, pszFilename, _T("gif")); - //FIP->FI_Unload(dib24); dib24 = NULL; - LPTSTR pszFile = NULL; - mir_tcsadd(pszFile, pszFilename); - mir_tcsadd(pszFile, _T(".gif")); - HBITMAP hBmp = FIP->FI_CreateHBITMAPFromDIB(dib_new); - SaveGIF(hBmp, pszFile); - ret = pszFile; - DeleteObject(hBmp); - } - break; - - default: - break; - } -/* //load PNG and save file in user format (if differ) - //this get better result for transparent aereas - //LPTSTR pszFormat = (LPTSTR)ComboBox_GetItemData(hwndCombo, ComboBox_GetCurSel(hwndCombo)); - TCHAR pszFormat[6]; - ComboBox_GetText(hwndCombo, pszFormat, 6); - if(ret && (_tcsicmp (pszFormat,_T("png")) != 0)) { - #if defined(_UNICODE) - fif = FIP->FI_GetFIFFromFilenameU(ret); - dib_new = FIP->FI_LoadU(fif, ret,0); - #else - fif = FIP->FI_GetFIFFromFilenameU(ret); - dib_new = FIP->FI_Load(fif, ret,0); - #endif - - if(dib_new) { - DeleteFile(ret); - mir_freeAndNil(ret); - FIBITMAP *dib_save = FIP->FI_ConvertTo24Bits(dib_new); - ret = SaveImage(FIF_UNKNOWN,dib_save, pszFilename, pszFormat); - FIP->FI_Unload(dib_new); dib_new = NULL; - FIP->FI_Unload(dib_save); dib_save = NULL; - } - }*/ - FIP->FI_Unload(dib_new); dib_new = NULL; - mir_freeAndNil(pszFilename); - - if (ret) { - DBWriteContactSettingDword(NULL, SZ_SENDSS, "FileNumber", (DWORD)FileNumber); - mir_freeAndNil(m_pszFile); - mir_freeAndNil(m_pszFileDesc); - m_pszFile = ret; - if (IsWindowEnabled(GetDlgItem(m_hWnd, ID_btnDesc)) && m_opt_btnDesc) { - m_pszFileDesc = pszFileDesc; - } - else { - mir_tcsadd(m_pszFileDesc, _T("")); - } - - if(m_cSend) { - mir_freeAndNil(m_cSend->m_pszFile); - mir_freeAndNil(m_cSend->m_pszFileDesc); - m_cSend->m_pszFile = mir_tstrdup(m_pszFile); - m_cSend->m_pszFileDesc = mir_tstrdup(m_pszFileDesc); - } - return 0; //OK - } - mir_freeAndNil(ret); - mir_freeAndNil(pszFileDesc); - return 1; //error -} - -//--------------------------------------------------------------------------- -void TfrmMain::FormClose() { - - // Saving the screenshot - if (SaveScreenshot(m_Screenshot)) { - Show(); // Error from SaveScreenshot - return; - } - - if (m_cSend && m_pszFile && m_hContact && !m_bFormEdit) { - m_cSend->Send(); - if (m_cSend->m_bFreeOnExit) cboxSendByChange(); -// Not finish delete this if events from m_opt_cboxSendBy implementet - SendMessage(m_hWnd,UM_EVENT, (WPARAM)0, (LPARAM)EVT_CheckOpenAgain); - } - else { - SendMessage(m_hWnd,UM_EVENT, (WPARAM)0, (LPARAM)EVT_CheckOpenAgain); - } -} - -//--------------------------------------------------------------------------- -/*/ Edit window call this event before it closes -void TfrmMain::OnCloseEditWindow(TObject *Sender, TCloseAction &Action) { - TfrmEdit *form=dynamic_cast(Sender); - form->Hide(); - - // delete the form automatically,after this event returns - Action = caFree; - - // This will saves settings, free resources, ... - form->CallBeforeClose(Action); - - // User selected "Capture" on action menu of edit window - if (form->ModalResult == mrCancel) { - this->Show(); - } else { - Screenshot = form->Screen; - bFormEdit = form->DontSend; - this->Close(); - } -}*/ - -//--------------------------------------------------------------------------- diff --git a/plugins/SendScreenshotPlus/UMainForm.h b/plugins/SendScreenshotPlus/UMainForm.h deleted file mode 100644 index a7fdcdc643..0000000000 --- a/plugins/SendScreenshotPlus/UMainForm.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2009 Miranda ICQ/IM project, - -This file is part of Send Screenshot Plus, a Miranda IM plugin. -Copyright (c) 2010 Ing.U.Horn - -Parts of this file based on original sorce code -(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/UMainForm.h $ -Revision : $Revision: 22 $ -Last change on : $Date: 2010-05-02 21:25:02 +0400 (Р’СЃ, 02 май 2010) $ -Last change by : $Author: ing.u.horn $ - -*/ - -#ifndef UMainFormH -#define UMainFormH -//--------------------------------------------------------------------------- -#include "global.h" -#include "Utils.h" -#include "CSend.h" -#include "CSendFile.h" -#include "CSendImageShack.h" -#include "CSendHTTPServer.h" -#include "CSendFTPFile.h" -#include "CSendEmail.h" - -#define SS_JUSTSAVE 0 -#define SS_FILESEND 1 -#define SS_EMAIL 2 -#define SS_HTTPSERVER 3 -#define SS_FTPFILE 4 -#define SS_IMAGESHACK 5 - -// Used for our own cheap TrackMouseEvent -#define BUTTON_POLLDELAY 50 - -// User Events -#define EVT_CaptureDone 1 -#define EVT_SendFileDone 2 -#define EVT_CheckOpenAgain 3 - -extern FI_INTERFACE *FIP; - -typedef struct MyTabData { - TCITEMHEADER tcih; - HWND hwndMain; //main window - HWND hwndTab; //tab control - HWND hwndTabPage; //current child dialog box -}TAB_INFO; - -//--------------------------------------------------------------------------- -class TfrmMain{ - - public: - // Deklaration Standardkonstruktor/Standarddestructor - TfrmMain(); - ~TfrmMain(); - - BYTE m_opt_tabCapture; //capure tab page - BYTE m_opt_btnDesc; //TCheckBox *chkDesc; - BYTE m_opt_cboxDesktop; //TRadioButton *rbtnDesktop; - BYTE m_opt_chkEditor; //TCheckBox *chkEditor; - BYTE m_opt_chkTimed; //TCheckBox *chkTimed; - BYTE m_opt_cboxSendBy; //TComboBox *cboxSendBy; - bool m_bOnExitSave; - - void Show(){ShowWindow(m_hWnd,SW_SHOW);} - void Hide(){ShowWindow(m_hWnd,SW_HIDE);} - void Close(){SendMessage(m_hWnd,WM_CLOSE,0,0);} - void Init(LPTSTR DestFolder, HANDLE Contact); - void btnCaptureClick(); - void cboxSendByChange(); - - private: - HWND m_hWnd; - HANDLE m_hContact; - bool m_bSelectingWindow, m_bDeleteAfterSend; - bool m_bFormAbout, m_bFormEdit; - HWND m_hTargetWindow, m_hLastWin; - LPTSTR m_FDestFolder; - LPTSTR m_pszFile; - LPTSTR m_pszFileDesc; - FIBITMAP* m_Screenshot; //Graphics::TBitmap *Screenshot; - RGBQUAD m_AlphaColor; // - HCURSOR m_hCursor; - CSend* m_cSend; - - void chkTimedClick(); - void imgTargetMouseDown(); - void imgTargetMouseUp(); - void btnAboutClick(); - void btnAboutOnCloseWindow(HWND hWnd); - void btnExploreClick(); - void LoadOptions(void); - void SaveOptions(void); - INT_PTR SaveScreenshot(FIBITMAP* dib); - void FormClose(); - static void edtSizeUpdate(HWND hWnd, BOOL ClientArea, HWND hTarget, UINT Ctrl); - static void edtSizeUpdate(RECT rect, HWND hTarget, UINT Ctrl); - - protected: - size_t m_MonitorCount; - MONITORINFOEX* m_Monitors; - RECT m_VirtualScreen; - - BYTE m_opt_chkOpenAgain; //TCheckBox *chkOpenAgain; - BYTE m_opt_chkClientArea; //TCheckBox *chkClientArea; - BYTE m_opt_edtQuality; //TLabeledEdit *edtQuality; - BYTE m_opt_btnDeleteAfterSend; //TCheckBox *chkDeleteAfterSend; - BYTE m_opt_cboxFormat; //TComboBox *cboxFormat; - BYTE m_opt_edtTimed; //TLabeledEdit *edtTimed; - bool m_bCapture; //is capture activ - - typedef std::map CHandleMapping; - static CHandleMapping _HandleMapping; - static LRESULT CALLBACK DlgTfrmMain(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); - - LRESULT wmInitdialog(WPARAM wParam, LPARAM lParam); - LRESULT wmCommand(WPARAM wParam, LPARAM lParam); - LRESULT wmClose(WPARAM wParam, LPARAM lParam); - LRESULT wmNotify(WPARAM wParam, LPARAM lParam); - LRESULT wmTimer(WPARAM wParam, LPARAM lParam); - - LRESULT UMevent(WPARAM wParam, LPARAM lParam); - LRESULT UMClosing(WPARAM wParam, LPARAM lParam); - LRESULT UMTab1(WPARAM wParam, LPARAM lParam); - - HWND m_hwndTab; //TabControl handle - HWND m_hwndTabPage; //TabControl activ page handle - HIMAGELIST m_himlTab; //TabControl imagelist - static INT_PTR CALLBACK DlgProc_CaptureWindow (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - static INT_PTR CALLBACK DlgProc_CaptureDesktop(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); -// LRESULT CALLBACK DlgProc_UseLastFile (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - -}; - -//--------------------------------------------------------------------------- - -#endif diff --git a/plugins/SendScreenshotPlus/Utils.cpp b/plugins/SendScreenshotPlus/Utils.cpp deleted file mode 100644 index f1b7251fd7..0000000000 --- a/plugins/SendScreenshotPlus/Utils.cpp +++ /dev/null @@ -1,579 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2009 Miranda ICQ/IM project, - -This file is part of Send Screenshot Plus, a Miranda IM plugin. -Copyright (c) 2010 Ing.U.Horn - -Parts of this file based on original sorce code -(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/Utils.cpp $ -Revision : $Revision: 22 $ -Last change on : $Date: 2010-05-02 21:25:02 +0400 (Р’СЃ, 02 май 2010) $ -Last change by : $Author: ing.u.horn $ - -*/ - -#include "Utils.h" - -//--------------------------------------------------------------------------- -extern HINSTANCE hInst; - -//--------------------------------------------------------------------------- -//Workaround for MS bug ComboBox_SelectItemData -int ComboBox_SelectItemData(HWND hwndCtl, int indexStart, LPARAM data) { - int i = 0; - for ( i ; i < ComboBox_GetCount(hwndCtl); i++) { - if(data == ComboBox_GetItemData(hwndCtl, i)) { - ComboBox_SetCurSel (hwndCtl,i); - return i; - } - } - return CB_ERR; -} - -//--------------------------------------------------------------------------- -// MonitorInfoEnum -size_t MonitorInfoEnum(MONITORINFOEX* & myMonitors, RECT & virtualScreen) { - MONITORS tmp = {0,0}; - if (EnumDisplayMonitors(NULL, NULL, MonitorInfoEnumProc, (LPARAM)&tmp)){ - myMonitors = tmp.info; - memset(&virtualScreen, 0, sizeof(virtualScreen)); - for (size_t i = 0; i < tmp.count; ++i) { - UnionRect(&virtualScreen, &virtualScreen, &tmp.info[i].rcMonitor); - } - return tmp.count; - } - else { - if (tmp.info) mir_free(tmp.info); - } - return 0; -} - -// MonitorInfoEnumProc - CALLBACK for MonitorInfoEnum -BOOL CALLBACK MonitorInfoEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) { - MONITORS* monitors = (MONITORS*)dwData; - monitors->count++; - monitors->info = (MONITORINFOEX*)mir_realloc(monitors->info, sizeof(MONITORINFOEX)*monitors->count); - monitors->info[monitors->count-1].cbSize = sizeof(MONITORINFOEX); - if(!GetMonitorInfo(hMonitor, (LPMONITORINFO)(monitors->info + monitors->count-1))) { - return FALSE; // stop enumeration if error - } - return TRUE; -} - -//--------------------------------------------------------------------------- -// capture window as FIBITMAP - caller must FIP->FI_Unload(dib) -FIBITMAP* CaptureWindow (HWND hCapture, BOOL ClientArea) { - FIBITMAP *dib = NULL; - HWND hForegroundWin = NULL; - HDC hScrDC; // screen DC - RECT rect= {0}; // screen RECT - SIZE size; // DIB width and height = window resolution - - if (!hCapture || !IsWindow(hCapture)) return 0; - hForegroundWin = GetForegroundWindow(); //Saving foreground window - BringWindowToTop(hCapture); // This window bring the target window to the top of all others - SetForegroundWindow(hCapture); // Make sure the target window is the foreground one - // redraw window to prevent runtime artefact in picture - UpdateWindow(hCapture); - - hScrDC = GetWindowDC(hCapture); - - // get window resolution - GetWindowRect(hCapture, &rect); - size.cx = ABS(rect.right - rect.left); - size.cy = ABS(rect.bottom - rect.top); - - //capture window and get FIBITMAP - dib = CaptureScreen(hScrDC, size, hCapture); - - if(ClientArea) { - RECT rectCA = {0}; - POINT pt = {0}; - GetClientRect (hCapture, &rectCA); - ClientToScreen(hCapture, &pt); - //crop the window to ClientArea - FIBITMAP* dibClient = FIP->FI_Copy(dib, - pt.x - rect.left, - pt.y - rect.top, - pt.x - rect.left + rectCA.right -1, - pt.y - rect.top + rectCA.bottom -1); - FIP->FI_Unload(dib); - dib = dibClient; - } - - ReleaseDC(NULL, hScrDC); - - // Restoring foreground window - if (hForegroundWin) { - SetForegroundWindow(hForegroundWin); - } - - return dib; -} - -FIBITMAP* CaptureMonitor (LPTSTR szDevice) { - SIZE size; - HDC hScrDC; - FIBITMAP *dib = NULL; - // get screen resolution - if(!szDevice) { - hScrDC = GetDC(NULL); /*Get full virtualscreen*/ - size.cx = GetSystemMetrics(SM_CXVIRTUALSCREEN); - size.cy = GetSystemMetrics(SM_CYVIRTUALSCREEN); - } - else { - hScrDC = CreateDC(szDevice, NULL, NULL, NULL); - size.cx = GetDeviceCaps(hScrDC, HORZRES); - size.cy = GetDeviceCaps(hScrDC, VERTRES); - } - dib = CaptureScreen (hScrDC, size); - ReleaseDC(NULL, hScrDC); - return dib; -} - -FIBITMAP* CaptureScreen (HDC hDC, SIZE size, HWND hCapture) { -//HDC GetDC (NULL) entire desktp -//HDC GetDC (HWND hWnd) client area of the specified window. -//HDC GetWindowDC (HWND hWnd) entire window. - FIBITMAP *dib = NULL; - HBITMAP hBitmap; // handles to device-dependent bitmaps - HDC hScrDC, hMemDC; // screen DC and memory DC - - // create a DC for the screen and create - // a memory DC compatible to screen DC - hScrDC = hDC ? hDC : GetDC(NULL/*Get full screen*/); - hMemDC = CreateCompatibleDC(hScrDC); - // create a bitmap compatible with the screen DC - hBitmap = CreateCompatibleBitmap(hScrDC, size.cx, size.cy); - - // select new bitmap into memory DC - HBITMAP hOld = (HBITMAP) SelectObject(hMemDC, hBitmap); - - if(hCapture) { - PrintWindow(hCapture, hMemDC, 0/*PW_CLIENTONLY is buggy*/); - } - else { - // bitblt screen DC to memory DC - BitBlt(hMemDC, 0, 0, size.cx, size.cy, hScrDC, 0, 0, CAPTUREBLT|SRCCOPY); - } - - dib = FIP->FI_CreateDIBFromHBITMAP(hBitmap); - - //alpha channel from window is always wrong, - //coz GDI do not draw all in alpha mode. - //we have to create our own new alpha channel. - bool bFixAlpha = true; - bool bInvert = false; - - // Create monochrome (1 bit) B+W mask bitmap. - HBITMAP hMask = CreateBitmap(size.cx,size.cy, 1, 1, NULL); - HDC hMaskDC = CreateCompatibleDC(0); - SelectBitmap(hMaskDC, hMask); - - //Create a SolidBrush object for non transparent area - HBRUSH hBr = CreateSolidBrush(RGB(255,255,255)); - - HRGN hrgn = NULL; - int regionType; - if(hCapture) { - hrgn = CreateRectRgn(0,0,0,0); - regionType = GetWindowRgn(hCapture, hrgn); - if (regionType != ERROR) { - // not layerd - fill the window region - FillRgn(hMaskDC, hrgn, hBr); - } - else { //layerd window (WS_EX_LAYERED) - BYTE bAlpha= 0; - COLORREF crKey=0; //0x00bbggrr - DWORD dwFlags=0; - if(GetLayeredWindowAttributes(hCapture,&crKey,&bAlpha,&dwFlags)) { - //per window transparency (like fading in a whole window). - if((dwFlags & LWA_ALPHA) == LWA_ALPHA) { - //Use bAlpha to determine the opacity of the layered window. - bFixAlpha = false; - } - if((dwFlags & LWA_COLORKEY) == LWA_COLORKEY) { - //Use crKey as the transparency color. - SetBkColor(hMemDC, crKey); - BitBlt(hMaskDC, 0, 0, size.cx, size.cy, hMemDC, 0, 0, SRCCOPY); - bInvert = true; - bFixAlpha = true; - } - } - else { - //per-pixel transparency (won't use the WM_PAINT ) - bFixAlpha = false; - } - } - } - else { //fill the desktop region - hrgn = CreateRectRgn(0,0,size.cx,size.cy); - FillRgn(hMaskDC, hrgn, hBr); - } - - if(bFixAlpha) { - FIBITMAP* dibMask = FIP->FI_CreateDIBFromHBITMAP(hMask); - if(bInvert) FIP->FI_Invert(dibMask); - FIBITMAP* dib8 = FIP->FI_ConvertTo8Bits(dibMask); - - //copy the dib8 alpha mask to dib32 main bitmap - FIP->FI_SetChannel(dib,dib8,FICC_ALPHA); - FIP->FI_Unload(dibMask); - FIP->FI_Unload(dib8); - } - - //clean up - DeleteObject(hBr); - if(hrgn) DeleteObject(hrgn); - DeleteDC(hMaskDC); - DeleteObject(hMask); - SelectObject(hMemDC, hOld); - DeleteDC(hMemDC); - if(!hDC) ReleaseDC(NULL, hScrDC); - DeleteObject(hBitmap); - - #ifdef _DEBUG - switch (FIP->FI_GetImageType(dib)){ - case FIT_UNKNOWN: - OutputDebugStringA("FIBITMAP Typ: FIT_UNKNOWN\r\n" ); - break; - case FIT_BITMAP: - OutputDebugStringA("FIBITMAP Typ: FIT_BITMAP\r\n" ); - break; - case FIT_UINT16: - OutputDebugStringA("FIBITMAP Typ: FIT_UINT16\r\n" ); - break; - case FIT_INT16: - OutputDebugStringA("FIBITMAP Typ: FIT_INT16\r\n" ); - break; - case FIT_UINT32: - OutputDebugStringA("FIBITMAP Typ: FIT_UINT32\r\n" ); - break; - case FIT_INT32: - OutputDebugStringA("FIBITMAP Typ: FIT_INT32\r\n" ); - break; - case FIT_FLOAT: - OutputDebugStringA("FIBITMAP Typ: FIT_FLOAT\r\n" ); - break; - case FIT_DOUBLE: - OutputDebugStringA("FIBITMAP Typ: FIT_DOUBLE\r\n" ); - break; - case FIT_COMPLEX: - OutputDebugStringA("FIBITMAP Typ: FIT_COMPLEX\r\n" ); - break; - case FIT_RGB16: - OutputDebugStringA("FIBITMAP Typ: FIT_RGB16\r\n" ); - break; - case FIT_RGBA16: - OutputDebugStringA("FIBITMAP Typ: FIT_RGBA16\r\n" ); - break; - case FIT_RGBF: - OutputDebugStringA("FIBITMAP Typ: FIT_RGBF\r\n" ); - break; - case FIT_RGBAF: - OutputDebugStringA("FIBITMAP Typ: FIT_RGBAF\r\n" ); - break; - default: - OutputDebugStringA("FIBITMAP Typ: nicht feststellbar\r\n" ); - break; - } - BOOL inf = FIP->FI_IsTransparent(dib); - OutputDebugStringA(inf ? "FIBITMAP Transparent: true\r\n" : "FIBITMAP Transparent: fase\r\n"); - #endif - - return dib; -} - -FIBITMAP* CaptureDesktop/*emulate print screen*/() { - FIBITMAP *dib = NULL; - HBITMAP hBitmap; // handles to device-dependent bitmaps - BOOL bBitmap = false; - int i = 0; - keybd_event(VK_SNAPSHOT, 0x45, KEYEVENTF_EXTENDEDKEY, 0); - keybd_event(VK_SNAPSHOT, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); - do {//Clipboard need time to get bitmap from keybd_event, - i++; //we use a counter to get this time. - bBitmap = IsClipboardFormatAvailable(CF_BITMAP); - if(i == 500) return (FIBITMAP*)0; //emergency exit if something go wrong - } while (!bBitmap); - #ifdef _DEBUG - char mess[120] = {0}; - LPSTR pszMess = mess; - mir_snprintf(pszMess,120,"SS Bitmap counter: %i\r\n",i); - OutputDebugStringA( pszMess ); - #endif - //get clipboard data - OpenClipboard(NULL); - hBitmap = (HBITMAP)GetClipboardData(CF_BITMAP); - - //create FIBITMAP * from HBITMAP - FIP->FI_CorrectBitmap32Alpha(hBitmap, FALSE); - dib = FIP->FI_CreateDIBFromHBITMAP(hBitmap); - CloseClipboard(); - - return dib; -} - -LPTSTR SaveImage(FREE_IMAGE_FORMAT fif, FIBITMAP* dib, LPTSTR pszFilename, LPTSTR pszExt, int flag) { - int ret=0; - LPTSTR pszFile = NULL; - LPTSTR FileExt = (LPTSTR)GetFileExt (pszFilename, DBVT_TCHAR); - if(!FileExt) { - if(!pszExt) return NULL; - mir_tcsadd(pszFile, pszFilename); - mir_tcsadd(pszFile, _T(".")); - mir_tcsadd(pszFile, pszExt); - } - else { - mir_tcsadd(pszFile, pszFilename); - } - - if(fif==FIF_UNKNOWN) { - #if defined(_UNICODE) - fif = FIP->FI_GetFIFFromFilenameU(pszFile); - #else - fif = FIP->FI_GetFIFFromFilename(pszFile); - #endif - } - if(FIP->FI_FIFSupportsICCProfiles(fif)) { - bool bDummy = true; - } - - #if defined(_UNICODE) - ret = FIP->FI_SaveU(fif, dib, pszFile, flag); - #else - ret = FIP->FI_Save(fif, dib, pszFile, flag); - #endif - - mir_free(FileExt); - - if(ret) return pszFile; - mir_free(pszFile); - return NULL; -} - -//--------------------------------------------------------------------------- -//Draws a selection border on the window under cursor -void DrawBorderInverted(HWND hWindow) { - if (!hWindow){ - return; - } - HDC hDC=GetWindowDC(hWindow); - RECT rect={0}; - GetWindowRect(hWindow, &rect); - - int dcSave = SaveDC(hDC); - - SetROP2(hDC, R2_NOT); - - HPEN hPen=0; - hPen = CreatePen(PS_SOLID, 10, RGB(0, 0, 0)); - - SelectObject(hDC, &hPen); - SelectObject(hDC, GetStockObject(NULL_BRUSH)); - - Rectangle(hDC, 0, 0, rect.right-rect.left, rect.bottom-rect.top); - Rectangle(hDC, 1, 1, rect.right-rect.left-1, rect.bottom-rect.top-1); - Rectangle(hDC, 2, 2, rect.right-rect.left-2, rect.bottom-rect.top-2); - - RestoreDC(hDC, dcSave); -} - -//--------------------------------------------------------------------------- -//is left mouse button down -BOOL GetLmouse() { - SHORT temp = GetAsyncKeyState((GetSystemMetrics(SM_SWAPBUTTON)) ? VK_RBUTTON : VK_LBUTTON); - if ((temp & 0x8000) == 0x8000) { // LBUTTON down - return TRUE; - } - return FALSE; -} - -//--------------------------------------------------------------------------- -//is miranda unicode -BOOL mir_is_unicode() { - char ver[1024]; - CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM) sizeof(ver), (LPARAM) ver); - return strstr(ver, "Unicode") != NULL; -} - -//--------------------------------------------------------------------------- -INT_PTR GetFileName(LPTSTR pszPath, UINT typ) { - /*DBVT_ASCIIZ, DBVT_WCHAR, DBVT_TCHAR*/ - LPTSTR slash = _tcsrchr(pszPath,_T('\\')); - if (slash) { - switch (typ) { - case DBVT_ASCIIZ: - return (INT_PTR)mir_t2a(slash+1); - case DBVT_WCHAR: - return (INT_PTR)mir_t2u(slash+1); - default: - return 0; - } - } - else { - switch (typ) { - case DBVT_ASCIIZ: - return (INT_PTR)mir_t2a(pszPath); - case DBVT_WCHAR: - return (INT_PTR)mir_t2u(pszPath); - default: - return 0; - } - } -} - -INT_PTR GetFileExt (LPTSTR pszPath, UINT typ) { - /*DBVT_ASCIIZ, DBVT_WCHAR, DBVT_TCHAR*/ - LPTSTR slash = _tcsrchr(pszPath,_T('.')); - if (slash) { - switch (typ) { - case DBVT_ASCIIZ: - return (INT_PTR)mir_t2a(slash); - case DBVT_WCHAR: - return (INT_PTR)mir_t2u(slash); - default: - return 0; - } - } - else { - return NULL; - } -} - -//--------------------------------------------------------------------------- -BOOL GetEncoderClsid(wchar_t *wchMimeType, CLSID& clsidEncoder) { - UINT uiNum = 0; - UINT uiSize = 0; - BOOL bOk = FALSE; - Gdiplus::ImageCodecInfo* pImageCodecInfo = NULL; - Gdiplus::GetImageEncodersSize(&uiNum, &uiSize); - if( uiSize > 0 ) { - pImageCodecInfo = (Gdiplus::ImageCodecInfo *)new char[uiSize]; - if( pImageCodecInfo ) { - Gdiplus::GetImageEncoders(uiNum, uiSize, pImageCodecInfo); - for( UINT i = 0; i < uiNum; i++ ) { - if( wcscmp(pImageCodecInfo[i].MimeType, wchMimeType) == 0 ) { - clsidEncoder = pImageCodecInfo[i].Clsid; - bOk = TRUE; - } - } - } - delete pImageCodecInfo; - } - return bOk; -} - -INT_PTR SavePNG(HBITMAP hBmp, LPTSTR szFilename) { - Gdiplus::GdiplusStartupInput gdiplusStartupInput; - ULONG_PTR gdiplusToken; - Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); - - Gdiplus::Bitmap *pBitmap = Gdiplus::Bitmap::FromHBITMAP(hBmp, (HPALETTE)GetStockObject(DEFAULT_PALETTE) ); - if( pBitmap ) { - // Get the CLSID of the PNG encoder. - CLSID clsidEncoder; - if( GetEncoderClsid(L"image/png", clsidEncoder)) { - LPWSTR pswFile = mir_t2u(szFilename); - pBitmap->Save((const WCHAR*)pswFile, &clsidEncoder, NULL); - mir_free(pswFile); - } - delete pBitmap; - } - Gdiplus::GdiplusShutdown(gdiplusToken); - return 0; -} - -INT_PTR SaveGIF(HBITMAP hBmp, LPTSTR szFilename) { - Gdiplus::GdiplusStartupInput gdiplusStartupInput; - ULONG_PTR gdiplusToken; - Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); - - Gdiplus::Bitmap *pBitmap = Gdiplus::Bitmap::FromHBITMAP(hBmp, (HPALETTE)GetStockObject(DEFAULT_PALETTE) ); - if( pBitmap ) { - // Get the CLSID of the GIF encoder. - CLSID clsidEncoder; - if( GetEncoderClsid(L"image/gif", clsidEncoder)) { - LPWSTR pswFile = mir_t2u(szFilename); - pBitmap->Save((const WCHAR*)pswFile, &clsidEncoder, NULL); - mir_free(pswFile); - } - delete pBitmap; - } - Gdiplus::GdiplusShutdown(gdiplusToken); - return 0; -} - -INT_PTR SaveTIF(HBITMAP hBmp, LPTSTR szFilename) { -//http://www.codeproject.com/Messages/1406708/How-to-reduce-the-size-of-an-Image-using-GDIplus.aspx - ULONG_PTR gdiplusToken; - Gdiplus::GdiplusStartupInput gdiplusStartupInput; - Gdiplus::Status stat; - Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); - - Gdiplus::Bitmap *pBitmap = Gdiplus::Bitmap::FromHBITMAP(hBmp, (HPALETTE)GetStockObject(DEFAULT_PALETTE) ); - if( pBitmap ) { - // Get the CLSID of the GIF encoder. - CLSID EncCLSID; - if( GetEncoderClsid(L"image/tiff", EncCLSID)) { - //--- Create a 2-parameter array, for Compression and for Color Bit depth - Gdiplus::EncoderParameters* EncParams = (Gdiplus::EncoderParameters*) malloc(sizeof(Gdiplus::EncoderParameters) + 1 * sizeof(Gdiplus::EncoderParameter)); - // Gdiplus::EncoderParameters pEncoderParameters; - //--- Use LZW Compression instead of Group 4, since it works for color and G4 doesn't - ULONG ulCompression = Gdiplus::EncoderValueCompressionLZW ; - ULONG ulColorDepth = 24L ; - - EncParams->Count = 2 ; - EncParams->Parameter[0].Guid = Gdiplus::EncoderCompression ; - EncParams->Parameter[0].Type = Gdiplus::EncoderParameterValueTypeLong ; - EncParams->Parameter[0].NumberOfValues = 1 ; - EncParams->Parameter[0].Value = &ulCompression ; - EncParams->Parameter[1].Guid = Gdiplus::EncoderColorDepth ; - EncParams->Parameter[1].Type = Gdiplus::EncoderParameterValueTypeLong ; - EncParams->Parameter[1].NumberOfValues = 1 ; - EncParams->Parameter[1].Value = &ulColorDepth ; - - LPWSTR pswFile = mir_t2u(szFilename); - stat = pBitmap->Save((const WCHAR*)pswFile, &EncCLSID, EncParams); - mir_free(pswFile); - free(EncParams); - } - delete pBitmap; - } - Gdiplus::GdiplusShutdown(gdiplusToken); - return 0; -} - -//--------------------------------------------------------------------------- -/* Old stuff from Borland C++ */ -//--------------------------------------------------------------------------- -/*/Popup -void ShowPopUp(char *title, char *text) { - POPUPDATAEX pude={0}; - - strcpy(pude.lpzText, text); - strcpy(pude.lpzContactName, title); - pude.lchIcon = LoadIcon(g_hAppInstance, MAKEINTRESOURCE(MAIN)); - pude.colorBack = POPUP_USE_SKINNED_BG; - - CallService(MS_POPUP_ADDPOPUP, (WPARAM)&pude, 0); -}*/ - diff --git a/plugins/SendScreenshotPlus/Utils.h b/plugins/SendScreenshotPlus/Utils.h deleted file mode 100644 index 2934391a8b..0000000000 --- a/plugins/SendScreenshotPlus/Utils.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2009 Miranda ICQ/IM project, - -This file is part of Send Screenshot Plus, a Miranda IM plugin. -Copyright (c) 2010 Ing.U.Horn - -Parts of this file based on original sorce code -(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/Utils.h $ -Revision : $Revision: 22 $ -Last change on : $Date: 2010-05-02 21:25:02 +0400 (Р’СЃ, 02 май 2010) $ -Last change by : $Author: ing.u.horn $ - -*/ - -#ifndef UTILSH -#define UTILSH - -#include "global.h" -//#include -//#include -#define SPP_USERPANE 1 - -extern FI_INTERFACE *FIP; - -#define ABS(x) ((x)<0?-(x):(x)) - -typedef struct TEnumDataTemp { -size_t count; -MONITORINFOEX* info; -}MONITORS; - -extern HWND g_hCapture; -extern HBITMAP g_hBitmap, g_hbmMask; - -//--------------------------------------------------------------------------- -int ComboBox_SelectItemData(HWND hwndCtl, int indexStart, LPARAM data); - -size_t MonitorInfoEnum(MONITORINFOEX* & myMonitors, RECT & virtualScreen); -BOOL CALLBACK MonitorInfoEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData); - -FIBITMAP* CaptureWindow(HWND hCapture, BOOL ClientArea); -FIBITMAP* CaptureMonitor(LPTSTR szDevice); -FIBITMAP* CaptureScreen(HDC hDC, SIZE size, HWND hCapture=0); -FIBITMAP* CaptureDesktop(); /*emulate print screen (not used)*/ -LPTSTR SaveImage(FREE_IMAGE_FORMAT fif, FIBITMAP* dib, LPTSTR pszFilename, LPTSTR pszExt, int flag=0); - -void DrawBorderInverted(HWND hWindow); -BOOL GetLmouse(); -BOOL mir_is_unicode(); -INT_PTR GetFileName(LPTSTR pszPath, UINT typ); -INT_PTR GetFileExt (LPTSTR pszPath, UINT typ); - -BOOL GetEncoderClsid(wchar_t *wchMimeType, CLSID& clsidEncoder); -INT_PTR SavePNG(HBITMAP hBmp, LPTSTR szFilename); -INT_PTR SaveGIF(HBITMAP hBmp, LPTSTR szFilename); -INT_PTR SaveTIF(HBITMAP hBmp, LPTSTR szFilename); - -//--------------------------------------------------------------------------- -/* Old stuff from Borland C++ -//void ShowPopUp(char *title, char *text); - -*/ -#endif diff --git a/plugins/SendScreenshotPlus/ctrl_button.cpp b/plugins/SendScreenshotPlus/ctrl_button.cpp deleted file mode 100644 index ad8e542fa3..0000000000 --- a/plugins/SendScreenshotPlus/ctrl_button.cpp +++ /dev/null @@ -1,699 +0,0 @@ -/* -Miranda IM -Copyright (C) 2002 Robert Rainwater - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ -#include "global.h" - -// Used for our own cheap TrackMouseEvent -#define BUTTON_POLLID 100 -#define BUTTON_POLLDELAY 50 - -#define MGPROC(x) GetProcAddress(themeAPIHandle,x) - -typedef struct TMBCtrl{ - HWND hwnd; - HANDLE hThemeButton; - HANDLE hThemeToolbar; - - HICON hIcon; - HICON arrow; // uses down arrow - HBITMAP hBitmap; - HFONT hFont; // font - - DWORD dwStyle; - BOOLEAN bFocus; - - INT stateId; // button state - INT defbutton; // default button - INT pbState; - TCHAR cHot; -} BTNCTRL, *LPBTNCTRL; - -// External theme methods and properties -CRITICAL_SECTION csTips; -HWND hwndToolTips = NULL; -HMODULE themeAPIHandle = NULL; - -// theme procedures -HANDLE (WINAPI *OpenThemeData)(HWND,LPCWSTR); -HRESULT (WINAPI *CloseThemeData)(HANDLE); -BOOL (WINAPI *IsThemeBackgroundPartiallyTransparent)(HANDLE,INT,INT); -HRESULT (WINAPI *DrawThemeParentBackground)(HWND,HDC,RECT *); -HRESULT (WINAPI *DrawThemeBackground)(HANDLE,HDC,INT,INT,const RECT *,const RECT *); -HRESULT (WINAPI *DrawThemeText)(HANDLE,HDC,INT,INT,LPCWSTR,INT,DWORD,DWORD,const RECT *); -HRESULT (WINAPI *GetThemeTextExtent)(HANDLE,HDC,INT,INT,LPCWSTR,INT,DWORD,OPTIONAL const RECT*, RECT *); -HRESULT (WINAPI *GetThemeBackgroundRegion)(HANDLE,HDC,INT,INT,const RECT *,HRGN *); - -/** - * name: ThemeSupport - * desc: Loads the uxtheme functions, if supported by the os - * param: none - * return: TRUE if themes are supported, FALSE if not - **/ -BOOLEAN __fastcall ThemeSupport() { - if (IsWinVerXPPlus()) { - if (!themeAPIHandle) { - themeAPIHandle = GetModuleHandleA("uxtheme"); - if (themeAPIHandle) { - OpenThemeData = (HANDLE (WINAPI *)(HWND,LPCWSTR))MGPROC("OpenThemeData"); - CloseThemeData = (HRESULT (WINAPI *)(HANDLE))MGPROC("CloseThemeData"); - IsThemeBackgroundPartiallyTransparent = (BOOL (WINAPI *)(HANDLE,INT,INT))MGPROC("IsThemeBackgroundPartiallyTransparent"); - DrawThemeParentBackground = (HRESULT (WINAPI *)(HWND,HDC,RECT *))MGPROC("DrawThemeParentBackground"); - DrawThemeBackground = (HRESULT (WINAPI *)(HANDLE,HDC,INT,INT,const RECT *,const RECT *))MGPROC("DrawThemeBackground"); - DrawThemeText = (HRESULT (WINAPI *)(HANDLE,HDC,INT,INT,LPCWSTR,INT,DWORD,DWORD,const RECT *))MGPROC("DrawThemeText"); - GetThemeTextExtent = (HRESULT (WINAPI *)(HANDLE,HDC,INT,INT,LPCWSTR,INT,DWORD,OPTIONAL const RECT*, RECT *))MGPROC("GetThemeTextExtent"); - GetThemeBackgroundRegion = (HRESULT (WINAPI *)(HANDLE,HDC,INT,INT,const RECT *,HRGN *))MGPROC("GetThemeBackgroundRegion"); - } - } - // Make sure all of these methods are valid (i would hope either all or none work) - if (OpenThemeData - && CloseThemeData - && IsThemeBackgroundPartiallyTransparent - && DrawThemeParentBackground - && DrawThemeBackground - && DrawThemeText - && GetThemeTextExtent) - { - return TRUE; - } - } - return FALSE; -} - -/** - * name: DestroyTheme - * desc: destroys theme data for buttons - * param: ctl - BTNCTRL structure with the information about the theme to close - * return: nothing - **/ -static VOID __fastcall DestroyTheme(BTNCTRL *ctl) { - if (ctl->hThemeButton) { - CloseThemeData(ctl->hThemeButton); - ctl->hThemeButton = NULL; - } - if (ctl->hThemeToolbar) { - CloseThemeData(ctl->hThemeToolbar); - ctl->hThemeToolbar = NULL; - } -} - -/** - * name: LoadTheme - * desc: load theme data for buttons if supported by os - * param: ctl - BTNCTRL structure with the information about the theme to load - * return: nothing - **/ -static VOID __fastcall LoadTheme(BTNCTRL *ctl) { - if (ThemeSupport()) { - DestroyTheme(ctl); - ctl->hThemeButton = OpenThemeData(ctl->hwnd,L"BUTTON"); - ctl->hThemeToolbar = OpenThemeData(ctl->hwnd,L"TOOLBAR"); - } -} - -/** - * name: TBStateConvert2Flat - * desc: convert button stateIDs - * param: state - state id for the normal theme button - * return: stateID for the flat theme button - **/ -static INT __fastcall TBStateConvert2Flat(INT state) { - switch (state) { - case PBS_NORMAL: return TS_NORMAL; - case PBS_HOT: return TS_HOT; - case PBS_PRESSED: return TS_PRESSED; - case PBS_DISABLED: return TS_DISABLED; - case PBS_DEFAULTED: return TS_NORMAL; - } - return TS_NORMAL; -} - -/** - * name: PaintIcon - * desc: Draws the Icon of the button - * param: ctl - BTNCTRL structure for the button - * hdcMem - device context to draw to - * ccText - character count of the text of the button - * rcClient - rectangle of the whole button - * rcText - rectangle of the text to draw later on - * return: nothing - **/ -static VOID __fastcall PaintIcon(BTNCTRL *ctl, HDC hdcMem, LPWORD ccText, LPRECT rcClient, LPRECT rcText) -{ - RECT rcImage; - - // draw icon on the left of the button - if (ctl->hIcon) { - rcImage.right = GetSystemMetrics(SM_CXSMICON); - rcImage.bottom = GetSystemMetrics(SM_CYSMICON); - rcImage.left = (rcClient->right - rcClient->left) / 2 - ((rcImage.right + rcText->right + (*ccText > 0 ? 4 : 0) + (ctl->arrow ? rcImage.right : 0)) / 2); - rcImage.top = (rcClient->bottom - rcClient->top - rcImage.bottom) / 2; - rcImage.right += rcImage.left; - rcImage.bottom += rcImage.top; - - OffsetRect(rcText, rcImage.right + 4, 0); - if (ctl->stateId == PBS_PRESSED) OffsetRect(&rcImage, 1, 1); - - DrawState(hdcMem, NULL, NULL, (LPARAM)ctl->hIcon, 0, - rcImage.left, rcImage.top, - rcImage.right - rcImage.left, rcImage.bottom - rcImage.top, - IsWindowEnabled(ctl->hwnd) ? DST_ICON | DSS_NORMAL : DST_ICON | DSS_DISABLED); - } - - // draw arrow on the right of the button - if (ctl->arrow) { - rcImage.right = GetSystemMetrics(SM_CXSMICON); - rcImage.left = (*ccText > 0 || ctl->hIcon) - ? rcClient->right - GetSystemMetrics(SM_CXSMICON) - : (rcClient->right - rcClient->left - rcImage.right) / 2; - rcImage.right += rcImage.left; - rcImage.bottom = GetSystemMetrics(SM_CYSMICON); - rcImage.top = (rcClient->bottom - rcClient->top - rcImage.bottom) / 2; - if (ctl->stateId == PBS_PRESSED) OffsetRect(&rcImage, 1, 1); - - DrawState(hdcMem, NULL, NULL, (LPARAM)ctl->arrow, 0, - rcImage.left, rcImage.top, - rcImage.right - rcImage.left, rcImage.bottom - rcImage.top, - IsWindowEnabled(ctl->hwnd) ? DST_ICON | DSS_NORMAL : DST_ICON | DSS_DISABLED); - } -} - -/** - * name: PaintThemeButton - * desc: Draws the themed button - * param: ctl - BTNCTRL structure for the button - * hdcMem - device context to draw to - * rcClient - rectangle of the whole button - * return: nothing - **/ -static VOID __fastcall PaintThemeButton(BTNCTRL *ctl, HDC hdcMem, LPRECT rcClient) -{ - RECT rcText = { 0, 0, 0, 0 }; - WCHAR wszText[MAX_PATH] = { 0 }; - WORD ccText; - - // Draw the flat button - if ((ctl->dwStyle & MBS_FLAT) && ctl->hThemeToolbar) { - INT state = IsWindowEnabled(ctl->hwnd) - ? (ctl->stateId == PBS_NORMAL && ctl->defbutton - ? PBS_DEFAULTED - : ctl->stateId) - : PBS_DISABLED; - if (IsThemeBackgroundPartiallyTransparent(ctl->hThemeToolbar, TP_BUTTON, TBStateConvert2Flat(state))) { - if (SUCCEEDED(DrawThemeParentBackground(ctl->hwnd, hdcMem, rcClient))) - DrawThemeParentBackground(GetParent(ctl->hwnd), hdcMem, rcClient); - } - DrawThemeBackground(ctl->hThemeToolbar, hdcMem, TP_BUTTON, TBStateConvert2Flat(state), rcClient, rcClient); - } - else { - // draw themed button background - if (ctl->hThemeButton) { - INT state = IsWindowEnabled(ctl->hwnd) - ? (ctl->stateId == PBS_NORMAL && ctl->defbutton - ? PBS_DEFAULTED - : ctl->stateId) - : PBS_DISABLED; - if (IsThemeBackgroundPartiallyTransparent(ctl->hThemeButton, BP_PUSHBUTTON, state)) { - if (SUCCEEDED(DrawThemeParentBackground(ctl->hwnd, hdcMem, rcClient))) - DrawThemeParentBackground(GetParent(ctl->hwnd), hdcMem, rcClient); - } - DrawThemeBackground(ctl->hThemeButton, hdcMem, BP_PUSHBUTTON, state, rcClient, rcClient); - } - } - - // calculate text rect - { - RECT sizeText; - HFONT hOldFont; - - ccText = GetWindowTextW(ctl->hwnd, wszText, sizeof(wszText) / sizeof(WCHAR)); - - if (ccText > 0) { - hOldFont = (HFONT)SelectObject(hdcMem, ctl->hFont); - - GetThemeTextExtent( - ctl->hThemeButton, - hdcMem, - BP_PUSHBUTTON, - IsWindowEnabled(ctl->hwnd) ? ctl->stateId : PBS_DISABLED, - wszText, - ccText, - DST_PREFIXTEXT, - NULL, - &sizeText); - - if (ctl->cHot) { - RECT rcHot; - - GetThemeTextExtent(ctl->hThemeButton, - hdcMem, - BP_PUSHBUTTON, - IsWindowEnabled(ctl->hwnd) ? ctl->stateId : PBS_DISABLED, - L"&", - 1, - DST_PREFIXTEXT, - NULL, - &rcHot); - - sizeText.right -= (rcHot.right - rcHot.left); - } - SelectObject(hdcMem, hOldFont); - - rcText.left = (ctl->hIcon) ? 0 : (rcClient->right - rcClient->left - (sizeText.right - sizeText.left)) / 2; - rcText.top = (rcClient->bottom - rcClient->top - (sizeText.bottom - sizeText.top)) / 2; - rcText.right = rcText.left + (sizeText.right - sizeText.left); - rcText.bottom = rcText.top + (sizeText.bottom - sizeText.top); - if (ctl->stateId == PBS_PRESSED) { - OffsetRect(&rcText, 1, 1); - } - } - } - PaintIcon(ctl, hdcMem, &ccText, rcClient, &rcText); - // draw text - if (ccText > 0 && ctl->hThemeButton) { - HFONT hOldFont = (HFONT)SelectObject(hdcMem, ctl->hFont); - DrawThemeText(ctl->hThemeButton, hdcMem, BP_PUSHBUTTON, IsWindowEnabled(ctl->hwnd) ? ctl->stateId : PBS_DISABLED, wszText, ccText, DST_PREFIXTEXT, 0, &rcText); - SelectObject(hdcMem, hOldFont); - } -} - -/** - * name: PaintThemeButton - * desc: Draws the none themed button - * param: ctl - BTNCTRL structure for the button - * hdcMem - device context to draw to - * rcClient - rectangle of the whole button - * return: nothing - **/ -static VOID __fastcall PaintButton(BTNCTRL *ctl, HDC hdcMem, LPRECT rcClient) -{ - RECT rcText = { 0, 0, 0, 0 }; - TCHAR szText[MAX_PATH] = { 0 }; - WORD ccText; - - // Draw the flat button - if (ctl->dwStyle & MBS_FLAT) { - HBRUSH hbr = NULL; - - if (ctl->stateId == PBS_PRESSED || ctl->stateId == PBS_HOT) - hbr = GetSysColorBrush(COLOR_3DLIGHT); - else { - HDC dc; - HWND hwndParent; - - hwndParent = GetParent(ctl->hwnd); - if (dc = GetDC(hwndParent)) { - hbr = (HBRUSH)SendMessage(hwndParent, WM_CTLCOLORDLG, (WPARAM)dc, (LPARAM)hwndParent); - ReleaseDC(hwndParent, dc); - } - } - if (hbr) { - FillRect(hdcMem, rcClient, hbr); - DeleteObject(hbr); - } - if (ctl->stateId == PBS_HOT || ctl->bFocus) { - if (ctl->pbState) DrawEdge(hdcMem, rcClient, EDGE_ETCHED, BF_RECT|BF_SOFT); - else DrawEdge(hdcMem, rcClient, BDR_RAISEDOUTER, BF_RECT|BF_SOFT|BF_FLAT); - } - else - if (ctl->stateId == PBS_PRESSED) - DrawEdge(hdcMem, rcClient, BDR_SUNKENOUTER, BF_RECT|BF_SOFT); - } - else { - UINT uState = DFCS_BUTTONPUSH|((ctl->stateId == PBS_HOT) ? DFCS_HOT : 0)|((ctl->stateId == PBS_PRESSED) ? DFCS_PUSHED : 0); - if (ctl->defbutton&&ctl->stateId==PBS_NORMAL) uState |= DLGC_DEFPUSHBUTTON; - DrawFrameControl(hdcMem, rcClient, DFC_BUTTON, uState); - // Draw focus rectangle if button has focus - if (ctl->bFocus) { - RECT focusRect = *rcClient; - InflateRect(&focusRect, -3, -3); - DrawFocusRect(hdcMem, &focusRect); - } - } - // calculate text rect - { - SIZE sizeText; - HFONT hOldFont; - - ccText = GetWindowText(ctl->hwnd, szText, SIZEOF(szText)); - - if (ccText > 0) { - hOldFont = (HFONT)SelectObject(hdcMem, ctl->hFont); - GetTextExtentPoint32(hdcMem, szText, ccText, &sizeText); - if (ctl->cHot) { - SIZE sizeHot; - - GetTextExtentPoint32A(hdcMem, "&", 1, &sizeHot); - sizeText.cx -= sizeHot.cx; - } - SelectObject(hdcMem, hOldFont); - - rcText.left = (ctl->hIcon) ? 0 : (rcClient->right - rcClient->left - sizeText.cx) / 2; - rcText.top = (rcClient->bottom - rcClient->top - sizeText.cy) / 2; - rcText.right = rcText.left + sizeText.cx; - rcText.bottom = rcText.top + sizeText.cy; - if (ctl->stateId == PBS_PRESSED) - OffsetRect(&rcText, 1, 1); - } - } - PaintIcon(ctl, hdcMem, &ccText, rcClient, &rcText); - - // draw text - if (ccText > 0) { - HFONT hOldFont; - - hOldFont = (HFONT)SelectObject(hdcMem, ctl->hFont); - - SetBkMode(hdcMem, TRANSPARENT); - SetTextColor(hdcMem, - IsWindowEnabled(ctl->hwnd) || !ctl->hThemeButton - ? ctl->stateId == PBS_HOT - ? GetSysColor(COLOR_HOTLIGHT) - : GetSysColor(COLOR_BTNTEXT) - : GetSysColor(COLOR_GRAYTEXT)); - - DrawState(hdcMem, NULL, NULL, (LPARAM)szText, 0, - rcText.left, rcText.top, rcText.right - rcText.left, rcText.bottom - rcText.top, - IsWindowEnabled(ctl->hwnd) || ctl->hThemeButton ? DST_PREFIXTEXT | DSS_NORMAL : DST_PREFIXTEXT | DSS_DISABLED); - SelectObject(hdcMem, hOldFont); - } -} - -/** - * name: Button_WndProc - * desc: window procedure for the button class - * param: hwndBtn - window handle to the button - * uMsg - message to handle - * wParam - message specific parameter - * lParam - message specific parameter - * return: message specific - **/ -static LRESULT CALLBACK Button_WndProc(HWND hwndBtn, UINT uMsg, WPARAM wParam, LPARAM lParam) { - LPBTNCTRL bct = (LPBTNCTRL)GetWindowLongPtr(hwndBtn, 0); - - switch (uMsg) { - case WM_NCCREATE: - { - LPCREATESTRUCT cs = (LPCREATESTRUCT)lParam; - - cs->style |= BS_OWNERDRAW; - if (!(bct = (LPBTNCTRL)malloc(sizeof(BTNCTRL)))) - return FALSE; - ZeroMemory(bct, sizeof(BTNCTRL)); - bct->hwnd = hwndBtn; - bct->stateId = PBS_NORMAL; - bct->hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); - bct->dwStyle = cs->style; - if (cs->style & MBS_DOWNARROW) - bct->arrow = IcoLib_GetIcon(ICO_BTN_DOWNARROW); - LoadTheme(bct); - SetWindowLongPtr(hwndBtn, 0, (LONG_PTR)bct); - if (cs->lpszName) SetWindowText(hwndBtn, cs->lpszName); - return TRUE; - } - case WM_DESTROY: - if (bct) { - EnterCriticalSection(&csTips); - if (hwndToolTips) { - TOOLINFO ti; - - ZeroMemory(&ti, sizeof(ti)); - ti.cbSize = sizeof(ti); - ti.uFlags = TTF_IDISHWND; - ti.hwnd = bct->hwnd; - ti.uId = (UINT)bct->hwnd; - if (SendMessage(hwndToolTips, TTM_GETTOOLINFO, 0, (LPARAM)&ti)) { - SendMessage(hwndToolTips, TTM_DELTOOL, 0, (LPARAM)&ti); - } - if (SendMessage(hwndToolTips, TTM_GETTOOLCOUNT, 0, (LPARAM)&ti) == 0) { - DestroyWindow(hwndToolTips); - hwndToolTips = NULL; - } - } - LeaveCriticalSection(&csTips); - DestroyTheme(bct); - free(bct); - } - SetWindowLongPtr(hwndBtn, 0, NULL); - break; - case WM_SETTEXT: - bct->cHot = 0; - if ((LPTSTR)lParam) { - LPTSTR tmp = (LPTSTR)lParam; - - while (*tmp) { - if (*tmp=='&' && *(tmp+1)) { - bct->cHot = _totlower(*(tmp+1)); - break; - } - tmp++; - } - InvalidateRect(bct->hwnd, NULL, TRUE); - } - break; - case WM_SYSKEYUP: - if (bct->stateId != PBS_DISABLED && bct->cHot && bct->cHot == _totlower((TCHAR)wParam)) { - if (bct->dwStyle & MBS_PUSHBUTTON) { - if (bct->pbState) bct->pbState = 0; - else bct->pbState = 1; - InvalidateRect(bct->hwnd, NULL, TRUE); - } - else - SetFocus(hwndBtn); - SendMessage(GetParent(hwndBtn), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndBtn), BN_CLICKED), (LPARAM)hwndBtn); - return 0; - } - break; - case WM_THEMECHANGED: - { - // themed changed, reload theme object - LoadTheme(bct); - InvalidateRect(bct->hwnd, NULL, TRUE); // repaint it - break; - } - case WM_SETFONT: // remember the font so we can use it later - bct->hFont = (HFONT)wParam; // maybe we should redraw? - break; - case WM_NCPAINT: - case WM_PAINT: - { - PAINTSTRUCT ps; - HDC hdcPaint; - HDC hdcMem; - HBITMAP hbmMem; - HDC hOld; - RECT rcClient; - - if (hdcPaint = BeginPaint(hwndBtn, &ps)) { - GetClientRect(bct->hwnd, &rcClient); - hdcMem = CreateCompatibleDC(hdcPaint); - hbmMem = CreateCompatibleBitmap(hdcPaint, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top); - hOld = (HDC)SelectObject(hdcMem, hbmMem); - - // If its a push button, check to see if it should stay pressed - if ((bct->dwStyle & MBS_PUSHBUTTON) && bct->pbState) bct->stateId = PBS_PRESSED; - - if ((bct->dwStyle & MBS_FLAT) && bct->hThemeToolbar || bct->hThemeButton) - PaintThemeButton(bct, hdcMem, &rcClient); - else - PaintButton(bct, hdcMem, &rcClient); - - BitBlt(hdcPaint, 0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top, hdcMem, 0, 0, SRCCOPY); - SelectObject(hdcMem, hOld); - DeleteObject(hbmMem); - DeleteDC(hdcMem); - EndPaint(hwndBtn, &ps); - } - return 0; - } - case BM_SETIMAGE: - if (wParam == IMAGE_ICON) { - bct->hIcon = (HICON)lParam; - bct->hBitmap = NULL; - InvalidateRect(bct->hwnd, NULL, TRUE); - } - else if (wParam == IMAGE_BITMAP) { - bct->hIcon = NULL; - bct->hBitmap = (HBITMAP)lParam; - InvalidateRect(bct->hwnd, NULL, TRUE); - } - else if (wParam == NULL && lParam == NULL) { - bct->hIcon = NULL; - bct->hBitmap = NULL; - InvalidateRect(bct->hwnd, NULL, TRUE); - } - break; - case BM_SETCHECK: - if (!(bct->dwStyle & MBS_PUSHBUTTON)) break; - if (wParam == BST_CHECKED) { - bct->pbState = 1; - bct->stateId = PBS_PRESSED; - } - else if (wParam == BST_UNCHECKED) { - bct->pbState = 0; - bct->stateId = PBS_NORMAL; - } - InvalidateRect(bct->hwnd, NULL, TRUE); - break; - case BM_GETCHECK: - if (bct->dwStyle & MBS_PUSHBUTTON) return bct->pbState ? BST_CHECKED : BST_UNCHECKED; - return 0; - case BUTTONSETDEFAULT: - bct->defbutton = wParam ? 1 : 0; - InvalidateRect(bct->hwnd, NULL, TRUE); - break; - case BUTTONADDTOOLTIP: - { - if (!wParam) break; - EnterCriticalSection(&csTips); - if (!hwndToolTips) { - hwndToolTips = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP, 0, 0, 0, 0, NULL, NULL, GetModuleHandle(NULL), NULL); - } - - if (lParam == MBF_UNICODE) { - TOOLINFOW ti; - - ZeroMemory(&ti, sizeof(TOOLINFOW)); - ti.cbSize = sizeof(TOOLINFOW); - ti.uFlags = TTF_IDISHWND; - ti.hwnd = bct->hwnd; - ti.uId = (UINT)bct->hwnd; - if (SendMessage(hwndToolTips, TTM_GETTOOLINFOW, 0, (LPARAM)&ti)) { - SendMessage(hwndToolTips, TTM_DELTOOLW, 0, (LPARAM)&ti); - } - ti.uFlags = TTF_IDISHWND|TTF_SUBCLASS; - ti.uId = (UINT)bct->hwnd; - ti.lpszText=(LPWSTR)wParam; - SendMessage(hwndToolTips, TTM_ADDTOOLW, 0, (LPARAM)&ti); - } - else { - TOOLINFOA ti; - - ZeroMemory(&ti, sizeof(TOOLINFOA)); - ti.cbSize = sizeof(TOOLINFOA); - ti.uFlags = TTF_IDISHWND; - ti.hwnd = bct->hwnd; - ti.uId = (UINT)bct->hwnd; - if (SendMessage(hwndToolTips, TTM_GETTOOLINFOA, 0, (LPARAM)&ti)) { - SendMessage(hwndToolTips, TTM_DELTOOLA, 0, (LPARAM)&ti); - } - ti.uFlags = TTF_IDISHWND|TTF_SUBCLASS; - ti.uId = (UINT)bct->hwnd; - ti.lpszText=(LPSTR)wParam; - SendMessage(hwndToolTips, TTM_ADDTOOLA, 0, (LPARAM)&ti); - } - LeaveCriticalSection(&csTips); - break; - } - case BUTTONTRANSLATE: - { - TCHAR szButton[MAX_PATH]; - GetWindowText(bct->hwnd, szButton, MAX_PATH); - SetWindowText(bct->hwnd, TranslateTS(szButton)); - break; - } - case WM_SETFOCUS: // set keybord bFocus and redraw - bct->bFocus = 1; - InvalidateRect(bct->hwnd, NULL, TRUE); - break; - case WM_KILLFOCUS: // kill bFocus and redraw - bct->bFocus = 0; - InvalidateRect(bct->hwnd, NULL, TRUE); - break; - case WM_WINDOWPOSCHANGED: - InvalidateRect(bct->hwnd, NULL, TRUE); - break; - case WM_ENABLE: // windows tells us to enable/disable - bct->stateId = wParam ? PBS_NORMAL : PBS_DISABLED; - InvalidateRect(bct->hwnd, NULL, TRUE); - break; - case WM_MOUSELEAVE: // faked by the WM_TIMER - if (bct->stateId != PBS_DISABLED) { // don't change states if disabled - bct->stateId = PBS_NORMAL; - InvalidateRect(bct->hwnd, NULL, TRUE); - } - break; - case WM_LBUTTONDOWN: - if (bct->stateId != PBS_DISABLED) { // don't change states if disabled - bct->stateId = PBS_PRESSED; - InvalidateRect(bct->hwnd, NULL, TRUE); - } - break; - case WM_LBUTTONUP: - if (bct->stateId != PBS_DISABLED) { // don't change states if disabled - BOOLEAN bPressed = bct->stateId == PBS_PRESSED; - - if (bct->dwStyle & MBS_PUSHBUTTON) { - if (bct->pbState) bct->pbState = 0; - else bct->pbState = 1; - } - bct->stateId = PBS_HOT; - - // Tell your daddy you got clicked, if mouse is still over the button. - if ((bct->dwStyle & MBS_PUSHBUTTON) || bPressed) - SendMessage(GetParent(hwndBtn), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndBtn), BN_CLICKED), (LPARAM)hwndBtn); - InvalidateRect(bct->hwnd, NULL, TRUE); - } - break; - case WM_MOUSEMOVE: - if (bct->stateId == PBS_NORMAL) { - bct->stateId = PBS_HOT; - InvalidateRect(bct->hwnd, NULL, TRUE); - } - // Call timer, used to start cheesy TrackMouseEvent faker - SetTimer(hwndBtn, BUTTON_POLLID, BUTTON_POLLDELAY, NULL); - break; - case WM_TIMER: // use a timer to check if they have did a mouseout - if (wParam == BUTTON_POLLID) { - RECT rc; - POINT pt; - - GetWindowRect(hwndBtn, &rc); - GetCursorPos(&pt); - if (!PtInRect(&rc, pt)) { // mouse must be gone, trigger mouse leave - PostMessage(hwndBtn, WM_MOUSELEAVE, 0, 0L); - KillTimer(hwndBtn, BUTTON_POLLID); - } - } - break; - case WM_ERASEBKGND: - return 1; - } - return DefWindowProc(hwndBtn, uMsg, wParam, lParam); -} - -VOID CtrlButtonUnloadModule() -{ - DeleteCriticalSection(&csTips); - UnregisterClass(UINFOBUTTONCLASS, hInst); -} - -VOID CtrlButtonLoadModule() -{ - WNDCLASSEX wc; - - ZeroMemory(&wc, sizeof(wc)); - wc.cbSize = sizeof(wc); - wc.lpszClassName = UINFOBUTTONCLASS; - wc.lpfnWndProc = Button_WndProc; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.cbWndExtra = sizeof(LPBTNCTRL); - wc.style = CS_GLOBALCLASS; - RegisterClassEx(&wc); - InitializeCriticalSection(&csTips); -} - diff --git a/plugins/SendScreenshotPlus/ctrl_button.h b/plugins/SendScreenshotPlus/ctrl_button.h deleted file mode 100644 index dc77334b05..0000000000 --- a/plugins/SendScreenshotPlus/ctrl_button.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2009 Miranda ICQ/IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -aLONG with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ -#ifndef _UINFOEX_BOTTONS_H_INCLUDED_ -#define _UINFOEX_BOTTONS_H_INCLUDED_ 1 - -// theme procedures -extern HANDLE (WINAPI *OpenThemeData)(HWND,LPCWSTR); -extern HRESULT (WINAPI *CloseThemeData)(HANDLE); -extern BOOL (WINAPI *IsThemeBackgroundPartiallyTransparent)(HANDLE,INT,INT); -extern HRESULT (WINAPI *DrawThemeParentBackground)(HWND,HDC,RECT *); -extern HRESULT (WINAPI *DrawThemeBackground)(HANDLE,HDC,INT,INT,const RECT *,const RECT *); -extern HRESULT (WINAPI *DrawThemeText)(HANDLE,HDC,INT,INT,LPCWSTR,INT,DWORD,DWORD,const RECT *); -extern HRESULT (WINAPI *GetThemeTextExtent)(HANDLE,HDC,INT,INT,LPCWSTR,INT,DWORD,OPTIONAL const RECT*, RECT *); -extern HRESULT (WINAPI *GetThemeBackgroundRegion)(HANDLE,HDC,INT,INT,const RECT *,HRGN *); - - -VOID CtrlButtonLoadModule(); -VOID CtrlButtonUnloadModule(); - -BOOLEAN __fastcall ThemeSupport(); - -#endif /* _UINFOEX_BOTTONS_H_INCLUDED_ */ \ No newline at end of file diff --git a/plugins/SendScreenshotPlus/dlg_msgbox.cpp b/plugins/SendScreenshotPlus/dlg_msgbox.cpp deleted file mode 100644 index f1b1535802..0000000000 --- a/plugins/SendScreenshotPlus/dlg_msgbox.cpp +++ /dev/null @@ -1,854 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2009 Miranda ICQ/IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -aLONG with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $HeadURL: https://userinfoex.googlecode.com/svn/trunk/dlg_msgbox.cpp $ -Revision : $Revision: 164 $ -Last change on : $Date: 2009-12-02 21:24:35 +0100 (Mi, 02. Dez 2009) $ -Last change by : $Author: ing.u.horn $ - -*/ - -#include "dlg_msgbox.h" - -typedef struct _MSGPOPUPDATA -{ - POPUPACTION pa[3]; - HWND hDialog; -} -MSGPOPUPDATA, *LPMSGPOPUPDATA; - -/** - * This helper function moves and resizes a dialog box's control element. - * - * @param hDlg - the dialog box's window handle - * @param idCtrl - the identication number of the control to move - * @param dx -ґnumber of pixels to horizontal move the control - * @param dy - number of pixels to vertical move the control - * @param dw - number of pixels to horizontal resize the control - * @param dh - number of pixels to vertical resize the control - * - * @return nothing - **/ -static FORCEINLINE VOID MoveCtrl(HWND hDlg, INT idCtrl, INT dx, INT dy, INT dw, INT dh) -{ - RECT ws; - HWND hCtrl = GetDlgItem(hDlg, idCtrl); - GetWindowRect(hCtrl, &ws); - OffsetRect(&ws, dx, dy); - MoveWindow(hCtrl, ws.left, ws.top, ws.right - ws.left + dw, ws.bottom - ws.top + dh, FALSE); -} - -/** - * This function loads the icon to display for the current message. - * - * @param pMsgBox - pointer to a MSGBOX structure, with information about the message to display. - * - * @retval HICON - The function returns an icon to display with the message. - * @retval NULL - There is no icon for the message. - **/ -HICON MsgLoadIcon(LPMSGBOX pMsgBox) -{ - HICON hIcon; - - // load the desired status icon - switch (pMsgBox->uType & MB_ICONMASK) - { - - // custom icon defined by caller function - case MB_ICON_OTHER: - { - hIcon = pMsgBox->hiMsg; - } - break; - - // default windows icons - case MB_ICON_ERROR: - case MB_ICON_QUESTION: - case MB_ICON_WARNING: - case MB_ICON_INFO: - { - LPCTSTR ico[] = { 0, IDI_ERROR, IDI_QUESTION, IDI_WARNING, IDI_INFORMATION }; - hIcon = LoadIcon(NULL, ico[MB_ICON_INDEX(pMsgBox->uType)]); - } - break; - - // no icon - default: - { - hIcon = NULL; - } - } - return hIcon; -} - -/** - * This function fills a given POPUPACTION structure with the data of a given message id, - * which is normally used by the message box. This is required to let the user interact - * with a popup in the same way as with a normal message dialog box. - * - * @param pa - reference to a POPUPACTION structure to fill - * @param id - the message id - * @param result - This parameter is passed to the POPUPACTION structure as is. - * - * @return nothing - **/ -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 IDOK: - { - pa.lchIcon = IcoLib_GetIcon(ICO_BTN_OK); - mir_strcpy(pa.lpzTitle, MODNAME"/Ok"); - } - break; - - case IDCLOSE: - case IDCANCEL: - { - pa.lchIcon = IcoLib_GetIcon(ICO_BTN_CANCEL); - mir_strcpy(pa.lpzTitle, MODNAME"/Cancel"); - } - break; - - case IDABORT: - { - pa.lchIcon = IcoLib_GetIcon(ICO_BTN_CANCEL); - mir_strcpy(pa.lpzTitle, MODNAME"/Abort"); - } - break; - - case IDRETRY: - { - pa.lchIcon = IcoLib_GetIcon(ICO_BTN_UPDATE); - mir_strcpy(pa.lpzTitle, MODNAME"/Retry"); - } - break; - - case IDIGNORE: - { - pa.lchIcon = IcoLib_GetIcon(ICO_BTN_OK); - mir_strcpy(pa.lpzTitle, MODNAME"/Ignore"); - } - break; - - case IDYES: - { - pa.lchIcon = IcoLib_GetIcon(ICO_BTN_OK); - mir_strcpy(pa.lpzTitle, MODNAME"/Yes"); - } - break; - - case IDNO: - { - pa.lchIcon = IcoLib_GetIcon(ICO_BTN_CANCEL); - mir_strcpy(pa.lpzTitle, MODNAME"/No"); - } - break; - - case IDHELP: - { - pa.lchIcon = IcoLib_GetIcon(ICO_BTN_CANCEL); - mir_strcpy(pa.lpzTitle, MODNAME"/Help"); - } - break; - - case IDALL: - { - pa.lchIcon = IcoLib_GetIcon(ICO_BTN_OK); - mir_strcpy(pa.lpzTitle, MODNAME"/All"); - } - break; - - case IDNONE: - { - pa.lchIcon = IcoLib_GetIcon(ICO_BTN_CANCEL); - mir_strcpy(pa.lpzTitle, MODNAME"/None"); - } - } -} - -/** - * This is the message procedure for my nice looking message box - * - * @param hDlg - window handle - * @param uMsg - message to handle - * @param wParam - message specific parameter - * @param lParam - message specific parameter - * - * @return TRUE, FALSE, IDOK, IDYES, IDALL, IDNO or IDCANCEL - **/ -INT_PTR CALLBACK MsgBoxProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - static INT retOk = IDOK; - static INT retAll = IDALL; - static INT retNon = IDNONE; - static INT retCancel = IDCANCEL; - - switch (uMsg) - { - case WM_INITDIALOG: - { - LPMSGBOX pMsgBox = (LPMSGBOX)lParam; - - if (PtrIsValid(pMsgBox)) - { - INT icoWidth = 0; - INT InfoBarHeight = 0; - HFONT hNormalFont; - - hNormalFont = (HFONT)SendDlgItemMessage(hDlg, TXT_NAME, WM_GETFONT, 0, 0); - if (pMsgBox->uType & MB_INFOBAR) - { - LOGFONT lf; - - // set bold font for name in description area - GetObject(hNormalFont, sizeof(lf), &lf); - lf.lfWeight = FW_BOLD; - hNormalFont = CreateFontIndirect(&lf); - - // set infobar's textfont - SendDlgItemMessage(hDlg, TXT_NAME, WM_SETFONT, (WPARAM)hNormalFont, 0); - - // set infobar's logo icon - SendDlgItemMessage(hDlg, ICO_DLGLOGO, STM_SETIMAGE, IMAGE_ICON, - (LPARAM)((pMsgBox->hiLogo) ? pMsgBox->hiLogo : IcoLib_GetIcon(ICO_DLG_DETAILS))); - - // anable headerbar - ShowWindow(GetDlgItem(hDlg, TXT_NAME), SW_SHOW); - ShowWindow(GetDlgItem(hDlg, ICO_DLGLOGO), SW_SHOW); - } - else - { - RECT rc; - GetClientRect(GetDlgItem(hDlg, TXT_NAME), &rc); - InfoBarHeight = rc.bottom; - - if (pMsgBox->hiLogo) - { - SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)pMsgBox->hiLogo); - } - } - - // draw the desired status icon - HICON hIcon = MsgLoadIcon(pMsgBox); - if (hIcon) - { - SendDlgItemMessage(hDlg, ICO_MSGDLG, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); - } - else - { - RECT ws; - GetWindowRect(GetDlgItem(hDlg, ICO_MSGDLG), &ws); - icoWidth = ws.right - ws.left; - ShowWindow(GetDlgItem(hDlg, ICO_MSGDLG), SW_HIDE); - } - - // resize the messagebox and reorganize the buttons - if (HDC hDC = GetDC(hDlg)) - { - POINT mpt = {0,0}; - RECT ws = {0,0,0,0}; - INT txtWidth, - txtHeight, - needX, needY; - RECT rcDlg; - SIZE ts; - LPTSTR h, rs; - - SelectObject(hDC, hNormalFont); - - for (rs = h = pMsgBox->ptszMsg, txtHeight = 0, txtWidth = 0; h; h++) - { - if (*h == '\n' || *h == '\0') - { - GetTextExtentPoint32(hDC, rs, h - rs, &ts); - if (ts.cx > txtWidth) - { - txtWidth = ts.cx; - } - txtHeight += ts.cy; - if (*h == '\0') - { - break; - } - rs = h + 1; - } - } - ReleaseDC(hDlg, hDC); - - // calc new dialog size - GetWindowRect(hDlg, &rcDlg); - GetWindowRect(GetDlgItem(hDlg, TXT_MESSAGE), &ws); - needX = txtWidth - (ws.right - ws.left) - icoWidth; - needY = max(0, txtHeight - (ws.bottom - ws.top) + 5); - rcDlg.left -= needX/2; rcDlg.right += needX/2; - rcDlg.top -= (needY-InfoBarHeight)/2; rcDlg.bottom += (needY-InfoBarHeight)/2; - - // resize dialog window - MoveWindow(hDlg, - rcDlg.left, rcDlg.top, - rcDlg.right - rcDlg.left, - rcDlg.bottom - rcDlg.top, - FALSE); - ClientToScreen(hDlg, &mpt); - - MoveCtrl(hDlg, STATIC_WHITERECT, -mpt.x, -mpt.y, needX, needY - InfoBarHeight); - MoveCtrl(hDlg, TXT_NAME, -mpt.x, -mpt.y, needX, 0); - MoveCtrl(hDlg, ICO_DLGLOGO, -mpt.x + needX, -mpt.y, 0, 0); - MoveCtrl(hDlg, ICO_MSGDLG, -mpt.x, -mpt.y - InfoBarHeight, 0, 0); - MoveCtrl(hDlg, TXT_MESSAGE, -mpt.x - icoWidth, -mpt.y - InfoBarHeight, needX, needY); - MoveCtrl(hDlg, STATIC_LINE2, -mpt.x, -mpt.y + needY - InfoBarHeight, needX, 0); - - // - // Do pushbutton positioning - // - { - RECT rcOk, rcAll, rcNone, rcCancel; - LONG okWidth, caWidth, allWidth, noneWidth, dlgMid; - - // get button rectangles - GetWindowRect(GetDlgItem(hDlg, IDOK), &rcOk); - OffsetRect(&rcOk, -mpt.x, -mpt.y + needY - InfoBarHeight); - - GetWindowRect(GetDlgItem(hDlg, IDALL), &rcAll); - OffsetRect(&rcAll, -mpt.x, -mpt.y + needY - InfoBarHeight); - - GetWindowRect(GetDlgItem(hDlg, IDNONE), &rcNone); - OffsetRect(&rcNone, -mpt.x, -mpt.y + needY - InfoBarHeight); - - GetWindowRect(GetDlgItem(hDlg, IDCANCEL), &rcCancel); - OffsetRect(&rcCancel, -mpt.x, -mpt.y + needY - InfoBarHeight); - - okWidth = rcOk.right - rcOk.left; - allWidth = rcAll.right - rcAll.left; - noneWidth = rcNone.right - rcNone.left; - caWidth = rcCancel.right - rcCancel.left; - dlgMid = (rcDlg.right - rcDlg.left) / 2; - - // load button configuration - switch (MB_TYPE(pMsgBox->uType)) - { - - case MB_OK: - { - rcOk.left = dlgMid - (okWidth / 2); - rcOk.right = rcOk.left + okWidth; - ShowWindow(GetDlgItem(hDlg, IDOK), SW_SHOW); - } - break; - - case MB_OKCANCEL: - { - retOk = IDRETRY; - SetDlgItemText(hDlg, IDOK, LPGENT("OK")); - retCancel = IDCANCEL; - SetDlgItemText(hDlg, IDCANCEL, LPGENT("Cancel")); - rcOk.left = dlgMid - okWidth - 10; - rcOk.right = rcOk.left + okWidth; - rcCancel.left = dlgMid + 10; - rcCancel.right = rcCancel.left + caWidth; - ShowWindow(GetDlgItem(hDlg, IDOK), SW_SHOW); - ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_SHOW); - } - break; - - case MB_RETRYCANCEL: - { - retOk = IDRETRY; - SetDlgItemText(hDlg, IDOK, LPGENT("Retry")); - retCancel = IDCANCEL; - SetDlgItemText(hDlg, IDCANCEL, LPGENT("Cancel")); - rcOk.left = dlgMid - okWidth - 10; - rcOk.right = rcOk.left + okWidth; - rcCancel.left = dlgMid + 10; - rcCancel.right = rcCancel.left + caWidth; - ShowWindow(GetDlgItem(hDlg, IDOK), SW_SHOW); - ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_SHOW); - } - break; - - case MB_YESNO: - { - retOk = IDYES; - SetDlgItemText(hDlg, IDOK, LPGENT("Yes")); - retCancel = IDNO; - SetDlgItemText(hDlg, IDCANCEL, LPGENT("No")); - rcOk.left = dlgMid - okWidth - 10; - rcOk.right = rcOk.left + okWidth; - rcCancel.left = dlgMid + 10; - rcCancel.right = rcCancel.left + caWidth; - ShowWindow(GetDlgItem(hDlg, IDOK), SW_SHOW); - ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_SHOW); - } - break; - - case MB_ABORTRETRYIGNORE: - { - retOk = IDABORT; - SetDlgItemText(hDlg, IDOK, LPGENT("Abord")); - retAll = IDABORT; - SetDlgItemText(hDlg, IDALL, LPGENT("Retry")); - retCancel = IDCANCEL; - SetDlgItemText(hDlg, IDCANCEL, LPGENT("Ignore")); - rcAll.left = dlgMid - (allWidth / 2); - rcAll.right = rcAll.left + allWidth; - rcOk.left = rcAll.left - okWidth - 5; - rcOk.right = rcOk.left + okWidth; - rcCancel.left = rcAll.right + 5; - rcCancel.right = rcCancel.left + caWidth; - ShowWindow(GetDlgItem(hDlg, IDOK), SW_SHOW); - ShowWindow(GetDlgItem(hDlg, IDALL), SW_SHOW); - ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_SHOW); - } - break; - - case MB_YESNOCANCEL: - { - retOk = IDYES; - SetDlgItemText(hDlg, IDOK, LPGENT("Yes")); - retAll = IDNO; - SetDlgItemText(hDlg, IDALL, LPGENT("No")); - retCancel = IDCANCEL; - SetDlgItemText(hDlg, IDCANCEL, LPGENT("Cancel")); - rcAll.left = dlgMid - (allWidth / 2); - rcAll.right = rcAll.left + allWidth; - rcOk.left = rcAll.left - okWidth - 5; - rcOk.right = rcOk.left + okWidth; - rcCancel.left = rcAll.right + 5; - rcCancel.right = rcCancel.left + caWidth; - ShowWindow(GetDlgItem(hDlg, IDOK), SW_SHOW); - ShowWindow(GetDlgItem(hDlg, IDALL), SW_SHOW); - ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_SHOW); - } - break; - - case MB_YESALLNO: - { - retOk = IDYES; - SetDlgItemText(hDlg, IDOK, LPGENT("Yes")); - retAll = IDALL; - SetDlgItemText(hDlg, IDALL, LPGENT("All")); - //retNon = IDNONE; - SetDlgItemText(hDlg, IDNONE, LPGENT("None")); - retCancel = IDNO; - SetDlgItemText(hDlg, IDCANCEL, LPGENT("No")); - rcCancel.right = rcDlg.right - rcDlg.left - 10; - rcCancel.left = rcCancel.right - caWidth; - rcNone.right = rcCancel.left - 5; - rcNone.left = rcNone.right - noneWidth; - rcAll.right = rcNone.left - 5; - rcAll.left = rcAll.right - allWidth; - rcOk.right = rcAll.left - 5; - rcOk.left = rcOk.right - okWidth; - // show buttons - ShowWindow(GetDlgItem(hDlg, IDOK), SW_SHOW); - ShowWindow(GetDlgItem(hDlg, IDALL), SW_SHOW); - ShowWindow(GetDlgItem(hDlg, IDNONE), SW_SHOW); - ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_SHOW); - } - break; - - default: - { - rcOk.left = dlgMid - (okWidth / 2); - rcOk.right = rcOk.left + okWidth; - } - } - // move ok button - MoveWindow(GetDlgItem(hDlg, IDOK), - rcOk.left, rcOk.top, - rcOk.right - rcOk.left, rcOk.bottom - rcOk.top, - FALSE); - // move all button - MoveWindow(GetDlgItem(hDlg, IDALL), - rcAll.left, rcAll.top, - rcAll.right - rcAll.left, rcAll.bottom - rcAll.top, - FALSE); - // move none button - MoveWindow(GetDlgItem(hDlg, IDNONE), - rcNone.left, rcNone.top, - rcNone.right - rcNone.left, rcNone.bottom - rcNone.top, - FALSE); - // move cancel button - MoveWindow(GetDlgItem(hDlg, IDCANCEL), - rcCancel.left, rcCancel.top, - rcCancel.right - rcCancel.left, rcCancel.bottom - rcCancel.top, - FALSE); - } // end* Do pushbutton positioning - } // end* resize the messagebox and reorganize the buttons - - TranslateDialogDefault(hDlg); - - // set text's - SetWindowText(hDlg, pMsgBox->ptszTitle); - SetDlgItemText(hDlg, TXT_NAME, pMsgBox->ptszInfoText); - SetDlgItemText(hDlg, TXT_MESSAGE, pMsgBox->ptszMsg); - - return TRUE; - } // end* PtrIsValid(pMsgBox) - } // end* WM_INITDIALOG: - break; - - case WM_CTLCOLORSTATIC: - { - switch (GetWindowLong((HWND)lParam, GWL_ID)) - { - case STATIC_WHITERECT: - case ICO_DLGLOGO: - case ICO_MSGDLG: - case TXT_MESSAGE: - case TXT_NAME: - { - SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT)); - return GetSysColor(COLOR_WINDOW); - } - } - } - break; - - case WM_COMMAND: - { - switch (LOWORD(wParam)) - { - case IDOK: - EndDialog(hDlg, retOk); - break; - case IDCANCEL: - EndDialog(hDlg, retCancel); - break; - case IDALL: - EndDialog(hDlg, retAll); - break; - case IDNONE: - EndDialog(hDlg, retNon); - } - } - break; - - case WM_DESTROY: - { - DeleteObject((HFONT)SendDlgItemMessage(hDlg, TXT_NAME, WM_GETFONT, 0, 0)); - } - break; - } - return FALSE; -} - - -/** - * Dummi modal MsgBox for popup, - * this set call function in wait stait and do not freece miranda main thread - * the window is outside the desktop - */ -INT_PTR CALLBACK MsgBoxPop(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch (uMsg) - { - case WM_INITDIALOG: - { - POPUPDATAT_V2 pd; - LPMSGPOPUPDATA pmpd; - LPMSGBOX pMsgBox = (LPMSGBOX)lParam; - - MoveWindow(hDlg,-10,-10,0,0,FALSE); - pmpd = (LPMSGPOPUPDATA)mir_alloc(sizeof(MSGPOPUPDATA)); - if (pmpd) - { - ZeroMemory(&pd, sizeof(pd)); - pd.cbSize = sizeof(POPUPDATAT); - pd.lchContact = NULL; //(HANDLE)wParam; - // icon - pd.lchIcon = MsgLoadIcon(pMsgBox); - mir_tcsncpy(pd.lptzContactName, pMsgBox->ptszTitle, SIZEOF(pd.lptzContactName)); - mir_tcsncpy(pd.lptzText, pMsgBox->ptszMsg, SIZEOF(pd.lptzText)); - - // CALLBAC Proc - pd.PluginWindowProc = (WNDPROC)PopupProc; - // - pd.PluginData = pmpd; - - pd.iSeconds = -1; - - pd.hNotification = NULL; - pd.lpActions = pmpd->pa; - - // set color of popup - switch (pMsgBox->uType & MB_ICONMASK) - { - case MB_ICON_ERROR: - { - pd.colorBack = RGB(200, 10, 0); - pd.colorText = RGB(255, 255, 255); - } - break; - - case MB_ICON_WARNING: - { - pd.colorBack = RGB(200, 100, 0); - pd.colorText = RGB(255, 255, 255); - } - break; - - default: - { - if (pMsgBox->uType & MB_CUSTOMCOLOR) - { - pd.colorBack = pMsgBox->colorBack; - pd.colorText = pMsgBox->colorText; - } - } - } - - // handle for MakePopupAction - pmpd->hDialog = hDlg; - - // active buttons - switch (MB_TYPE(pMsgBox->uType)) - { - case MB_OK: - { - MakePopupAction(pmpd->pa[pd.actionCount++], IDOK); - } - break; - - case MB_OKCANCEL: - { - MakePopupAction(pmpd->pa[pd.actionCount++], IDOK); - MakePopupAction(pmpd->pa[pd.actionCount++], IDCANCEL); - } - break; - - case MB_RETRYCANCEL: - { - MakePopupAction(pmpd->pa[pd.actionCount++], IDRETRY); - MakePopupAction(pmpd->pa[pd.actionCount++], IDCANCEL); - } - break; - - case MB_YESNO: - { - MakePopupAction(pmpd->pa[pd.actionCount++], IDYES); - MakePopupAction(pmpd->pa[pd.actionCount++], IDNO); - } - break; - - case MB_ABORTRETRYIGNORE: - { - MakePopupAction(pmpd->pa[pd.actionCount++], IDABORT); - MakePopupAction(pmpd->pa[pd.actionCount++], IDRETRY); - MakePopupAction(pmpd->pa[pd.actionCount++], IDIGNORE); - } - break; - - case MB_YESNOCANCEL: - { - MakePopupAction(pmpd->pa[pd.actionCount++], IDYES); - MakePopupAction(pmpd->pa[pd.actionCount++], IDNO); - MakePopupAction(pmpd->pa[pd.actionCount++], IDCANCEL); - } - break; - - case MB_YESALLNO: - { - MakePopupAction(pmpd->pa[pd.actionCount++], IDYES); - MakePopupAction(pmpd->pa[pd.actionCount++], IDALL); - MakePopupAction(pmpd->pa[pd.actionCount++], IDNO); - } - break; - - } // end* switch - - // create popup - CallService(MS_POPUP_ADDPOPUPT, (WPARAM) &pd, APF_NEWDATA); - if (MB_TYPE(pMsgBox->uType) == MB_OK) - { - EndDialog(hDlg, IDOK); - } - } // end*if (pmpd) - break; - } // end* WM_INITDIALOG: - } // end* switch (uMsg) - return FALSE; -} - -/** - * This is the message procedure for popup - * - * @param hDlg - window handle - * @param uMsg - message to handle - * @param wParam - message specific parameter - * @param lParam - message specific parameter - * - * @return TRUE, FALSE, IDOK, IDYES, IDALL, IDNO or IDCANCEL - **/ -INT_PTR CALLBACK PopupProc(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 IDOK: - case IDCANCEL: - case IDABORT: - case IDRETRY: - case IDIGNORE: - case IDYES: - case IDNO: - case IDALL: - case IDNONE: - { - if (IsWindow(pmpd->hDialog)) - EndDialog(pmpd->hDialog, LOWORD(wParam)); - } - break; - - default: - { - if (IsWindow(pmpd->hDialog)) - EndDialog(pmpd->hDialog, IDCANCEL); - } - } - } - PUDeletePopUp(hDlg); - } - } - break; - - case UM_FREEPLUGINDATA: - { - LPMSGPOPUPDATA pmpd = (LPMSGPOPUPDATA)PUGetPluginData(hDlg); - if (pmpd > 0) { - mir_freeAndNil(pmpd); - } - return TRUE; //TRUE or FALSE is the same, it gets ignored. - } - break; - - default: - break; - } - return DefWindowProc(hDlg, uMsg, wParam, lParam); -} - -/** - * This is the service function for external plugins to use the nice messagebox - * - * @param wParam - HANDLE hContact which can display an avatar for popups - * @param lParam - MSGBOX structure holding parameters - * - * @return The function returns the ID of the clicked button (IDOK, IDCANCEL, ...) - * or -1 on error. - **/ -INT_PTR MsgBoxService(WPARAM wParam, LPARAM lParam) -{ - INT rc = -1; - LPMSGBOX pMsgBox = (LPMSGBOX)lParam; - - // check input - if (PtrIsValid(pMsgBox) && pMsgBox->cbSize == sizeof(MSGBOX)) - { - // Shall the MessageBox displayed as popup? - if (!(pMsgBox->uType & (MB_INFOBAR|MB_NOPOPUP)) && // message box can be a popup? - ServiceExists(MS_POPUP_ADDPOPUPT) && // popups exist? - myGlobals.PopUpActionsExist == 1 && // popup support ext stuct? - (DBGetContactSettingDword(NULL, "PopUp","Actions", 0) & 1) && // popup++ actions on? - DBGetContactSettingByte(NULL, MODNAME, SET_POPUPMSGBOX, DEFVAL_POPUPMSGBOX) // user likes popups? - ) - { - rc = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_MSGBOXDUMMI), pMsgBox->hParent, (DLGPROC)MsgBoxPop, lParam); - } - else - { - rc = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_MSGBOX), pMsgBox->hParent, (DLGPROC)MsgBoxProc, lParam); - } - } - return rc; -} - -/** - * name: MsgBox - * desc: calls a messagebox - * param: - **/ -INT_PTR MsgBox(HWND hParent, UINT uType, LPTSTR pszTitle, LPTSTR pszInfo, LPTSTR pszFormat, ...) -{ - MSGBOX mb = {0}; - TCHAR tszMsg[MAX_SECONDLINE]; - va_list vl; - - va_start(vl, pszFormat); - mir_vsntprintf(tszMsg, SIZEOF(tszMsg), TranslateTS(pszFormat), vl); - va_end(vl); - - mb.cbSize = sizeof(MSGBOX); - mb.hParent = hParent; - mb.hiLogo = LoadIcon(hInst, MAKEINTRESOURCE(IDI_PLUG_MAIN)); - mb.hiMsg = NULL; - mb.ptszTitle = TranslateTS(pszTitle); - mb.ptszInfoText = TranslateTS(pszInfo); - mb.ptszMsg = tszMsg; - mb.uType = uType; - return MsgBoxService(NULL, (LPARAM)&mb); -} - -/** - * name: MsgErr - * desc: calls a messagebox - * param: - **/ -INT_PTR MsgErr(HWND hParent, LPCTSTR pszFormat, ...) -{ - if(!pszFormat) return -1; - MSGBOX mb = {0}; - TCHAR tszTitle[MAX_SECONDLINE]; - TCHAR tszMsg[MAX_SECONDLINE]; - va_list vl; - - mir_sntprintf(tszTitle, SIZEOF(tszMsg),_T("%s - %s") ,_T(MODNAME), TranslateT("Error")); - - va_start(vl, pszFormat); - mir_vsntprintf(tszMsg, SIZEOF(tszMsg), TranslateTS(pszFormat), vl); - va_end(vl); - - mb.cbSize = sizeof(MSGBOX); - mb.hParent = hParent; - mb.hiLogo = LoadIcon(hInst, MAKEINTRESOURCE(IDI_PLUG_MAIN)); - mb.hiMsg = NULL; - mb.ptszTitle = tszTitle; - mb.ptszMsg = tszMsg; - mb.uType = MB_OK|MB_ICON_ERROR; - return MsgBoxService(NULL, (LPARAM)&mb); -} diff --git a/plugins/SendScreenshotPlus/dlg_msgbox.h b/plugins/SendScreenshotPlus/dlg_msgbox.h deleted file mode 100644 index a6cd04c6b7..0000000000 --- a/plugins/SendScreenshotPlus/dlg_msgbox.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2009 Miranda ICQ/IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -aLONG with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $HeadURL: https://userinfoex.googlecode.com/svn/trunk/dlg_msgbox.h $ -Revision : $Revision: 164 $ -Last change on : $Date: 2009-12-02 21:24:35 +0100 (Mi, 02. Dez 2009) $ -Last change by : $Author: ing.u.horn $ - -*/ - -#ifndef _DLG_MSGBOX -#define _DLG_MSGBOX 1 - -//--------------------------------------------------------------------------- -#include "global.h" - -//--------------------------------------------------------------------------- -#define SET_POPUPMSGBOX "PopupMsgBox" -#define DEFVAL_POPUPMSGBOX TRUE //FALSE - -/* UserInfo/MsgBox v0.1.0.3+ -Some little changed message box for nicer look of miranda's messages or questions :-) -wParam=hContact - can be null -lParam=(_MSGBOX*)pMsg - structure that holds information about the look of the message dialog -uType member of _MSGBOX can be a combination of the following values, where most of them are defined in winuser.h: -MB_OK -MB_OKCANCEL -MB_YESALLNO -MB_YESNO -For valid icon values use one of the following MB_ICON_... -Funktion returns: IDOK, IDYES, IDALL, IDNO or IDCANCEL -*/ - -/* - Defined in winuser.h - ******************** - -#define MB_OK 0x00000000L -#define MB_OKCANCEL 0x00000001L -#define MB_ABORTRETRYIGNORE 0x00000002L -#define MB_YESNOCANCEL 0x00000003L -#define MB_YESNO 0x00000004L -#define MB_RETRYCANCEL 0x00000005L -*/ -#define MB_YESALLNO 0x00000007L -#define MB_TYPE(p) ((p)&MB_TYPEMASK) - -/* -valid predefined icon values -*/ -#define MB_ICON_NONE 0x00000000L // 0 - no icon -#define MB_ICON_ERROR 0x00000010L // 16 - error icon -#define MB_ICON_QUESTION 0x00000020L // 32 - question mark -#define MB_ICON_WARNING 0x00000030L // 48 - warning -#define MB_ICON_INFO 0x00000040L // 64 - info -#define MB_ICON_OTHER 0x00000080L // 240 - use icon _MSGBOX->hiMsg -#define MB_ICON_INDEX(p) (((p)&MB_ICONMASK)>>4) - -/* -flags -*/ -#define MB_INFOBAR 0x00000100L -#define MB_NOPOPUP 0x00000200L -#define MB_CUSTOMCOLOR 0x00000300L - -typedef struct _MSGBOX -{ - UINT cbSize; // size of this structure - UINT uType; // parameters - HICON hiLogo; // right upper icon of the info bar - HICON hiMsg; // icon left next to the message text - LPTSTR ptszTitle; - LPTSTR ptszInfoText; - LPTSTR ptszMsg; - HWND hParent; // parent window for the messagebox - COLORREF colorBack; // valid if MB_CUSTOMCOLOR is set - COLORREF colorText; // valid if MB_CUSTOMCOLOR is set -} MSGBOX, *LPMSGBOX; - - -INT_PTR CALLBACK MsgBoxProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); -INT_PTR CALLBACK MsgBoxPop (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); -INT_PTR CALLBACK PopupProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); - -INT_PTR MsgBoxService(WPARAM wParam, LPARAM lParam); -INT_PTR MsgBox(HWND hParent, UINT uType, LPTSTR pszTitle, LPTSTR pszInfo, LPTSTR pszFormat, ...); -INT_PTR MsgErr(HWND hParent, LPCTSTR pszFormat, ...); - -#endif /* _DLG_MSGBOX */ \ No newline at end of file diff --git a/plugins/SendScreenshotPlus/docs/credits.txt b/plugins/SendScreenshotPlus/docs/credits.txt new file mode 100644 index 0000000000..122042be3b --- /dev/null +++ b/plugins/SendScreenshotPlus/docs/credits.txt @@ -0,0 +1,10 @@ +Special thanks to Michael Kunz aka "Protogenes" +for helping me with 1001 tips and suggestions +to design the program code. +http://www-user.tu-chemnitz.de/~kunmi/?dbx_tree&lang=de + +Thanks to the "UserinfoEx" programmers group +for the nice button class code. +http://code.google.com/p/userinfoex/ + +and special thanks to all beta-testers... diff --git a/plugins/SendScreenshotPlus/docs/license.txt b/plugins/SendScreenshotPlus/docs/license.txt new file mode 100644 index 0000000000..c5ebcce31f --- /dev/null +++ b/plugins/SendScreenshotPlus/docs/license.txt @@ -0,0 +1,15 @@ +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied +warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +You should have received a copy of the GNU General +Public License along with this program; if not, write to the +Free Software Foundation, Inc., +675 Mass Ave, Cambridge, MA 02139, USA. diff --git a/plugins/SendScreenshotPlus/global.h b/plugins/SendScreenshotPlus/global.h deleted file mode 100644 index 48586f83d3..0000000000 --- a/plugins/SendScreenshotPlus/global.h +++ /dev/null @@ -1,189 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2009 Miranda ICQ/IM project, - -This file is part of Send Screenshot Plus, a Miranda IM plugin. -Copyright (c) 2010 Ing.U.Horn - -Parts of this file based on original sorce code -(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/global.h $ -Revision : $Revision: 22 $ -Last change on : $Date: 2010-05-02 21:25:02 +0400 (Р’СЃ, 02 май 2010) $ -Last change by : $Author: ing.u.horn $ - -*/ - -#ifndef _GLOBAL_H_ -#define _GLOBAL_H_ - -#define WINVER 0x0700 -#define _WIN32_WINNT 0x0700 -#define _WIN32_IE 0x0601 - -#define OEMRESOURCE -#define MIRANDA_VER 0x0A00 - -// Windows includes -#include -#include - -// Standard includes -#include -//#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -using namespace std; - -// Miranda IM SDK includes -#include -#include -#include -#include // This must be included first -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// plugins SDK -#include -#include -#include -#include -#include "icons.h" //from uiex icon pack - -// Project resources -#include "m_sendss.h" -#include "mir_string.h" -#include "mir_icolib.h" -#include "ctrl_button.h" -#include "dlg_msgbox.h" -#include "resource.h" -#include "version.h" - -#ifdef ComboBox_SelectItemData - // use Workaround for MS bug ComboBox_SelectItemData; - #undef ComboBox_SelectItemData -#endif - -#define UM_CLOSING WM_USER+1 -#define UM_EVENT WM_USER+2 -#define UM_TAB1 WM_USER+11 - -// Generic Message Box for Errors -#define MSGERROR(text) MessageBox(NULL, text, _T("SendSS"), MB_OK | MB_ICONERROR) -#define MSGINFO (text) MessageBox(NULL, text, _T("SendSS"), MB_OK | MB_ICONINFORMATION) - -typedef struct _MGLOBAL { - DWORD mirandaVersion; // mirandaVersion - BOOLEAN PopUpExist : 1; // Popup or MS_POPUP_ADDPOPUP exist - BOOLEAN PopUpActionsExist : 1; // Popup++ or MS_POPUP_REGISTERACTIONS exist - BOOLEAN PluginHTTPExist : 1; // HTTPServer or MS_HTTP_ACCEPT_CONNECTIONS exist - BOOLEAN PluginFTPExist : 1; // FTPFile or MS_FTPFILE_SHAREFILE exist - -} MGLOBAL, *LPMGLOBAL; - -//--------------------------------------------------------------------------- -#define ERROR_TITLE _T("SendScreenshot - Error") - -// Miranda Database Key -#define SZ_SENDSS "SendSS" -#define MODNAME "SendSS" - -extern HINSTANCE hInst; -extern MGLOBAL myGlobals; -extern HANDLE hNetlibUser; - -#define PtrIsValid(p) (((p)!=0)&&(((HANDLE)(p))!=INVALID_HANDLE_VALUE)) - -template -std::basic_string<_Elem> replace(const std::basic_string<_Elem> & Origninal, const std::basic_string<_Elem> & What, const std::basic_string<_Elem> & With) -{ - std::basic_string<_Elem> res; - size_t l = 0; - size_t p = 0; - - for (size_t p = Origninal.find(What.c_str(), 0); p != std::basic_string<_Elem>::npos; p = Origninal.find(What.c_str(), l)) - { - if (l != p) - res.append(Origninal.c_str() + l, p - l); - res.append(With); - l = p + What.length(); - } - if (l < Origninal.length()) - res.append(Origninal.c_str() + l); - - return res; -} - -#endif - -/************************************************************* - * Uinfobuttonclass module - */ - -// button styles -#define MBS_DEFBUTTON 0x00001000L // default button -#define MBS_PUSHBUTTON 0x00002000L // toggle button -#define MBS_FLAT 0x00004000L // flat button -#define MBS_DOWNARROW 0x00008000L // has arrow on the right - -#define MBF_UNICODE 1 -#ifdef _UNICODE - #define MBF_TCHAR MBF_UNICODE -#else - #define MBF_TCHAR 0 -#endif - -// BUTTONADDTOOLTIP -// use lParam=MBF_UNICODE to set unicode tooltips -// for lParam=0 the string is interpreted as ansi - -// message to explicitly translate the buttons text, -// as it is not done by default translation routine -// wParam=lParam=NULL -#define BUTTONTRANSLATE (WM_USER+6) - -/* UserInfo/MsgBox v0.1.0.4+ -Slightly modified version of MButtonClass, to draw both text and icon in a button control -*/ -#define UINFOBUTTONCLASS _T("UInfoButtonClass") - diff --git a/plugins/SendScreenshotPlus/mir_icolib.cpp b/plugins/SendScreenshotPlus/mir_icolib.cpp deleted file mode 100644 index 33718faf98..0000000000 --- a/plugins/SendScreenshotPlus/mir_icolib.cpp +++ /dev/null @@ -1,382 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2009 Miranda ICQ/IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -aLONG with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -this file is taken from UserinfoEx plugin and support UserinfoEx icon pack !!!! - -*/ - -#include "global.h" - - -typedef struct _ICODESC -{ - LPSTR pszName; - LPSTR pszDesc; - LPSTR pszSection; - BOOL bfromIconPack; - WORD idResource; - BYTE size; -} ICODESC; - -HICON ghDefIcon = NULL; - -//IDI_PLUG_MAIN must be the first icon from Plugin.dll, all other icon must be IDI_PLUG_MAIN+n -static ICODESC icoDesc[] = -{ - // common - { ICO_PLUG_SSWINDOW1, "Screenshot Icon1", SECT_COMMON, 0, IDI_PLUG_MAIN, -1 }, - { ICO_PLUG_SSWINDOW2, "Screenshot Icon2", SECT_COMMON, 0, IDI_PLUG_ICON1, 0 }, - { ICO_PLUG_SSTARGET, "Target Cursor", SECT_COMMON, 0, IDI_PLUG_ICON2, 1 }, - { ICO_PLUG_SSMONITOR, "Target Desktop", SECT_COMMON, 0, IDI_PLUG_ICON3, 1 }, - { ICO_PLUG_SSDEFAULT, "Default", SECT_COMMON, 0, IDI_PLUG_DEFAULT, 0 }, - - // overlays - { ICO_PLUG_OVERLAYON, "overlay on", SECT_OVERLAY, 0, IDI_PLUG_OVERLAYON, 0 }, - { ICO_PLUG_OVERLAYOFF, "overlay off", SECT_OVERLAY, 0, IDI_PLUG_OVERLAYOFF,0 }, - - // dialogs -// { ICO_DLG_DETAILS, "Details Infobar", SECT_DLG, 1, IDI_DLG_DETAILS, 48 }, -// { ICO_DLG_PHONE, "Phone Infobar", SECT_DLG, 1, IDI_DLG_PHONE, 1 }, -// { ICO_DLG_EMAIL, "E-Mail Infobar", SECT_DLG, 1, IDI_DLG_EMAIL, 1 }, - - // button icons - { ICO_PLUG_SSHELP, "Help", SECT_BUTTONS, 0, IDI_PLUG_HELP, 0 }, - { ICO_PLUG_SSFOLDERO, "Open Folder", SECT_BUTTONS, 0, IDI_PLUG_FOLDERO, 0 }, - { ICO_PLUG_SSDESKOFF, "description off", SECT_BUTTONS, 0, IDI_PLUG_DESKOFF, 0 }, - { ICO_PLUG_SSDESKON, "description on", SECT_BUTTONS, 0, IDI_PLUG_DESKON, 0 }, - { ICO_PLUG_SSDELOFF, "delete off", SECT_BUTTONS, 0, IDI_PLUG_DELOFF, 0 }, - { ICO_PLUG_SSDELON, "delete on", SECT_BUTTONS, 0, IDI_PLUG_DELON, 0 }, - { ICO_PLUG_ARROWL, "Prev", SECT_BUTTONS, 0, IDI_PLUG_ARROWL, 0 }, - { ICO_PLUG_ARROWR, "Next", SECT_BUTTONS, 0, IDI_PLUG_ARROWR, 0 }, - - { ICO_BTN_UPDATE, "Update", SECT_BUTTONS, 1, IDI_BTN_UPDATE, 0 }, - { ICO_BTN_OK, "Ok", SECT_BUTTONS, 1, IDI_BTN_OK, 0 }, - { ICO_BTN_CANCEL, "Cancel", SECT_BUTTONS, 1, IDI_BTN_CLOSE, 0 }, - { ICO_BTN_APPLY, "Apply", SECT_BUTTONS, 1, IDI_BTN_APPLY, 0 }, -// { ICO_BTN_GOTO, "Goto", SECT_BUTTONS, 1, IDI_BTN_GOTO, 0 }, -// { ICO_BTN_EMAIL, "e-mail", SECT_BUTTONS, 1, IDI_BTN_EMAIL, 0 }, -// { ICO_BTN_DOWNARROW, "Down arrow", SECT_BUTTONS, 1, IDI_BTN_DOWNARROW, 0 }, -// { ICO_BTN_ADD, "Add", SECT_BUTTONS, 1, IDI_BTN_ADD, 0 }, - { ICO_BTN_EDIT, "Edit", SECT_BUTTONS, 1, IDI_BTN_EDIT, 0 }, -// { ICO_BTN_DELETE, "Delete", SECT_BUTTONS, 1, IDI_BTN_DELETE, 0 }, -// { ICO_BTN_SEARCH, "Search", SECT_BUTTONS, 1, IDI_SEARCH, 0 }, -// { ICO_BTN_YES, "Yes", SECT_BUTTONS, 1, IDI_BTN_YES, 0 }, -// { ICO_BTN_NO, "No", SECT_BUTTONS, 1, IDI_BTN_NO, 0 }, -// { ICO_BTN_IGNORE, "Ignore", SECT_BUTTONS, 1, IDI_BTN_IGNORE, 0 }, - -}; - -/** - * This function finds the default iconpack file and return its path. - * - * @param - none - * - * @return This function returns the relative path to an existing icon pack. - **/ -LPTSTR IcoLib_GetDefaultIconFileName() -{ - static LPTSTR path[] = { - _T("Icons\\uinfoex_icons.dll"), - _T("Plugins\\uinfoex_icons.dll"), - _T("Customize\\Icons\\uinfoex_icons.dll") - }; - TCHAR absolute[MAX_PATH]; - - for (INT i = 0; i < SIZEOF(path); i++) - { - CallService(MS_UTILS_PATHTOABSOLUTET, (WPARAM)path[i], (LPARAM)absolute); - if (PathFileExists(absolute)) - { - return path[i]; - } - } - return NULL; -} - -/** - * This function checks the version of an iconpack. - * If the icon pack's version differs from the desired one, - * dialog with a warning is displayed. - * - * @param szIconPack - This is the path to the icon pack. - * It can be absolute or relative. - * - * @return nothing - **/ -static VOID IcoLib_CheckIconPackVersion(LPTSTR szIconPack) -{ - //if (DB::Setting::GetByte(SET_ICONS_CHECKFILEVERSION, TRUE)) - if (DBGetContactSettingByte(NULL,MODNAME,SET_ICONS_CHECKFILEVERSION, TRUE)) - { - if (szIconPack) - { - TCHAR szAbsolutePath[MAX_PATH]; - HMODULE hIconDll; - - CallService(MS_UTILS_PATHTOABSOLUTET, (WPARAM)szIconPack, (LPARAM)szAbsolutePath); - - hIconDll = LoadLibrary(szAbsolutePath); - if (hIconDll) - { - CHAR szFileVersion[64]; - - if (!LoadStringA(hIconDll, IDS_ICOPACKVERSION, szFileVersion, sizeof(szFileVersion)) || - mir_strcmp(szFileVersion, "__UserInfoEx_IconPack_1.2__")) - { - MsgErr(NULL, LPGENT("Warning: Your current IconPack's version differs from the one UserInfoEx is designed for.\nSome icons may not be displayed correctly")); - } - FreeLibrary(hIconDll); - } - } - else - { - MsgErr(NULL, LPGENT("Warning: No IconPack found in one of the following directories: 'customize\\icons', 'icons' or 'plugins'!")); - } - } -} - -/** - * Returns a icon, identified by a name - * - * @param pszIcon - name of the icon - * - * @return: HICON if the icon is loaded, NULL otherwise - **/ -HICON IcoLib_GetIcon(LPCSTR pszIcon, bool big) -{ - return (pszIcon) ? (HICON)CallService(MS_SKIN2_GETICON, (WPARAM)big, (LPARAM) pszIcon) : NULL; -} - -/** - * Returns a icon, identified by a name - * - * @param hIconItem - this is the pointer to an IconItem structure in icolib. - * - * @return: HICON if the icon is loaded, NULL otherwise - **/ -HICON IcoLib_GetIconByHandle(HANDLE hIconItem, bool big) -{ - return (HICON)CallService(MS_SKIN2_GETICONBYHANDLE, (WPARAM)big, (LPARAM) hIconItem); -} - -/** - * Set the icon of each control in the list - * - * @param hDlg - handle to the dialog control, that owns the controls - * @param pCtrl - list to all controls and its icon names - * @param numCtrls - number of elements in the pCtrl list - * - * @return nothing - **/ -VOID IcoLib_SetCtrlIcons(HWND hDlg, const ICONCTRL* pCtrl, BYTE numCtrls) -{ - HICON hIcon; - BYTE i; - HWND hCtrl; - - for (i = 0; i < numCtrls; i++) - { - hIcon = IcoLib_GetIcon(pCtrl[i].pszIcon); - if (pCtrl[i].idCtrl) - { - hCtrl = GetDlgItem(hDlg, pCtrl[i].idCtrl); - switch (pCtrl[i].Message) - { - case STM_SETICON: - case STM_SETIMAGE: - { - ShowWindow(hCtrl, hIcon ? SW_SHOW : SW_HIDE); - } - case BM_SETIMAGE: - { - SendMessage(hCtrl, pCtrl[i].Message, IMAGE_ICON, (LPARAM) hIcon); - } - } - } - else - { - SendMessage(hDlg, pCtrl[i].Message, ICON_BIG, (LPARAM) hIcon); - } - } -} - -/** - * This function manually registers a single icon from the default icon library. - * - * @param szIconID - This is the uniquely identifying string for an icon. - * This string is the setting name in the database and should - * only use ASCII characters. - * @param szDescription - This is the description displayed in the options dialog. - * @param szSection - This is the subsection, where the icon is organized in the options dialog. - * @param szDefaultFile - This is the validated path to the default icon file. - * @param idIcon - This is the ResourceID of the icon in the default file. - * @param Size - This is the desired size of the icon to load. - * 0: default size for small icons (16x16) - * 1: default size for normal icons (32x32) - * @param hDefIcon - This is the default icon to use if the default icon - * file does not exist and no custom icon is set up in the config. - * - * @return This function returns the HANDLE of the icon item. - **/ -static HANDLE IcoLib_RegisterIconHandleEx(LPSTR szIconID, LPSTR szDescription, LPSTR szSection, LPTSTR szDefaultFile, INT idIcon, INT Size, HICON hDefIcon) -{ - HANDLE hIconHandle = NULL; - - if (szIconID && szDescription && szSection) - { - SKINICONDESC sid; - - ZeroMemory(&sid, sizeof(sid)); - sid.cbSize = sizeof(sid); - sid.flags = SIDF_ALL_TCHAR; - sid.pszName = szIconID; - sid.ptszDescription = mir_a2t(szDescription); - sid.ptszSection = mir_a2t(szSection); - - if (sid.ptszDescription && sid.ptszSection) - { - switch (Size) - { - // small and big icons - case -1: - { - sid.cx = sid.cy = 0; - break; - } - // small icons (16x16) - case 0: - { - sid.cx = GetSystemMetrics(SM_CXSMICON); - sid.cy = GetSystemMetrics(SM_CYSMICON); - break; - } - // normal icons (32x32) - case 1: - { - sid.cx = GetSystemMetrics(SM_CXICON); - sid.cy = GetSystemMetrics(SM_CYICON); - break; - } - // custom icon size - default: - { - sid.cx = sid.cy = Size; - break; - } - } - - sid.ptszDefaultFile = szDefaultFile; - if (sid.ptszDefaultFile && sid.ptszDefaultFile[0]) - { - if(idIcon < IDI_FIRST_ICON || idIcon > IDI_LASTICON) { - // Icon from Plugin.dll - sid.iDefaultIndex = idIcon - IDI_PLUG_MAIN; - } - else{ - //UserinfoEx Icon pack - sid.iDefaultIndex = ICONINDEX(idIcon); - } - } - else - { - sid.hDefaultIcon = hDefIcon; - sid.iDefaultIndex = -1; - } - hIconHandle = Skin_AddIcon(&sid); - } - mir_freeAndNil(sid.ptszDescription); - mir_freeAndNil(sid.ptszSection); - } - return hIconHandle; -} - -/** - * This function manually registers a single icon from the default icon library. - * - * @param szIconID - This is the uniquely identifying string for an icon. - * This string is the setting name in the database and should - * only use ASCII characters. - * @param szDescription - This is the description displayed in the options dialog. - * @param szSection - This is the subsection, where the icon is organized in the options dialog. - * @param idIcon - This is the ResourceID of the icon in the default file - * @param Size - This is the desired size of the icon to load. - * 0: default size for small icons (16x16) - * 1: default size for normal icons (32x32) - * - * @return This function returns the HANDLE of the icon item. - **/ -HANDLE IcoLib_RegisterIconHandle(LPSTR szIconID, LPSTR szDescription, LPSTR szSection, INT idIcon, INT Size) -{ - return IcoLib_RegisterIconHandleEx(szIconID, szDescription, szSection, IcoLib_GetDefaultIconFileName(), idIcon, Size, ghDefIcon); -} - -/** - * This function manually registers a single icon from the default icon library. - * - * @param szIconID - This is the uniquely identifying string for an icon. - * This string is the setting name in the database and should - * only use ASCII characters. - * @param szDescription - This is the description displayed in the options dialog. - * @param szSection - This is the subsection, where the icon is organized in the options dialog. - * @param idIcon - This is the ResourceID of the icon in the default file - * @param Size - This is the desired size of the icon to load. - * 0: default size for small icons (16x16) - * 1: default size for normal icons (32x32) - * - * @return This function returns the HICON of the icon itself. - **/ -HICON IcoLib_RegisterIcon(LPSTR szIconID, LPSTR szDescription, LPSTR szSection, INT idIcon, INT Size) -{ - return IcoLib_GetIconByHandle(IcoLib_RegisterIconHandle(szIconID, szDescription, szSection, idIcon, Size)); -} - -/** - * Add default icons to the skin library or load customized icons - * - * @param none - * - * @return nothing - **/ -VOID IcoLib_LoadModule() -{ - LPTSTR szDefaultFile; - LPTSTR szPluginFile; - INT_PTR i; - - // search for default icon file - szDefaultFile = IcoLib_GetDefaultIconFileName(); - IcoLib_CheckIconPackVersion(szDefaultFile); - - szPluginFile = _T("Plugins\\")_T(__FILENAME); - - // load default icon if required - ghDefIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_PLUG_DEFAULT), IMAGE_ICON, - GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0); - - for (i = 0; i < SIZEOF(icoDesc); i++) - { - IcoLib_RegisterIconHandleEx( - icoDesc[i].pszName, icoDesc[i].pszDesc, icoDesc[i].pszSection, - icoDesc[i].bfromIconPack ? szDefaultFile : szPluginFile, icoDesc[i].idResource, icoDesc[i].size, ghDefIcon); - } -} - diff --git a/plugins/SendScreenshotPlus/mir_icolib.h b/plugins/SendScreenshotPlus/mir_icolib.h deleted file mode 100644 index b80c014a07..0000000000 --- a/plugins/SendScreenshotPlus/mir_icolib.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2009 Miranda ICQ/IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -aLONG with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ -#ifndef _UINFOEX_ICONS_H_INCLUDED_ -#define _UINFOEX_ICONS_H_INCLUDED_ 1 - -#include "m_icolib.h" - -// sections -#define SECT_COMMON MODNAME -#define SECT_DLG MODNAME"/Dialogs" -#define SECT_BUTTONS MODNAME"/Buttons" -#define SECT_OVERLAY MODNAME"/overlays" -#define SECT_TOOLBAR "ToolBar" // global toolbar section as used by modern clist - -// icons -#define ICO_PLUG_SSWINDOW1 MODNAME"_plug_SSwindow1" -#define ICO_PLUG_SSWINDOW2 MODNAME"_plug_SSwindow2" -#define ICO_PLUG_SSMONITOR MODNAME"_plug_SSmonitor" -#define ICO_PLUG_SSDEFAULT MODNAME"_plug_SSdefault" -#define ICO_PLUG_SSTARGET MODNAME"_plug_SSTarget" -#define ICO_PLUG_SSHELP MODNAME"_plug_SSHelp" -#define ICO_PLUG_SSFOLDERO MODNAME"_plug_SSFolderOpen" -#define ICO_PLUG_ARROWL MODNAME"_plug_SSArrowL" -#define ICO_PLUG_ARROWR MODNAME"_plug_SSArrowR" -#define ICO_PLUG_SSDESKOFF MODNAME"_plug_SSDeskOff" -#define ICO_PLUG_SSDESKON MODNAME"_plug_SSDeskOn" -#define ICO_PLUG_SSDELOFF MODNAME"_plug_SSDelOff" -#define ICO_PLUG_SSDELON MODNAME"_plug_SSDelOn" - -#define ICO_PLUG_OVERLAYOFF MODNAME"_plug_SSOverlayOff" -#define ICO_PLUG_OVERLAYON MODNAME"_plug_SSOverlayOn" - -#define ICO_COMMON_IM MODNAME"_common_im" -#define ICO_COMMON_FEMALE MODNAME"_common_female" -#define ICO_COMMON_MALE MODNAME"_common_male" -#define ICO_COMMON_CLOCK MODNAME"_common_clock" -#define ICO_COMMON_MARITAL MODNAME"_common_marital" -#define ICO_COMMON_PASSWORD MODNAME"_common_password" -#define ICO_COMMON_ADDRESS MODNAME"_common_address" -#define ICO_TREE_DEFAULT MODNAME"_tree_default" -#define ICO_DLG_DETAILS MODNAME"_dlg_details" -#define ICO_DLG_PHONE MODNAME"_dlg_phone" -#define ICO_DLG_EMAIL MODNAME"_dlg_email" -#define ICO_DLG_EXPORT MODNAME"_dlg_export" -#define ICO_DLG_IMPORT MODNAME"_dlg_import" -#define ICO_DLG_SEARCH MODNAME"_dlg_search" -#define ICO_LST_MODULES MODNAME"_lst_modules" -#define ICO_LST_FOLDER MODNAME"_lst_folder" -#define ICO_BTN_UPDATE MODNAME"_btn_update" -#define ICO_BTN_OK MODNAME"_btn_ok" -#define ICO_BTN_CANCEL MODNAME"_btn_cancel" -#define ICO_BTN_APPLY MODNAME"_btn_apply" -#define ICO_BTN_GOTO MODNAME"_btn_goto" -#define ICO_BTN_ADD MODNAME"_btn_add" -#define ICO_BTN_EDIT MODNAME"_btn_edit" -#define ICO_BTN_DELETE MODNAME"_btn_delete" -#define ICO_BTN_IMPORT MODNAME"_btn_import" -#define ICO_BTN_EXPORT MODNAME"_btn_export" -#define ICO_BTN_NOTES MODNAME"_btn_notes" -#define ICO_BTN_ABOUT MODNAME"_btn_about" -#define ICO_BTN_PROFILE MODNAME"_btn_profile" -#define ICO_BTN_DOWNARROW MODNAME"_btn_downarrow" -#define ICO_BTN_PHONE MODNAME"_btn_phone" -#define ICO_BTN_FAX MODNAME"_btn_fax" -#define ICO_BTN_CELLULAR MODNAME"_btn_cellular" -#define ICO_BTN_EMAIL MODNAME"_btn_email" -#define ICO_BTN_SEARCH MODNAME"_btn_search" -#define ICO_BTN_YES MODNAME"_btn_yes" -#define ICO_BTN_NO MODNAME"_btn_no" -#define ICO_BTN_IGNORE MODNAME"_btn_ignore" - -#define ICO_RMD_DTB0 MODNAME"_rmd_dtb0" -#define ICO_RMD_DTB1 MODNAME"_rmd_dtb1" -#define ICO_RMD_DTB2 MODNAME"_rmd_dtb2" -#define ICO_RMD_DTB3 MODNAME"_rmd_dtb3" -#define ICO_RMD_DTB4 MODNAME"_rmd_dtb4" -#define ICO_RMD_DTB5 MODNAME"_rmd_dtb5" -#define ICO_RMD_DTB6 MODNAME"_rmd_dtb6" -#define ICO_RMD_DTB7 MODNAME"_rmd_dtb7" -#define ICO_RMD_DTB8 MODNAME"_rmd_dtb8" -#define ICO_RMD_DTB9 MODNAME"_rmd_dtb9" -#define ICO_RMD_DTBX MODNAME"_rmd_dtbx" - -#define ICO_RMD_DTA0 MODNAME"_rmd_dta0" -#define ICO_RMD_DTA1 MODNAME"_rmd_dta1" -#define ICO_RMD_DTA2 MODNAME"_rmd_dta2" -#define ICO_RMD_DTA3 MODNAME"_rmd_dta3" -#define ICO_RMD_DTA4 MODNAME"_rmd_dta4" -#define ICO_RMD_DTA5 MODNAME"_rmd_dta5" -#define ICO_RMD_DTA6 MODNAME"_rmd_dta6" -#define ICO_RMD_DTA7 MODNAME"_rmd_dta7" -#define ICO_RMD_DTA8 MODNAME"_rmd_dta8" -#define ICO_RMD_DTA9 MODNAME"_rmd_dta9" -#define ICO_RMD_DTAX MODNAME"_rmd_dtax" - -#define SET_ICONS_CHECKFILEVERSION "CheckIconPackVersion" -#define SET_ICONS_BUTTONS "ButtonIcons" - -#define ICONINDEX(id) max((min((id), IDI_LASTICON)) - IDI_FIRST_ICON, 0) - -typedef struct TIconCtrl -{ - LPCSTR pszIcon; - UINT Message; - WORD idCtrl; -} ICONCTRL, *LPICONCTRL; - -LPTSTR IcoLib_GetDefaultIconFileName(); -VOID IcoLib_SetCtrlIcons(HWND hDlg, const ICONCTRL* pCtrl, BYTE numCtrls); - -HANDLE IcoLib_RegisterIconHandle(LPSTR szName, LPSTR szDescription, LPSTR szSection, INT idIcon, INT Size); -HICON IcoLib_RegisterIcon(LPSTR szName, LPSTR szDescription, LPSTR szSection, INT idIcon, INT Size); -HICON IcoLib_GetIcon(LPCSTR pszIcon, bool big = false); -HICON IcoLib_GetIconByHandle(HANDLE hIconItem, bool big = false); - -VOID IcoLib_LoadModule(); - -#endif /* _UINFOEX_ICONS_H_INCLUDED_ */ diff --git a/plugins/SendScreenshotPlus/mir_string.cpp b/plugins/SendScreenshotPlus/mir_string.cpp deleted file mode 100644 index 0ee154b7b9..0000000000 --- a/plugins/SendScreenshotPlus/mir_string.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2009 Miranda ICQ/IM project, - -This file is part of Send Screenshot Plus, a Miranda IM plugin. -Copyright (c) 2010 Ing.U.Horn - -Parts of this file based on original sorce code -from UserInfoEx Plugin - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/mir_string.cpp $ -Revision : $Revision: 13 $ -Last change on : $Date: 2010-04-02 02:54:30 +0400 (РџС‚, 02 апр 2010) $ -Last change by : $Author: ing.u.horn $ - -*/ - -#include "global.h" -#include "mir_string.h" - -char *mir_strncpy(char *pszDest, const char *pszSrc, const size_t cchDest) -{ - if (!pszDest || !pszSrc || !cchDest) - return NULL; - pszDest = strncpy(pszDest, pszSrc, cchDest-1); - pszDest[cchDest-1] = 0; - return pszDest; -} - -wchar_t *mir_wcsncpy(wchar_t *pszDest, const wchar_t *pszSrc, const size_t cchDest) -{ - if (!pszDest || !pszSrc || !cchDest) - return NULL; - pszDest = wcsncpy(pszDest, pszSrc, cchDest-1); - pszDest[cchDest-1] = 0; - return pszDest; -} - -char *mir_strncat(char *pszDest, const char *pszSrc, const size_t cchDest) -{ - if (!pszDest || !pszSrc || !cchDest) - return NULL; - strncat(pszDest, pszSrc, cchDest-1); - pszDest[cchDest-1] = 0; - return pszDest; -} - -wchar_t *mir_wcsncat(wchar_t *pszDest, const wchar_t *pszSrc, const size_t cchDest) -{ - if (!pszDest || !pszSrc || !cchDest) - return NULL; - pszDest = wcsncat(pszDest, pszSrc, cchDest-1); - pszDest[cchDest-1] = 0; - return pszDest; -} - -char *mir_strncat_c(char *pszDest, const char cSrc) { - size_t lenNew = strlen(pszDest) + 2; - if (!pszDest) - pszDest = (char *) mir_alloc(sizeof(char) * lenNew); - else - pszDest = (char *) mir_realloc(pszDest, sizeof(char) * lenNew); - pszDest[lenNew-2] = cSrc; - pszDest[lenNew-1] = 0; - return pszDest; -} - -wchar_t *mir_wcsncat_c(wchar_t *pwszDest, const wchar_t wcSrc) { - size_t lenNew = wcslen(pwszDest) + 2; - if (!pwszDest) - pwszDest = (wchar_t *) mir_alloc(sizeof(wchar_t) * lenNew); - else - pwszDest = (wchar_t *) mir_realloc(pwszDest, sizeof(wchar_t) * lenNew); - pwszDest[lenNew-2] = wcSrc; - pwszDest[lenNew-1] = 0; - return pwszDest; -} - -char *mir_strnerase(char *pszDest, size_t sizeFrom, size_t sizeTo) { - char *pszReturn = NULL; - size_t sizeNew, sizeLen = strlen(pszDest); - if (sizeFrom >= 0 && sizeFrom < sizeLen && sizeTo >= 0 && sizeTo <= sizeLen && sizeFrom < sizeTo) { - sizeNew = sizeLen - (sizeTo - sizeFrom); - size_t sizeCopy = sizeNew - sizeFrom; - pszReturn = (char *) mir_alloc(sizeNew + 1); - memcpy(pszReturn, pszDest, sizeFrom); - memcpy(pszReturn + sizeFrom, pszDest + sizeTo, sizeCopy); - pszReturn[sizeNew] = 0; - } - - pszDest = (char *) mir_realloc(pszDest, sizeNew + 1); - pszDest = mir_strcpy(pszDest, pszReturn); - mir_free(pszReturn); - return pszDest; -} - -size_t mir_vsnwprintf(wchar_t *pszDest, const size_t cchDest, const wchar_t *pszFormat, va_list& argList) -{ - size_t iRet, cchMax; - - if (!pszDest || !pszFormat || !*pszFormat) - return -1; - - cchMax = cchDest - 1; - iRet = _vsnwprintf(pszDest, cchMax, pszFormat, argList); - if (iRet < 0) pszDest[0] = 0; - else if (iRet >= cchMax) { - pszDest[cchMax] = 0; - iRet = cchMax; - } - return iRet; -} - -size_t mir_snwprintf(wchar_t *pszDest, const size_t cchDest, const wchar_t *pszFormat, ...) -{ - size_t iRet; - va_list argList; - - va_start(argList, pszFormat); - iRet = mir_vsnwprintf(pszDest, cchDest, pszFormat, argList); - va_end(argList); - return iRet; -} - -//--------------------------------------------------------------------------- -void mir_stradd(char* &pszDest, const char *pszSrc) -{ - if(!pszSrc) { - return; - } - else if(!pszDest) { - pszDest = mir_strdup(pszSrc); - } - else { - size_t lenDest = strlen(pszDest); - size_t lenSrc = strlen(pszSrc); - size_t lenNew = lenDest + lenSrc + 1; - pszDest = (char *) mir_realloc(pszDest, sizeof(char)* lenNew); - - strcpy(pszDest + lenDest, pszSrc); - pszDest[lenNew-1] = 0; - } -} - -void mir_wcsadd(wchar_t* &pszDest, const wchar_t *pszSrc) -{ - if(!pszSrc) { - return; - } - else if(!pszDest) { - pszDest = mir_wstrdup(pszSrc); - } - else { - size_t lenDest = wcslen(pszDest); - size_t lenSrc = wcslen(pszSrc); - size_t lenNew = lenDest + lenSrc + 1; - pszDest = (wchar_t *) mir_realloc(pszDest, sizeof(wchar_t)*lenNew); - - wcscpy(pszDest + lenDest, pszSrc); - pszDest[lenNew-1] = 0; - } -} - diff --git a/plugins/SendScreenshotPlus/mir_string.h b/plugins/SendScreenshotPlus/mir_string.h deleted file mode 100644 index 882cd38896..0000000000 --- a/plugins/SendScreenshotPlus/mir_string.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2009 Miranda ICQ/IM project, - -This file is part of Send Screenshot Plus, a Miranda IM plugin. -Copyright (c) 2010 Ing.U.Horn - -Parts of this file based on original sorce code -from UserInfoEx Plugin - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/mir_string.h $ -Revision : $Revision: 13 $ -Last change on : $Date: 2010-04-02 02:54:30 +0400 (РџС‚, 02 апр 2010) $ -Last change by : $Author: ing.u.horn $ - -*/ - -#ifndef _MIR_STRING_H_INCLUDED_ -#define _MIR_STRING_H_INCLUDED_ - -#define mir_wcsdup mir_wstrdup - -#ifdef _UNICODE - #define mir_tcslen mir_wcslen - #define mir_tcscpy mir_wcscpy - #define mir_tcsncpy mir_wcsncpy - #define mir_tcsncat mir_wcsncat - #define mir_tcsdup mir_wcsdup - #define mir_tcscmp mir_wcscmp - #define mir_tcsncmp mir_wcsncmp - #define mir_tcsicmp mir_wcsicmp - #define mir_tcsnicmp mir_wcsnicmp - #define mir_tcschr mir_wcschr - #define mir_tcsrchr mir_wcsrchr - #define mir_tcsncat_c mir_wcsncat_c - #define mir_tcsadd mir_wcsadd -#else - #define mir_tcslen mir_strlen - #define mir_tcscpy mir_strcpy - #define mir_tcsncpy mir_strncpy - #define mir_tcsncat mir_strncat - #define mir_tcsdup mir_strdup - #define mir_tcscmp mir_strcmp - #define mir_tcsncmp mir_strncmp - #define mir_tcsicmp mir_stricmp - #define mir_tcsnicmp mir_strnicmp - #define mir_tcschr mir_strchr - #define mir_tcsrchr mir_strrchr - #define mir_tcsncat_c mir_strncat_c - #define mir_tcsadd mir_stradd -#endif - - -#define mir_strlen(s) (((s)!=0)?strlen(s):0) -#define mir_strcpy(d,s) (((s)!=0&&(d)!=0)?strcpy(d,s):0) -#define mir_strcmp(s1,s2) ((s1)==0||(s2)==0||strcmp((s1),(s2))) -#define mir_strncmp(s1,s2,n) ((s1)==0||(s2)==0||strncmp((s1),(s2),(n))) -#define mir_stricmp(s1,s2) ((s1)==0||(s2)==0||_stricmp((s1),(s2))) -#define mir_strnicmp(s1,s2,n) ((s1)==0||(s2)==0||_strnicmp((s1),(s2),(n))) -#define mir_strchr(s,c) (((s)!=0)?strchr((s),(c)):0) -#define mir_strrchr(s,c) (((s)!=0)?strrchr((s),(c)):0) - -#define mir_wcslen(s) (((s)!=0)?wcslen(s):0) -#define mir_wcscpy(d,s) (((s)!=0&&(d)!=0)?wcscpy(d,s):0) -#define mir_wcscmp(s1,s2) ((s1)==0||(s2)==0||wcscmp((s1),(s2))) -#define mir_wcsncmp(s1,s2,n) ((s1)==0||(s2)==0||wcsncmp((s1),(s2),(n))) -#define mir_wcsicmp(s1,s2) ((s1)==0||(s2)==0||_wcsicmp((s1),(s2))) -#define mir_wcsnicmp(s1,s2,n) ((s1)==0||(s2)==0||_wcsnicmp((s1),(s2),(n))) -#define mir_wcschr(s,c) (((s)!=0)?wcschr((s),(c)):0) -#define mir_wcsrchr(s,c) (((s)!=0)?wcsrchr((s),(c)):0) - -//#define mir_free(ptr) (if (x) mmi.free(x); *(&(x)) = 0;} -#define mir_freeAndNil(ptr) {if(ptr) mir_free(ptr); ptr = NULL;} - -char * mir_strncpy(char *pszDest, const char *pszSrc, const size_t cchDest); -wchar_t * mir_wcsncpy(wchar_t *pszDest, const wchar_t *pszSrc, const size_t cchDest); - -char * mir_strncat(char *pszDest, const char *pszSrc, const size_t cchDest); -wchar_t * mir_wcsncat(wchar_t *pszDest, const wchar_t *pszSrc, const size_t cchDest); - -char * mir_strncat_c(char *pszDest, const char cSrc); -char * mir_wcsncat_c(char *pszDest, const char cSrc); - -size_t mir_vsnwprintf(wchar_t *pszDest, const size_t cchDest, const wchar_t *pszFormat, va_list& argList); -size_t mir_snwprintf(wchar_t *pszDest, const size_t cchDest, const wchar_t *pszFormat, ...); - -char * mir_strnerase(char *pszDest, size_t sizeFrom, size_t sizeTo); - -void mir_stradd(char * &pszDest, const char *pszSrc); -void mir_wcsadd(wchar_t * &pszDest, const wchar_t *pszSrc); - -#endif /* _MIR_STRING_H_INCLUDED_ */ \ No newline at end of file diff --git a/plugins/SendScreenshotPlus/res/credits.txt b/plugins/SendScreenshotPlus/res/credits.txt deleted file mode 100644 index 122042be3b..0000000000 --- a/plugins/SendScreenshotPlus/res/credits.txt +++ /dev/null @@ -1,10 +0,0 @@ -Special thanks to Michael Kunz aka "Protogenes" -for helping me with 1001 tips and suggestions -to design the program code. -http://www-user.tu-chemnitz.de/~kunmi/?dbx_tree&lang=de - -Thanks to the "UserinfoEx" programmers group -for the nice button class code. -http://code.google.com/p/userinfoex/ - -and special thanks to all beta-testers... diff --git a/plugins/SendScreenshotPlus/res/license.txt b/plugins/SendScreenshotPlus/res/license.txt deleted file mode 100644 index c5ebcce31f..0000000000 --- a/plugins/SendScreenshotPlus/res/license.txt +++ /dev/null @@ -1,15 +0,0 @@ -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied -warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General -Public License along with this program; if not, write to the -Free Software Foundation, Inc., -675 Mass Ave, Cambridge, MA 02139, USA. diff --git a/plugins/SendScreenshotPlus/res/resource.rc b/plugins/SendScreenshotPlus/res/resource.rc new file mode 100644 index 0000000000..6a0a12a119 --- /dev/null +++ b/plugins/SendScreenshotPlus/res/resource.rc @@ -0,0 +1,266 @@ +// Microsoft Visual C++ generated resource script. +// +#include "..\src\resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Deutsch (Deutschland) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) +#ifdef _WIN32 +LANGUAGE LANG_GERMAN, SUBLANG_GERMAN +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_MSGBOX DIALOGEX 0, 0, 219, 97 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Dialog" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + LTEXT "",STATIC_WHITERECT,0,0,219,72 + LTEXT "",TXT_NAME,11,3,173,20,SS_ENDELLIPSIS | NOT WS_VISIBLE,WS_EX_TRANSPARENT + ICON "",ICO_DLGLOGO,191,3,21,20,NOT WS_VISIBLE + ICON "",ICO_MSGDLG,7,29,21,20 + LTEXT "",TXT_MESSAGE,34,37,180,35 + CONTROL "",STATIC_LINE2,"Static",SS_ETCHEDHORZ,0,71,219,1 + DEFPUSHBUTTON "OK",IDOK,6,78,50,14 + PUSHBUTTON "All",IDALL,58,78,50,14,NOT WS_VISIBLE + PUSHBUTTON "None",IDNONE,110,78,50,14,NOT WS_VISIBLE + PUSHBUTTON "Cancel",IDCANCEL,162,78,50,14,NOT WS_VISIBLE +END + +IDD_MSGBOXDUMMI 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_UMainForm DIALOGEX 0, 0, 231, 164 +STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_CONTROLPARENT +CAPTION "Send screenshot" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + CONTROL "Send screenshot to\n",IDC_HEADERBAR, + "MHeaderbarCtrl",0x0,0,0,231,25 + CONTROL "",IDC_CAPTURETAB,"SysTabControl32",TCS_RAGGEDRIGHT | WS_TABSTOP,8,36,218,68,WS_EX_TRANSPARENT + CONTROL "Ti&med capture",ID_chkTimed,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,106,85,10 + RTEXT "Time (secs) :",ID_edtTimedLabel,9,119,49,8 + EDITTEXT ID_edtTimed,62,117,31,13,ES_AUTOHSCROLL | ES_NUMBER + CONTROL "",ID_upTimed,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,81,117,11,13 + LTEXT "&Format :",ID_lblFmtInfo,100,107,41,8 + COMBOBOX ID_cboxFormat,100,117,41,84,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | CBS_HASSTRINGS | CBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + LTEXT "Send B&y :",ID_lblSendBy,148,107,75,8 + COMBOBOX ID_cboxSendBy,148,117,75,84,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | CBS_HASSTRINGS | CBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + CONTROL "?",ID_btnAbout,"UInfoButtonClass",WS_TABSTOP | 0x4000,3,145,16,14,WS_EX_NOACTIVATE | 0x10000000L + CONTROL "E&xplore",ID_btnExplore,"UInfoButtonClass",WS_TABSTOP | 0x4000,21,145,16,14,WS_EX_NOACTIVATE | 0x10000000L + CONTROL "&Fill description textbox.",ID_btnDesc,"UInfoButtonClass",WS_TABSTOP | 0x6000,39,145,16,14,WS_EX_NOACTIVATE | 0x10000000L + CONTROL "Delete &after send",ID_btnDeleteAfterSend, + "UInfoButtonClass",WS_TABSTOP | 0x6000,57,145,16,14,WS_EX_NOACTIVATE | 0x10000000L + CONTROL "Open again",ID_chkOpenAgain,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,100,147,57,9 + CONTROL "&Capture",ID_btnCapture,"UInfoButtonClass",WS_GROUP | WS_TABSTOP | 0x1000,169,145,54,14,WS_EX_NOACTIVATE | 0x10000000L + CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,0,139,231,1 +END + +IDD_UAboutForm DIALOGEX 0, 0, 214, 185 +STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_TOPMOST +CAPTION "About" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + CONTROL "%s\nv%s",IDC_HEADERBAR,"MHeaderbarCtrl",0x0,0,0,214,25 + CONTROL "Credits >",IDA_CONTRIBLINK,"UInfoButtonClass",WS_GROUP | WS_TABSTOP,5,166,61,14,WS_EX_NOACTIVATE | 0x10000000L + PUSHBUTTON "&Close",IDA_btnClose,149,166,60,14 + LTEXT "",IDC_WHITERECT,0,25,213,135,NOT WS_GROUP + EDITTEXT IDC_LICENSE,5,37,204,95,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL + EDITTEXT IDC_CREDIT,5,37,204,95,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL + EDITTEXT IDC_BUILDTIME,5,147,146,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP + CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,0,160,213,1 +END + +IDD_UEditForm DIALOGEX 217, 152, 329, 285 +STYLE DS_SETFONT | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME +EXSTYLE WS_EX_WINDOWEDGE | WS_EX_CONTROLPARENT +CAPTION "Edit" +FONT 8, "MS Sans Serif", 0, 0, 0x1 +BEGIN + CONTROL "",IDE_Image,"Static",SS_BITMAP | WS_GROUP,0,0,265,194 + CONTROL "",IDE_imgSelection,"Static",SS_BITMAP | WS_GROUP,195,133,100,76 + CONTROL "",IDE_StatusBar,"msctls_statusbar32",WS_CLIPSIBLINGS | 0x100,0,272,323,12 +END + +IDD_UMain_CaptureWindow DIALOGEX 0, 0, 214, 48 +STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_VISIBLE +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + LTEXT "",IDC_WHITERECT,0,0,214,48 + CONTROL "C&lient Area",ID_chkClientArea,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,100,30,62,8,WS_EX_RIGHT + LTEXT "Caption :",ID_edtCaptionLabel,4,1,158,8 + EDITTEXT ID_edtCaption,4,12,158,13,ES_AUTOHSCROLL | ES_READONLY + RTEXT "Size (HxW) :",ID_edtSizeLabel,0,30,50,8 + EDITTEXT ID_edtSize,52,28,43,13,ES_CENTER | ES_AUTOHSCROLL | ES_READONLY + CTEXT "Target Tool",ID_lblDropInfo,162,1,51,8 + LTEXT "",ID_bvlTarget,174,12,29,29,SS_NOTIFY | SS_SUNKEN + ICON IDI_PLUG_ICON2,ID_imgTarget,178,16,20,20,SS_NOTIFY | SS_CENTERIMAGE | WS_GROUP +END + +IDD_UMain_CaptureDesktop DIALOGEX 0, 0, 214, 48 +STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_VISIBLE +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + LTEXT "",IDC_WHITERECT,0,0,214,48 + LTEXT "Caption :",ID_edtCaptionLabel,4,1,158,8 + RTEXT "Size (HxW) :",ID_edtSizeLabel,0,30,50,8 + EDITTEXT ID_edtSize,52,28,43,13,ES_AUTOHSCROLL | ES_READONLY + LTEXT "",ID_bvlTarget,174,12,29,29,SS_NOTIFY | SS_SUNKEN + ICON "",ID_imgTarget,178,16,20,20,SS_NOTIFY | SS_CENTERIMAGE | WS_GROUP + COMBOBOX ID_edtCaption,4,12,158,30,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_TABSTOP +END + +IDD_CAPTURE DIALOGEX 0, 0, 316, 180 +STYLE DS_SYSMODAL | DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME +CAPTION "Dialog" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_PLUG_MAIN ICON "ssCamera_1.ico" +IDI_PLUG_ICON1 ICON "ssCamera_2.ico" +IDI_PLUG_DEFAULT ICON "ssDefault.ico" +IDI_PLUG_ICON2 ICON "ssTarget.ico" +IDI_PLUG_ICON3 ICON "ssMonitor.ico" +IDI_PLUG_HELP ICON "sshelp.ico" +IDI_PLUG_FOLDERO ICON "ssOpen.ico" +IDI_PLUG_ARROWL ICON "ssArrow_Left.ico" +IDI_PLUG_ARROWR ICON "ssArrow_Right.ico" +IDI_PLUG_OVERLAYOFF ICON "overlay_disabled.ico" +IDI_PLUG_OVERLAYON ICON "overlay_enabled.ico" +IDI_PLUG_DESKOFF ICON "ssDeskOff.ico" +IDI_PLUG_DESKON ICON "ssDeskOn.ico" +IDI_PLUG_DELOFF ICON "ssDelOff.ico" +IDI_PLUG_DELON ICON "ssDelOn.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Bitmap +// + +IDB_Bmp1 BITMAP "UEditForm_nvr_1.bmp" +IDB_Bmp2 BITMAP "UEditForm_nvr_2.bmp" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "..\\src\\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_MSGBOX, DIALOG + BEGIN + HORZGUIDE, 23 + HORZGUIDE, 29 + HORZGUIDE, 72 + END + + IDD_UMainForm, DIALOG + BEGIN + HORZGUIDE, 159 + END + + IDD_UAboutForm, DIALOG + BEGIN + LEFTMARGIN, 5 + RIGHTMARGIN, 209 + BOTTOMMARGIN, 180 + END + + IDD_UEditForm, DIALOG + BEGIN + RIGHTMARGIN, 230 + END + + IDD_UMain_CaptureWindow, DIALOG + BEGIN + RIGHTMARGIN, 213 + VERTGUIDE, 162 + END + + IDD_UMain_CaptureDesktop, DIALOG + BEGIN + VERTGUIDE, 162 + END + + IDD_CAPTURE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 309 + TOPMARGIN, 7 + BOTTOMMARGIN, 173 + END +END +#endif // APSTUDIO_INVOKED + +#endif // Deutsch (Deutschland) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/SendScreenshotPlus/res/version.rc b/plugins/SendScreenshotPlus/res/version.rc new file mode 100644 index 0000000000..453bbb1742 --- /dev/null +++ b/plugins/SendScreenshotPlus/res/version.rc @@ -0,0 +1,42 @@ +#ifdef APSTUDIO_INVOKED +#error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + +#include // include for version info constants +#include "..\src\version.h" + +// +// TO CHANGE VERSION INFORMATION, EDIT PROJECT OPTIONS... +// +VS_VERSION_INFO VERSIONINFO + FILEVERSION __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM + PRODUCTVERSION __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + BEGIN + VALUE "CompanyName", "" + VALUE "FileVersion", __VERSION_STRING_DOT + VALUE "FileDescription", __DESC + VALUE "InternalName", __PLUGIN_NAME + VALUE "LegalCopyright", __COPYRIGHT + VALUE "OriginalFilename", __FILENAME + VALUE "ProductName", __PLUGIN_NAME + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 1252 + END +END + diff --git a/plugins/SendScreenshotPlus/resource.h b/plugins/SendScreenshotPlus/resource.h deleted file mode 100644 index 6818f5b23f..0000000000 --- a/plugins/SendScreenshotPlus/resource.h +++ /dev/null @@ -1,102 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by resource.rc -// -#define IDOK 1 -#define IDA_btnClose 1 -#define IDCANCEL 2 -#define IDB_Bmp1 2 -#define IDABORT 3 -#define IDB_Bmp2 3 -#define IDRETRY 4 -#define IDIGNORE 5 -#define IDYES 6 -#define IDNO 7 -#define IDCLOSE 8 -#define IDHELP 9 -#define IDTRYAGAIN 10 -#define IDCONTINUE 11 -#define IDALL 21 -#define IDD_UMainForm 101 -#define MAIN 102 -#define IDR_LICENSE 103 -#define IDD_UMain_CaptureWindow 107 -#define IDD_CAPTURE 111 -#define IDR_CREDIT 116 -#define IDI_PLUG_MAIN 190 -#define IDI_PLUG_DEFAULT 191 -#define IDI_PLUG_ICON1 192 -#define IDI_PLUG_ICON2 193 -#define IDI_PLUG_ICON3 194 -#define IDI_PLUG_HELP 195 -#define IDI_PLUG_FOLDERO 196 -#define IDI_PLUG_ARROWL 197 -#define IDI_PLUG_ARROWR 198 -#define IDI_PLUG_OVERLAYON 199 -#define IDI_PLUG_OVERLAYOFF 200 -#define IDD_UAboutForm 201 -#define IDI_PLUG_DESKOFF 201 -#define IDI_PLUG_DESKON 202 -#define IDI_PLUG_DELOFF 203 -#define IDI_PLUG_DELON 204 -#define IDD_UEditForm 301 -#define IDC_CAPTURETAB 1005 -#define IDD_MSGBOX 1008 -#define IDC_CREDIT 1009 -#define IDD_MSGBOXDUMMI 1024 -#define IDD_UMain_CaptureDesktop 1025 -#define STATIC_WHITERECT 1100 -#define STATIC_LINE2 1103 -#define ICO_DLGLOGO 1105 -#define ICO_MSGDLG 1106 -#define IDC_BUILDTIME 1108 -#define TXT_NAME 1114 -#define TXT_MESSAGE 1126 -#define ID_edtCaption 1201 -#define ID_edtSize 1202 -#define ID_edtQuality 1203 -#define ID_upQuality 1204 -#define ID_edtTimed 1205 -#define ID_upTimed 1206 -#define IDC_WHITERECT 1221 -#define ID_cboxFormat 1301 -#define ID_cboxSendBy 1302 -#define ID_lblFmtInfo 1501 -#define IDE_Image 1501 -#define ID_lblSendBy 1502 -#define IDE_imgSelection 1502 -#define ID_bvlTarget 1503 -#define IDC_COPYRIGHT 1503 -#define ID_lblDropInfo 1504 -#define ID_imgTarget 1505 -#define ID_edtCaptionLabel 1506 -#define ID_edtSizeLabel 1507 -#define ID_edtQualityLabel 1508 -#define ID_edtTimedLabel 1509 -#define IDNONE 1565 -#define IDA_CONTRIBLINK 1586 -#define IDC_LICENSE 1589 -#define ID_gboxAreaToTake 1602 -#define ID_gboxOptions 1603 -#define ID_chkEditor 1701 -#define ID_chkClientArea 1704 -#define ID_chkTimed 1708 -#define ID_chkOpenAgain 1710 -#define IDC_HEADERBAR 1734 -#define ID_btnAbout 2001 -#define ID_btnExplore 2002 -#define ID_btnDesc 2003 -#define ID_btnDeleteAfterSend 2004 -#define ID_btnCapture 2005 -#define IDE_StatusBar 2501 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 123 -#define _APS_NEXT_COMMAND_VALUE 40002 -#define _APS_NEXT_CONTROL_VALUE 1011 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/plugins/SendScreenshotPlus/resource.rc b/plugins/SendScreenshotPlus/resource.rc deleted file mode 100644 index 8e24cc0204..0000000000 --- a/plugins/SendScreenshotPlus/resource.rc +++ /dev/null @@ -1,274 +0,0 @@ -// 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 - -///////////////////////////////////////////////////////////////////////////// -// Deutsch (Deutschland) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) -#ifdef _WIN32 -LANGUAGE LANG_GERMAN, SUBLANG_GERMAN -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_MSGBOX DIALOGEX 0, 0, 219, 97 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Dialog" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - LTEXT "",STATIC_WHITERECT,0,0,219,72 - LTEXT "",TXT_NAME,11,3,173,20,SS_ENDELLIPSIS | NOT WS_VISIBLE,WS_EX_TRANSPARENT - ICON "",ICO_DLGLOGO,191,3,21,20,NOT WS_VISIBLE - ICON "",ICO_MSGDLG,7,29,21,20 - LTEXT "",TXT_MESSAGE,34,37,180,35 - CONTROL "",STATIC_LINE2,"Static",SS_ETCHEDHORZ,0,71,219,1 - DEFPUSHBUTTON "OK",IDOK,6,78,50,14 - PUSHBUTTON "All",IDALL,58,78,50,14,NOT WS_VISIBLE - PUSHBUTTON "None",IDNONE,110,78,50,14,NOT WS_VISIBLE - PUSHBUTTON "Cancel",IDCANCEL,162,78,50,14,NOT WS_VISIBLE -END - -IDD_MSGBOXDUMMI 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_UMainForm DIALOGEX 0, 0, 231, 164 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_CONTROLPARENT -CAPTION "Send screenshot" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - CONTROL "Send screenshot to\n",IDC_HEADERBAR, - "MHeaderbarCtrl",0x0,0,0,231,25 - CONTROL "",IDC_CAPTURETAB,"SysTabControl32",TCS_RAGGEDRIGHT | WS_TABSTOP,8,36,218,68,WS_EX_TRANSPARENT - CONTROL "Ti&med capture",ID_chkTimed,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,106,85,10 - RTEXT "Time (secs) :",ID_edtTimedLabel,9,119,49,8 - EDITTEXT ID_edtTimed,62,117,31,13,ES_AUTOHSCROLL | ES_NUMBER - CONTROL "",ID_upTimed,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,81,117,11,13 - LTEXT "&Format :",ID_lblFmtInfo,100,107,41,8 - COMBOBOX ID_cboxFormat,100,117,41,84,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | CBS_HASSTRINGS | CBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP - LTEXT "Send B&y :",ID_lblSendBy,148,107,75,8 - COMBOBOX ID_cboxSendBy,148,117,75,84,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | CBS_HASSTRINGS | CBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP - CONTROL "?",ID_btnAbout,"UInfoButtonClass",WS_TABSTOP | 0x4000,3,145,16,14,WS_EX_NOACTIVATE | 0x10000000L - CONTROL "E&xplore",ID_btnExplore,"UInfoButtonClass",WS_TABSTOP | 0x4000,21,145,16,14,WS_EX_NOACTIVATE | 0x10000000L - CONTROL "&Fill description textbox.",ID_btnDesc,"UInfoButtonClass",WS_TABSTOP | 0x6000,39,145,16,14,WS_EX_NOACTIVATE | 0x10000000L - CONTROL "Delete &after send",ID_btnDeleteAfterSend, - "UInfoButtonClass",WS_TABSTOP | 0x6000,57,145,16,14,WS_EX_NOACTIVATE | 0x10000000L - CONTROL "Open again",ID_chkOpenAgain,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,100,147,57,9 - CONTROL "&Capture",ID_btnCapture,"UInfoButtonClass",WS_GROUP | WS_TABSTOP | 0x1000,169,145,54,14,WS_EX_NOACTIVATE | 0x10000000L - CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,0,139,231,1 -END - -IDD_UAboutForm DIALOGEX 0, 0, 214, 185 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_TOPMOST -CAPTION "About" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - CONTROL "%s\nv%s",IDC_HEADERBAR,"MHeaderbarCtrl",0x0,0,0,214,25 - CONTROL "Credits >",IDA_CONTRIBLINK,"UInfoButtonClass",WS_GROUP | WS_TABSTOP,5,166,61,14,WS_EX_NOACTIVATE | 0x10000000L - PUSHBUTTON "&Close",IDA_btnClose,149,166,60,14 - LTEXT "",IDC_WHITERECT,0,25,213,135,NOT WS_GROUP - EDITTEXT IDC_LICENSE,5,37,204,95,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL - EDITTEXT IDC_CREDIT,5,37,204,95,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL - EDITTEXT IDC_BUILDTIME,5,147,146,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP - CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,0,160,213,1 -END - -IDD_UEditForm DIALOGEX 217, 152, 329, 285 -STYLE DS_SETFONT | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME -EXSTYLE WS_EX_WINDOWEDGE | WS_EX_CONTROLPARENT -CAPTION "Edit" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - CONTROL "",IDE_Image,"Static",SS_BITMAP | WS_GROUP,0,0,265,194 - CONTROL "",IDE_imgSelection,"Static",SS_BITMAP | WS_GROUP,195,133,100,76 - CONTROL "",IDE_StatusBar,"msctls_statusbar32",WS_CLIPSIBLINGS | 0x100,0,272,323,12 -END - -IDD_UMain_CaptureWindow DIALOGEX 0, 0, 214, 48 -STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_VISIBLE -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - LTEXT "",IDC_WHITERECT,0,0,214,48 - CONTROL "C&lient Area",ID_chkClientArea,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,100,30,62,8,WS_EX_RIGHT - LTEXT "Caption :",ID_edtCaptionLabel,4,1,158,8 - EDITTEXT ID_edtCaption,4,12,158,13,ES_AUTOHSCROLL | ES_READONLY - RTEXT "Size (HxW) :",ID_edtSizeLabel,0,30,50,8 - EDITTEXT ID_edtSize,52,28,43,13,ES_CENTER | ES_AUTOHSCROLL | ES_READONLY - CTEXT "Target Tool",ID_lblDropInfo,162,1,51,8 - LTEXT "",ID_bvlTarget,174,12,29,29,SS_NOTIFY | SS_SUNKEN - ICON IDI_PLUG_ICON2,ID_imgTarget,178,16,20,20,SS_NOTIFY | SS_CENTERIMAGE | WS_GROUP -END - -IDD_UMain_CaptureDesktop DIALOGEX 0, 0, 214, 48 -STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_VISIBLE -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - LTEXT "",IDC_WHITERECT,0,0,214,48 - LTEXT "Caption :",ID_edtCaptionLabel,4,1,158,8 - RTEXT "Size (HxW) :",ID_edtSizeLabel,0,30,50,8 - EDITTEXT ID_edtSize,52,28,43,13,ES_AUTOHSCROLL | ES_READONLY - LTEXT "",ID_bvlTarget,174,12,29,29,SS_NOTIFY | SS_SUNKEN - ICON "",ID_imgTarget,178,16,20,20,SS_NOTIFY | SS_CENTERIMAGE | WS_GROUP - COMBOBOX ID_edtCaption,4,12,158,30,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_TABSTOP -END - -IDD_CAPTURE DIALOGEX 0, 0, 316, 180 -STYLE DS_SYSMODAL | DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME -CAPTION "Dialog" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_PLUG_MAIN ICON "res\\ssCamera_1.ico" -IDI_PLUG_ICON1 ICON "res\\ssCamera_2.ico" -IDI_PLUG_DEFAULT ICON "res\\ssDefault.ico" -IDI_PLUG_ICON2 ICON "res\\ssTarget.ico" -IDI_PLUG_ICON3 ICON "res\\ssMonitor.ico" -IDI_PLUG_HELP ICON "res\\sshelp.ico" -IDI_PLUG_FOLDERO ICON "res\\ssOpen.ico" -IDI_PLUG_ARROWL ICON "res\\ssArrow_Left.ico" -IDI_PLUG_ARROWR ICON "res\\ssArrow_Right.ico" -IDI_PLUG_OVERLAYOFF ICON "res\\overlay_disabled.ico" -IDI_PLUG_OVERLAYON ICON "res\\overlay_enabled.ico" -IDI_PLUG_DESKOFF ICON "res\\ssDeskOff.ico" -IDI_PLUG_DESKON ICON "res\\ssDeskOn.ico" -IDI_PLUG_DELOFF ICON "res\\ssDelOff.ico" -IDI_PLUG_DELON ICON "res\\ssDelOn.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDB_Bmp1 BITMAP "res\\UEditForm_nvr_1.bmp" -IDB_Bmp2 BITMAP "res\\UEditForm_nvr_2.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// TEXT -// - -IDR_CREDIT TEXT "./res/credits.txt" -IDR_LICENSE TEXT "./res/license.txt" - -#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_MSGBOX, DIALOG - BEGIN - HORZGUIDE, 23 - HORZGUIDE, 29 - HORZGUIDE, 72 - END - - IDD_UMainForm, DIALOG - BEGIN - HORZGUIDE, 159 - END - - IDD_UAboutForm, DIALOG - BEGIN - LEFTMARGIN, 5 - RIGHTMARGIN, 209 - BOTTOMMARGIN, 180 - END - - IDD_UEditForm, DIALOG - BEGIN - RIGHTMARGIN, 230 - END - - IDD_UMain_CaptureWindow, DIALOG - BEGIN - RIGHTMARGIN, 213 - VERTGUIDE, 162 - END - - IDD_UMain_CaptureDesktop, DIALOG - BEGIN - VERTGUIDE, 162 - END - - IDD_CAPTURE, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 309 - TOPMARGIN, 7 - BOTTOMMARGIN, 173 - END -END -#endif // APSTUDIO_INVOKED - -#endif // Deutsch (Deutschland) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/plugins/SendScreenshotPlus/sdk/DevKey.h b/plugins/SendScreenshotPlus/sdk/DevKey.h deleted file mode 100644 index 2999f74466..0000000000 --- a/plugins/SendScreenshotPlus/sdk/DevKey.h +++ /dev/null @@ -1,3 +0,0 @@ -#ifndef DEVKEY_IMAGESHACK -#define DEVKEY_IMAGESHACK "IA5ZRTV6fb6256ccbc3c38650bdce6e6dcfc9e55" /*Test DevKey*/ -#endif diff --git a/plugins/SendScreenshotPlus/sdk/icons.h b/plugins/SendScreenshotPlus/sdk/icons.h deleted file mode 100644 index 46871836bd..0000000000 --- a/plugins/SendScreenshotPlus/sdk/icons.h +++ /dev/null @@ -1,112 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by uinfoex_icons.rc -// -#define IDI_FIRST_ICON 101 - -// dialog inforbar -#define IDI_DLG_DETAILS 101 -#define IDI_DLG_PHONE 102 -#define IDI_DLG_EMAIL 103 - -// dialog infobar & buttons -#define IDI_ANNIVERSARY 104 -#define IDI_EXPORT 105 -#define IDI_IMPORT 106 -#define IDI_SEARCH 107 - -// common icons of details dialog pages -#define IDI_MIRANDA 108 -#define IDI_PASSWORD 109 -#define IDI_FEMALE 110 -#define IDI_MALE 111 -#define IDI_CLOCK 112 -#define IDI_MARITAL 113 - -// commonly used buttons -#define IDI_BTN_UPDATE 114 -#define IDI_BTN_OK 115 -#define IDI_BTN_CLOSE 116 -#define IDI_BTN_APPLY 117 -#define IDI_BTN_GOTO 118 -#define IDI_BTN_PHONE 119 -#define IDI_BTN_FAX 120 -#define IDI_BTN_CELLULAR 121 -#define IDI_BTN_CUSTOMPHONE 122 -#define IDI_BTN_EMAIL 123 -#define IDI_BTN_DOWNARROW 124 -#define IDI_BTN_ADD 125 -#define IDI_BTN_EDIT 126 -#define IDI_BTN_DELETE 127 -#define IDI_BTN_EXIMPORT 128 -#define IDI_BTN_BIRTHDAY_BACKUP 129 - -// details treeview icons -#define IDI_TREE_GENERAL 130 -#define IDI_TREE_ADVANCED 131 -#define IDI_TREE_COMPANY 132 -#define IDI_TREE_CONTACT 133 -#define IDI_TREE_ABOUT 134 -#define IDI_TREE_PHOTO 135 -#define IDI_TREE_ADDRESS 136 -#define IDI_TREE_NOTES 137 -#define IDI_TREE_PROFILE 138 - -// export: choose modules -#define IDI_LST_MODULES 139 -#define IDI_LST_FOLDER 140 - -// zodiac icons -#define IDI_ZOD_AQUARIUS 141 -#define IDI_ZOD_ARIES 142 -#define IDI_ZOD_CANCER 143 -#define IDI_ZOD_CAPRICORN 144 -#define IDI_ZOD_GEMINI 145 -#define IDI_ZOD_LEO 146 -#define IDI_ZOD_LIBRA 147 -#define IDI_ZOD_PISCES 148 -#define IDI_ZOD_SAGITTARIUS 149 -#define IDI_ZOD_SCORPIO 150 -#define IDI_ZOD_TAURUS 151 -#define IDI_ZOD_VIRGO 152 - -// reminder -#define IDI_BIRTHDAY 153 -#define IDI_RMD_DTB0 154 -#define IDI_RMD_DTB1 155 -#define IDI_RMD_DTB2 156 -#define IDI_RMD_DTB3 157 -#define IDI_RMD_DTB4 158 -#define IDI_RMD_DTB5 159 -#define IDI_RMD_DTB6 160 -#define IDI_RMD_DTB7 161 -#define IDI_RMD_DTB8 162 -#define IDI_RMD_DTB9 163 -#define IDI_RMD_DTBX 164 -#define IDI_RMD_DTA0 165 -#define IDI_RMD_DTA1 166 -#define IDI_RMD_DTA2 167 -#define IDI_RMD_DTA3 168 -#define IDI_RMD_DTA4 169 -#define IDI_RMD_DTA5 170 -#define IDI_RMD_DTA6 171 -#define IDI_RMD_DTA7 172 -#define IDI_RMD_DTA8 173 -#define IDI_RMD_DTA9 174 -#define IDI_RMD_DTAX 175 - -#define IDI_LASTICON 175 - -// version text -#define IDS_ICOPACKVERSION 1001 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 1002 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/plugins/SendScreenshotPlus/src/CSend.cpp b/plugins/SendScreenshotPlus/src/CSend.cpp new file mode 100644 index 0000000000..4e48ecb2b4 --- /dev/null +++ b/plugins/SendScreenshotPlus/src/CSend.cpp @@ -0,0 +1,416 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* +Copyright 2000-2009 Miranda ICQ/IM project, + +This file is part of Send Screenshot Plus, a Miranda IM plugin. +Copyright (c) 2010 Ing.U.Horn + +Parts of this file based on original sorce code +(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/CSend.cpp $ +Revision : $Revision: 19 $ +Last change on : $Date: 2010-04-09 03:24:04 +0400 (РџС‚, 09 апр 2010) $ +Last change by : $Author: ing.u.horn $ + +*/ + +#include "CSend.h" + +//--------------------------------------------------------------------------- +CSend::CSend(HWND Owner, HANDLE hContact, bool bFreeOnExit) { + m_hWndO = Owner; + m_bFreeOnExit = bFreeOnExit; + m_pszFile = NULL; + m_pszFileDesc = NULL; + m_pszProto = NULL; + m_ChatRoom = NULL; + m_PFflag = NULL; + m_hContact = NULL; + if (hContact) SetContact(hContact); + m_hOnSend = NULL; + m_szEventMsg = NULL; + m_szEventMsgT = NULL; + m_pszSendTyp = NULL; + + m_ErrorMsg = NULL; + m_ErrorTitle = NULL; +} + +CSend::~CSend(){ + mir_free(m_pszFile); + mir_free(m_pszFileDesc); + mir_free(m_szEventMsg); + mir_free(m_szEventMsgT); + mir_free(m_ErrorMsg); + mir_free(m_ErrorTitle); + if (m_hOnSend) UnhookEvent(m_hOnSend); +} + +//--------------------------------------------------------------------------- +void CSend::SetContact(HANDLE hContact) { + m_hContact = hContact; + m_pszProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0); + m_ChatRoom = DBGetContactSettingByte(hContact, m_pszProto, "ChatRoom", 0); + m_PFflag = hasCap(PF1_URLSEND); + m_PFflag = hasCap(PF1_CHAT); + m_PFflag = hasCap(PF1_IMSEND); +} + +//--------------------------------------------------------------------------- +bool CSend::hasCap(unsigned int Flag) { + return (Flag & CallContactService(m_hContact, PS_GETCAPS, (WPARAM)PFLAGNUM_1, NULL)) == Flag; +} + +//--------------------------------------------------------------------------- +void CSend::svcSendMsg(const char* szMessage) { + mir_freeAndNil(m_szEventMsg); + m_cbEventMsg=lstrlenA(szMessage)+1; + m_szEventMsg=(char*)mir_realloc(m_szEventMsg, sizeof(char)*m_cbEventMsg); + ZeroMemory(m_szEventMsg, m_cbEventMsg); + lstrcpyA(m_szEventMsg,szMessage); + if (m_pszFileDesc && m_pszFileDesc[0] != NULL) { + char *temp = mir_t2a(m_pszFileDesc); + mir_stradd(m_szEventMsg, "\r\n"); + mir_stradd(m_szEventMsg, temp); + m_cbEventMsg = lstrlenA(m_szEventMsg)+1; + mir_free(temp); + } + //create a HookEventObj on ME_PROTO_ACK + if (!m_hOnSend) { + int (__cdecl CSend::*hookProc)(WPARAM, LPARAM); + hookProc = &CSend::OnSend; + m_hOnSend = HookEventObj(ME_PROTO_ACK, (MIRANDAHOOKOBJ)*(void **)&hookProc, this); + } + //start PSS_MESSAGE service + m_hSend = (HANDLE)CallContactService(m_hContact, PSS_MESSAGE, NULL, (LPARAM)m_szEventMsg); + // check we actually got an ft handle back from the protocol + if (!m_hSend) { + Unhook(); + Error(SS_ERR_INIT, m_pszSendTyp); + Exit(ACKRESULT_FAILED); + } +} + +void CSend::svcSendUrl(const char* url) { +//szMessage should be encoded as the URL followed by the description, the +//separator being a single nul (\0). If there is no description, do not forget +//to end the URL with two nuls. + mir_freeAndNil(m_szEventMsg) + m_cbEventMsg=lstrlenA(url)+2; + m_szEventMsg=(char*)mir_realloc(m_szEventMsg, m_cbEventMsg); + ZeroMemory(m_szEventMsg, m_cbEventMsg); + lstrcpyA(m_szEventMsg,url); + if (m_pszFileDesc && m_pszFileDesc[0] != NULL) { + char *temp = mir_t2a(m_pszFileDesc); + m_cbEventMsg += lstrlenA(temp); + m_szEventMsg=(char*)mir_realloc(m_szEventMsg, sizeof(char)*m_cbEventMsg); + lstrcpyA(m_szEventMsg+lstrlenA(url)+1,temp); + m_szEventMsg[m_cbEventMsg-1] = 0; + mir_free(temp); + } + //create a HookEventObj on ME_PROTO_ACK + if (!m_hOnSend) { + int (__cdecl CSend::*hookProc)(WPARAM, LPARAM); + hookProc = &CSend::OnSend; + m_hOnSend = HookEventObj(ME_PROTO_ACK, (MIRANDAHOOKOBJ)*(void **)&hookProc, this); + } + //start PSS_URL service + m_hSend = (HANDLE)CallContactService(m_hContact, PSS_URL, NULL, (LPARAM)m_szEventMsg); + // check we actually got an ft handle back from the protocol + if (!m_hSend) { + //SetFtStatus(hwndDlg, LPGENT("Unable to initiate transfer."), FTS_TEXT); + //dat->waitingForAcceptance=0; + Unhook(); + } +} + +void CSend::svcSendChat() { + LPTSTR dirtyFix = NULL; + GC_INFO gci = {0}; + GCDEST gcd = {0}; + GCEVENT gce = {0}; + int res = GC_RESULT_NOSESSION; + int cnt = (int)CallService(MS_GC_GETSESSIONCOUNT, 0, (LPARAM)m_pszProto); + + //loop on all gc session to get the right (save) ptszID for the chatroom from m_hContact + gci.pszModule = m_pszProto; + for (int i = 0; i < cnt ; i++ ) { + gci.iItem = i; + gci.Flags = BYINDEX | HCONTACT | ID; //need dirty fix + CallService(MS_GC_GETINFO, 0, (LPARAM)(GC_INFO *) &gci); + if (gci.hContact == m_hContact) { + gcd.pszModule = m_pszProto; + gcd.iType = GC_EVENT_SENDMESSAGE; //GC_EVENT_MESSAGE ???; +#ifdef _UNICODE + gcd.ptszID = gci.pszID; +#else //dirty fix coz MS_GC_GETINFO dont know if caller is ansi or unicode. + //result from MS_GC_GETINFO only depend on type of chat.dll and not of caller type + if (mir_is_unicode()) { + dirtyFix = mir_u2t((wchar_t*)gci.pszID); + } + else { + dirtyFix = mir_tstrdup(gci.pszID); + } + gcd.ptszID = dirtyFix; //fixed gci.pszID; +#endif + gce.cbSize = sizeof(GCEVENT); + gce.pDest = &gcd; + gce.bIsMe = TRUE; + gce.dwFlags = GC_TCHAR|GCEF_ADDTOLOG; + gce.ptszText = m_szEventMsgT; + gce.time = time(NULL); + + //* returns 0 on success or error code on failure + res = 200 + (int)CallService(MS_GC_EVENT, 0, (LPARAM)(GCEVENT *) &gce); + mir_freeAndNil(dirtyFix); + break; + } + } + Exit(res); +} + +void CSend::svcSendChat(const char* szMessage) { + if (!m_ChatRoom) { + svcSendMsg(szMessage); + return; + } + mir_freeAndNil(m_szEventMsgT); + m_szEventMsgT = mir_a2t(szMessage); + if (m_pszFileDesc) { + mir_tcsadd(m_szEventMsgT, _T("\r\n")); + mir_tcsadd(m_szEventMsgT, m_pszFileDesc); + } + svcSendChat(); +} + +void CSend::svcSendFile() { +//szMessage should be encoded as the File followed by the description, the +//separator being a single nul (\0). If there is no description, do not forget +//to end the File with two nuls. + mir_freeAndNil(m_szEventMsg) + char *szFile = mir_t2a(m_pszFile); + m_cbEventMsg=lstrlenA(szFile)+2; + m_szEventMsg=(char*)mir_realloc(m_szEventMsg, sizeof(char)*m_cbEventMsg); + ZeroMemory(m_szEventMsg, m_cbEventMsg); + lstrcpyA(m_szEventMsg,szFile); + if (m_pszFileDesc && m_pszFileDesc[0] != NULL) { + char* temp = mir_t2a(m_pszFileDesc); + m_cbEventMsg += lstrlenA(temp); + m_szEventMsg=(char*)mir_realloc(m_szEventMsg, sizeof(char)*m_cbEventMsg); + lstrcpyA(m_szEventMsg+lstrlenA(szFile)+1,temp); + m_szEventMsg[m_cbEventMsg-1] = 0; + mir_freeAndNil(temp); + } + mir_freeAndNil(szFile); + + //create a HookEventObj on ME_PROTO_ACK + if (!m_hOnSend) { + int (__cdecl CSend::*hookProc)(WPARAM, LPARAM); + hookProc = &CSend::OnSend; + m_hOnSend = HookEventObj(ME_PROTO_ACK, (MIRANDAHOOKOBJ)*(void **)&hookProc, this); + } + // Start miranda PSS_FILE based on mir ver (T) + if ((CallService(MS_SYSTEM_GETVERSION,0,0) >= 0x090000) && mir_is_unicode()) { + TCHAR *ppFile[2]={0,0}; + TCHAR *pDesc = mir_tstrdup(m_pszFileDesc); + ppFile[0] = mir_tstrdup (m_pszFile); +/* #if defined( _UNICODE ) + TCHAR *ppFile[2]={0,0}; + TCHAR *pDesc = mir_tstrdup(m_pszFileDesc); + ppFile[0] = mir_tstrdup (m_pszFile); + #else + wchar_t *ppFile[2]={0,0}; + wchar_t *pDesc = mir_t2u (m_pszFileDesc); + ppFile[0] = mir_t2u (m_pszFile); + #endif */ + ppFile[1] = NULL; + m_hSend = (HANDLE)CallContactService(m_hContact, PSS_FILET, (WPARAM)pDesc, (LPARAM)ppFile); + mir_free(pDesc); + mir_free(ppFile[0]); + } + else { + char *pDesc = mir_t2a(m_pszFileDesc); + char *ppFile[2]={0}; + ppFile[0] = mir_t2a(m_pszFile); + ppFile[1] = NULL; + m_hSend = (HANDLE)CallContactService(m_hContact, PSS_FILE, (WPARAM)pDesc, (LPARAM)ppFile); + mir_free(pDesc); + mir_free(ppFile[0]); + } + // check we actually got an ft handle back from the protocol + if (!m_hSend) { + Unhook(); + Error(SS_ERR_INIT, m_pszSendTyp); + Exit(ACKRESULT_FAILED); + } +} + +//--------------------------------------------------------------------------- +int __cdecl CSend::OnSend(WPARAM wParam, LPARAM lParam){ + ACKDATA *ack=(ACKDATA*)lParam; + if(ack->hProcess!= m_hSend) return 0; + /* if(dat->waitingForAcceptance) { + SetTimer(hwndDlg,1,1000,NULL); + dat->waitingForAcceptance=0; + } + */ + + switch(ack->result) { + case ACKRESULT_INITIALISING: //SetFtStatus(hwndDlg, LPGENT("Initialising..."), FTS_TEXT); break; + case ACKRESULT_CONNECTING: //SetFtStatus(hwndDlg, LPGENT("Connecting..."), FTS_TEXT); break; + case ACKRESULT_CONNECTPROXY: //SetFtStatus(hwndDlg, LPGENT("Connecting to proxy..."), FTS_TEXT); break; + case ACKRESULT_LISTENING: //SetFtStatus(hwndDlg, LPGENT("Waiting for connection..."), FTS_TEXT); break; + case ACKRESULT_CONNECTED: //SetFtStatus(hwndDlg, LPGENT("Connected"), FTS_TEXT); break; + case ACKRESULT_SENTREQUEST: //SetFtStatus(hwndDlg, LPGENT("Decision sent"), FTS_TEXT); break; + case ACKRESULT_NEXTFILE: //SetFtStatus(hwndDlg, LPGENT("Moving to next file..."), FTS_TEXT); + case ACKRESULT_FILERESUME: // + case ACKRESULT_DATA: //transfer is on progress + break; + case ACKRESULT_DENIED: + Unhook(); + Exit(ack->result); + break; + case ACKRESULT_FAILED: + Unhook(); + Exit(ack->result); + //type=ACKTYPE_MESSAGE, result=success/failure, (char*)lParam=error message or NULL. + //type=ACKTYPE_URL, result=success/failure, (char*)lParam=error message or NULL. + //type=ACKTYPE_FILE, result=ACKRESULT_FAILED then lParam=(LPARAM)(const char*)szReason + break; + case ACKRESULT_SUCCESS: + Unhook(); + switch(ack->type) { + case ACKTYPE_CHAT: + break; + case ACKTYPE_MESSAGE: + DB_EventAdd((WORD)EVENTTYPE_MESSAGE); + break; + case ACKTYPE_URL: + DB_EventAdd((WORD)EVENTTYPE_URL); + break; + case ACKTYPE_FILE: + //MS_DB_EVENT_ADD need 4byte extra at the beginning of m_szEventMsg for ACKTYPE_FILE + m_szEventMsg = (char*) mir_realloc(m_szEventMsg, sizeof(DWORD) + m_cbEventMsg); + //memmove_s(m_szEventMsg+sizeof(DWORD), m_cbEventMsg, m_szEventMsg, m_cbEventMsg); + memmove(m_szEventMsg+sizeof(DWORD), m_szEventMsg, m_cbEventMsg); + m_cbEventMsg += sizeof(DWORD); + DB_EventAdd((WORD)EVENTTYPE_FILE); + break; + default: + break; + } + Exit(ack->result); + break; + default: + return 0; + break; + } + return 0; +} + +void CSend::DB_EventAdd(WORD EventType) { + DBEVENTINFO dbei={0}; + dbei.cbSize = sizeof(dbei); + dbei.szModule = m_pszProto; + dbei.eventType = EventType; + dbei.flags = DBEF_SENT; + dbei.timestamp = time(NULL); + #if defined( _UNICODE ) + dbei.flags |= DBEF_UTF; + #endif + dbei.cbBlob= m_cbEventMsg; + dbei.pBlob=(PBYTE)m_szEventMsg; + + CallService(MS_DB_EVENT_ADD,(WPARAM)m_hContact,(LPARAM)&dbei); +} + +//--------------------------------------------------------------------------- +void CSend::AfterSendDelete() { + if (m_pszFile && m_bDeleteAfterSend && (m_EnableItem & SS_DLG_DELETEAFTERSSEND) == SS_DLG_DELETEAFTERSSEND) { + DeleteFile(m_pszFile); + } +} + +//--------------------------------------------------------------------------- +void CSend::Exit(unsigned int Result) { + bool err = true; + if (m_hWndO && IsWindow(m_hWndO)){ + ; + } + switch(Result) { + case ACKRESULT_SUCCESS: + case GC_RESULT_SUCCESS: + SkinPlaySound("FileDone"); + err = false; + break; + case ACKRESULT_DENIED: + SkinPlaySound("FileDenied"); + Error(_T("%s (%i):\nFile transfer denied."),TranslateTS(m_pszSendTyp),Result); + MsgBoxService(NULL, (LPARAM)&m_box); + err = false; + break; + case GC_RESULT_WRONGVER: //.You appear to be using the wrong version of GC API. + Error(_T("%s (%i):\nYou appear to be using the wrong version of GC API"),TranslateT("GCHAT error"),Result); + break; + case GC_RESULT_ERROR: // An internal GC error occurred. + Error(_T("%s (%i):\nAn internal GC error occurred."),TranslateT("GCHAT error"),Result); + break; + case GC_RESULT_NOSESSION: // contact has no open GC session + Error(_T("%s (%i):\nContact has no open GC session."),TranslateT("GCHAT error"),Result); + break; + case ACKRESULT_FAILED: + default: + break; + } + if (err){ + SkinPlaySound("FileFailed"); + if(m_ErrorMsg && m_ErrorMsg[0] != 0) MsgBoxService(NULL, (LPARAM)&m_box); + else MsgErr(NULL, LPGENT("An unknown error has occured.")); + } + + AfterSendDelete(); + if(m_bFreeOnExit) delete this; +} + +void CSend::Error(LPCTSTR pszFormat, ...) { + if(!pszFormat) return; + + TCHAR tszTemp[MAX_SECONDLINE]; + va_list vl; + + mir_sntprintf(tszTemp, SIZEOF(tszTemp),_T("%s - %s") ,_T(MODNAME), TranslateT("Error")); + mir_freeAndNil(m_ErrorTitle); + m_ErrorTitle = mir_tstrdup(tszTemp); + + va_start(vl, pszFormat); + mir_vsntprintf(tszTemp, SIZEOF(tszTemp), TranslateTS(pszFormat), vl); + va_end(vl); + mir_freeAndNil(m_ErrorMsg); + m_ErrorMsg = mir_tstrdup(tszTemp); + + ZeroMemory(&m_box, sizeof(m_box)); + m_box.cbSize = sizeof(MSGBOX); + m_box.hParent = NULL; + m_box.hiLogo = IcoLib_GetIcon(ICO_PLUG_SSWINDOW1); + m_box.hiMsg = NULL; + m_box.ptszTitle = m_ErrorTitle; + m_box.ptszMsg = m_ErrorMsg; + m_box.uType = MB_OK|MB_ICON_ERROR; +} + diff --git a/plugins/SendScreenshotPlus/src/CSend.h b/plugins/SendScreenshotPlus/src/CSend.h new file mode 100644 index 0000000000..082f3e961a --- /dev/null +++ b/plugins/SendScreenshotPlus/src/CSend.h @@ -0,0 +1,113 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* +Copyright 2000-2009 Miranda ICQ/IM project, + +This file is part of Send Screenshot Plus, a Miranda IM plugin. +Copyright (c) 2010 Ing.U.Horn + +Parts of this file based on original sorce code +(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/CSend.h $ +Revision : $Revision: 17 $ +Last change on : $Date: 2010-04-03 18:01:11 +0400 (РЎР±, 03 апр 2010) $ +Last change by : $Author: ing.u.horn $ + +*/ + +#ifndef _CSEND_H +#define _CSEND_H + +//--------------------------------------------------------------------------- +#include "global.h" +#include "Utils.h" +#include "dlg_msgbox.h" + + +//--------------------------------------------------------------------------- +#define SS_AUTOSEND 1 +#define SS_DELETEAFTERSSEND 2 + +#define SS_DLG_AUTOSEND 1 //Button_Enable(GetDlgItem(Owner, ID_chkEmulateClick), TRUE); +#define SS_DLG_DELETEAFTERSSEND 2 //Button_Enable(GetDlgItem(Owner, ID_btnDeleteAfterSend), TRUE); +#define SS_DLG_DESCRIPTION 4 //Button_Enable(GetDlgItem(Owner, ID_btnDesc), TRUE); + +#define GC_RESULT_SUCCESS 200 +#define GC_RESULT_WRONGVER 201 +#define GC_RESULT_ERROR 202 +#define GC_RESULT_NOSESSION 209 + +#define SS_ERR_INIT _T("Unable to initiate %s.") +#define SS_ERR_MAPI _T("MAPI error (%i):\n%s.") + +//--------------------------------------------------------------------------- +class CSend { + public: + CSend(HWND Owner, HANDLE hContact, bool bFreeOnExit); // oder (TfrmMain & Owner) + virtual ~CSend(); + + virtual void Send() = 0; + void SendSync(bool Sync) {m_SendSync = Sync;}; + bool m_bFreeOnExit; // need to "delete object;" on exit ? + void SetContact(HANDLE hContact); + BYTE GetEnableItem() {return m_EnableItem;}; + LPTSTR GetErrorMsg() {return m_ErrorMsg;}; + + LPTSTR m_pszFile; + LPTSTR m_pszFileDesc; + + BOOL m_bDeleteAfterSend; + + private: + + protected: + LPTSTR m_pszSendTyp; //hold string for error mess + HWND m_hWndO; //window handle of caller + HANDLE m_hContact; //Contact handle + char* m_pszProto; //Contact Proto Modul + BYTE m_EnableItem; //hold flag for send type + void AfterSendDelete(); + BYTE m_ChatRoom; //is Contact chatroom + bool m_SendSync; //send sync / async + + bool hasCap(unsigned int Flag); + unsigned int m_PFflag; + + void svcSendFile(); + void svcSendUrl (const char* url); + void svcSendMsg (const char* szMessage); + void svcSendChat(); //main GC service + void svcSendChat(const char* szMessage); //GC ansi wrapper + + DWORD m_cbEventMsg; //sizeof EventMsg(T) buffer + char* m_szEventMsg; //EventMsg char* + LPTSTR m_szEventMsgT; //EventMsg TCHAR* + HANDLE m_hSend; //protocol send handle + HANDLE m_hOnSend; //HookEventObj on ME_PROTO_ACK + int __cdecl OnSend(WPARAM wParam, LPARAM lParam); + void Unhook(){if(m_hOnSend) {UnhookEvent(m_hOnSend);m_hOnSend = NULL;}} + void DB_EventAdd(WORD EventType); + void Exit(unsigned int Result); + + MSGBOX m_box; + LPTSTR m_ErrorMsg; + LPTSTR m_ErrorTitle; + void Error(LPCTSTR pszFormat, ...); +}; + +#endif diff --git a/plugins/SendScreenshotPlus/src/CSendEmail.cpp b/plugins/SendScreenshotPlus/src/CSendEmail.cpp new file mode 100644 index 0000000000..14e539ea0d --- /dev/null +++ b/plugins/SendScreenshotPlus/src/CSendEmail.cpp @@ -0,0 +1,221 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* +Copyright 2000-2009 Miranda ICQ/IM project, + +This file is part of Send Screenshot Plus, a Miranda IM plugin. +Copyright (c) 2010 Ing.U.Horn + +Parts of this file based on original sorce code +(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/CSendEmail.cpp $ +Revision : $Revision: 13 $ +Last change on : $Date: 2010-04-02 02:54:30 +0400 (РџС‚, 02 апр 2010) $ +Last change by : $Author: ing.u.horn $ + +*/ + +//--------------------------------------------------------------------------- +#include "CSendEmail.h" + +//--------------------------------------------------------------------------- +CSendEmail::CSendEmail(HWND Owner, HANDLE hContact, bool bFreeOnExit) +: CSend(Owner, hContact, bFreeOnExit){ + m_EnableItem = SS_DLG_DELETEAFTERSSEND | SS_DLG_DESCRIPTION; // SS_DLG_AUTOSEND | ; + m_pszSendTyp = _T("Email transfer"); + m_pszFileA = NULL; + m_pszFileName = NULL; + m_Email = NULL; + m_FriendlyName = NULL; + m_Subject = NULL; +} + +CSendEmail::~CSendEmail(){ + mir_free(m_pszFileA); + mir_free(m_pszFileName); + mir_free(m_Email); + mir_free(m_FriendlyName); + mir_free(m_Subject); +} + +//--------------------------------------------------------------------------- +void CSendEmail::Send() { + + mir_freeAndNil(m_pszFileName); + m_pszFileName = (LPSTR)GetFileName(m_pszFile, DBVT_ASCIIZ); + + mir_freeAndNil(m_pszFileA); + m_pszFileA = mir_t2a(m_pszFile); + + +// AnsiString Email, Subject, FriendlyName; + CONTACTINFO ci={0}; + ci.cbSize = sizeof(ci); + ci.hContact = m_hContact; + ci.szProto = m_pszProto; + //ci.dwFlag = CNF_TCHAR; + + ci.dwFlag = CNF_EMAIL | CNF_TCHAR; + CallService(MS_CONTACT_GETCONTACTINFO,(WPARAM)0,(LPARAM)&ci); + m_Email = mir_t2a(ci.pszVal); + + ci.dwFlag = CNF_DISPLAY | CNF_TCHAR; + CallService(MS_CONTACT_GETCONTACTINFO,(WPARAM)0,(LPARAM)&ci); + m_FriendlyName = mir_t2a(ci.pszVal); + + mir_free(ci.pszVal); + + m_Subject = mir_t2a(m_pszFileDesc); + + //SendByEmail(m_pszFileA, "", m_FriendlyName, m_Email, m_Subject); + + //start Send thread + m_bFreeOnExit = TRUE; + mir_forkthread(&CSendEmail::SendThreadWrapper, this); +} + +void CSendEmail::SendThread() { + //This code based on SentTo.exe application. + //The default mail client for Simple MAPI or MAPI calls is defined by the + //HKLM\Software\Clients\Mail::(default) registry value. + + LPTSTR err = NULL; + MapiFileDesc arrfileDesc[1]; + + typedef ULONG (FAR PASCAL *MAPIFUNC)(LHANDLE,ULONG,lpMapiMessage,FLAGS,ULONG); + MapiMessage Msg; + MAPIFUNC lpMAPISendMail; + + HINSTANCE hMAPILib = ::LoadLibrary(_T("MAPI32.DLL")); + if (hMAPILib == NULL) { + //return -1; + Error(SS_ERR_INIT, m_pszSendTyp); + Exit(ACKRESULT_FAILED); + } + + lpMAPISendMail = (MAPIFUNC)GetProcAddress(hMAPILib, "MAPISendMail"); + if (lpMAPISendMail == NULL) { + ::FreeLibrary(hMAPILib); + //return -2; + Error(SS_ERR_INIT, m_pszSendTyp); + Exit(ACKRESULT_FAILED); + } + + memset(&Msg, 0, sizeof(Msg)); + + arrfileDesc[0].ulReserved = 0; + arrfileDesc[0].flFlags = 0; + arrfileDesc[0].lpFileType = NULL; + arrfileDesc[0].nPosition = -1; + arrfileDesc[0].lpszPathName = m_pszFileA; + arrfileDesc[0].lpszFileName = NULL; + + Msg.nFileCount = 1; + Msg.lpFiles = arrfileDesc; + Msg.lpszNoteText = ""; //body + Msg.lpszSubject = m_Subject; //subject + + Msg.nRecipCount = 1; + MapiRecipDesc recip; + recip.ulReserved = 0; + recip.ulRecipClass = MAPI_TO; + + if (m_FriendlyName && m_FriendlyName[0]!= NULL) { + recip.lpszName = m_FriendlyName; //friendly name set to contact's name + } + else { + recip.lpszName = m_Email; //friendly name set to contact's email + } + + recip.lpszAddress = m_Email; //email + recip.ulEIDSize = 0; + recip.lpEntryID = NULL; + Msg.lpRecips = &recip; + + try { + int res = lpMAPISendMail(NULL, NULL, &Msg, MAPI_LOGON_UI|MAPI_DIALOG, 0); + ::FreeLibrary(hMAPILib); + + switch (res) { + case SUCCESS_SUCCESS: + //The call succeeded and the message was sent. + Exit(ACKRESULT_SUCCESS); + return; + + // No message was sent + case MAPI_E_AMBIGUOUS_RECIPIENT: + err = _T("A recipient matched more than one of the recipient descriptor structures and MAPI_DIALOG was not set"); + break; + case MAPI_E_ATTACHMENT_NOT_FOUND: + err = _T("The specified attachment was not found"); + break; + case MAPI_E_ATTACHMENT_OPEN_FAILURE: + err = _T("The specified attachment could not be opened"); + break; + case MAPI_E_BAD_RECIPTYPE: + err = _T("The type of a recipient was not MAPI_TO, MAPI_CC, or MAPI_BCC"); + break; + case MAPI_E_FAILURE: + err = _T("One or more unspecified errors occurred"); + break; + case MAPI_E_INSUFFICIENT_MEMORY: + err = _T("There was insufficient memory to proceed"); + break; + case MAPI_E_INVALID_RECIPS: + err = _T("One or more recipients were invalid or did not resolve to any address"); + break; + case MAPI_E_LOGIN_FAILURE: + err = _T("There was no default logon, and the user failed to log on successfully when the logon dialog box was displayed"); + break; + case MAPI_E_TEXT_TOO_LARGE: + err = _T("The text in the message was too large"); + break; + case MAPI_E_TOO_MANY_FILES: + err = _T("There were too many file attachments"); + break; + case MAPI_E_TOO_MANY_RECIPIENTS: + err = _T("There were too many recipients"); + break; + case MAPI_E_UNKNOWN_RECIPIENT: + err = _T("A recipient did not appear in the address list"); + break; + case MAPI_E_USER_ABORT: + err = _T("The user canceled one of the dialog boxes"); + break; + default: + err = _T("Unknown Error"); + break; + } + Error(SS_ERR_MAPI, res, err); + Exit(ACKRESULT_FAILED); + + } catch (...) { + ::FreeLibrary(hMAPILib); + Error(SS_ERR_INIT, m_pszSendTyp); + Exit(ACKRESULT_FAILED); + //return -3; + return; + } +} + +void CSendEmail::SendThreadWrapper(void * Obj) { + reinterpret_cast(Obj)->SendThread(); +} + +//--------------------------------------------------------------------------- + diff --git a/plugins/SendScreenshotPlus/src/CSendEmail.h b/plugins/SendScreenshotPlus/src/CSendEmail.h new file mode 100644 index 0000000000..940558b0d6 --- /dev/null +++ b/plugins/SendScreenshotPlus/src/CSendEmail.h @@ -0,0 +1,63 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* +Copyright 2000-2009 Miranda ICQ/IM project, + +This file is part of Send Screenshot Plus, a Miranda IM plugin. +Copyright (c) 2010 Ing.U.Horn + +Parts of this file based on original sorce code +(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/CSendEmail.h $ +Revision : $Revision: 13 $ +Last change on : $Date: 2010-04-02 02:54:30 +0400 (РџС‚, 02 апр 2010) $ +Last change by : $Author: ing.u.horn $ + +*/ + +#ifndef _CSEND_EMAIL_H +#define _CSEND_EMAIL_H + +//--------------------------------------------------------------------------- +#include "global.h" +#include "CSend.h" +#include + +//--------------------------------------------------------------------------- +class CSendEmail : public CSend { + public: + // Deklaration Standardkonstruktor/Standarddestructor + CSendEmail(HWND Owner, HANDLE hContact, bool bFreeOnExit); + ~CSendEmail(); + + void Send(); + + protected: + LPSTR m_pszFileA; + LPSTR m_pszFileName; + LPSTR m_Email; + LPSTR m_FriendlyName; + LPSTR m_Subject; + void SendThread(); + static void SendThreadWrapper(void * Obj); + +}; + +//--------------------------------------------------------------------------- + +#endif diff --git a/plugins/SendScreenshotPlus/src/CSendFTPFile.cpp b/plugins/SendScreenshotPlus/src/CSendFTPFile.cpp new file mode 100644 index 0000000000..d7512d2fe6 --- /dev/null +++ b/plugins/SendScreenshotPlus/src/CSendFTPFile.cpp @@ -0,0 +1,99 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* +Copyright 2000-2009 Miranda ICQ/IM project, + +This file is part of Send Screenshot Plus, a Miranda IM plugin. +Copyright (c) 2010 Ing.U.Horn + +Parts of this file based on original sorce code +(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/CSendFTPFile.cpp $ +Revision : $Revision: 13 $ +Last change on : $Date: 2010-04-02 02:54:30 +0400 (РџС‚, 02 апр 2010) $ +Last change by : $Author: ing.u.horn $ + +*/ + +//--------------------------------------------------------------------------- +#include "CSendFTPFile.h" + + +//--------------------------------------------------------------------------- +CSendFTPFile::CSendFTPFile(HWND Owner, HANDLE hContact, bool bFreeOnExit) +: CSend(Owner, hContact, bFreeOnExit){ + m_EnableItem = NULL ; //SS_DLG_DESCRIPTION| SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND; + m_pszSendTyp = _T("FTPFile transfer"); + m_pszFileName = NULL; + m_URL = NULL; +} + +CSendFTPFile::~CSendFTPFile(){ + mir_free(m_pszFileName); + mir_free(m_URL); +} + +//--------------------------------------------------------------------------- +void CSendFTPFile::Send() { + + /********************************************************************************************* + * Send file (files) to the FTP server and copy file URL + * to message log or clipboard (according to plugin setting) + * wParam = (HANDLE)hContact + * lParam = (char *)filename + * Filename format is same as GetOpenFileName (OPENFILENAME.lpstrFile) returns, + * see http://msdn2.microsoft.com/en-us/library/ms646839.aspx + * Returns 0 on success or nonzero on failure + * if (!wParam || !lParam) return 1 + ********************************************************************************************/ + mir_freeAndNil(m_pszFileName); + m_pszFileName = (LPSTR)GetFileName(m_pszFile, DBVT_ASCIIZ); + size_t size = sizeof(char)*(strlen(m_pszFileName)+2); + m_pszFileName = (LPSTR) mir_realloc(m_pszFileName, size); + m_pszFileName[size-1] = NULL; + + //start Send thread + m_bFreeOnExit = TRUE; + mir_forkthread(&CSendFTPFile::SendThreadWrapper, this); +} + +void CSendFTPFile::SendThread() { + int ret; + mir_freeAndNil(m_URL); + + ret = (int)CallService(MS_FTPFILE_SHAREFILE, (WPARAM)m_hContact, (LPARAM)m_pszFileName); + if (ret != 0) { + Error(_T("%s (%i):\nCould not add a share to the FTP File plugin."),TranslateTS(m_pszSendTyp),ret); + Exit(ret); + } + + //Can't delete the file since FTP File plugin will use it + m_bDeleteAfterSend = false; + + if (m_URL && m_URL[0]!= NULL) { + m_ChatRoom ? svcSendChat(m_URL) : svcSendMsg(m_URL); + return; + } +} + +void CSendFTPFile::SendThreadWrapper(void * Obj) { + reinterpret_cast(Obj)->SendThread(); +} + +//--------------------------------------------------------------------------- + diff --git a/plugins/SendScreenshotPlus/src/CSendFTPFile.h b/plugins/SendScreenshotPlus/src/CSendFTPFile.h new file mode 100644 index 0000000000..6012f76232 --- /dev/null +++ b/plugins/SendScreenshotPlus/src/CSendFTPFile.h @@ -0,0 +1,59 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* +Copyright 2000-2009 Miranda ICQ/IM project, + +This file is part of Send Screenshot Plus, a Miranda IM plugin. +Copyright (c) 2010 Ing.U.Horn + +Parts of this file based on original sorce code +(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/CSendFTPFile.h $ +Revision : $Revision: 13 $ +Last change on : $Date: 2010-04-02 02:54:30 +0400 (РџС‚, 02 апр 2010) $ +Last change by : $Author: ing.u.horn $ + +*/ + +#ifndef _CSEND_FTP_FILE_H +#define _CSEND_FTP_FILE_H + +//--------------------------------------------------------------------------- +#include "global.h" +#include "CSend.h" + +//--------------------------------------------------------------------------- +class CSendFTPFile : public CSend { + public: + // Deklaration Standardkonstruktor/Standarddestructor + CSendFTPFile(HWND Owner, HANDLE hContact, bool bFreeOnExit); + ~CSendFTPFile(); + + void Send(); + + protected: + LPSTR m_pszFileName; + LPSTR m_URL; + void SendThread(); + static void SendThreadWrapper(void * Obj); + +}; + +//--------------------------------------------------------------------------- + +#endif diff --git a/plugins/SendScreenshotPlus/src/CSendFile.cpp b/plugins/SendScreenshotPlus/src/CSendFile.cpp new file mode 100644 index 0000000000..1884c8307f --- /dev/null +++ b/plugins/SendScreenshotPlus/src/CSendFile.cpp @@ -0,0 +1,53 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* +Copyright 2000-2009 Miranda ICQ/IM project, + +This file is part of Send Screenshot Plus, a Miranda IM plugin. +Copyright (c) 2010 Ing.U.Horn + +Parts of this file based on original sorce code +(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/CSendFile.cpp $ +Revision : $Revision: 13 $ +Last change on : $Date: 2010-04-02 02:54:30 +0400 (РџС‚, 02 апр 2010) $ +Last change by : $Author: ing.u.horn $ + +*/ + +//--------------------------------------------------------------------------- +#include "CSendFile.h" + +//--------------------------------------------------------------------------- +CSendFile::CSendFile(HWND Owner, HANDLE hContact, bool bFreeOnExit) +: CSend(Owner, hContact, bFreeOnExit){ + m_EnableItem = SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND | SS_DLG_DESCRIPTION; + m_pszSendTyp = _T("File transfer"); +} + +CSendFile::~CSendFile(){ + ; +} + +//--------------------------------------------------------------------------- +void CSendFile::Send() { + m_bFreeOnExit = TRUE; + svcSendFile(); +} + +//--------------------------------------------------------------------------- diff --git a/plugins/SendScreenshotPlus/src/CSendFile.h b/plugins/SendScreenshotPlus/src/CSendFile.h new file mode 100644 index 0000000000..edbb49822d --- /dev/null +++ b/plugins/SendScreenshotPlus/src/CSendFile.h @@ -0,0 +1,55 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* +Copyright 2000-2009 Miranda ICQ/IM project, + +This file is part of Send Screenshot Plus, a Miranda IM plugin. +Copyright (c) 2010 Ing.U.Horn + +Parts of this file based on original sorce code +(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/CSendFile.h $ +Revision : $Revision: 13 $ +Last change on : $Date: 2010-04-02 02:54:30 +0400 (РџС‚, 02 апр 2010) $ +Last change by : $Author: ing.u.horn $ + +*/ + +#ifndef _CSEND_FILE_H +#define _CSEND_FILE_H + +//--------------------------------------------------------------------------- +#include "global.h" +#include "CSend.h" + +//--------------------------------------------------------------------------- +class CSendFile : public CSend { + public: + // Deklaration Standardkonstruktor/Standarddestructor + CSendFile(HWND Owner, HANDLE hContact, bool bFreeOnExit); + ~CSendFile(); + + void Send(); + + protected: + +}; + +//---------------------------------------------------------------------------*/ + +#endif diff --git a/plugins/SendScreenshotPlus/src/CSendHTTPServer.cpp b/plugins/SendScreenshotPlus/src/CSendHTTPServer.cpp new file mode 100644 index 0000000000..788ebca4d1 --- /dev/null +++ b/plugins/SendScreenshotPlus/src/CSendHTTPServer.cpp @@ -0,0 +1,140 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* +Copyright 2000-2009 Miranda ICQ/IM project, + +This file is part of Send Screenshot Plus, a Miranda IM plugin. +Copyright (c) 2010 Ing.U.Horn + +Parts of this file based on original sorce code +(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/CSendHTTPServer.cpp $ +Revision : $Revision: 13 $ +Last change on : $Date: 2010-04-02 02:54:30 +0400 (РџС‚, 02 апр 2010) $ +Last change by : $Author: ing.u.horn $ + +*/ + +//--------------------------------------------------------------------------- +#include "CSendHTTPServer.h" +INT_PTR (*g_MirCallService)(const char *, WPARAM, LPARAM)=NULL; +//INT_PTR (*CallService)(const char *,WPARAM,LPARAM); + + +//--------------------------------------------------------------------------- +CSendHTTPServer::CSendHTTPServer(HWND Owner, HANDLE hContact, bool bFreeOnExit) +: CSend(Owner, hContact, bFreeOnExit){ + m_EnableItem = SS_DLG_DESCRIPTION ; //| SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND; + m_pszSendTyp = _T("HTTPServer transfer"); + m_pszFileName = NULL; + m_URL = NULL; + m_fsi_pszSrvPath = NULL; + m_fsi_pszRealPath = NULL; +} + +CSendHTTPServer::~CSendHTTPServer(){ + mir_free(m_pszFileName); + mir_free(m_URL); + mir_free(m_fsi_pszSrvPath); + mir_free(m_fsi_pszRealPath); +} + +//--------------------------------------------------------------------------- +void CSendHTTPServer::Send() { + + if (CallService(MS_HTTP_ACCEPT_CONNECTIONS, (WPARAM)true, (LPARAM)0) != 0) { + Error(NULL, _T("Could not start the HTTP Server plugin.")); + return; + } + + if (!m_pszFileName) { + m_pszFileName = (LPSTR)GetFileName(m_pszFile, DBVT_ASCIIZ); + } + mir_freeAndNil(m_fsi_pszSrvPath); + mir_stradd(m_fsi_pszSrvPath, "/"); + mir_stradd(m_fsi_pszSrvPath, m_pszFileName); + + mir_freeAndNil(m_fsi_pszRealPath); + m_fsi_pszRealPath = mir_t2a(m_pszFile); + + ZeroMemory(&m_fsi, sizeof(m_fsi)); + m_fsi.lStructSize = sizeof(STFileShareInfo); + m_fsi.pszSrvPath = m_fsi_pszSrvPath; + m_fsi.nMaxDownloads = -1; // -1 = infinite + m_fsi.pszRealPath = m_fsi_pszRealPath; + //m_fsi.dwOptions = NULL; //OPT_SEND_LINK only work on single chat; + + //start Send thread + m_bFreeOnExit = TRUE; + mir_forkthread(&CSendHTTPServer::SendThreadWrapper, this); +} + +void CSendHTTPServer::SendThread() { + int ret; + mir_freeAndNil(m_URL); + + if (ServiceExists(MS_HTTP_GET_LINK)) { + //patched plugin version + ret = (int)CallService(MS_HTTP_ADD_CHANGE_REMOVE, (WPARAM)m_hContact, (LPARAM)&m_fsi); + if (!ret) { + m_URL = (LPSTR)CallService(MS_HTTP_GET_LINK, (WPARAM)m_fsi.pszSrvPath, NULL); + } + } + else { + //original plugin + m_fsi.dwOptions = OPT_SEND_LINK; + + //send DATA and wait for reply + ret = (int)CallService(MS_HTTP_ADD_CHANGE_REMOVE, (WPARAM)m_hContact, (LPARAM)&m_fsi); + } + + if (ret != 0) { + Error(_T("%s (%i):\nCould not add a share to the HTTP Server plugin."),TranslateTS(m_pszSendTyp),ret); + Exit(ret); + } + + //Share the file by HTTP Server plugin, SendSS does not own the file anymore = auto-delete won't work + m_bDeleteAfterSend = false; + + if (m_URL && m_URL[0]!= NULL) { + m_ChatRoom ? svcSendChat(m_URL) : svcSendMsg(m_URL); + return; + } + Exit(ACKRESULT_FAILED); +} + +void CSendHTTPServer::SendThreadWrapper(void * Obj) { + reinterpret_cast(Obj)->SendThread(); +} + +//--------------------------------------------------------------------------- +CSendHTTPServer::CContactMapping CSendHTTPServer::_CContactMapping; + +INT_PTR CSendHTTPServer::MyCallService(const char *name, WPARAM wParam, LPARAM lParam) { + CContactMapping::iterator Contact(_CContactMapping.end()); +/* + if ( wParam == m_hContact && ( + (strcmp(name, MS_MSG_SENDMESSAGE)== 0) || + (strcmp(name, "SRMsg/LaunchMessageWindow")== 0) )) + { + m_URL= mir_strdup((char*)lParam); + return 0; + }*/ + return g_MirCallService(name, wParam, lParam); +} + diff --git a/plugins/SendScreenshotPlus/src/CSendHTTPServer.h b/plugins/SendScreenshotPlus/src/CSendHTTPServer.h new file mode 100644 index 0000000000..129153e0c6 --- /dev/null +++ b/plugins/SendScreenshotPlus/src/CSendHTTPServer.h @@ -0,0 +1,67 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* +Copyright 2000-2009 Miranda ICQ/IM project, + +This file is part of Send Screenshot Plus, a Miranda IM plugin. +Copyright (c) 2010 Ing.U.Horn + +Parts of this file based on original sorce code +(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/CSendHTTPServer.h $ +Revision : $Revision: 13 $ +Last change on : $Date: 2010-04-02 02:54:30 +0400 (РџС‚, 02 апр 2010) $ +Last change by : $Author: ing.u.horn $ + +*/ + +#ifndef _CSEND_HTTP_SERVER_H +#define _CSEND_HTTP_SERVER_H + +//--------------------------------------------------------------------------- +#include "global.h" +#include "CSend.h" + +//--------------------------------------------------------------------------- +class CSendHTTPServer : public CSend { + public: + // Deklaration Standardkonstruktor/Standarddestructor + CSendHTTPServer(HWND Owner, HANDLE hContact, bool bFreeOnExit); + ~CSendHTTPServer(); + + void Send(); + + protected: + LPSTR m_pszFileName; + LPSTR m_URL; + STFileShareInfo m_fsi; + LPSTR m_fsi_pszSrvPath; + LPSTR m_fsi_pszRealPath; + void SendThread(); + static void SendThreadWrapper(void * Obj); + + typedef std::map CContactMapping; + static CContactMapping _CContactMapping; + + static INT_PTR MyCallService(const char *name, WPARAM wParam, LPARAM lParam); + +}; + +//--------------------------------------------------------------------------- + +#endif diff --git a/plugins/SendScreenshotPlus/src/CSendImageShack.cpp b/plugins/SendScreenshotPlus/src/CSendImageShack.cpp new file mode 100644 index 0000000000..a27b4f5273 --- /dev/null +++ b/plugins/SendScreenshotPlus/src/CSendImageShack.cpp @@ -0,0 +1,299 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* +Copyright 2000-2009 Miranda ICQ/IM project, + +This file is part of Send Screenshot Plus, a Miranda IM plugin. +Copyright (c) 2010 Ing.U.Horn + +Parts of this file based on original sorce code +(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/CSendImageShack.cpp $ +Revision : $Revision: 13 $ +Last change on : $Date: 2010-04-02 02:54:30 +0400 (РџС‚, 02 апр 2010) $ +Last change by : $Author: ing.u.horn $ + +*/ + +//--------------------------------------------------------------------------- +#include +#include +#include + +#include "CSendImageShack.h" +#include "DevKey.h" + +//--------------------------------------------------------------------------- +CSendImageShack::CSendImageShack(HWND Owner, HANDLE hContact, bool bFreeOnExit) +: CSend(Owner, hContact, bFreeOnExit) { + m_EnableItem = SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND | SS_DLG_DESCRIPTION; + m_pszSendTyp = _T("Image upload"); + m_pszFileName = NULL; + m_pszContentType = NULL; + m_MFDRboundary = NULL; + m_nlreply = NULL; + m_SendSync = false; + m_Url = NULL; +} + +CSendImageShack::~CSendImageShack(){ + mir_free(m_pszFileName); + mir_free(m_MFDRboundary); + // FREEHTTPREQUESTSTRUCT* + if (m_nlreply) CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM) m_nlreply); + mir_free(m_Url); +}; + +//--------------------------------------------------------------------------- +void CSendImageShack::Send() { + // check Netlib + if( !hNetlibUser ) { + //PrintError(1,TRUE); + return; + } + if (!m_pszFileName) { + m_pszFileName = (LPSTR)GetFileName(m_pszFile, DBVT_ASCIIZ); + } + if (!m_pszContentType) GetContentType(); + + // create new boundary + MFDR_Reset(); + + // initialize the netlib request + ZeroMemory(&m_nlhr, sizeof(m_nlhr)); + m_nlhr.cbSize = sizeof(m_nlhr); + m_nlhr.requestType = REQUEST_POST; + m_nlhr.flags = NLHRF_HTTP11; //NLHRF_DUMPASTEXT; + m_nlhr.szUrl = "http://www.imageshack.us/upload_api.php"; + m_nlhr.headersCount = 6; + { //NETLIBHTTPHEADER start + m_nlhr.headers=(NETLIBHTTPHEADER*)mir_alloc(sizeof(NETLIBHTTPHEADER)*m_nlhr.headersCount); + m_nlhr.headers[0].szName = "Referer"; + m_nlhr.headers[0].szValue = "http://www.imageshack.us/upload_api.php"; + m_nlhr.headers[1].szName = "Connection"; + m_nlhr.headers[1].szValue = "Keep-alive"; + m_nlhr.headers[2].szName = "AcceptLanguage"; + m_nlhr.headers[2].szValue = "en-us, pt-br"; + m_nlhr.headers[3].szName = "Host"; + m_nlhr.headers[3].szValue = "imageshack.us"; + m_nlhr.headers[4].szName = "User-Agent"; + m_nlhr.headers[4].szValue = __USER_AGENT_STRING; //szAgent; /; + //nlhr.headers[x].szName = "Authorization"; + //nlhr.headers[x].szValue = auth; //Basic base-64-authorization + + //$header .= "Content-type: multipart/form-data; boundary=" . part::getBoundary() . "\r\n"; + sprintf(m_nlheader_ContentType, "multipart/form-data; boundary=%s", m_MFDRboundary); + m_nlhr.headers[m_nlhr.headersCount-1].szName = "Content-Type"; + m_nlhr.headers[m_nlhr.headersCount-1].szValue = m_nlheader_ContentType; + } //NETLIBHTTPHEADER end + +//POST DATA file-header, init DATA with MultipartFormDataRequest + //$params[] = new filepart('fileupload', $file, basename($file), $contentType, 'iso-8859-1'); + //($this->sendStart($h);) + AppendToData("--"); + AppendToData(m_MFDRboundary); + AppendToData("\r\n"); + //($this->sendDispositionHeader($h);) + AppendToData("Content-Disposition: form-data; name=\""); + AppendToData("fileupload"); + AppendToData("\"; filename=\""); + AppendToData(m_pszFileName); + AppendToData("\""); + AppendToData("\r\n"); + //($this->sendContentTypeHeader($h);) + AppendToData("Content-Type: "); + AppendToData(m_pszContentType); + AppendToData("; charset="); + AppendToData("iso-8859-1"); + //($this->sendEndOfHeader($h);) + AppendToData("\r\n"); + AppendToData("\r\n"); + //Now we add the file binary ($this->sendData($h)) + FILE * fileId = _tfsopen(m_pszFile, _T("rb"), _SH_DENYWR ); + if( !fileId) { + //PrintError(1,TRUE); + return; + } + fseek(fileId, NULL, SEEK_END); + size_t lenFile = ftell(fileId); + size_t sizeDest = sizeof(char)*(m_nlhr.dataLength + lenFile + 1); + m_nlhr.pData = (char *) mir_realloc(m_nlhr.pData, sizeDest); + fseek(fileId, NULL, SEEK_SET ); + int i; + int ch = fgetc( fileId ); + for( i=0; (i < (int)lenFile ) && ( feof( fileId ) == 0 ); i++ ) { + m_nlhr.pData[m_nlhr.dataLength+i] = (char)ch; + ch = fgetc( fileId ); + } + m_nlhr.pData[sizeDest-1] = 0; //NULL Termination for binary data + m_nlhr.dataLength = (int)sizeDest - 1; + fclose(fileId); + //($this->sendEnd($h);) + AppendToData("\r\n"); + +//POST DATA footer (for "optimage", 1) +//POST DATA footer (for "optsize", optsize) + +//POST DATA footer (for "tags", tags) +//POST DATA footer (for "rembar", "yes" : "no") +//POST DATA footer (for "public", "yes" : "no") +//POST DATA footer (for "cookie", cookie) + +//POST DATA footer (for "key", DEVKEY_IMAGESHACK) + //($this->sendStart($h);) + AppendToData("--"); + AppendToData(m_MFDRboundary); + AppendToData("\r\n"); + //($this->sendDispositionHeader($h);) + AppendToData("Content-Disposition: form-data; name=\""); + AppendToData("key"); + AppendToData("\""); + //($this->sendTransferEncodingHeader($h); ) + AppendToData("\r\n"); + AppendToData("Content-Transfer-Encoding: "); + AppendToData("8bit"); //??"binary" + //($this->sendEndOfHeader($h);) + AppendToData("\r\n"); + AppendToData("\r\n"); + //($this->sendData($h);) + AppendToData(DEVKEY_IMAGESHACK); + //($this->sendEnd($h);) + AppendToData("\r\n"); + +//POST DATA Exit + //$postdata = "--" . part::getBoundary() . "--\r\n"; + AppendToData("--"); + AppendToData(m_MFDRboundary); + AppendToData("--\r\n"); + +//start upload thread + if (m_SendSync) { + m_bFreeOnExit = FALSE; + SendThread(); + return; + } + m_bFreeOnExit = TRUE; + mir_forkthread(&CSendImageShack::SendThreadWrapper, this); +} + +void CSendImageShack::SendThread() { + //send DATA and wait for m_nlreply + m_nlreply = (NETLIBHTTPREQUEST *) CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM) hNetlibUser, (LPARAM) &m_nlhr); + mir_freeAndNil(m_nlhr.pData); + mir_freeAndNil(m_nlhr.headers); + if(m_nlreply){ + if( m_nlreply->resultCode >= 200 && m_nlreply->resultCode < 300 ){ + m_nlreply->pData[m_nlreply->dataLength] = 0;// make sure its null terminated + const char* URL = NULL; + LPTSTR err = NULL; + URL = GetTagContent(m_nlreply->pData, "", ""); + if (URL && URL[0]!= NULL) { + m_Url = mir_strdup(URL); + if(m_SendSync) { + Exit(ACKRESULT_SUCCESS); + return; + } + m_ChatRoom ? svcSendChat(URL) : svcSendMsg(URL); + return; + } + else{ //check error mess from server + err = mir_a2t(GetTagContent(m_nlreply->pData, "")); + if (err && err[0]!= NULL) { //parsed err messege + Error(NULL, err); + } + else{ //fallback to server response mess + mir_freeAndNil(err); + err = mir_a2t(m_nlreply->pData); + } + mir_free(err); + } + } + else { + Error(NULL, _T("Upload server did not respond timely.")); + } + CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM) m_nlreply); + m_nlreply = NULL; + } + else { + Error(SS_ERR_INIT, m_pszSendTyp); + } + Exit(ACKRESULT_FAILED); +} + +void CSendImageShack::SendThreadWrapper(void * Obj) { + reinterpret_cast(Obj)->SendThread(); +} + +//--------------------------------------------------------------------------- +void CSendImageShack::MFDR_Reset() { + char Temp[64]; + DWORD dwBoundaryRand1 = GetTickCount(); + DWORD dwBoundaryRand2 = rand(); + + mir_freeAndNil(m_MFDRboundary); + sprintf(Temp, "B-O-U-N-D-A-R-Y%u%u", dwBoundaryRand1, dwBoundaryRand2); + mir_stradd(m_MFDRboundary,Temp); +} + +void CSendImageShack::GetContentType() { + if (m_pszContentType) mir_freeAndNil(m_pszContentType); + LPSTR FileExtension = (LPSTR)GetFileExt(m_pszFile, DBVT_ASCIIZ); + + if ((strcmp(FileExtension, ".jpeg")==0) || (strcmp(FileExtension, ".jpe")==0) || (strcmp(FileExtension ,".jpg")==0)) + m_pszContentType="image/jpeg"; + else if (strcmp(FileExtension, ".bmp")==0) + m_pszContentType="image/bmp"; + else if (strcmp(FileExtension, ".png")==0) + m_pszContentType="image/png"; + else if (strcmp(FileExtension, ".gif")==0) + m_pszContentType="image/gif"; + else if ((strcmp(FileExtension, ".tif")==0) || (strcmp(FileExtension, ".tiff")==0)) + m_pszContentType="image/tiff"; + else + m_pszContentType="application/octet-stream"; + + mir_free(FileExtension); + return; +} + +void CSendImageShack::AppendToData(const char *pszVal) { + if (!m_nlhr.pData) { + m_nlhr.pData = mir_strdup(pszVal); + m_nlhr.dataLength = (int)strlen(pszVal); + } + else { + size_t lenVal = strlen(pszVal); + size_t sizeNew = sizeof(char)*(m_nlhr.dataLength + lenVal + 1); + m_nlhr.pData = (char*) mir_realloc(m_nlhr.pData, sizeNew); + + strcpy(m_nlhr.pData + sizeof(char)*m_nlhr.dataLength, pszVal); + m_nlhr.pData[sizeNew-1] = 0; + m_nlhr.dataLength = (int)sizeNew -1; + } +} + +//--------------------------------------------------------------------------- +const char * CSendImageShack::GetTagContent(char * pszSource, const char * pszTagStart, const char * pszTagEnd) { + char * b = strstr(pszSource, pszTagStart); + if (!b) return NULL; + b += strlen(pszTagStart); + char * e = strstr(b, pszTagEnd); + if (e) *e = 0; + return b; +} + diff --git a/plugins/SendScreenshotPlus/src/CSendImageShack.h b/plugins/SendScreenshotPlus/src/CSendImageShack.h new file mode 100644 index 0000000000..eae406aca9 --- /dev/null +++ b/plugins/SendScreenshotPlus/src/CSendImageShack.h @@ -0,0 +1,77 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* +Copyright 2000-2009 Miranda ICQ/IM project, + +This file is part of Send Screenshot Plus, a Miranda IM plugin. +Copyright (c) 2010 Ing.U.Horn + +Parts of this file based on original sorce code +(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/CSendImageShack.h $ +Revision : $Revision: 13 $ +Last change on : $Date: 2010-04-02 02:54:30 +0400 (РџС‚, 02 апр 2010) $ +Last change by : $Author: ing.u.horn $ + +*/ + +#ifndef _CSEND_IMAGESHACK_H +#define _CSEND_IMAGESHACK_H + +//--------------------------------------------------------------------------- +#include "global.h" +#include "Utils.h" +#include "CSend.h" + +//--------------------------------------------------------------------------- +class CSendImageShack : public CSend { + public: + // Deklaration Standardkonstruktor/Standarddestructor + CSendImageShack(HWND Owner, HANDLE hContact, bool bFreeOnExit); + ~CSendImageShack(); + + void Send(); + void SendSync(bool Sync) {m_SendSync = Sync;}; + LPSTR GetURL(){return m_Url;}; + LPSTR GetError(){return mir_t2a(m_ErrorMsg);}; + + protected: + LPSTR m_pszFileName; + NETLIBHTTPREQUEST m_nlhr; + NETLIBHTTPREQUEST* m_nlreply; + NETLIBHTTPHEADER* m_nlheader; + char m_nlheader_ContentType[64]; + LPSTR m_Url; + + void AppendToData(const char *pszVal); //append to netlib DATA + LPSTR m_pszContentType; //hold mimeType (does not need free) + void GetContentType(); //get mimeType + const char * GetTagContent(char * pszSource, const char * pszTagStart, const char * pszTagEnd); + + char* m_MFDRboundary; + void MFDR_Reset(); + + bool m_SendSync; + void SendThread(); + static void SendThreadWrapper(void * Obj); + +}; + +//--------------------------------------------------------------------------- + +#endif diff --git a/plugins/SendScreenshotPlus/src/DevKey.h b/plugins/SendScreenshotPlus/src/DevKey.h new file mode 100644 index 0000000000..2999f74466 --- /dev/null +++ b/plugins/SendScreenshotPlus/src/DevKey.h @@ -0,0 +1,3 @@ +#ifndef DEVKEY_IMAGESHACK +#define DEVKEY_IMAGESHACK "IA5ZRTV6fb6256ccbc3c38650bdce6e6dcfc9e55" /*Test DevKey*/ +#endif diff --git a/plugins/SendScreenshotPlus/src/Main.cpp b/plugins/SendScreenshotPlus/src/Main.cpp new file mode 100644 index 0000000000..75e5655ac5 --- /dev/null +++ b/plugins/SendScreenshotPlus/src/Main.cpp @@ -0,0 +1,364 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* +Copyright 2000-2009 Miranda ICQ/IM project, + +This file is part of Send Screenshot Plus, a Miranda IM plugin. +Copyright (c) 2010 Ing.U.Horn + +Parts of this file based on original sorce code +(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/Main.cpp $ +Revision : $Revision: 22 $ +Last change on : $Date: 2010-05-02 21:25:02 +0400 (Р’СЃ, 02 май 2010) $ +Last change by : $Author: ing.u.horn $ + +*/ + +//--------------------------------------------------------------------------- +#include "main.h" + +// Prototypes /////////////////////////////////////////////////////////////////////////// +//LIST_INTERFACE li; +FI_INTERFACE *FIP = 0; +HINSTANCE hInst; //!< Global reference to the application +MGLOBAL myGlobals; +int hLangpack; + + +//Information gathered by Miranda, displayed in the plugin pane of the Option Dialog +PLUGININFOEX pluginInfo={ + sizeof(PLUGININFOEX), + __PLUGIN_NAME, // altered here and on file listing, so as not to match original + PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), + __DESC, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, //doesn't replace anything built-in + MIID_PLUGIN +}; + +//static char szSendSS[]=SZ_SENDSS; + +HANDLE hsvc_SendScreenshot=0; +HANDLE hsvc_SendDesktop=0; +HANDLE hsvc_EditBitmap=0; +HANDLE hsvc_Send2ImageShack=0; + +HANDLE hNetlibUser = 0; //!< Netlib Register User +HANDLE hFolderScreenshot=0; + +HANDLE hhook_ModulesLoad=0; +HANDLE hhook_SystemPShutdown=0; + + +// Functions //////////////////////////////////////////////////////////////////////////// + +/*--------------------------------------------------------------------------- +* DLL entry point - Required to store the instance handle +*/ +extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { + hInst = hinstDLL; + // Freeing some unneeded resources + DisableThreadLibraryCalls(GetModuleHandle(_T("sendss.dll"))); + + return TRUE; +} + +/*--------------------------------------------------------------------------- +* Called by Miranda to get the information associated to this plugin. +* It only returns the PLUGININFO structure, without any test on the version +* @param mirandaVersion The version of the application calling this function +*/ +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) { + pluginInfo.cbSize = sizeof(PLUGININFOEX); + myGlobals.mirandaVersion = mirandaVersion; + return &pluginInfo; +} + +extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PLUGIN, MIID_LAST }; + +/*--------------------------------------------------------------------------- +* Initializes the services provided and the link to those needed +* Called when the plugin is loaded into Miranda +*/ +extern "C" int __declspec(dllexport) Load(void) { + mir_getLP(&pluginInfo); + INT_PTR result = CALLSERVICE_NOTFOUND; + + if(ServiceExists(MS_IMG_GETINTERFACE)) + result = CallService(MS_IMG_GETINTERFACE, FI_IF_VERSION, (LPARAM)&FIP); + + if(FIP == NULL || result != S_OK) { + MessageBoxEx(NULL, TranslateT("Fatal error, image services not found. Send Screenshot will be disabled."), _T("Error"), MB_OK | MB_ICONERROR | MB_APPLMODAL, 0); + return 1; + } + + // load icon library (use UserInfoEx icon Pack) + IcoLib_LoadModule(); + + hhook_ModulesLoad = HookEvent(ME_SYSTEM_MODULESLOADED, hook_ModulesLoaded); + //hhook_options_init = HookEvent(ME_OPT_INITIALISE, hook_options_init); + //hhook_OkToExit = HookEvent(ME_SYSTEM_OKTOEXIT, hook_OkToExit); + hhook_SystemPShutdown = HookEvent(ME_SYSTEM_PRESHUTDOWN, hook_SystemPShutdown); + + AddMenuItems(); + RegisterServices(); + + return 0; +} + +int hook_ModulesLoaded(WPARAM, LPARAM) { + + myGlobals.PopUpExist = ServiceExists(MS_POPUP_ADDPOPUP); + myGlobals.PopUpActionsExist = ServiceExists(MS_POPUP_REGISTERACTIONS); + myGlobals.PluginHTTPExist = ServiceExists(MS_HTTP_ACCEPT_CONNECTIONS); + myGlobals.PluginFTPExist = ServiceExists(MS_FTPFILE_SHAREFILE); +// myGlobals.PluginUserinfoEx = ServiceExists(MS_USERINFO_VCARD_EXPORT); + + // Netlib register + if (!NetlibInit()){ + ; + } + + // load my button class + if(!ServiceExists("UserInfo/vCard/Export")) { + CtrlButtonLoadModule(); + } + + // Folders plugin support + if (ServiceExists(MS_FOLDERS_REGISTER_PATH)) { + hFolderScreenshot = (HANDLE) FoldersRegisterCustomPathT("SendSS", "Screenshots", + _T(PROFILE_PATH)_T("\\")_T(CURRENT_PROFILE)_T("\\Screenshots")); + } + + return 0; +} + +/*--------------------------------------------------------------------------- +* Prepare the plugin to stop +* Called by Miranda when it will exit or when the plugin gets deselected +*/ +extern "C" int __declspec(dllexport) Unload(void) { + UnhookEvent(hhook_SystemPShutdown); + + DestroyServiceFunction(MS_SENDSS_OPENDIALOG); + DestroyServiceFunction(MS_SENDSS_EDITBITMAP); + DestroyServiceFunction(MS_SENDSS_SENDDESKTOP); + DestroyServiceFunction(MS_SENDSS_SEND2IMAGESHACK); + return 0; +} + +int hook_SystemPShutdown(WPARAM wParam, LPARAM lParam) { + UnhookEvent(hhook_ModulesLoad); + + // Netlib unregister + NetlibClose(); + + // uninitialize classes + CtrlButtonUnloadModule(); + + return 0; +} + +//--------------------------------------------------------------------------- +// Netlib +HANDLE NetlibInit(void) { + NETLIBUSER nlu = {0}; + nlu.cbSize = sizeof(nlu); + nlu.szSettingsModule = (char*)PLUGNAME; + nlu.szDescriptiveName = Translate("SendSS HTTP connections"); + nlu.flags = NUF_OUTGOING|NUF_HTTPCONNS; //|NUF_NOHTTPSOPTION; + hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu); + return hNetlibUser; +} + +void NetlibClose(void) { + Netlib_CloseHandle(hNetlibUser); +} + + +//--------------------------------------------------------------------------- +// Callback function of service +// 1. Send a screenshot of the desktop to the selected contact +// wParam = contact handle +// lParam = 0 +// 2. Open the capture dialog in take screenshot only mode (it will not be sent) +// wParam = 0 +// lParam = anything but 0 +INT_PTR service_CaptureAndSendDesktop(WPARAM wParam, LPARAM lParam) { + LPTSTR pszPath = NULL; + LPSTR pszProto = NULL; + bool bChatRoom; + + TfrmMain *frmMain=new TfrmMain(); + if (!frmMain) { + MessageBoxEx(NULL, TranslateT("Could not create main dialog."), TranslateT("Error"), MB_OK | MB_ICONERROR | MB_APPLMODAL, 0); + return -1; + } + pszPath = GetCustomPath(); + + pszProto = (LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0); + bChatRoom = DBGetContactSettingByte((HANDLE)wParam, pszProto, "ChatRoom", 0) != 0; + frmMain->m_opt_chkTimed = false; + frmMain->m_opt_tabCapture = 1; + frmMain->m_opt_cboxDesktop = 0; + frmMain->m_opt_chkEditor = false; + frmMain->m_opt_cboxSendBy = bChatRoom ? SS_IMAGESHACK:SS_FILESEND; + frmMain->Init(pszPath, (HANDLE)wParam); // this method create the window hidden. + frmMain->btnCaptureClick(); // this method will call Close() + mir_free(pszPath); + return 0; +} + +//--------------------------------------------------------------------------- +// Callback function of service for contact menu and main menu +// wParam = contact handle +// lParam = 0 +INT_PTR service_OpenCaptureDialog(WPARAM wParam, LPARAM lParam) { + LPTSTR pszPath = NULL; + + TfrmMain *frmMain=new TfrmMain(); + if (!frmMain) { + MessageBoxEx(NULL, TranslateT("Could not create main dialog."), TranslateT("Error"), MB_OK | MB_ICONERROR | MB_APPLMODAL, 0); + return -1; + } + + pszPath = GetCustomPath(); + frmMain->Init(pszPath, (HANDLE)wParam); + mir_free(pszPath); + frmMain->Show(); + return 0; +} + +//--------------------------------------------------------------------------- +// Edit a in-memory bitmap on the edit window +// wParam = (SENDSSCB) callback function address to call when editing is done +// lParam = (HBITMAP) bitmap handle, a copy is made so the calling function can free this handle after the service function returns +// Returns: +INT_PTR service_EditBitmap(WPARAM wParam, LPARAM lParam) { +/* TfrmEdit *frmEdit=new TfrmEdit(NULL); + if (!frmEdit) + return -1; + + Graphics::TBitmap *bitmap=new Graphics::TBitmap(); + if (!bitmap) + return -2; + + bitmap->Handle = (void*)lParam; + frmEdit->InitEditor(bitmap); // a copy of the bitmap is made inside this function + frmEdit->Show(); + delete bitmap; +*/ + return 0; +} + +//--------------------------------------------------------------------------- +// Callback function of service for sending image to imageshack.us +// wParam = (char*)filename +// lParam = (HANDLE)contact (can be null) +INT_PTR service_Send2ImageShack(WPARAM wParam, LPARAM lParam) { + LPSTR result = NULL; + CSendImageShack* cSend = new CSendImageShack(NULL, (HANDLE)lParam, false); + cSend->m_pszFile = mir_a2t((char*)wParam); + cSend->m_bDeleteAfterSend = FALSE; + if (lParam != NULL) { + cSend->Send(); + return 0; + } + cSend->SendSync(TRUE); + cSend->Send(); + if (cSend->GetURL()) { + result = mir_strdup(cSend->GetURL()); + } + else { + result = cSend->GetError(); + } + delete cSend; + return (INT_PTR)result; +} + +//--------------------------------------------------------------------------- +// Add SendSS menu item in contact menu +void AddMenuItems(void) { + CLISTMENUITEM mi={0}; + + // Common + mi.cbSize = sizeof(mi); + // support new genmenu style + mi.flags = CMIF_ROOTHANDLE|CMIF_UNICODE; + mi.hParentMenu = HGENMENU_ROOT; + + // Add item to contact menu + mi.position = 1000000; + mi.ptszName = LPGENT("Send Screenshot"); + mi.hIcon = IcoLib_GetIcon(ICO_PLUG_SSWINDOW2); + mi.pszService = MS_SENDSS_OPENDIALOG; + Menu_AddContactMenuItem(&mi); + + // Add item to contact menu + mi.position = 1000001; + mi.ptszName = LPGENT("Send desktop screenshot"); + mi.hIcon = IcoLib_GetIcon(ICO_PLUG_SSWINDOW2); + mi.pszService = MS_SENDSS_SENDDESKTOP; + Menu_AddContactMenuItem(&mi); + + // Add item to main menu + mi.position = 1000001; + mi.ptszName = LPGENT("Take a screenshot"); + mi.hIcon = IcoLib_GetIcon(ICO_PLUG_SSWINDOW2); + mi.pszService = MS_SENDSS_OPENDIALOG; + Menu_AddMainMenuItem(&mi); +} + +//--------------------------------------------------------------------------- +// Register Send screenshot services +int RegisterServices(void) { + hsvc_SendScreenshot = CreateServiceFunction(MS_SENDSS_OPENDIALOG, service_OpenCaptureDialog); + if (!hsvc_SendScreenshot) + MessageBoxEx(NULL, TranslateT("Could not register miranda service."), _T("MS_SENDSS_OPENDIALOG"), MB_OK | MB_ICONERROR | MB_APPLMODAL, 0); + + hsvc_SendDesktop = CreateServiceFunction(MS_SENDSS_SENDDESKTOP, service_CaptureAndSendDesktop); + if (!hsvc_SendDesktop) + MessageBoxEx(NULL, TranslateT("Could not register miranda service."), _T("MS_SENDSS_SENDDESKTOP"), MB_OK | MB_ICONERROR | MB_APPLMODAL, 0); + + hsvc_EditBitmap = CreateServiceFunction(MS_SENDSS_EDITBITMAP, service_EditBitmap); + if (!hsvc_EditBitmap) + MessageBoxEx(NULL, TranslateT("Could not register miranda service."), _T("MS_SENDSS_EDITBITMAP"), MB_OK | MB_ICONERROR | MB_APPLMODAL, 0); + + hsvc_Send2ImageShack = CreateServiceFunction(MS_SENDSS_SEND2IMAGESHACK, service_Send2ImageShack); + if (!hsvc_Send2ImageShack) + MessageBoxEx(NULL, TranslateT("Could not register miranda service."), _T("MS_SENDSS_SEND2IMAGESHACK"), MB_OK | MB_ICONERROR | MB_APPLMODAL, 0); + + return 0; +} + +//--------------------------------------------------------------------------- +LPTSTR GetCustomPath() { + LPTSTR pszPath = NULL; + pszPath = Utils_ReplaceVarsT(_T("%miranda_userdata%\\Screenshots")); + if (hFolderScreenshot) { + TCHAR szPath[1024] = {'\0'}; + FoldersGetCustomPathT(hFolderScreenshot, szPath, 1024, pszPath); + mir_freeAndNil(pszPath); + pszPath = mir_tstrdup(szPath); + } + return pszPath; +} diff --git a/plugins/SendScreenshotPlus/src/Main.h b/plugins/SendScreenshotPlus/src/Main.h new file mode 100644 index 0000000000..67059fb73c --- /dev/null +++ b/plugins/SendScreenshotPlus/src/Main.h @@ -0,0 +1,65 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* +Copyright 2000-2009 Miranda ICQ/IM project, + +This file is part of Send Screenshot Plus, a Miranda IM plugin. +Copyright (c) 2010 Ing.U.Horn + +Parts of this file based on original sorce code +(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/Main.h $ +Revision : $Revision: 22 $ +Last change on : $Date: 2010-05-02 21:25:02 +0400 (Р’СЃ, 02 май 2010) $ +Last change by : $Author: ing.u.horn $ + +*/ + +#ifndef MainH +#define MainH + +//--------------------------------------------------------------------------- +#include "global.h" +#include "UMainForm.h" +//#include "UEditForm.h" + +extern HANDLE hNetlibUser; + +//--------------------------------------------------------------------------- + +HANDLE NetlibInit(void); +void NetlibClose(void); + +void IcoLib_LoadModule(void); +void AddMenuItems(void); +int RegisterServices(void); + +int hook_ModulesLoaded(WPARAM, LPARAM); +int hook_SystemPShutdown(WPARAM wParam, LPARAM lParam); + +INT_PTR service_CaptureAndSendDesktop(WPARAM wParam, LPARAM lParam); +INT_PTR service_OpenCaptureDialog(WPARAM wParam, LPARAM lParam); +INT_PTR service_EditBitmap(WPARAM wParam, LPARAM lParam); +INT_PTR service_Send2ImageShack(WPARAM wParam, LPARAM lParam); + +int OnSendScreenShot(WPARAM wParam, LPARAM lParam); + +LPTSTR GetCustomPath(); + +//--------------------------------------------------------------------------- +#endif diff --git a/plugins/SendScreenshotPlus/src/UAboutForm.cpp b/plugins/SendScreenshotPlus/src/UAboutForm.cpp new file mode 100644 index 0000000000..f4ea2b6bc2 --- /dev/null +++ b/plugins/SendScreenshotPlus/src/UAboutForm.cpp @@ -0,0 +1,212 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* +Copyright 2000-2009 Miranda ICQ/IM project, + +This file is part of Send Screenshot Plus, a Miranda IM plugin. +Copyright (c) 2010 Ing.U.Horn + +Parts of this file based on original sorce code +(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/UAboutForm.cpp $ +Revision : $Revision: 22 $ +Last change on : $Date: 2010-05-02 21:25:02 +0400 (Р’СЃ, 02 май 2010) $ +Last change by : $Author: ing.u.horn $ + +*/ + +#include "UAboutForm.h" + +//--------------------------------------------------------------------------- +TfrmAbout::CHandleMapping TfrmAbout::_HandleMapping; + +LRESULT CALLBACK TfrmAbout::DlgTfrmAbout(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + if (msg == WM_CTLCOLOREDIT || msg == WM_CTLCOLORSTATIC) { + switch ( GetWindowLongPtr(( HWND )lParam, GWL_ID )) { + case IDC_WHITERECT: + case IDC_BUILDTIME: + case IDC_CREDIT: + case IDC_LICENSE: + SetTextColor((HDC)wParam,GetSysColor(COLOR_WINDOWTEXT)); + break; + default: + return FALSE; + } + SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); + return (LRESULT)GetStockObject(WHITE_BRUSH); //GetSysColorBrush(COLOR_WINDOW); + } + + CHandleMapping::iterator wnd(_HandleMapping.end()); + if (msg == WM_INITDIALOG) { + wnd = _HandleMapping.insert(CHandleMapping::value_type(hWnd, reinterpret_cast(lParam))).first; + reinterpret_cast(lParam)->m_hWnd = hWnd; + return wnd->second->wmInitdialog(wParam, lParam); + } + else { + wnd = _HandleMapping.find(hWnd); + } + if (wnd == _HandleMapping.end()) { // something screwed up + return FALSE; //dialog! do not use ::DefWindowProc(hWnd, msg, wParam, lParam); + } + + switch (msg) + { + // case WM_INITDIALOG: done on top + case WM_COMMAND: + return wnd->second->wmCommand(wParam, lParam); + break; + case WM_CLOSE: + return wnd->second->wmClose(wParam, lParam); + break; + case WM_DESTROY: + delete wnd->second; + break; + } + return FALSE; +} + +//--------------------------------------------------------------------------- +//WM_INITDIALOG: +LRESULT TfrmAbout::wmInitdialog(WPARAM wParam, LPARAM lParam) { + char* pszMsg = NULL; + HRSRC hResInfo; + DWORD ResSize; + TCHAR oldTitle[256], newTitle[256]; + LPTSTR temp = NULL; + LPTSTR pszTitle = NULL; + // Headerbar + LPTSTR pszPlug = mir_a2t(__PLUGIN_NAME); + LPTSTR pszVer = mir_a2t(__VERSION_STRING_DOT); + GetDlgItemText( m_hWnd, IDC_HEADERBAR, oldTitle, SIZEOF( oldTitle )); + mir_sntprintf( newTitle, SIZEOF(newTitle), oldTitle, pszPlug, pszVer ); + mir_freeAndNil(pszPlug); + mir_freeAndNil(pszVer); + SetDlgItemText( m_hWnd, IDC_HEADERBAR, newTitle ); + SendMessage(GetDlgItem(m_hWnd, IDC_HEADERBAR), WM_SETICON, 0, (WPARAM)IcoLib_GetIcon(ICO_PLUG_SSWINDOW1, true)); + + //Buildtime + mir_sntprintf(newTitle,SIZEOF(newTitle),TranslateT("Built %s %s"),_T(__DATE__),_T(__TIME__)); + SetDlgItemText(m_hWnd,IDC_BUILDTIME,newTitle); + + //License + { mir_tcsadd(pszTitle ,_T(__COPYRIGHT)); + mir_tcsadd(pszTitle ,_T("\r\n\r\n")); + + hResInfo = FindResource(hInst,MAKEINTRESOURCE(IDR_LICENSE),_T("TEXT")); + ResSize = SizeofResource(hInst,hResInfo); + pszMsg = (char*)LockResource(LoadResource(hInst,hResInfo)); + temp = mir_a2t(pszMsg); + temp [ResSize] = 0; //LockResource is not NULL terminatet !! + mir_tcsadd(pszTitle ,temp); + mir_freeAndNil(temp); + SetDlgItemText(m_hWnd,IDC_LICENSE, pszTitle); + mir_freeAndNil(pszTitle); + } + + //Credit + { + hResInfo = FindResource(hInst,MAKEINTRESOURCE(IDR_CREDIT),_T("TEXT")); + ResSize = SizeofResource(hInst,hResInfo); + pszMsg = (char*)LockResource(LoadResource(hInst,hResInfo)); + temp = mir_a2t(pszMsg); + temp [ResSize] = 0; //LockResource is not NULL terminatet !! + mir_tcsadd(pszTitle ,temp); + mir_freeAndNil(temp); + SetDlgItemText(m_hWnd,IDC_CREDIT, pszTitle); + mir_freeAndNil(pszTitle); + } + + SendMessage(m_hWnd, WM_SETICON, ICON_BIG, (LPARAM)IcoLib_GetIcon(ICO_PLUG_SSWINDOW1, true)); + SendMessage(m_hWnd, WM_SETICON, ICON_SMALL, (LPARAM)IcoLib_GetIcon(ICO_PLUG_SSWINDOW2)); + + //init controls + btnPageClick(); + SendMessage(GetDlgItem(m_hWnd, IDA_CONTRIBLINK), BUTTONSETDEFAULT, (WPARAM)1, NULL); + + TranslateDialogDefault(m_hWnd); + return FALSE; +} + +//WM_COMMAND: +LRESULT TfrmAbout::wmCommand(WPARAM wParam, LPARAM lParam) { + //--------------------------------------------------------------------------- + if (HIWORD(wParam) == BN_CLICKED) { + int IDControl = LOWORD(wParam); + HWND hCtrl = (HWND)lParam; + switch(IDControl) { + case IDCANCEL: + case IDCLOSE: + break; + case IDA_btnClose: + Close(); + break; + case IDA_CONTRIBLINK: + m_Page = m_Page ? 0 : 1; + btnPageClick(); + break; + default: + break; + } + } + return FALSE; +} + +//WM_CLOSE: +LRESULT TfrmAbout::wmClose(WPARAM wParam, LPARAM lParam) { + SendMessage(m_hWndOwner,UM_CLOSING, (WPARAM)m_hWnd, (LPARAM)IDD_UAboutForm); + DestroyWindow(m_hWnd); + return FALSE; +} + +//--------------------------------------------------------------------------- +// Standard konstruktor/destruktor +TfrmAbout::TfrmAbout(HWND Owner) { + m_hWndOwner = Owner; + // create window + m_hWnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_UAboutForm),0, (DLGPROC)DlgTfrmAbout,(LPARAM)this); + //register object + _HandleMapping.insert(CHandleMapping::value_type(m_hWnd, this)); + //init page + m_Page = 1; +} + +TfrmAbout::~TfrmAbout() { + _HandleMapping.erase(m_hWnd); +} + +//--------------------------------------------------------------------------- +void TfrmAbout::btnPageClick() { + HWND hCtrl = GetDlgItem(m_hWnd, IDA_CONTRIBLINK); + if(!m_Page) { + ShowWindow(GetDlgItem(m_hWnd, IDC_CREDIT), SW_HIDE); + ShowWindow(GetDlgItem(m_hWnd, IDC_LICENSE), SW_SHOW); + SendDlgItemMessage(m_hWnd, IDA_CONTRIBLINK, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Credits >"), MBF_TCHAR); + HICON hIcon = IcoLib_GetIcon(ICO_PLUG_ARROWR); + SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); + SetWindowText(hCtrl, hIcon ? TranslateT("Credits") : TranslateT("Credits >")); + } + else { + ShowWindow(GetDlgItem(m_hWnd, IDC_CREDIT), SW_SHOW); + ShowWindow(GetDlgItem(m_hWnd, IDC_LICENSE), SW_HIDE); + SendDlgItemMessage(m_hWnd, IDA_CONTRIBLINK, BUTTONADDTOOLTIP, (WPARAM)TranslateT("< Copyright"), MBF_TCHAR); + HICON hIcon = IcoLib_GetIcon(ICO_PLUG_ARROWL); + SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); + SetWindowText(hCtrl, hIcon ? TranslateT("Copyright") : TranslateT("< Copyright")); + } +} diff --git a/plugins/SendScreenshotPlus/src/UAboutForm.h b/plugins/SendScreenshotPlus/src/UAboutForm.h new file mode 100644 index 0000000000..d9d598aeb6 --- /dev/null +++ b/plugins/SendScreenshotPlus/src/UAboutForm.h @@ -0,0 +1,69 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* +Copyright 2000-2009 Miranda ICQ/IM project, + +This file is part of Send Screenshot Plus, a Miranda IM plugin. +Copyright (c) 2010 Ing.U.Horn + +Parts of this file based on original sorce code +(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/UAboutForm.h $ +Revision : $Revision: 19 $ +Last change on : $Date: 2010-04-09 03:24:04 +0400 (РџС‚, 09 апр 2010) $ +Last change by : $Author: ing.u.horn $ + +*/ + +#ifndef UAboutFormH +#define UAboutFormH +//--------------------------------------------------------------------------- +#include "global.h" + +//--------------------------------------------------------------------------- +class TfrmAbout{ + + public: + // Deklaration Standardkonstruktor/Standarddestructor + TfrmAbout(HWND Owner); + ~TfrmAbout(); + + HWND m_hWndOwner; + void Show(){ShowWindow(m_hWnd,SW_SHOW);} + void Hide(){ShowWindow(m_hWnd,SW_HIDE);} + void Close(){SendMessage(m_hWnd,WM_CLOSE,0,0);} + + private: + HWND m_hWnd; + + protected: + UINT m_Page; + typedef std::map CHandleMapping; + static CHandleMapping _HandleMapping; + static LRESULT CALLBACK DlgTfrmAbout(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); + + LRESULT wmInitdialog(WPARAM wParam, LPARAM lParam); + LRESULT wmCommand(WPARAM wParam, LPARAM lParam); + LRESULT wmClose(WPARAM wParam, LPARAM lParam); + + void btnPageClick(); + +}; + +//--------------------------------------------------------------------------- +#endif diff --git a/plugins/SendScreenshotPlus/src/UMainForm.cpp b/plugins/SendScreenshotPlus/src/UMainForm.cpp new file mode 100644 index 0000000000..2061f80d83 --- /dev/null +++ b/plugins/SendScreenshotPlus/src/UMainForm.cpp @@ -0,0 +1,1180 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* +Copyright 2000-2009 Miranda ICQ/IM project, + +This file is part of Send Screenshot Plus, a Miranda IM plugin. +Copyright (c) 2010 Ing.U.Horn + +Parts of this file based on original sorce code +(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/UMainForm.cpp $ +Revision : $Revision: 22 $ +Last change on : $Date: 2010-05-02 21:25:02 +0400 (Р’СЃ, 02 май 2010) $ +Last change by : $Author: ing.u.horn $ + +*/ + +#include "UMainForm.h" +#include "UAboutForm.h" +//#include "UEditForm.h" + +//--------------------------------------------------------------------------- +INT_PTR CALLBACK TfrmMain::DlgProc_CaptureWindow(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { +// main message handling is done inside TfrmMain::DlgTfrmMain + switch (uMsg) { + case WM_INITDIALOG: + Static_SetIcon(GetDlgItem(hDlg, ID_imgTarget), IcoLib_GetIcon(ICO_PLUG_SSTARGET)); + SetDlgItemText(hDlg, ID_edtCaption, _T("Drag&&Drop the target on the desired window.")); + TranslateDialogDefault(hDlg); + break; + case WM_CTLCOLOREDIT: //ctrl is NOT read-only or disabled + case WM_CTLCOLORSTATIC: //ctrl is read-only or disabled + // make the rectangle on the top white + switch (GetWindowLongPtr((HWND)lParam, GWL_ID)) { + case IDC_WHITERECT: + case ID_chkClientArea: + case ID_lblDropInfo: + case ID_edtCaption: + case ID_edtCaptionLabel: + case ID_edtSize: + case ID_edtSizeLabel: + case ID_bvlTarget: + case ID_imgTarget: + SetBkColor((HDC)wParam,GetSysColor(COLOR_WINDOW)); + SetTextColor((HDC)wParam,GetSysColor(COLOR_WINDOWTEXT)); + + //SetBkMode((HDC)wParam,OPAQUE); + //return (INT_PTR)GetSysColorBrush(COLOR_WINDOW); + return (LRESULT)GetStockObject(WHITE_BRUSH); + break; + default: + SetBkMode((HDC)wParam, TRANSPARENT); + return (LRESULT)GetStockObject(NULL_BRUSH); + break; + } + break; //this return false + case WM_COMMAND: + SendMessage(GetParent(hDlg), uMsg, wParam, lParam); + break; + case WM_MOUSEMOVE: + SendMessage(GetParent(hDlg), UM_TAB1, uMsg, 0); + break; + case WM_NOTIFY: + SendMessage(GetParent(hDlg), uMsg, wParam, lParam); + break; + case WM_DESTROY: + break; + } + return FALSE; +} + +//--------------------------------------------------------------------------- +INT_PTR CALLBACK TfrmMain::DlgProc_CaptureDesktop(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { +// main message handling is done inside TfrmMain::DlgTfrmMain + switch (uMsg) { + case WM_INITDIALOG: + Static_SetIcon(GetDlgItem(hDlg, ID_imgTarget), IcoLib_GetIcon(ICO_PLUG_SSMONITOR)); + break; + case WM_CTLCOLOREDIT: + case WM_CTLCOLORSTATIC: + // make the rectangle on the top white + switch (GetWindowLongPtr((HWND)lParam, GWL_ID)) { + case IDC_WHITERECT: + case ID_lblDropInfo: + case ID_edtCaption: + case ID_edtCaptionLabel: + case ID_edtSize: + case ID_edtSizeLabel: + case ID_bvlTarget: + case ID_imgTarget: + SetBkColor((HDC)wParam,GetSysColor(COLOR_WINDOW)); + SetTextColor((HDC)wParam,GetSysColor(COLOR_WINDOWTEXT)); + return (LRESULT)GetStockObject(WHITE_BRUSH); + break; + default: + SetBkMode((HDC)wParam, TRANSPARENT); + return (LRESULT)GetStockObject(NULL_BRUSH); + break; + } + break; + case WM_COMMAND: + SendMessage(GetParent(hDlg), uMsg, wParam, lParam); + break; + case WM_NOTIFY: + SendMessage(GetParent(hDlg), uMsg, wParam, lParam); + break; + case WM_DESTROY: + break; + } + return FALSE; +} + +//--------------------------------------------------------------------------- + +TfrmMain::CHandleMapping TfrmMain::_HandleMapping; + +LRESULT CALLBACK TfrmMain::DlgTfrmMain(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + if (msg == WM_CTLCOLOREDIT || msg == WM_CTLCOLORSTATIC) { + switch ( GetWindowLongPtr(( HWND )lParam, GWL_ID )) { + /* case IDC_WHITERECT:*/ + case IDC_HEADERBAR: + SetTextColor((HDC)wParam,GetSysColor(COLOR_WINDOWTEXT)); + break; + default: + return FALSE; + } + SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); + return (LRESULT)GetStockObject(WHITE_BRUSH); //GetSysColorBrush(COLOR_WINDOW); + } + + CHandleMapping::iterator wnd(_HandleMapping.end()); + if (msg == WM_INITDIALOG) { + wnd = _HandleMapping.insert(CHandleMapping::value_type(hWnd, reinterpret_cast(lParam))).first; + reinterpret_cast(lParam)->m_hWnd = hWnd; + return wnd->second->wmInitdialog(wParam, lParam); + } + else { + wnd = _HandleMapping.find(hWnd); + } + if (wnd == _HandleMapping.end()) { // something screwed up + return FALSE; //dialog! do not use ::DefWindowProc(hWnd, msg, wParam, lParam); + } + + switch (msg) + { + // case WM_INITDIALOG: done on top + case WM_COMMAND: + return wnd->second->wmCommand(wParam, lParam); + break; + case WM_CLOSE: + return wnd->second->wmClose(wParam, lParam); + break; + case WM_DESTROY: + delete wnd->second; + break; + case UM_TAB1: + return wnd->second->UMTab1(wParam, lParam); + break; + case WM_NOTIFY: + return wnd->second->wmNotify(wParam, lParam); + break; + case WM_TIMER: + return wnd->second->wmTimer(wParam, lParam); + break; + case UM_CLOSING: + return wnd->second->UMClosing(wParam, lParam); + break; + case UM_EVENT: + return wnd->second->UMevent(wParam, lParam); + break; + } + return FALSE; +} + +//--------------------------------------------------------------------------- +//WM_INITDIALOG: +LRESULT TfrmMain::wmInitdialog(WPARAM wParam, LPARAM lParam) { + HWND hCtrl; + //Taskbar and Window icon + SendMessage(m_hWnd, WM_SETICON, ICON_BIG, (LPARAM)IcoLib_GetIcon(ICO_PLUG_SSWINDOW1, true)); + SendMessage(m_hWnd, WM_SETICON, ICON_SMALL, (LPARAM)IcoLib_GetIcon(ICO_PLUG_SSWINDOW2)); + LPTSTR pt = mir_a2t(__PLUGIN_NAME); + SetWindowText(m_hWnd, pt); + mir_freeAndNil(pt); + + // Headerbar + pt = mir_tstrdup((LPTSTR)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)m_hContact, (LPARAM)GCDNF_TCHAR)); + if (pt && (m_hContact != 0)) { + LPTSTR lptString = NULL; + mir_tcsadd(lptString , TranslateT("Send screenshot to\n")); + mir_tcsadd(lptString , pt); + SetDlgItemText(m_hWnd, IDC_HEADERBAR, lptString); + mir_free(lptString); + } + mir_freeAndNil(pt); + + SendMessage(GetDlgItem(m_hWnd, IDC_HEADERBAR), WM_SETICON, 0, (WPARAM)IcoLib_GetIcon(ICO_PLUG_SSWINDOW1, true)); + + //Timed controls + CheckDlgButton(m_hWnd,ID_chkTimed, m_opt_chkTimed ? BST_CHECKED : BST_UNCHECKED); + SetDlgItemInt (m_hWnd,ID_edtTimed, (UINT)m_opt_edtTimed, FALSE); + SendDlgItemMessage(m_hWnd, ID_upTimed, UDM_SETRANGE, 0, (LPARAM)MAKELONG(250, 1)); + chkTimedClick(); //enable disable Timed controls + + //create Image list for tab control + if(m_himlTab == 0){ + //m_himlTab = ImageList_Create(16, 16, PluginConfig.m_bIsXP ? ILC_COLOR32 | ILC_MASK : ILC_COLOR8 | ILC_MASK, 2, 0); + m_himlTab = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 2, 0); + ImageList_AddIcon(m_himlTab, IcoLib_GetIcon(ICO_PLUG_SSWINDOW2)); + ImageList_AddIcon(m_himlTab, IcoLib_GetIcon(ICO_PLUG_SSWINDOW2)); + } + + //create the tab control. + { + TAB_INFO itab; + RECT rcClient, rcTab; + m_hwndTab = GetDlgItem(m_hWnd, IDC_CAPTURETAB); + TabCtrl_SetItemExtra(m_hwndTab, sizeof(TAB_INFO) - sizeof(TCITEMHEADER)); + + ZeroMemory(&itab, sizeof(itab)); + itab.hwndMain = m_hWnd; + itab.hwndTab = m_hwndTab; + + GetWindowRect(m_hwndTab, &rcTab); + GetWindowRect(m_hWnd, &rcClient); + + TabCtrl_SetImageList(m_hwndTab, m_himlTab); + + // Add a tab for each of the three child dialog boxes. + itab.tcih.mask = TCIF_PARAM|TCIF_TEXT|TCIF_IMAGE; + + itab.tcih.pszText = TranslateT("Window"); + itab.tcih.iImage = 0; + itab.hwndTabPage = CreateDialog(hInst,MAKEINTRESOURCE(IDD_UMain_CaptureWindow), m_hWnd,(DLGPROC)DlgProc_CaptureWindow); + TabCtrl_InsertItem(m_hwndTab, 0, &itab); + MoveWindow(itab.hwndTabPage, (rcTab.left - rcClient.left)+2, (rcTab.top - rcClient.top), (rcTab.right - rcTab.left) - 2*5, (rcTab.bottom - rcTab.top) - 2*20, TRUE); + ShowWindow(itab.hwndTabPage, SW_HIDE); + CheckDlgButton(itab.hwndTabPage, ID_chkClientArea, m_opt_chkClientArea ? BST_CHECKED : BST_UNCHECKED); + + itab.tcih.pszText = TranslateT("Desktop"); + itab.tcih.iImage = 1; + itab.hwndTabPage = CreateDialog(hInst,MAKEINTRESOURCE(IDD_UMain_CaptureDesktop), m_hWnd, DlgProc_CaptureDesktop); + TabCtrl_InsertItem(m_hwndTab, 1, &itab); + MoveWindow(itab.hwndTabPage, (rcTab.left - rcClient.left)+2, (rcTab.top - rcClient.top), (rcTab.right - rcTab.left) - 2*5, (rcTab.bottom - rcTab.top) - 2*20, TRUE); + ShowWindow(itab.hwndTabPage, SW_HIDE); + + hCtrl = GetDlgItem(itab.hwndTabPage, ID_edtCaption); + ComboBox_ResetContent(hCtrl); + ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("")) ,(DWORD)0); + ComboBox_SetCurSel (hCtrl,0); + if(m_MonitorCount >1) { + TCHAR tszTemp[120]; + for (size_t i = 0; i < m_MonitorCount; ++i) { + mir_sntprintf(tszTemp, SIZEOF(tszTemp),_T("%i. %s%s"), + i+1, + TranslateT("Monitor"), + (m_Monitors[i].dwFlags & MONITORINFOF_PRIMARY) ? TranslateT(" (primary)") : _T("") + ); + ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, (LPCTSTR)tszTemp) , i+1); + } + ComboBox_SelectItemData (hCtrl, -1, m_opt_cboxDesktop); //use Workaround for MS bug ComboBox_SelectItemData + } + PostMessage(m_hWnd, WM_COMMAND, MAKEWPARAM(ID_edtCaption, CBN_SELCHANGE),(LPARAM)hCtrl); + + //select tab and set m_hwndTabPage + TabCtrl_SetCurSel(m_hwndTab, m_opt_tabCapture); + ZeroMemory(&itab, sizeof(itab)); + itab.tcih.mask = TCIF_PARAM; + TabCtrl_GetItem(m_hwndTab,TabCtrl_GetCurSel(m_hwndTab),&itab); + ShowWindow(itab.hwndTabPage,SW_SHOW); + m_hwndTabPage = itab.hwndTabPage; + } + //init Format combo box + { + hCtrl = GetDlgItem(m_hWnd, ID_cboxFormat); + ComboBox_ResetContent(hCtrl); + ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, _T("PNG")),0); + ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, _T("JPG")),1); + ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, _T("BMP")),2); + ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, _T("TIF")),3); + ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, _T("GIF")),4); + ComboBox_SelectItemData (hCtrl, -1, m_opt_cboxFormat); //use Workaround for MS bug ComboBox_SelectItemData + } + //init SendBy combo box + { + hCtrl = GetDlgItem(m_hWnd, ID_cboxSendBy); + ComboBox_ResetContent(hCtrl); + ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("")) ,SS_JUSTSAVE); + if (m_hContact) { + ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("File Transfer")),SS_FILESEND); + } + else if(m_opt_cboxSendBy == SS_FILESEND) { + m_opt_cboxSendBy = SS_IMAGESHACK; + } + ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("E-mail")) ,SS_EMAIL); + if (myGlobals.PluginHTTPExist) { + ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, _T("HTTP Server")) ,SS_HTTPSERVER); + } + else if(m_opt_cboxSendBy == SS_HTTPSERVER) { + m_opt_cboxSendBy = SS_IMAGESHACK; + } + if (myGlobals.PluginFTPExist) { + ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("FTP File")) ,SS_FTPFILE); + } + else if(m_opt_cboxSendBy == SS_FTPFILE) { + m_opt_cboxSendBy = SS_IMAGESHACK; + } + ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("ImageShack")) ,(BYTE)SS_IMAGESHACK); + ComboBox_SelectItemData (hCtrl, -1, m_opt_cboxSendBy); //use Workaround for MS bug ComboBox_SelectItemData + cboxSendByChange(); //enable disable controls + } + //init footer options + CheckDlgButton(m_hWnd,ID_chkOpenAgain, m_opt_chkOpenAgain ? BST_CHECKED : BST_UNCHECKED); + + if (hCtrl = GetDlgItem(m_hWnd, ID_btnAbout)) { + SendDlgItemMessage(m_hWnd, ID_btnAbout, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Information"), MBF_TCHAR); + HICON hIcon = IcoLib_GetIcon(ICO_PLUG_SSHELP); + SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); + SetWindowText(hCtrl, hIcon ? _T("") : _T("?")); + } + + if (hCtrl = GetDlgItem(m_hWnd, ID_btnExplore)) { + SendDlgItemMessage(m_hWnd, ID_btnExplore, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Open Folder"), MBF_TCHAR); + HICON hIcon = IcoLib_GetIcon(ICO_PLUG_SSFOLDERO); + SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); + SetWindowText(hCtrl, hIcon ? _T("") : _T("...")); + } + + if (hCtrl = GetDlgItem(m_hWnd, ID_btnDesc)) { + SendDlgItemMessage(m_hWnd, ID_btnDesc, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Fill description textbox."), MBF_TCHAR); + HICON hIcon = IcoLib_GetIcon(m_opt_btnDesc ? ICO_PLUG_SSDESKON : ICO_PLUG_SSDESKOFF); + SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); + SetWindowText(hCtrl, hIcon ? _T("") : _T("D")); + SendMessage(hCtrl, BM_SETCHECK, m_opt_btnDesc ? BST_CHECKED : BST_UNCHECKED, NULL); + } + + if (hCtrl = GetDlgItem(m_hWnd, ID_btnDeleteAfterSend)) { + SendDlgItemMessage(m_hWnd, ID_btnDeleteAfterSend, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Delete after send"), MBF_TCHAR); + HICON hIcon = IcoLib_GetIcon(m_opt_btnDeleteAfterSend ? ICO_PLUG_SSDELON : ICO_PLUG_SSDELOFF); + SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); + SetWindowText(hCtrl, hIcon ? _T("") : _T("X")); + SendMessage(hCtrl, BM_SETCHECK, m_opt_btnDeleteAfterSend ? BST_CHECKED : BST_UNCHECKED, NULL); + } + + if (hCtrl = GetDlgItem(m_hWnd, ID_btnCapture)) { + SendDlgItemMessage(m_hWnd, ID_btnCapture, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Capture"), MBF_TCHAR); + HICON hIcon = IcoLib_GetIcon(ICO_BTN_OK); + SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); + SetWindowText(hCtrl, TranslateT("&Capture")); + SendMessage(hCtrl, BUTTONSETDEFAULT, (WPARAM)1, NULL); + } + +// CheckDlgButton(m_hWnd,ID_chkEditor, m_opt_chkEditor ? BST_CHECKED : BST_UNCHECKED); + TranslateDialogDefault(m_hWnd); + return FALSE; +} + +//WM_COMMAND: +LRESULT TfrmMain::wmCommand(WPARAM wParam, LPARAM lParam) { + //--------------------------------------------------------------------------- + int IDControl = LOWORD(wParam); + switch (HIWORD(wParam)) { + case BN_CLICKED: //Button controls + switch(IDControl) { + case IDCANCEL: + case IDCLOSE: + break; + + case ID_chkTimed: + m_opt_chkTimed = (BYTE)Button_GetCheck((HWND)lParam); + TfrmMain::chkTimedClick(); + break; + case ID_chkClientArea: + m_opt_chkClientArea = (BYTE)Button_GetCheck((HWND)lParam); + if(m_hTargetWindow) + edtSizeUpdate(m_hTargetWindow, m_opt_chkClientArea, GetParent((HWND)lParam), ID_edtSize); + break; + case ID_chkOpenAgain: + m_opt_chkOpenAgain = (BYTE)Button_GetCheck((HWND)lParam); + break; + case ID_chkEditor: + m_opt_chkEditor = (BYTE)Button_GetCheck((HWND)lParam); + break; + + case ID_btnAbout: + TfrmMain::btnAboutClick(); + break; + case ID_btnExplore: + TfrmMain::btnExploreClick(); + break; + case ID_btnDesc: + { + m_opt_btnDesc = (m_opt_btnDesc == 0); + HICON hIcon = IcoLib_GetIcon(m_opt_btnDesc ? ICO_PLUG_SSDESKON : ICO_PLUG_SSDESKOFF); + SendMessage((HWND)lParam, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); + } + break; + case ID_btnDeleteAfterSend: + { + m_opt_btnDeleteAfterSend = (m_opt_btnDeleteAfterSend == 0); + HICON hIcon = IcoLib_GetIcon(m_opt_btnDeleteAfterSend ? ICO_PLUG_SSDELON : ICO_PLUG_SSDELOFF); + SendMessage((HWND)lParam, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); + if(m_cSend) m_cSend->m_bDeleteAfterSend = m_opt_btnDeleteAfterSend; + } + break; + case ID_btnCapture: + TfrmMain::btnCaptureClick(); + break; + default: + break; + } + break; + case CBN_SELCHANGE: //ComboBox controls + switch(IDControl) { + //lParam = Handle to the control + case ID_cboxFormat: //not finish + m_opt_cboxFormat = (BYTE)ComboBox_GetItemData((HWND)lParam, ComboBox_GetCurSel((HWND)lParam)); + break; + case ID_cboxSendBy: + m_opt_cboxSendBy = (BYTE)ComboBox_GetItemData((HWND)lParam, ComboBox_GetCurSel((HWND)lParam)); + cboxSendByChange(); + break; + case ID_edtCaption: //cboxDesktopChange + m_opt_cboxDesktop = (BYTE)ComboBox_GetItemData((HWND)lParam, ComboBox_GetCurSel((HWND)lParam)); + m_hTargetWindow = 0; + if (m_opt_cboxDesktop > 0) { + edtSizeUpdate(m_Monitors[m_opt_cboxDesktop-1].rcMonitor, GetParent((HWND)lParam), ID_edtSize); + } + else { + edtSizeUpdate(m_VirtualScreen, GetParent((HWND)lParam), ID_edtSize); + } + break; + default: + break; + } + break; + case EN_CHANGE: //Edit controls + switch(IDControl) { + //lParam = Handle to the control + case ID_edtQuality: + m_opt_edtQuality = (BYTE)GetDlgItemInt(m_hWnd, ID_edtQuality, NULL, FALSE); + break; + case ID_edtTimed: + m_opt_edtTimed = (BYTE)GetDlgItemInt(m_hWnd, ID_edtTimed, NULL, FALSE); + break; + default: + break; + } + break; + default: + break; + } + return FALSE; +} + +//WM_CLOSE: +LRESULT TfrmMain::wmClose(WPARAM wParam, LPARAM lParam) { + DestroyWindow(m_hWnd); + return FALSE; +} + +//WM_TIMER: +LRESULT TfrmMain::wmTimer(WPARAM wParam, LPARAM lParam) { + if (wParam == ID_bvlTarget) { // Timer for Target selector + if (m_hCursor) { //imgTarget is activ + //LmouseButton = false + if (!GetLmouse()) { + TfrmMain::imgTargetMouseUp(); + return FALSE; + } + //Timer action if LmouseButton = true + m_hLastWin = m_hTargetWindow; + POINT point={0}; + GetCursorPos(&point); + HWND hCurrentWin = WindowFromPoint(point); + while (GetParent(hCurrentWin)) { + hCurrentWin = GetParent(hCurrentWin); + } + if (m_hLastWin != hCurrentWin) { + LPTSTR lpTitle = NULL; + if (m_hLastWin) { + DrawBorderInverted(m_hLastWin); + } + int Count = GetWindowTextLength(hCurrentWin)+1; + if(Count > 1){ + lpTitle = (LPTSTR)mir_alloc(Count*sizeof(TCHAR)); + GetWindowText(hCurrentWin, lpTitle, Count); + } + else { + //no WindowText present, use WindowClass + lpTitle = (LPTSTR)mir_alloc(MAX_PATH*sizeof(TCHAR)); + RealGetWindowClass(hCurrentWin, lpTitle, MAX_PATH); + } + SetDlgItemText(m_hwndTabPage, ID_edtCaption, lpTitle); + mir_free(lpTitle); + edtSizeUpdate(hCurrentWin, m_opt_chkClientArea, m_hwndTabPage, ID_edtSize); + DrawBorderInverted(hCurrentWin); + m_hTargetWindow = hCurrentWin; + } + return FALSE; + } + //imgTarget is not activ (check if cursor is over ID_bvlTarget control) + RECT rc; + POINT pt; + GetWindowRect(GetDlgItem(m_hwndTabPage, wParam),&rc); + GetCursorPos(&pt); + //check Mouse cursor + if(!PtInRect(&rc,pt)) { // mouse must be gone, trigger mouse leave + //PostMessage(m_hWnd,WM_MOUSELEAVE,wParam,lParam); + KillTimer(m_hWnd,wParam); + } + else if (GetLmouse() && !m_hCursor) { //mouse hover + LButton + TfrmMain::imgTargetMouseDown(); + } + } + if (wParam == ID_chkTimed) { // Timer for Screenshot + #ifdef _DEBUG + OutputDebugStringA("SS Bitmap Timer Start\r\n" ); + #endif + if(!m_bCapture) { //only start once + if (m_Screenshot) { + FIP->FI_Unload(m_Screenshot); + m_Screenshot = NULL; + } + m_bCapture = true; + switch (m_opt_tabCapture) { + case 0: + m_Screenshot = CaptureWindow(m_hTargetWindow, (BOOL)m_opt_chkClientArea); + break; + case 1: + m_Screenshot = CaptureMonitor((m_opt_cboxDesktop > 0) ? m_Monitors[m_opt_cboxDesktop-1].szDevice : NULL); + break; + default: + KillTimer(m_hWnd,wParam); + m_bCapture = false; + #ifdef _DEBUG + OutputDebugStringA("SS Bitmap Timer Stop (no tabCapture)\r\n" ); + #endif + return FALSE; + } + if (!m_Screenshot) m_bCapture = false; + } + if (m_Screenshot) { + KillTimer(m_hWnd,wParam); + m_bCapture = false; + #ifdef _DEBUG + OutputDebugStringA("SS Bitmap Timer Stop (CaptureDone)\r\n" ); + #endif + SendMessage(m_hWnd,UM_EVENT, (WPARAM)0, (LPARAM)EVT_CaptureDone); + } + } + return FALSE; +} + +//WM_NOTIFY: +LRESULT TfrmMain::wmNotify(WPARAM wParam, LPARAM lParam) { + switch(((LPNMHDR)lParam)->idFrom) { + case IDC_CAPTURETAB: //TabControl IDC_CAPTURETAB + switch (((LPNMHDR)lParam)->code) { + // HWND hwndFrom; = member is handle to the tab control + // UINT_PTR idFrom; = member is the child window identifier of the tab control. + // UINT code; = member is TCN_SELCHANGE + case TCN_SELCHANGING: + { + TAB_INFO itab; + ZeroMemory(&itab, sizeof(itab)); + itab.tcih.mask = TCIF_PARAM; + TabCtrl_GetItem(m_hwndTab,TabCtrl_GetCurSel(m_hwndTab),&itab); + ShowWindow(itab.hwndTabPage,SW_HIDE); + m_hwndTabPage = NULL; + } + break; + + case TCN_SELCHANGE: + { + TAB_INFO itab; + ZeroMemory(&itab, sizeof(itab)); + itab.tcih.mask = TCIF_PARAM; + m_opt_tabCapture = TabCtrl_GetCurSel(m_hwndTab); + TabCtrl_GetItem(m_hwndTab, m_opt_tabCapture, &itab); + ShowWindow(itab.hwndTabPage, SW_SHOW); + m_hwndTabPage = itab.hwndTabPage; + } + break; + default: + break; + } + break; + default: + break; + } + return FALSE; +} + +//UM_CLOSING: +LRESULT TfrmMain::UMClosing(WPARAM wParam, LPARAM lParam) { + HWND hWnd = (HWND)wParam; + switch (lParam) { + case IDD_UAboutForm: + btnAboutOnCloseWindow(hWnd); + break; + case IDD_UEditForm: + ; + break; + default: + break; + } + return FALSE; +} + +//UM_TAB1: +LRESULT TfrmMain::UMTab1(WPARAM wParam, LPARAM lParam) { + switch (wParam) { + case WM_MOUSEMOVE: + if (m_opt_tabCapture == 0) { + // Call timer, used to start cheesy TrackMouseEvent faker + SetTimer(m_hWnd,ID_bvlTarget,BUTTON_POLLDELAY,NULL); + } + break; + default: + break; + } + return FALSE; +} + +//UM_EVENT: +LRESULT TfrmMain::UMevent(WPARAM wParam, LPARAM lParam) { + //HWND hWnd = (HWND)wParam; + switch (lParam) { + case EVT_CaptureDone: + if (!m_Screenshot) { + TCHAR *err = TranslateT("Cant create a Screenshot"); + MessageBox(m_hWnd,err,ERROR_TITLE,MB_OK|MB_ICONWARNING); + Show(); + return FALSE; + } + if (m_opt_chkEditor) { + /* TfrmEdit *frmEdit=new TfrmEdit(this); + m_bFormEdit = true; + + frmEdit->mniClose->Enabled = !chkJustSaveIt->Checked; + frmEdit->mniCloseSend->Enabled = frmEdit->mniClose->Enabled; + frmEdit->OnClose = OnCloseEditWindow; + frmEdit->InitEditor(Screenshot); // Screenshot is copied to another in-memory bitmap inside this method + frmEdit->Show(); + delete Screenshot; // This way we can delete it after the method returns + Screenshot = NULL; + */ + return FALSE; + } + else { + FormClose(); + } + break; + case EVT_SendFileDone: + break; + case EVT_CheckOpenAgain: + if (m_opt_chkOpenAgain) { + if (m_Screenshot) { + FIP->FI_Unload(m_Screenshot); + m_Screenshot = NULL; + } + m_hTargetWindow = m_hLastWin = NULL; + Show(); + } + else { + // Saving Options and close + SaveOptions(); + Close(); + } + break; + default: + break; + } + return FALSE; +} + +//--------------------------------------------------------------------------- +// Standard konstruktor/destruktor +TfrmMain::TfrmMain() { + m_hWnd = NULL; + m_hContact = NULL; + m_hTargetWindow = NULL; + m_hCursor = NULL; + m_Screenshot = NULL; + m_pszFile = m_pszFileDesc = m_FDestFolder = NULL; + m_bFormAbout = m_bFormEdit = m_bDeleteAfterSend = m_bSelectingWindow = false; + m_cSend = NULL; + m_bOnExitSave = TRUE; + LoadOptions(); + m_bCapture = false; + m_himlTab = NULL; + m_Monitors = NULL; + m_MonitorCount = MonitorInfoEnum(m_Monitors, m_VirtualScreen); + +} + +TfrmMain::~TfrmMain() { + _HandleMapping.erase(m_hWnd); + mir_free(m_pszFile); + mir_free(m_FDestFolder); + mir_free(m_pszFileDesc); + mir_free(m_Monitors); + if (m_Screenshot) FIP->FI_Unload(m_Screenshot); + if (m_cSend) delete m_cSend; +} + +//--------------------------------------------------------------------------- +// Load / Saving options from miranda's database +void TfrmMain::LoadOptions(void) { + DWORD rgb = DBGetContactSettingDword(NULL, SZ_SENDSS, "AlphaColor", 16777215); + m_AlphaColor.rgbRed = GetRValue(rgb); + m_AlphaColor.rgbGreen = GetGValue(rgb); + m_AlphaColor.rgbBlue = GetBValue(rgb); + m_AlphaColor.rgbReserved = 0; + +// m_opt_chkEmulateClick = DBGetContactSettingByte(NULL, SZ_SENDSS, "AutoSend", 1); + m_opt_edtQuality = DBGetContactSettingByte(NULL, SZ_SENDSS, "JpegQuality", 75); + + m_opt_tabCapture = DBGetContactSettingByte(NULL, SZ_SENDSS, "Capture", 0); + m_opt_chkClientArea = DBGetContactSettingByte(NULL, SZ_SENDSS, "ClientArea", 0); + m_opt_cboxDesktop = DBGetContactSettingByte(NULL, SZ_SENDSS, "Desktop", 0); + + m_opt_chkTimed = DBGetContactSettingByte(NULL, SZ_SENDSS, "TimedCap", 0); + m_opt_edtTimed = DBGetContactSettingByte(NULL, SZ_SENDSS, "CapTime", 3); + m_opt_cboxFormat = DBGetContactSettingByte(NULL, SZ_SENDSS, "OutputFormat", 3); + m_opt_cboxSendBy = DBGetContactSettingByte(NULL, SZ_SENDSS, "SendBy", 0); + + m_opt_chkEditor = DBGetContactSettingByte(NULL, SZ_SENDSS, "Preview", 0); + m_opt_btnDesc = DBGetContactSettingByte(NULL, SZ_SENDSS, "AutoDescription", 1); + m_opt_btnDeleteAfterSend = DBGetContactSettingByte(NULL, SZ_SENDSS, "DelAfterSend", 1); + m_opt_chkOpenAgain = DBGetContactSettingByte(NULL, SZ_SENDSS, "OpenAgain", 0); +} + +void TfrmMain::SaveOptions(void) { + if(m_bOnExitSave) { + DBWriteContactSettingDword(NULL, SZ_SENDSS, "AlphaColor", + (DWORD)RGB(m_AlphaColor.rgbRed, m_AlphaColor.rgbGreen, m_AlphaColor.rgbBlue)); + +// DBWriteContactSettingByte(NULL, SZ_SENDSS, "AutoSend", m_opt_chkEmulateClick); + DBWriteContactSettingByte(NULL, SZ_SENDSS, "JpegQuality", m_opt_edtQuality); + + DBWriteContactSettingByte(NULL, SZ_SENDSS, "Capture", m_opt_tabCapture); + DBWriteContactSettingByte(NULL, SZ_SENDSS, "ClientArea", m_opt_chkClientArea); + DBWriteContactSettingByte(NULL, SZ_SENDSS, "Desktop", m_opt_cboxDesktop); + + DBWriteContactSettingByte(NULL, SZ_SENDSS, "TimedCap", m_opt_chkTimed); + DBWriteContactSettingByte(NULL, SZ_SENDSS, "CapTime", m_opt_edtTimed); + DBWriteContactSettingByte(NULL, SZ_SENDSS, "OutputFormat", m_opt_cboxFormat); + DBWriteContactSettingByte(NULL, SZ_SENDSS, "SendBy", m_opt_cboxSendBy); + + DBWriteContactSettingByte(NULL, SZ_SENDSS, "AutoDescription", m_opt_btnDesc); + DBWriteContactSettingByte(NULL, SZ_SENDSS, "DelAfterSend", m_opt_btnDeleteAfterSend); + DBWriteContactSettingByte(NULL, SZ_SENDSS, "OpenAgain", m_opt_chkOpenAgain); + DBWriteContactSettingByte(NULL, SZ_SENDSS, "Preview", m_opt_chkEditor); + } +} + +//--------------------------------------------------------------------------- +void TfrmMain::Init(LPTSTR DestFolder, HANDLE Contact) { + m_FDestFolder = mir_tstrdup(DestFolder); + m_hContact = Contact; + if(!m_hContact) m_opt_cboxSendBy = SS_JUSTSAVE; + + // create window + m_hWnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_UMainForm),0, (DLGPROC)DlgTfrmMain,(LPARAM)this); + //register object + _HandleMapping.insert(CHandleMapping::value_type(m_hWnd, this)); + + //check Contact + if(m_cSend) m_cSend->SetContact(Contact); +} + +//--------------------------------------------------------------------------- +void TfrmMain::btnCaptureClick() { + m_bFormEdit = false; //until UEditForm is includet + + if (m_opt_tabCapture == 0 && m_hTargetWindow == 0) { + TCHAR *err = TranslateT("Select a target window."); + MessageBox(m_hWnd,err,ERROR_TITLE,MB_OK|MB_ICONWARNING); + return; + } + TfrmMain::Hide(); + + if (!m_hTargetWindow) m_hTargetWindow = GetDesktopWindow(); + + if (m_opt_chkTimed) { + SetTimer(m_hWnd, ID_chkTimed, m_opt_edtTimed ? m_opt_edtTimed*1000 : 500, NULL); + } + else if (m_opt_tabCapture == 1){ + //desktop need always time to update from TfrmMain::Hide() + SetTimer(m_hWnd, ID_chkTimed, 500, NULL); + } + else { + m_Screenshot = CaptureWindow(m_hTargetWindow, (BOOL)(m_opt_chkClientArea)); + SendMessage(m_hWnd,UM_EVENT, (WPARAM)0, (LPARAM)EVT_CaptureDone); + } +} + +//--------------------------------------------------------------------------- +void TfrmMain::chkTimedClick() { + Button_Enable(GetDlgItem(m_hWnd, ID_edtTimedLabel), (BOOL)m_opt_chkTimed); + Button_Enable(GetDlgItem(m_hWnd, ID_edtTimed), (BOOL)m_opt_chkTimed); + Button_Enable(GetDlgItem(m_hWnd, ID_upTimed), (BOOL)m_opt_chkTimed); +} + +//--------------------------------------------------------------------------- +void TfrmMain::imgTargetMouseDown() { + //if (Button != mbLeft) return; + m_hCursor = CopyCursor(GetCursor()); //backup cursor + //SetSystemCursor need a copy coz it destroy the handle + SetSystemCursor(CopyCursor(IcoLib_GetIcon(ICO_PLUG_SSTARGET)),OCR_NORMAL); + m_bSelectingWindow = true; + m_hTargetWindow = NULL; + Hide(); + SetCapture(m_hWnd); +} + +//--------------------------------------------------------------------------- +void TfrmMain::imgTargetMouseUp() { + //if (Button == mbLeft && m_bSelectingWindow && TimerCheckFocus->Enabled) + if (m_bSelectingWindow && m_hCursor) { + Show(); + ReleaseCapture(); + SetSystemCursor(m_hCursor, OCR_NORMAL); + m_hCursor = NULL; + if (m_hTargetWindow){ + DrawBorderInverted(m_hTargetWindow); + } + m_bSelectingWindow = false; + } +} + +//--------------------------------------------------------------------------- +void TfrmMain::cboxSendByChange() { + BOOL bState; + HICON hIcon; + BYTE itemFlag = SS_DLG_DESCRIPTION; //SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND | + if (m_cSend && !m_cSend->m_bFreeOnExit) { + delete m_cSend; + m_cSend = NULL; + } + switch(m_opt_cboxSendBy) { + case SS_FILESEND: //"File Transfer" + m_cSend = new CSendFile(m_hWnd, m_hContact, false); + break; + case SS_EMAIL: //"E-mail" + m_cSend = new CSendEmail(m_hWnd, m_hContact, false); + break; + case SS_HTTPSERVER: //"HTTP Server" + m_cSend = new CSendHTTPServer(m_hWnd, m_hContact, false); + break; + case SS_FTPFILE: //"FTP File" + m_cSend = new CSendFTPFile(m_hWnd, m_hContact, false); + break; + case SS_IMAGESHACK: //"ImageShack" + m_cSend = new CSendImageShack(m_hWnd, m_hContact, false); + break; + default: //SS_JUSTSAVE - "Just save it " + m_cSend = NULL; + break; + } + if(m_cSend){ + itemFlag = m_cSend->GetEnableItem(); + m_cSend->m_bDeleteAfterSend = m_opt_btnDeleteAfterSend; + } + bState = ((itemFlag & SS_DLG_DELETEAFTERSSEND) == SS_DLG_DELETEAFTERSSEND); + hIcon = IcoLib_GetIcon(m_opt_btnDeleteAfterSend ? ICO_PLUG_SSDELON : ICO_PLUG_SSDELOFF); + SendMessage(GetDlgItem(m_hWnd, ID_btnDeleteAfterSend), BM_SETIMAGE, IMAGE_ICON, (LPARAM)(bState ? hIcon : 0)); + Button_Enable(GetDlgItem(m_hWnd, ID_btnDeleteAfterSend), bState); + + bState = ((itemFlag & SS_DLG_DESCRIPTION) == SS_DLG_DESCRIPTION); + hIcon = IcoLib_GetIcon(m_opt_btnDesc ? ICO_PLUG_SSDESKON : ICO_PLUG_SSDESKOFF); + SendMessage(GetDlgItem(m_hWnd, ID_btnDesc), BM_SETIMAGE, IMAGE_ICON, (LPARAM)(bState ? hIcon : 0)); + Button_Enable(GetDlgItem(m_hWnd, ID_btnDesc), bState); +} + +//--------------------------------------------------------------------------- +void TfrmMain::btnAboutClick() { + if (m_bFormAbout) return; + + TfrmAbout *frmAbout=new TfrmAbout(m_hWnd); + frmAbout->Show(); + m_bFormAbout = true; +} + +// Edit window call this event before it closes +void TfrmMain::btnAboutOnCloseWindow(HWND hWnd) { + m_bFormAbout = false; +} + +//--------------------------------------------------------------------------- +void TfrmMain::btnExploreClick() { + if (m_FDestFolder) + ShellExecute(NULL, _T("explore"), m_FDestFolder, NULL, NULL, SW_SHOW); +} + +//--------------------------------------------------------------------------- +void TfrmMain::edtSizeUpdate(HWND hWnd, BOOL ClientArea, HWND hTarget, UINT Ctrl) { + // get window dimensions + RECT rect = {0}; + RECT cliRect = {0}; + TCHAR B[33], H[16]; + GetWindowRect(hWnd, &rect); + if (ClientArea) { + POINT pt = {0}; + GetClientRect(hWnd, &cliRect); + pt.x = cliRect.left; + pt.y = cliRect.top; + ClientToScreen(hWnd, &pt); + pt.x = pt.x - rect.left; //offset x for client area + pt.y = pt.y - rect.top; //offset y for client area + rect = cliRect; + } +// _itot_s(rect.right - rect.left, B, 33, 10); + _itot(rect.right - rect.left, B, 10); +// _itot_s(rect.bottom - rect.top, H, 16, 10); + _itot(rect.bottom - rect.top, H, 10); + mir_tcsncat(B, _T("x"), 33); + mir_tcsncat(B, H, 33); + SetDlgItemText(hTarget, Ctrl, B); +} + +void TfrmMain::edtSizeUpdate(RECT rect, HWND hTarget, UINT Ctrl) { + TCHAR B[33], H[16]; +// _itot_s(ABS(rect.right - rect.left), B, 33, 10); + _itot(ABS(rect.right - rect.left), B, 10); +// _itot_s(ABS(rect.bottom - rect.top), H, 16, 10); + _itot(ABS(rect.bottom - rect.top), H, 10); + mir_tcsncat(B, _T("x"), 33); + mir_tcsncat(B, H, 33); + SetDlgItemText(hTarget, Ctrl, B); +} + +//--------------------------------------------------------------------------- +INT_PTR TfrmMain::SaveScreenshot(FIBITMAP* dib) { + //generate File name + FREE_IMAGE_FORMAT fif = FIF_UNKNOWN; + LPTSTR ret = NULL; + LPTSTR path = NULL; + LPTSTR pszFilename = NULL; + LPTSTR pszFileDesc = NULL; + if (!dib) return 1; //error + + //Generate FileName + mir_tcsadd(path, m_FDestFolder); + if (path[_tcslen(path)-1] != _T('\\')) mir_tcsadd(path, _T("\\")); + mir_tcsadd(path, _T("shot%.5ld")); + int FileNumber=DBGetContactSettingDword(NULL, SZ_SENDSS, "FileNumber", 0) + 1; + // '00000'-'%.5ld'=0 (add more or less len if differ from 5 + size_t len = (_tcslen(path)+0+1); + pszFilename = (LPTSTR)mir_alloc(sizeof(TCHAR)*(len)); + mir_sntprintf(pszFilename, len, path, FileNumber); + mir_free(path); + + //Generate a description according to the screenshot + TCHAR winText[1024]; + mir_tcsadd(pszFileDesc, _T("Screenshot ")); + if (m_opt_tabCapture == 0 && m_opt_chkClientArea) { + mir_tcsadd(pszFileDesc, _T("for Client area ")); + } + mir_tcsadd(pszFileDesc, _T("of \"")); + GetDlgItemText(m_hwndTabPage, ID_edtCaption, winText, 1024); + mir_tcsadd(pszFileDesc, winText); + mir_tcsadd(pszFileDesc, _T("\" Window")); + + // convert to 32Bits (make shure it is 32bit) + FIBITMAP *dib_new = FIP->FI_ConvertTo32Bits(dib); + //RGBQUAD appColor = { 245, 0, 254, 0 }; //bgr0 schwarz + //FIP->FI_SetBackgroundColor(dib_new, &appColor); + FIP->FI_SetTransparent(dib_new,TRUE); + + // Investigates the color type of the bitmap (test for RGB or CMYK colour space) + switch (FREE_IMAGE_COLOR_TYPE ColTye=FIP->FI_GetColorType(dib_new)) { + case FIC_MINISBLACK: + //Monochrome bitmap (1-bit) : first palette entry is black. + //Palletised bitmap (4 or 8-bit) and single channel non standard bitmap: the bitmap has a greyscale palette + case FIC_MINISWHITE: + //Monochrome bitmap (1-bit) : first palette entry is white. + //Palletised bitmap (4 or 8-bit) : the bitmap has an inverted greyscale palette + case FIC_PALETTE: + //Palettized bitmap (1, 4 or 8 bit) + case FIC_RGB: + //High-color bitmap (16, 24 or 32 bit), RGB16 or RGBF + case FIC_RGBALPHA: + //High-color bitmap with an alpha channel (32 bit bitmap, RGBA16 or RGBAF) + case FIC_CMYK: + //CMYK bitmap (32 bit only) + default: + break; + } + + + if ((FIP->FI_GetICCProfile(dib_new)->flags & FIICC_COLOR_IS_CMYK) == FIICC_COLOR_IS_CMYK) { + // we are in CMYK colour space + bool bDummy = false; + } + else { + // we are in RGB colour space + bool bDummy = true; + } + + FIBITMAP *dib32 = NULL; + FIBITMAP *dib24 = NULL; + HWND hwndCombo = GetDlgItem(m_hWnd, ID_cboxFormat); + switch (ComboBox_GetItemData(hwndCombo, ComboBox_GetCurSel(hwndCombo))) { + case 0: //PNG + ret = SaveImage(fif,dib_new, pszFilename, _T("png")); + break; + + case 1: //JPG + /* + #define JPEG_QUALITYSUPERB 0x80 // save with superb quality (100:1) + #define JPEG_QUALITYGOOD 0x0100 // save with good quality (75:1) + #define JPEG_QUALITYNORMAL 0x0200 // save with normal quality (50:1) + #define JPEG_QUALITYAVERAGE 0x0400 // save with average quality (25:1) + #define JPEG_QUALITYBAD 0x0800 // save with bad quality (10:1) + #define JPEG_PROGRESSIVE 0x2000 // save as a progressive-JPEG (use | to combine with other save flags) + */ + dib32 = FIP->FI_Composite(dib_new,FALSE,&m_AlphaColor,NULL); + dib24 = FIP->FI_ConvertTo24Bits(dib32); + FIP->FI_Unload(dib32); dib32 = NULL; + ret = SaveImage(fif,dib24, pszFilename, _T("jpg")); + FIP->FI_Unload(dib24); dib24 = NULL; + break; + + case 2: //BMP + // ret = SaveImage(FIF_BMP,dib_new, pszFilename, _T("bmp")); //32bit alpha BMP + dib32 = FIP->FI_Composite(dib_new,FALSE,&m_AlphaColor,NULL); + dib24 = FIP->FI_ConvertTo24Bits(dib32); + FIP->FI_Unload(dib32); dib32 = NULL; + ret = SaveImage(FIF_BMP,dib24, pszFilename, _T("bmp")); + FIP->FI_Unload(dib24); dib24 = NULL; + break; + + case 3: //TIFF (miranda freeimage interface do not support save tiff, we udse GDI+) + { + LPTSTR pszFile = NULL; + mir_tcsadd(pszFile, pszFilename); + mir_tcsadd(pszFile, _T(".tif")); + + dib32 = FIP->FI_Composite(dib_new,FALSE,&m_AlphaColor,NULL); + dib24 = FIP->FI_ConvertTo24Bits(dib32); + FIP->FI_Unload(dib32); dib32 = NULL; + + HBITMAP hBmp = FIP->FI_CreateHBITMAPFromDIB(dib24); + FIP->FI_Unload(dib24); dib24 = NULL; + ret = SaveTIF(hBmp, pszFile) ? NULL : pszFile; + DeleteObject(hBmp); + } + break; + + case 4: //GIF + { + //dib24 = FIP->FI_ConvertTo8Bits(dib_new); + //ret = SaveImage(FIF_GIF,dib24, pszFilename, _T("gif")); + //FIP->FI_Unload(dib24); dib24 = NULL; + LPTSTR pszFile = NULL; + mir_tcsadd(pszFile, pszFilename); + mir_tcsadd(pszFile, _T(".gif")); + HBITMAP hBmp = FIP->FI_CreateHBITMAPFromDIB(dib_new); + SaveGIF(hBmp, pszFile); + ret = pszFile; + DeleteObject(hBmp); + } + break; + + default: + break; + } +/* //load PNG and save file in user format (if differ) + //this get better result for transparent aereas + //LPTSTR pszFormat = (LPTSTR)ComboBox_GetItemData(hwndCombo, ComboBox_GetCurSel(hwndCombo)); + TCHAR pszFormat[6]; + ComboBox_GetText(hwndCombo, pszFormat, 6); + if(ret && (_tcsicmp (pszFormat,_T("png")) != 0)) { + #if defined(_UNICODE) + fif = FIP->FI_GetFIFFromFilenameU(ret); + dib_new = FIP->FI_LoadU(fif, ret,0); + #else + fif = FIP->FI_GetFIFFromFilenameU(ret); + dib_new = FIP->FI_Load(fif, ret,0); + #endif + + if(dib_new) { + DeleteFile(ret); + mir_freeAndNil(ret); + FIBITMAP *dib_save = FIP->FI_ConvertTo24Bits(dib_new); + ret = SaveImage(FIF_UNKNOWN,dib_save, pszFilename, pszFormat); + FIP->FI_Unload(dib_new); dib_new = NULL; + FIP->FI_Unload(dib_save); dib_save = NULL; + } + }*/ + FIP->FI_Unload(dib_new); dib_new = NULL; + mir_freeAndNil(pszFilename); + + if (ret) { + DBWriteContactSettingDword(NULL, SZ_SENDSS, "FileNumber", (DWORD)FileNumber); + mir_freeAndNil(m_pszFile); + mir_freeAndNil(m_pszFileDesc); + m_pszFile = ret; + if (IsWindowEnabled(GetDlgItem(m_hWnd, ID_btnDesc)) && m_opt_btnDesc) { + m_pszFileDesc = pszFileDesc; + } + else { + mir_tcsadd(m_pszFileDesc, _T("")); + } + + if(m_cSend) { + mir_freeAndNil(m_cSend->m_pszFile); + mir_freeAndNil(m_cSend->m_pszFileDesc); + m_cSend->m_pszFile = mir_tstrdup(m_pszFile); + m_cSend->m_pszFileDesc = mir_tstrdup(m_pszFileDesc); + } + return 0; //OK + } + mir_freeAndNil(ret); + mir_freeAndNil(pszFileDesc); + return 1; //error +} + +//--------------------------------------------------------------------------- +void TfrmMain::FormClose() { + + // Saving the screenshot + if (SaveScreenshot(m_Screenshot)) { + Show(); // Error from SaveScreenshot + return; + } + + if (m_cSend && m_pszFile && m_hContact && !m_bFormEdit) { + m_cSend->Send(); + if (m_cSend->m_bFreeOnExit) cboxSendByChange(); +// Not finish delete this if events from m_opt_cboxSendBy implementet + SendMessage(m_hWnd,UM_EVENT, (WPARAM)0, (LPARAM)EVT_CheckOpenAgain); + } + else { + SendMessage(m_hWnd,UM_EVENT, (WPARAM)0, (LPARAM)EVT_CheckOpenAgain); + } +} + +//--------------------------------------------------------------------------- +/*/ Edit window call this event before it closes +void TfrmMain::OnCloseEditWindow(TObject *Sender, TCloseAction &Action) { + TfrmEdit *form=dynamic_cast(Sender); + form->Hide(); + + // delete the form automatically,after this event returns + Action = caFree; + + // This will saves settings, free resources, ... + form->CallBeforeClose(Action); + + // User selected "Capture" on action menu of edit window + if (form->ModalResult == mrCancel) { + this->Show(); + } else { + Screenshot = form->Screen; + bFormEdit = form->DontSend; + this->Close(); + } +}*/ + +//--------------------------------------------------------------------------- diff --git a/plugins/SendScreenshotPlus/src/UMainForm.h b/plugins/SendScreenshotPlus/src/UMainForm.h new file mode 100644 index 0000000000..a7fdcdc643 --- /dev/null +++ b/plugins/SendScreenshotPlus/src/UMainForm.h @@ -0,0 +1,157 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* +Copyright 2000-2009 Miranda ICQ/IM project, + +This file is part of Send Screenshot Plus, a Miranda IM plugin. +Copyright (c) 2010 Ing.U.Horn + +Parts of this file based on original sorce code +(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/UMainForm.h $ +Revision : $Revision: 22 $ +Last change on : $Date: 2010-05-02 21:25:02 +0400 (Р’СЃ, 02 май 2010) $ +Last change by : $Author: ing.u.horn $ + +*/ + +#ifndef UMainFormH +#define UMainFormH +//--------------------------------------------------------------------------- +#include "global.h" +#include "Utils.h" +#include "CSend.h" +#include "CSendFile.h" +#include "CSendImageShack.h" +#include "CSendHTTPServer.h" +#include "CSendFTPFile.h" +#include "CSendEmail.h" + +#define SS_JUSTSAVE 0 +#define SS_FILESEND 1 +#define SS_EMAIL 2 +#define SS_HTTPSERVER 3 +#define SS_FTPFILE 4 +#define SS_IMAGESHACK 5 + +// Used for our own cheap TrackMouseEvent +#define BUTTON_POLLDELAY 50 + +// User Events +#define EVT_CaptureDone 1 +#define EVT_SendFileDone 2 +#define EVT_CheckOpenAgain 3 + +extern FI_INTERFACE *FIP; + +typedef struct MyTabData { + TCITEMHEADER tcih; + HWND hwndMain; //main window + HWND hwndTab; //tab control + HWND hwndTabPage; //current child dialog box +}TAB_INFO; + +//--------------------------------------------------------------------------- +class TfrmMain{ + + public: + // Deklaration Standardkonstruktor/Standarddestructor + TfrmMain(); + ~TfrmMain(); + + BYTE m_opt_tabCapture; //capure tab page + BYTE m_opt_btnDesc; //TCheckBox *chkDesc; + BYTE m_opt_cboxDesktop; //TRadioButton *rbtnDesktop; + BYTE m_opt_chkEditor; //TCheckBox *chkEditor; + BYTE m_opt_chkTimed; //TCheckBox *chkTimed; + BYTE m_opt_cboxSendBy; //TComboBox *cboxSendBy; + bool m_bOnExitSave; + + void Show(){ShowWindow(m_hWnd,SW_SHOW);} + void Hide(){ShowWindow(m_hWnd,SW_HIDE);} + void Close(){SendMessage(m_hWnd,WM_CLOSE,0,0);} + void Init(LPTSTR DestFolder, HANDLE Contact); + void btnCaptureClick(); + void cboxSendByChange(); + + private: + HWND m_hWnd; + HANDLE m_hContact; + bool m_bSelectingWindow, m_bDeleteAfterSend; + bool m_bFormAbout, m_bFormEdit; + HWND m_hTargetWindow, m_hLastWin; + LPTSTR m_FDestFolder; + LPTSTR m_pszFile; + LPTSTR m_pszFileDesc; + FIBITMAP* m_Screenshot; //Graphics::TBitmap *Screenshot; + RGBQUAD m_AlphaColor; // + HCURSOR m_hCursor; + CSend* m_cSend; + + void chkTimedClick(); + void imgTargetMouseDown(); + void imgTargetMouseUp(); + void btnAboutClick(); + void btnAboutOnCloseWindow(HWND hWnd); + void btnExploreClick(); + void LoadOptions(void); + void SaveOptions(void); + INT_PTR SaveScreenshot(FIBITMAP* dib); + void FormClose(); + static void edtSizeUpdate(HWND hWnd, BOOL ClientArea, HWND hTarget, UINT Ctrl); + static void edtSizeUpdate(RECT rect, HWND hTarget, UINT Ctrl); + + protected: + size_t m_MonitorCount; + MONITORINFOEX* m_Monitors; + RECT m_VirtualScreen; + + BYTE m_opt_chkOpenAgain; //TCheckBox *chkOpenAgain; + BYTE m_opt_chkClientArea; //TCheckBox *chkClientArea; + BYTE m_opt_edtQuality; //TLabeledEdit *edtQuality; + BYTE m_opt_btnDeleteAfterSend; //TCheckBox *chkDeleteAfterSend; + BYTE m_opt_cboxFormat; //TComboBox *cboxFormat; + BYTE m_opt_edtTimed; //TLabeledEdit *edtTimed; + bool m_bCapture; //is capture activ + + typedef std::map CHandleMapping; + static CHandleMapping _HandleMapping; + static LRESULT CALLBACK DlgTfrmMain(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); + + LRESULT wmInitdialog(WPARAM wParam, LPARAM lParam); + LRESULT wmCommand(WPARAM wParam, LPARAM lParam); + LRESULT wmClose(WPARAM wParam, LPARAM lParam); + LRESULT wmNotify(WPARAM wParam, LPARAM lParam); + LRESULT wmTimer(WPARAM wParam, LPARAM lParam); + + LRESULT UMevent(WPARAM wParam, LPARAM lParam); + LRESULT UMClosing(WPARAM wParam, LPARAM lParam); + LRESULT UMTab1(WPARAM wParam, LPARAM lParam); + + HWND m_hwndTab; //TabControl handle + HWND m_hwndTabPage; //TabControl activ page handle + HIMAGELIST m_himlTab; //TabControl imagelist + static INT_PTR CALLBACK DlgProc_CaptureWindow (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); + static INT_PTR CALLBACK DlgProc_CaptureDesktop(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); +// LRESULT CALLBACK DlgProc_UseLastFile (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); + +}; + +//--------------------------------------------------------------------------- + +#endif diff --git a/plugins/SendScreenshotPlus/src/Utils.cpp b/plugins/SendScreenshotPlus/src/Utils.cpp new file mode 100644 index 0000000000..f1b7251fd7 --- /dev/null +++ b/plugins/SendScreenshotPlus/src/Utils.cpp @@ -0,0 +1,579 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* +Copyright 2000-2009 Miranda ICQ/IM project, + +This file is part of Send Screenshot Plus, a Miranda IM plugin. +Copyright (c) 2010 Ing.U.Horn + +Parts of this file based on original sorce code +(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/Utils.cpp $ +Revision : $Revision: 22 $ +Last change on : $Date: 2010-05-02 21:25:02 +0400 (Р’СЃ, 02 май 2010) $ +Last change by : $Author: ing.u.horn $ + +*/ + +#include "Utils.h" + +//--------------------------------------------------------------------------- +extern HINSTANCE hInst; + +//--------------------------------------------------------------------------- +//Workaround for MS bug ComboBox_SelectItemData +int ComboBox_SelectItemData(HWND hwndCtl, int indexStart, LPARAM data) { + int i = 0; + for ( i ; i < ComboBox_GetCount(hwndCtl); i++) { + if(data == ComboBox_GetItemData(hwndCtl, i)) { + ComboBox_SetCurSel (hwndCtl,i); + return i; + } + } + return CB_ERR; +} + +//--------------------------------------------------------------------------- +// MonitorInfoEnum +size_t MonitorInfoEnum(MONITORINFOEX* & myMonitors, RECT & virtualScreen) { + MONITORS tmp = {0,0}; + if (EnumDisplayMonitors(NULL, NULL, MonitorInfoEnumProc, (LPARAM)&tmp)){ + myMonitors = tmp.info; + memset(&virtualScreen, 0, sizeof(virtualScreen)); + for (size_t i = 0; i < tmp.count; ++i) { + UnionRect(&virtualScreen, &virtualScreen, &tmp.info[i].rcMonitor); + } + return tmp.count; + } + else { + if (tmp.info) mir_free(tmp.info); + } + return 0; +} + +// MonitorInfoEnumProc - CALLBACK for MonitorInfoEnum +BOOL CALLBACK MonitorInfoEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) { + MONITORS* monitors = (MONITORS*)dwData; + monitors->count++; + monitors->info = (MONITORINFOEX*)mir_realloc(monitors->info, sizeof(MONITORINFOEX)*monitors->count); + monitors->info[monitors->count-1].cbSize = sizeof(MONITORINFOEX); + if(!GetMonitorInfo(hMonitor, (LPMONITORINFO)(monitors->info + monitors->count-1))) { + return FALSE; // stop enumeration if error + } + return TRUE; +} + +//--------------------------------------------------------------------------- +// capture window as FIBITMAP - caller must FIP->FI_Unload(dib) +FIBITMAP* CaptureWindow (HWND hCapture, BOOL ClientArea) { + FIBITMAP *dib = NULL; + HWND hForegroundWin = NULL; + HDC hScrDC; // screen DC + RECT rect= {0}; // screen RECT + SIZE size; // DIB width and height = window resolution + + if (!hCapture || !IsWindow(hCapture)) return 0; + hForegroundWin = GetForegroundWindow(); //Saving foreground window + BringWindowToTop(hCapture); // This window bring the target window to the top of all others + SetForegroundWindow(hCapture); // Make sure the target window is the foreground one + // redraw window to prevent runtime artefact in picture + UpdateWindow(hCapture); + + hScrDC = GetWindowDC(hCapture); + + // get window resolution + GetWindowRect(hCapture, &rect); + size.cx = ABS(rect.right - rect.left); + size.cy = ABS(rect.bottom - rect.top); + + //capture window and get FIBITMAP + dib = CaptureScreen(hScrDC, size, hCapture); + + if(ClientArea) { + RECT rectCA = {0}; + POINT pt = {0}; + GetClientRect (hCapture, &rectCA); + ClientToScreen(hCapture, &pt); + //crop the window to ClientArea + FIBITMAP* dibClient = FIP->FI_Copy(dib, + pt.x - rect.left, + pt.y - rect.top, + pt.x - rect.left + rectCA.right -1, + pt.y - rect.top + rectCA.bottom -1); + FIP->FI_Unload(dib); + dib = dibClient; + } + + ReleaseDC(NULL, hScrDC); + + // Restoring foreground window + if (hForegroundWin) { + SetForegroundWindow(hForegroundWin); + } + + return dib; +} + +FIBITMAP* CaptureMonitor (LPTSTR szDevice) { + SIZE size; + HDC hScrDC; + FIBITMAP *dib = NULL; + // get screen resolution + if(!szDevice) { + hScrDC = GetDC(NULL); /*Get full virtualscreen*/ + size.cx = GetSystemMetrics(SM_CXVIRTUALSCREEN); + size.cy = GetSystemMetrics(SM_CYVIRTUALSCREEN); + } + else { + hScrDC = CreateDC(szDevice, NULL, NULL, NULL); + size.cx = GetDeviceCaps(hScrDC, HORZRES); + size.cy = GetDeviceCaps(hScrDC, VERTRES); + } + dib = CaptureScreen (hScrDC, size); + ReleaseDC(NULL, hScrDC); + return dib; +} + +FIBITMAP* CaptureScreen (HDC hDC, SIZE size, HWND hCapture) { +//HDC GetDC (NULL) entire desktp +//HDC GetDC (HWND hWnd) client area of the specified window. +//HDC GetWindowDC (HWND hWnd) entire window. + FIBITMAP *dib = NULL; + HBITMAP hBitmap; // handles to device-dependent bitmaps + HDC hScrDC, hMemDC; // screen DC and memory DC + + // create a DC for the screen and create + // a memory DC compatible to screen DC + hScrDC = hDC ? hDC : GetDC(NULL/*Get full screen*/); + hMemDC = CreateCompatibleDC(hScrDC); + // create a bitmap compatible with the screen DC + hBitmap = CreateCompatibleBitmap(hScrDC, size.cx, size.cy); + + // select new bitmap into memory DC + HBITMAP hOld = (HBITMAP) SelectObject(hMemDC, hBitmap); + + if(hCapture) { + PrintWindow(hCapture, hMemDC, 0/*PW_CLIENTONLY is buggy*/); + } + else { + // bitblt screen DC to memory DC + BitBlt(hMemDC, 0, 0, size.cx, size.cy, hScrDC, 0, 0, CAPTUREBLT|SRCCOPY); + } + + dib = FIP->FI_CreateDIBFromHBITMAP(hBitmap); + + //alpha channel from window is always wrong, + //coz GDI do not draw all in alpha mode. + //we have to create our own new alpha channel. + bool bFixAlpha = true; + bool bInvert = false; + + // Create monochrome (1 bit) B+W mask bitmap. + HBITMAP hMask = CreateBitmap(size.cx,size.cy, 1, 1, NULL); + HDC hMaskDC = CreateCompatibleDC(0); + SelectBitmap(hMaskDC, hMask); + + //Create a SolidBrush object for non transparent area + HBRUSH hBr = CreateSolidBrush(RGB(255,255,255)); + + HRGN hrgn = NULL; + int regionType; + if(hCapture) { + hrgn = CreateRectRgn(0,0,0,0); + regionType = GetWindowRgn(hCapture, hrgn); + if (regionType != ERROR) { + // not layerd - fill the window region + FillRgn(hMaskDC, hrgn, hBr); + } + else { //layerd window (WS_EX_LAYERED) + BYTE bAlpha= 0; + COLORREF crKey=0; //0x00bbggrr + DWORD dwFlags=0; + if(GetLayeredWindowAttributes(hCapture,&crKey,&bAlpha,&dwFlags)) { + //per window transparency (like fading in a whole window). + if((dwFlags & LWA_ALPHA) == LWA_ALPHA) { + //Use bAlpha to determine the opacity of the layered window. + bFixAlpha = false; + } + if((dwFlags & LWA_COLORKEY) == LWA_COLORKEY) { + //Use crKey as the transparency color. + SetBkColor(hMemDC, crKey); + BitBlt(hMaskDC, 0, 0, size.cx, size.cy, hMemDC, 0, 0, SRCCOPY); + bInvert = true; + bFixAlpha = true; + } + } + else { + //per-pixel transparency (won't use the WM_PAINT ) + bFixAlpha = false; + } + } + } + else { //fill the desktop region + hrgn = CreateRectRgn(0,0,size.cx,size.cy); + FillRgn(hMaskDC, hrgn, hBr); + } + + if(bFixAlpha) { + FIBITMAP* dibMask = FIP->FI_CreateDIBFromHBITMAP(hMask); + if(bInvert) FIP->FI_Invert(dibMask); + FIBITMAP* dib8 = FIP->FI_ConvertTo8Bits(dibMask); + + //copy the dib8 alpha mask to dib32 main bitmap + FIP->FI_SetChannel(dib,dib8,FICC_ALPHA); + FIP->FI_Unload(dibMask); + FIP->FI_Unload(dib8); + } + + //clean up + DeleteObject(hBr); + if(hrgn) DeleteObject(hrgn); + DeleteDC(hMaskDC); + DeleteObject(hMask); + SelectObject(hMemDC, hOld); + DeleteDC(hMemDC); + if(!hDC) ReleaseDC(NULL, hScrDC); + DeleteObject(hBitmap); + + #ifdef _DEBUG + switch (FIP->FI_GetImageType(dib)){ + case FIT_UNKNOWN: + OutputDebugStringA("FIBITMAP Typ: FIT_UNKNOWN\r\n" ); + break; + case FIT_BITMAP: + OutputDebugStringA("FIBITMAP Typ: FIT_BITMAP\r\n" ); + break; + case FIT_UINT16: + OutputDebugStringA("FIBITMAP Typ: FIT_UINT16\r\n" ); + break; + case FIT_INT16: + OutputDebugStringA("FIBITMAP Typ: FIT_INT16\r\n" ); + break; + case FIT_UINT32: + OutputDebugStringA("FIBITMAP Typ: FIT_UINT32\r\n" ); + break; + case FIT_INT32: + OutputDebugStringA("FIBITMAP Typ: FIT_INT32\r\n" ); + break; + case FIT_FLOAT: + OutputDebugStringA("FIBITMAP Typ: FIT_FLOAT\r\n" ); + break; + case FIT_DOUBLE: + OutputDebugStringA("FIBITMAP Typ: FIT_DOUBLE\r\n" ); + break; + case FIT_COMPLEX: + OutputDebugStringA("FIBITMAP Typ: FIT_COMPLEX\r\n" ); + break; + case FIT_RGB16: + OutputDebugStringA("FIBITMAP Typ: FIT_RGB16\r\n" ); + break; + case FIT_RGBA16: + OutputDebugStringA("FIBITMAP Typ: FIT_RGBA16\r\n" ); + break; + case FIT_RGBF: + OutputDebugStringA("FIBITMAP Typ: FIT_RGBF\r\n" ); + break; + case FIT_RGBAF: + OutputDebugStringA("FIBITMAP Typ: FIT_RGBAF\r\n" ); + break; + default: + OutputDebugStringA("FIBITMAP Typ: nicht feststellbar\r\n" ); + break; + } + BOOL inf = FIP->FI_IsTransparent(dib); + OutputDebugStringA(inf ? "FIBITMAP Transparent: true\r\n" : "FIBITMAP Transparent: fase\r\n"); + #endif + + return dib; +} + +FIBITMAP* CaptureDesktop/*emulate print screen*/() { + FIBITMAP *dib = NULL; + HBITMAP hBitmap; // handles to device-dependent bitmaps + BOOL bBitmap = false; + int i = 0; + keybd_event(VK_SNAPSHOT, 0x45, KEYEVENTF_EXTENDEDKEY, 0); + keybd_event(VK_SNAPSHOT, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); + do {//Clipboard need time to get bitmap from keybd_event, + i++; //we use a counter to get this time. + bBitmap = IsClipboardFormatAvailable(CF_BITMAP); + if(i == 500) return (FIBITMAP*)0; //emergency exit if something go wrong + } while (!bBitmap); + #ifdef _DEBUG + char mess[120] = {0}; + LPSTR pszMess = mess; + mir_snprintf(pszMess,120,"SS Bitmap counter: %i\r\n",i); + OutputDebugStringA( pszMess ); + #endif + //get clipboard data + OpenClipboard(NULL); + hBitmap = (HBITMAP)GetClipboardData(CF_BITMAP); + + //create FIBITMAP * from HBITMAP + FIP->FI_CorrectBitmap32Alpha(hBitmap, FALSE); + dib = FIP->FI_CreateDIBFromHBITMAP(hBitmap); + CloseClipboard(); + + return dib; +} + +LPTSTR SaveImage(FREE_IMAGE_FORMAT fif, FIBITMAP* dib, LPTSTR pszFilename, LPTSTR pszExt, int flag) { + int ret=0; + LPTSTR pszFile = NULL; + LPTSTR FileExt = (LPTSTR)GetFileExt (pszFilename, DBVT_TCHAR); + if(!FileExt) { + if(!pszExt) return NULL; + mir_tcsadd(pszFile, pszFilename); + mir_tcsadd(pszFile, _T(".")); + mir_tcsadd(pszFile, pszExt); + } + else { + mir_tcsadd(pszFile, pszFilename); + } + + if(fif==FIF_UNKNOWN) { + #if defined(_UNICODE) + fif = FIP->FI_GetFIFFromFilenameU(pszFile); + #else + fif = FIP->FI_GetFIFFromFilename(pszFile); + #endif + } + if(FIP->FI_FIFSupportsICCProfiles(fif)) { + bool bDummy = true; + } + + #if defined(_UNICODE) + ret = FIP->FI_SaveU(fif, dib, pszFile, flag); + #else + ret = FIP->FI_Save(fif, dib, pszFile, flag); + #endif + + mir_free(FileExt); + + if(ret) return pszFile; + mir_free(pszFile); + return NULL; +} + +//--------------------------------------------------------------------------- +//Draws a selection border on the window under cursor +void DrawBorderInverted(HWND hWindow) { + if (!hWindow){ + return; + } + HDC hDC=GetWindowDC(hWindow); + RECT rect={0}; + GetWindowRect(hWindow, &rect); + + int dcSave = SaveDC(hDC); + + SetROP2(hDC, R2_NOT); + + HPEN hPen=0; + hPen = CreatePen(PS_SOLID, 10, RGB(0, 0, 0)); + + SelectObject(hDC, &hPen); + SelectObject(hDC, GetStockObject(NULL_BRUSH)); + + Rectangle(hDC, 0, 0, rect.right-rect.left, rect.bottom-rect.top); + Rectangle(hDC, 1, 1, rect.right-rect.left-1, rect.bottom-rect.top-1); + Rectangle(hDC, 2, 2, rect.right-rect.left-2, rect.bottom-rect.top-2); + + RestoreDC(hDC, dcSave); +} + +//--------------------------------------------------------------------------- +//is left mouse button down +BOOL GetLmouse() { + SHORT temp = GetAsyncKeyState((GetSystemMetrics(SM_SWAPBUTTON)) ? VK_RBUTTON : VK_LBUTTON); + if ((temp & 0x8000) == 0x8000) { // LBUTTON down + return TRUE; + } + return FALSE; +} + +//--------------------------------------------------------------------------- +//is miranda unicode +BOOL mir_is_unicode() { + char ver[1024]; + CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM) sizeof(ver), (LPARAM) ver); + return strstr(ver, "Unicode") != NULL; +} + +//--------------------------------------------------------------------------- +INT_PTR GetFileName(LPTSTR pszPath, UINT typ) { + /*DBVT_ASCIIZ, DBVT_WCHAR, DBVT_TCHAR*/ + LPTSTR slash = _tcsrchr(pszPath,_T('\\')); + if (slash) { + switch (typ) { + case DBVT_ASCIIZ: + return (INT_PTR)mir_t2a(slash+1); + case DBVT_WCHAR: + return (INT_PTR)mir_t2u(slash+1); + default: + return 0; + } + } + else { + switch (typ) { + case DBVT_ASCIIZ: + return (INT_PTR)mir_t2a(pszPath); + case DBVT_WCHAR: + return (INT_PTR)mir_t2u(pszPath); + default: + return 0; + } + } +} + +INT_PTR GetFileExt (LPTSTR pszPath, UINT typ) { + /*DBVT_ASCIIZ, DBVT_WCHAR, DBVT_TCHAR*/ + LPTSTR slash = _tcsrchr(pszPath,_T('.')); + if (slash) { + switch (typ) { + case DBVT_ASCIIZ: + return (INT_PTR)mir_t2a(slash); + case DBVT_WCHAR: + return (INT_PTR)mir_t2u(slash); + default: + return 0; + } + } + else { + return NULL; + } +} + +//--------------------------------------------------------------------------- +BOOL GetEncoderClsid(wchar_t *wchMimeType, CLSID& clsidEncoder) { + UINT uiNum = 0; + UINT uiSize = 0; + BOOL bOk = FALSE; + Gdiplus::ImageCodecInfo* pImageCodecInfo = NULL; + Gdiplus::GetImageEncodersSize(&uiNum, &uiSize); + if( uiSize > 0 ) { + pImageCodecInfo = (Gdiplus::ImageCodecInfo *)new char[uiSize]; + if( pImageCodecInfo ) { + Gdiplus::GetImageEncoders(uiNum, uiSize, pImageCodecInfo); + for( UINT i = 0; i < uiNum; i++ ) { + if( wcscmp(pImageCodecInfo[i].MimeType, wchMimeType) == 0 ) { + clsidEncoder = pImageCodecInfo[i].Clsid; + bOk = TRUE; + } + } + } + delete pImageCodecInfo; + } + return bOk; +} + +INT_PTR SavePNG(HBITMAP hBmp, LPTSTR szFilename) { + Gdiplus::GdiplusStartupInput gdiplusStartupInput; + ULONG_PTR gdiplusToken; + Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); + + Gdiplus::Bitmap *pBitmap = Gdiplus::Bitmap::FromHBITMAP(hBmp, (HPALETTE)GetStockObject(DEFAULT_PALETTE) ); + if( pBitmap ) { + // Get the CLSID of the PNG encoder. + CLSID clsidEncoder; + if( GetEncoderClsid(L"image/png", clsidEncoder)) { + LPWSTR pswFile = mir_t2u(szFilename); + pBitmap->Save((const WCHAR*)pswFile, &clsidEncoder, NULL); + mir_free(pswFile); + } + delete pBitmap; + } + Gdiplus::GdiplusShutdown(gdiplusToken); + return 0; +} + +INT_PTR SaveGIF(HBITMAP hBmp, LPTSTR szFilename) { + Gdiplus::GdiplusStartupInput gdiplusStartupInput; + ULONG_PTR gdiplusToken; + Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); + + Gdiplus::Bitmap *pBitmap = Gdiplus::Bitmap::FromHBITMAP(hBmp, (HPALETTE)GetStockObject(DEFAULT_PALETTE) ); + if( pBitmap ) { + // Get the CLSID of the GIF encoder. + CLSID clsidEncoder; + if( GetEncoderClsid(L"image/gif", clsidEncoder)) { + LPWSTR pswFile = mir_t2u(szFilename); + pBitmap->Save((const WCHAR*)pswFile, &clsidEncoder, NULL); + mir_free(pswFile); + } + delete pBitmap; + } + Gdiplus::GdiplusShutdown(gdiplusToken); + return 0; +} + +INT_PTR SaveTIF(HBITMAP hBmp, LPTSTR szFilename) { +//http://www.codeproject.com/Messages/1406708/How-to-reduce-the-size-of-an-Image-using-GDIplus.aspx + ULONG_PTR gdiplusToken; + Gdiplus::GdiplusStartupInput gdiplusStartupInput; + Gdiplus::Status stat; + Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); + + Gdiplus::Bitmap *pBitmap = Gdiplus::Bitmap::FromHBITMAP(hBmp, (HPALETTE)GetStockObject(DEFAULT_PALETTE) ); + if( pBitmap ) { + // Get the CLSID of the GIF encoder. + CLSID EncCLSID; + if( GetEncoderClsid(L"image/tiff", EncCLSID)) { + //--- Create a 2-parameter array, for Compression and for Color Bit depth + Gdiplus::EncoderParameters* EncParams = (Gdiplus::EncoderParameters*) malloc(sizeof(Gdiplus::EncoderParameters) + 1 * sizeof(Gdiplus::EncoderParameter)); + // Gdiplus::EncoderParameters pEncoderParameters; + //--- Use LZW Compression instead of Group 4, since it works for color and G4 doesn't + ULONG ulCompression = Gdiplus::EncoderValueCompressionLZW ; + ULONG ulColorDepth = 24L ; + + EncParams->Count = 2 ; + EncParams->Parameter[0].Guid = Gdiplus::EncoderCompression ; + EncParams->Parameter[0].Type = Gdiplus::EncoderParameterValueTypeLong ; + EncParams->Parameter[0].NumberOfValues = 1 ; + EncParams->Parameter[0].Value = &ulCompression ; + EncParams->Parameter[1].Guid = Gdiplus::EncoderColorDepth ; + EncParams->Parameter[1].Type = Gdiplus::EncoderParameterValueTypeLong ; + EncParams->Parameter[1].NumberOfValues = 1 ; + EncParams->Parameter[1].Value = &ulColorDepth ; + + LPWSTR pswFile = mir_t2u(szFilename); + stat = pBitmap->Save((const WCHAR*)pswFile, &EncCLSID, EncParams); + mir_free(pswFile); + free(EncParams); + } + delete pBitmap; + } + Gdiplus::GdiplusShutdown(gdiplusToken); + return 0; +} + +//--------------------------------------------------------------------------- +/* Old stuff from Borland C++ */ +//--------------------------------------------------------------------------- +/*/Popup +void ShowPopUp(char *title, char *text) { + POPUPDATAEX pude={0}; + + strcpy(pude.lpzText, text); + strcpy(pude.lpzContactName, title); + pude.lchIcon = LoadIcon(g_hAppInstance, MAKEINTRESOURCE(MAIN)); + pude.colorBack = POPUP_USE_SKINNED_BG; + + CallService(MS_POPUP_ADDPOPUP, (WPARAM)&pude, 0); +}*/ + diff --git a/plugins/SendScreenshotPlus/src/Utils.h b/plugins/SendScreenshotPlus/src/Utils.h new file mode 100644 index 0000000000..2934391a8b --- /dev/null +++ b/plugins/SendScreenshotPlus/src/Utils.h @@ -0,0 +1,81 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* +Copyright 2000-2009 Miranda ICQ/IM project, + +This file is part of Send Screenshot Plus, a Miranda IM plugin. +Copyright (c) 2010 Ing.U.Horn + +Parts of this file based on original sorce code +(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/Utils.h $ +Revision : $Revision: 22 $ +Last change on : $Date: 2010-05-02 21:25:02 +0400 (Р’СЃ, 02 май 2010) $ +Last change by : $Author: ing.u.horn $ + +*/ + +#ifndef UTILSH +#define UTILSH + +#include "global.h" +//#include +//#include +#define SPP_USERPANE 1 + +extern FI_INTERFACE *FIP; + +#define ABS(x) ((x)<0?-(x):(x)) + +typedef struct TEnumDataTemp { +size_t count; +MONITORINFOEX* info; +}MONITORS; + +extern HWND g_hCapture; +extern HBITMAP g_hBitmap, g_hbmMask; + +//--------------------------------------------------------------------------- +int ComboBox_SelectItemData(HWND hwndCtl, int indexStart, LPARAM data); + +size_t MonitorInfoEnum(MONITORINFOEX* & myMonitors, RECT & virtualScreen); +BOOL CALLBACK MonitorInfoEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData); + +FIBITMAP* CaptureWindow(HWND hCapture, BOOL ClientArea); +FIBITMAP* CaptureMonitor(LPTSTR szDevice); +FIBITMAP* CaptureScreen(HDC hDC, SIZE size, HWND hCapture=0); +FIBITMAP* CaptureDesktop(); /*emulate print screen (not used)*/ +LPTSTR SaveImage(FREE_IMAGE_FORMAT fif, FIBITMAP* dib, LPTSTR pszFilename, LPTSTR pszExt, int flag=0); + +void DrawBorderInverted(HWND hWindow); +BOOL GetLmouse(); +BOOL mir_is_unicode(); +INT_PTR GetFileName(LPTSTR pszPath, UINT typ); +INT_PTR GetFileExt (LPTSTR pszPath, UINT typ); + +BOOL GetEncoderClsid(wchar_t *wchMimeType, CLSID& clsidEncoder); +INT_PTR SavePNG(HBITMAP hBmp, LPTSTR szFilename); +INT_PTR SaveGIF(HBITMAP hBmp, LPTSTR szFilename); +INT_PTR SaveTIF(HBITMAP hBmp, LPTSTR szFilename); + +//--------------------------------------------------------------------------- +/* Old stuff from Borland C++ +//void ShowPopUp(char *title, char *text); + +*/ +#endif diff --git a/plugins/SendScreenshotPlus/src/ctrl_button.cpp b/plugins/SendScreenshotPlus/src/ctrl_button.cpp new file mode 100644 index 0000000000..ad8e542fa3 --- /dev/null +++ b/plugins/SendScreenshotPlus/src/ctrl_button.cpp @@ -0,0 +1,699 @@ +/* +Miranda IM +Copyright (C) 2002 Robert Rainwater + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +#include "global.h" + +// Used for our own cheap TrackMouseEvent +#define BUTTON_POLLID 100 +#define BUTTON_POLLDELAY 50 + +#define MGPROC(x) GetProcAddress(themeAPIHandle,x) + +typedef struct TMBCtrl{ + HWND hwnd; + HANDLE hThemeButton; + HANDLE hThemeToolbar; + + HICON hIcon; + HICON arrow; // uses down arrow + HBITMAP hBitmap; + HFONT hFont; // font + + DWORD dwStyle; + BOOLEAN bFocus; + + INT stateId; // button state + INT defbutton; // default button + INT pbState; + TCHAR cHot; +} BTNCTRL, *LPBTNCTRL; + +// External theme methods and properties +CRITICAL_SECTION csTips; +HWND hwndToolTips = NULL; +HMODULE themeAPIHandle = NULL; + +// theme procedures +HANDLE (WINAPI *OpenThemeData)(HWND,LPCWSTR); +HRESULT (WINAPI *CloseThemeData)(HANDLE); +BOOL (WINAPI *IsThemeBackgroundPartiallyTransparent)(HANDLE,INT,INT); +HRESULT (WINAPI *DrawThemeParentBackground)(HWND,HDC,RECT *); +HRESULT (WINAPI *DrawThemeBackground)(HANDLE,HDC,INT,INT,const RECT *,const RECT *); +HRESULT (WINAPI *DrawThemeText)(HANDLE,HDC,INT,INT,LPCWSTR,INT,DWORD,DWORD,const RECT *); +HRESULT (WINAPI *GetThemeTextExtent)(HANDLE,HDC,INT,INT,LPCWSTR,INT,DWORD,OPTIONAL const RECT*, RECT *); +HRESULT (WINAPI *GetThemeBackgroundRegion)(HANDLE,HDC,INT,INT,const RECT *,HRGN *); + +/** + * name: ThemeSupport + * desc: Loads the uxtheme functions, if supported by the os + * param: none + * return: TRUE if themes are supported, FALSE if not + **/ +BOOLEAN __fastcall ThemeSupport() { + if (IsWinVerXPPlus()) { + if (!themeAPIHandle) { + themeAPIHandle = GetModuleHandleA("uxtheme"); + if (themeAPIHandle) { + OpenThemeData = (HANDLE (WINAPI *)(HWND,LPCWSTR))MGPROC("OpenThemeData"); + CloseThemeData = (HRESULT (WINAPI *)(HANDLE))MGPROC("CloseThemeData"); + IsThemeBackgroundPartiallyTransparent = (BOOL (WINAPI *)(HANDLE,INT,INT))MGPROC("IsThemeBackgroundPartiallyTransparent"); + DrawThemeParentBackground = (HRESULT (WINAPI *)(HWND,HDC,RECT *))MGPROC("DrawThemeParentBackground"); + DrawThemeBackground = (HRESULT (WINAPI *)(HANDLE,HDC,INT,INT,const RECT *,const RECT *))MGPROC("DrawThemeBackground"); + DrawThemeText = (HRESULT (WINAPI *)(HANDLE,HDC,INT,INT,LPCWSTR,INT,DWORD,DWORD,const RECT *))MGPROC("DrawThemeText"); + GetThemeTextExtent = (HRESULT (WINAPI *)(HANDLE,HDC,INT,INT,LPCWSTR,INT,DWORD,OPTIONAL const RECT*, RECT *))MGPROC("GetThemeTextExtent"); + GetThemeBackgroundRegion = (HRESULT (WINAPI *)(HANDLE,HDC,INT,INT,const RECT *,HRGN *))MGPROC("GetThemeBackgroundRegion"); + } + } + // Make sure all of these methods are valid (i would hope either all or none work) + if (OpenThemeData + && CloseThemeData + && IsThemeBackgroundPartiallyTransparent + && DrawThemeParentBackground + && DrawThemeBackground + && DrawThemeText + && GetThemeTextExtent) + { + return TRUE; + } + } + return FALSE; +} + +/** + * name: DestroyTheme + * desc: destroys theme data for buttons + * param: ctl - BTNCTRL structure with the information about the theme to close + * return: nothing + **/ +static VOID __fastcall DestroyTheme(BTNCTRL *ctl) { + if (ctl->hThemeButton) { + CloseThemeData(ctl->hThemeButton); + ctl->hThemeButton = NULL; + } + if (ctl->hThemeToolbar) { + CloseThemeData(ctl->hThemeToolbar); + ctl->hThemeToolbar = NULL; + } +} + +/** + * name: LoadTheme + * desc: load theme data for buttons if supported by os + * param: ctl - BTNCTRL structure with the information about the theme to load + * return: nothing + **/ +static VOID __fastcall LoadTheme(BTNCTRL *ctl) { + if (ThemeSupport()) { + DestroyTheme(ctl); + ctl->hThemeButton = OpenThemeData(ctl->hwnd,L"BUTTON"); + ctl->hThemeToolbar = OpenThemeData(ctl->hwnd,L"TOOLBAR"); + } +} + +/** + * name: TBStateConvert2Flat + * desc: convert button stateIDs + * param: state - state id for the normal theme button + * return: stateID for the flat theme button + **/ +static INT __fastcall TBStateConvert2Flat(INT state) { + switch (state) { + case PBS_NORMAL: return TS_NORMAL; + case PBS_HOT: return TS_HOT; + case PBS_PRESSED: return TS_PRESSED; + case PBS_DISABLED: return TS_DISABLED; + case PBS_DEFAULTED: return TS_NORMAL; + } + return TS_NORMAL; +} + +/** + * name: PaintIcon + * desc: Draws the Icon of the button + * param: ctl - BTNCTRL structure for the button + * hdcMem - device context to draw to + * ccText - character count of the text of the button + * rcClient - rectangle of the whole button + * rcText - rectangle of the text to draw later on + * return: nothing + **/ +static VOID __fastcall PaintIcon(BTNCTRL *ctl, HDC hdcMem, LPWORD ccText, LPRECT rcClient, LPRECT rcText) +{ + RECT rcImage; + + // draw icon on the left of the button + if (ctl->hIcon) { + rcImage.right = GetSystemMetrics(SM_CXSMICON); + rcImage.bottom = GetSystemMetrics(SM_CYSMICON); + rcImage.left = (rcClient->right - rcClient->left) / 2 - ((rcImage.right + rcText->right + (*ccText > 0 ? 4 : 0) + (ctl->arrow ? rcImage.right : 0)) / 2); + rcImage.top = (rcClient->bottom - rcClient->top - rcImage.bottom) / 2; + rcImage.right += rcImage.left; + rcImage.bottom += rcImage.top; + + OffsetRect(rcText, rcImage.right + 4, 0); + if (ctl->stateId == PBS_PRESSED) OffsetRect(&rcImage, 1, 1); + + DrawState(hdcMem, NULL, NULL, (LPARAM)ctl->hIcon, 0, + rcImage.left, rcImage.top, + rcImage.right - rcImage.left, rcImage.bottom - rcImage.top, + IsWindowEnabled(ctl->hwnd) ? DST_ICON | DSS_NORMAL : DST_ICON | DSS_DISABLED); + } + + // draw arrow on the right of the button + if (ctl->arrow) { + rcImage.right = GetSystemMetrics(SM_CXSMICON); + rcImage.left = (*ccText > 0 || ctl->hIcon) + ? rcClient->right - GetSystemMetrics(SM_CXSMICON) + : (rcClient->right - rcClient->left - rcImage.right) / 2; + rcImage.right += rcImage.left; + rcImage.bottom = GetSystemMetrics(SM_CYSMICON); + rcImage.top = (rcClient->bottom - rcClient->top - rcImage.bottom) / 2; + if (ctl->stateId == PBS_PRESSED) OffsetRect(&rcImage, 1, 1); + + DrawState(hdcMem, NULL, NULL, (LPARAM)ctl->arrow, 0, + rcImage.left, rcImage.top, + rcImage.right - rcImage.left, rcImage.bottom - rcImage.top, + IsWindowEnabled(ctl->hwnd) ? DST_ICON | DSS_NORMAL : DST_ICON | DSS_DISABLED); + } +} + +/** + * name: PaintThemeButton + * desc: Draws the themed button + * param: ctl - BTNCTRL structure for the button + * hdcMem - device context to draw to + * rcClient - rectangle of the whole button + * return: nothing + **/ +static VOID __fastcall PaintThemeButton(BTNCTRL *ctl, HDC hdcMem, LPRECT rcClient) +{ + RECT rcText = { 0, 0, 0, 0 }; + WCHAR wszText[MAX_PATH] = { 0 }; + WORD ccText; + + // Draw the flat button + if ((ctl->dwStyle & MBS_FLAT) && ctl->hThemeToolbar) { + INT state = IsWindowEnabled(ctl->hwnd) + ? (ctl->stateId == PBS_NORMAL && ctl->defbutton + ? PBS_DEFAULTED + : ctl->stateId) + : PBS_DISABLED; + if (IsThemeBackgroundPartiallyTransparent(ctl->hThemeToolbar, TP_BUTTON, TBStateConvert2Flat(state))) { + if (SUCCEEDED(DrawThemeParentBackground(ctl->hwnd, hdcMem, rcClient))) + DrawThemeParentBackground(GetParent(ctl->hwnd), hdcMem, rcClient); + } + DrawThemeBackground(ctl->hThemeToolbar, hdcMem, TP_BUTTON, TBStateConvert2Flat(state), rcClient, rcClient); + } + else { + // draw themed button background + if (ctl->hThemeButton) { + INT state = IsWindowEnabled(ctl->hwnd) + ? (ctl->stateId == PBS_NORMAL && ctl->defbutton + ? PBS_DEFAULTED + : ctl->stateId) + : PBS_DISABLED; + if (IsThemeBackgroundPartiallyTransparent(ctl->hThemeButton, BP_PUSHBUTTON, state)) { + if (SUCCEEDED(DrawThemeParentBackground(ctl->hwnd, hdcMem, rcClient))) + DrawThemeParentBackground(GetParent(ctl->hwnd), hdcMem, rcClient); + } + DrawThemeBackground(ctl->hThemeButton, hdcMem, BP_PUSHBUTTON, state, rcClient, rcClient); + } + } + + // calculate text rect + { + RECT sizeText; + HFONT hOldFont; + + ccText = GetWindowTextW(ctl->hwnd, wszText, sizeof(wszText) / sizeof(WCHAR)); + + if (ccText > 0) { + hOldFont = (HFONT)SelectObject(hdcMem, ctl->hFont); + + GetThemeTextExtent( + ctl->hThemeButton, + hdcMem, + BP_PUSHBUTTON, + IsWindowEnabled(ctl->hwnd) ? ctl->stateId : PBS_DISABLED, + wszText, + ccText, + DST_PREFIXTEXT, + NULL, + &sizeText); + + if (ctl->cHot) { + RECT rcHot; + + GetThemeTextExtent(ctl->hThemeButton, + hdcMem, + BP_PUSHBUTTON, + IsWindowEnabled(ctl->hwnd) ? ctl->stateId : PBS_DISABLED, + L"&", + 1, + DST_PREFIXTEXT, + NULL, + &rcHot); + + sizeText.right -= (rcHot.right - rcHot.left); + } + SelectObject(hdcMem, hOldFont); + + rcText.left = (ctl->hIcon) ? 0 : (rcClient->right - rcClient->left - (sizeText.right - sizeText.left)) / 2; + rcText.top = (rcClient->bottom - rcClient->top - (sizeText.bottom - sizeText.top)) / 2; + rcText.right = rcText.left + (sizeText.right - sizeText.left); + rcText.bottom = rcText.top + (sizeText.bottom - sizeText.top); + if (ctl->stateId == PBS_PRESSED) { + OffsetRect(&rcText, 1, 1); + } + } + } + PaintIcon(ctl, hdcMem, &ccText, rcClient, &rcText); + // draw text + if (ccText > 0 && ctl->hThemeButton) { + HFONT hOldFont = (HFONT)SelectObject(hdcMem, ctl->hFont); + DrawThemeText(ctl->hThemeButton, hdcMem, BP_PUSHBUTTON, IsWindowEnabled(ctl->hwnd) ? ctl->stateId : PBS_DISABLED, wszText, ccText, DST_PREFIXTEXT, 0, &rcText); + SelectObject(hdcMem, hOldFont); + } +} + +/** + * name: PaintThemeButton + * desc: Draws the none themed button + * param: ctl - BTNCTRL structure for the button + * hdcMem - device context to draw to + * rcClient - rectangle of the whole button + * return: nothing + **/ +static VOID __fastcall PaintButton(BTNCTRL *ctl, HDC hdcMem, LPRECT rcClient) +{ + RECT rcText = { 0, 0, 0, 0 }; + TCHAR szText[MAX_PATH] = { 0 }; + WORD ccText; + + // Draw the flat button + if (ctl->dwStyle & MBS_FLAT) { + HBRUSH hbr = NULL; + + if (ctl->stateId == PBS_PRESSED || ctl->stateId == PBS_HOT) + hbr = GetSysColorBrush(COLOR_3DLIGHT); + else { + HDC dc; + HWND hwndParent; + + hwndParent = GetParent(ctl->hwnd); + if (dc = GetDC(hwndParent)) { + hbr = (HBRUSH)SendMessage(hwndParent, WM_CTLCOLORDLG, (WPARAM)dc, (LPARAM)hwndParent); + ReleaseDC(hwndParent, dc); + } + } + if (hbr) { + FillRect(hdcMem, rcClient, hbr); + DeleteObject(hbr); + } + if (ctl->stateId == PBS_HOT || ctl->bFocus) { + if (ctl->pbState) DrawEdge(hdcMem, rcClient, EDGE_ETCHED, BF_RECT|BF_SOFT); + else DrawEdge(hdcMem, rcClient, BDR_RAISEDOUTER, BF_RECT|BF_SOFT|BF_FLAT); + } + else + if (ctl->stateId == PBS_PRESSED) + DrawEdge(hdcMem, rcClient, BDR_SUNKENOUTER, BF_RECT|BF_SOFT); + } + else { + UINT uState = DFCS_BUTTONPUSH|((ctl->stateId == PBS_HOT) ? DFCS_HOT : 0)|((ctl->stateId == PBS_PRESSED) ? DFCS_PUSHED : 0); + if (ctl->defbutton&&ctl->stateId==PBS_NORMAL) uState |= DLGC_DEFPUSHBUTTON; + DrawFrameControl(hdcMem, rcClient, DFC_BUTTON, uState); + // Draw focus rectangle if button has focus + if (ctl->bFocus) { + RECT focusRect = *rcClient; + InflateRect(&focusRect, -3, -3); + DrawFocusRect(hdcMem, &focusRect); + } + } + // calculate text rect + { + SIZE sizeText; + HFONT hOldFont; + + ccText = GetWindowText(ctl->hwnd, szText, SIZEOF(szText)); + + if (ccText > 0) { + hOldFont = (HFONT)SelectObject(hdcMem, ctl->hFont); + GetTextExtentPoint32(hdcMem, szText, ccText, &sizeText); + if (ctl->cHot) { + SIZE sizeHot; + + GetTextExtentPoint32A(hdcMem, "&", 1, &sizeHot); + sizeText.cx -= sizeHot.cx; + } + SelectObject(hdcMem, hOldFont); + + rcText.left = (ctl->hIcon) ? 0 : (rcClient->right - rcClient->left - sizeText.cx) / 2; + rcText.top = (rcClient->bottom - rcClient->top - sizeText.cy) / 2; + rcText.right = rcText.left + sizeText.cx; + rcText.bottom = rcText.top + sizeText.cy; + if (ctl->stateId == PBS_PRESSED) + OffsetRect(&rcText, 1, 1); + } + } + PaintIcon(ctl, hdcMem, &ccText, rcClient, &rcText); + + // draw text + if (ccText > 0) { + HFONT hOldFont; + + hOldFont = (HFONT)SelectObject(hdcMem, ctl->hFont); + + SetBkMode(hdcMem, TRANSPARENT); + SetTextColor(hdcMem, + IsWindowEnabled(ctl->hwnd) || !ctl->hThemeButton + ? ctl->stateId == PBS_HOT + ? GetSysColor(COLOR_HOTLIGHT) + : GetSysColor(COLOR_BTNTEXT) + : GetSysColor(COLOR_GRAYTEXT)); + + DrawState(hdcMem, NULL, NULL, (LPARAM)szText, 0, + rcText.left, rcText.top, rcText.right - rcText.left, rcText.bottom - rcText.top, + IsWindowEnabled(ctl->hwnd) || ctl->hThemeButton ? DST_PREFIXTEXT | DSS_NORMAL : DST_PREFIXTEXT | DSS_DISABLED); + SelectObject(hdcMem, hOldFont); + } +} + +/** + * name: Button_WndProc + * desc: window procedure for the button class + * param: hwndBtn - window handle to the button + * uMsg - message to handle + * wParam - message specific parameter + * lParam - message specific parameter + * return: message specific + **/ +static LRESULT CALLBACK Button_WndProc(HWND hwndBtn, UINT uMsg, WPARAM wParam, LPARAM lParam) { + LPBTNCTRL bct = (LPBTNCTRL)GetWindowLongPtr(hwndBtn, 0); + + switch (uMsg) { + case WM_NCCREATE: + { + LPCREATESTRUCT cs = (LPCREATESTRUCT)lParam; + + cs->style |= BS_OWNERDRAW; + if (!(bct = (LPBTNCTRL)malloc(sizeof(BTNCTRL)))) + return FALSE; + ZeroMemory(bct, sizeof(BTNCTRL)); + bct->hwnd = hwndBtn; + bct->stateId = PBS_NORMAL; + bct->hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); + bct->dwStyle = cs->style; + if (cs->style & MBS_DOWNARROW) + bct->arrow = IcoLib_GetIcon(ICO_BTN_DOWNARROW); + LoadTheme(bct); + SetWindowLongPtr(hwndBtn, 0, (LONG_PTR)bct); + if (cs->lpszName) SetWindowText(hwndBtn, cs->lpszName); + return TRUE; + } + case WM_DESTROY: + if (bct) { + EnterCriticalSection(&csTips); + if (hwndToolTips) { + TOOLINFO ti; + + ZeroMemory(&ti, sizeof(ti)); + ti.cbSize = sizeof(ti); + ti.uFlags = TTF_IDISHWND; + ti.hwnd = bct->hwnd; + ti.uId = (UINT)bct->hwnd; + if (SendMessage(hwndToolTips, TTM_GETTOOLINFO, 0, (LPARAM)&ti)) { + SendMessage(hwndToolTips, TTM_DELTOOL, 0, (LPARAM)&ti); + } + if (SendMessage(hwndToolTips, TTM_GETTOOLCOUNT, 0, (LPARAM)&ti) == 0) { + DestroyWindow(hwndToolTips); + hwndToolTips = NULL; + } + } + LeaveCriticalSection(&csTips); + DestroyTheme(bct); + free(bct); + } + SetWindowLongPtr(hwndBtn, 0, NULL); + break; + case WM_SETTEXT: + bct->cHot = 0; + if ((LPTSTR)lParam) { + LPTSTR tmp = (LPTSTR)lParam; + + while (*tmp) { + if (*tmp=='&' && *(tmp+1)) { + bct->cHot = _totlower(*(tmp+1)); + break; + } + tmp++; + } + InvalidateRect(bct->hwnd, NULL, TRUE); + } + break; + case WM_SYSKEYUP: + if (bct->stateId != PBS_DISABLED && bct->cHot && bct->cHot == _totlower((TCHAR)wParam)) { + if (bct->dwStyle & MBS_PUSHBUTTON) { + if (bct->pbState) bct->pbState = 0; + else bct->pbState = 1; + InvalidateRect(bct->hwnd, NULL, TRUE); + } + else + SetFocus(hwndBtn); + SendMessage(GetParent(hwndBtn), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndBtn), BN_CLICKED), (LPARAM)hwndBtn); + return 0; + } + break; + case WM_THEMECHANGED: + { + // themed changed, reload theme object + LoadTheme(bct); + InvalidateRect(bct->hwnd, NULL, TRUE); // repaint it + break; + } + case WM_SETFONT: // remember the font so we can use it later + bct->hFont = (HFONT)wParam; // maybe we should redraw? + break; + case WM_NCPAINT: + case WM_PAINT: + { + PAINTSTRUCT ps; + HDC hdcPaint; + HDC hdcMem; + HBITMAP hbmMem; + HDC hOld; + RECT rcClient; + + if (hdcPaint = BeginPaint(hwndBtn, &ps)) { + GetClientRect(bct->hwnd, &rcClient); + hdcMem = CreateCompatibleDC(hdcPaint); + hbmMem = CreateCompatibleBitmap(hdcPaint, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top); + hOld = (HDC)SelectObject(hdcMem, hbmMem); + + // If its a push button, check to see if it should stay pressed + if ((bct->dwStyle & MBS_PUSHBUTTON) && bct->pbState) bct->stateId = PBS_PRESSED; + + if ((bct->dwStyle & MBS_FLAT) && bct->hThemeToolbar || bct->hThemeButton) + PaintThemeButton(bct, hdcMem, &rcClient); + else + PaintButton(bct, hdcMem, &rcClient); + + BitBlt(hdcPaint, 0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top, hdcMem, 0, 0, SRCCOPY); + SelectObject(hdcMem, hOld); + DeleteObject(hbmMem); + DeleteDC(hdcMem); + EndPaint(hwndBtn, &ps); + } + return 0; + } + case BM_SETIMAGE: + if (wParam == IMAGE_ICON) { + bct->hIcon = (HICON)lParam; + bct->hBitmap = NULL; + InvalidateRect(bct->hwnd, NULL, TRUE); + } + else if (wParam == IMAGE_BITMAP) { + bct->hIcon = NULL; + bct->hBitmap = (HBITMAP)lParam; + InvalidateRect(bct->hwnd, NULL, TRUE); + } + else if (wParam == NULL && lParam == NULL) { + bct->hIcon = NULL; + bct->hBitmap = NULL; + InvalidateRect(bct->hwnd, NULL, TRUE); + } + break; + case BM_SETCHECK: + if (!(bct->dwStyle & MBS_PUSHBUTTON)) break; + if (wParam == BST_CHECKED) { + bct->pbState = 1; + bct->stateId = PBS_PRESSED; + } + else if (wParam == BST_UNCHECKED) { + bct->pbState = 0; + bct->stateId = PBS_NORMAL; + } + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case BM_GETCHECK: + if (bct->dwStyle & MBS_PUSHBUTTON) return bct->pbState ? BST_CHECKED : BST_UNCHECKED; + return 0; + case BUTTONSETDEFAULT: + bct->defbutton = wParam ? 1 : 0; + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case BUTTONADDTOOLTIP: + { + if (!wParam) break; + EnterCriticalSection(&csTips); + if (!hwndToolTips) { + hwndToolTips = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP, 0, 0, 0, 0, NULL, NULL, GetModuleHandle(NULL), NULL); + } + + if (lParam == MBF_UNICODE) { + TOOLINFOW ti; + + ZeroMemory(&ti, sizeof(TOOLINFOW)); + ti.cbSize = sizeof(TOOLINFOW); + ti.uFlags = TTF_IDISHWND; + ti.hwnd = bct->hwnd; + ti.uId = (UINT)bct->hwnd; + if (SendMessage(hwndToolTips, TTM_GETTOOLINFOW, 0, (LPARAM)&ti)) { + SendMessage(hwndToolTips, TTM_DELTOOLW, 0, (LPARAM)&ti); + } + ti.uFlags = TTF_IDISHWND|TTF_SUBCLASS; + ti.uId = (UINT)bct->hwnd; + ti.lpszText=(LPWSTR)wParam; + SendMessage(hwndToolTips, TTM_ADDTOOLW, 0, (LPARAM)&ti); + } + else { + TOOLINFOA ti; + + ZeroMemory(&ti, sizeof(TOOLINFOA)); + ti.cbSize = sizeof(TOOLINFOA); + ti.uFlags = TTF_IDISHWND; + ti.hwnd = bct->hwnd; + ti.uId = (UINT)bct->hwnd; + if (SendMessage(hwndToolTips, TTM_GETTOOLINFOA, 0, (LPARAM)&ti)) { + SendMessage(hwndToolTips, TTM_DELTOOLA, 0, (LPARAM)&ti); + } + ti.uFlags = TTF_IDISHWND|TTF_SUBCLASS; + ti.uId = (UINT)bct->hwnd; + ti.lpszText=(LPSTR)wParam; + SendMessage(hwndToolTips, TTM_ADDTOOLA, 0, (LPARAM)&ti); + } + LeaveCriticalSection(&csTips); + break; + } + case BUTTONTRANSLATE: + { + TCHAR szButton[MAX_PATH]; + GetWindowText(bct->hwnd, szButton, MAX_PATH); + SetWindowText(bct->hwnd, TranslateTS(szButton)); + break; + } + case WM_SETFOCUS: // set keybord bFocus and redraw + bct->bFocus = 1; + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case WM_KILLFOCUS: // kill bFocus and redraw + bct->bFocus = 0; + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case WM_WINDOWPOSCHANGED: + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case WM_ENABLE: // windows tells us to enable/disable + bct->stateId = wParam ? PBS_NORMAL : PBS_DISABLED; + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case WM_MOUSELEAVE: // faked by the WM_TIMER + if (bct->stateId != PBS_DISABLED) { // don't change states if disabled + bct->stateId = PBS_NORMAL; + InvalidateRect(bct->hwnd, NULL, TRUE); + } + break; + case WM_LBUTTONDOWN: + if (bct->stateId != PBS_DISABLED) { // don't change states if disabled + bct->stateId = PBS_PRESSED; + InvalidateRect(bct->hwnd, NULL, TRUE); + } + break; + case WM_LBUTTONUP: + if (bct->stateId != PBS_DISABLED) { // don't change states if disabled + BOOLEAN bPressed = bct->stateId == PBS_PRESSED; + + if (bct->dwStyle & MBS_PUSHBUTTON) { + if (bct->pbState) bct->pbState = 0; + else bct->pbState = 1; + } + bct->stateId = PBS_HOT; + + // Tell your daddy you got clicked, if mouse is still over the button. + if ((bct->dwStyle & MBS_PUSHBUTTON) || bPressed) + SendMessage(GetParent(hwndBtn), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndBtn), BN_CLICKED), (LPARAM)hwndBtn); + InvalidateRect(bct->hwnd, NULL, TRUE); + } + break; + case WM_MOUSEMOVE: + if (bct->stateId == PBS_NORMAL) { + bct->stateId = PBS_HOT; + InvalidateRect(bct->hwnd, NULL, TRUE); + } + // Call timer, used to start cheesy TrackMouseEvent faker + SetTimer(hwndBtn, BUTTON_POLLID, BUTTON_POLLDELAY, NULL); + break; + case WM_TIMER: // use a timer to check if they have did a mouseout + if (wParam == BUTTON_POLLID) { + RECT rc; + POINT pt; + + GetWindowRect(hwndBtn, &rc); + GetCursorPos(&pt); + if (!PtInRect(&rc, pt)) { // mouse must be gone, trigger mouse leave + PostMessage(hwndBtn, WM_MOUSELEAVE, 0, 0L); + KillTimer(hwndBtn, BUTTON_POLLID); + } + } + break; + case WM_ERASEBKGND: + return 1; + } + return DefWindowProc(hwndBtn, uMsg, wParam, lParam); +} + +VOID CtrlButtonUnloadModule() +{ + DeleteCriticalSection(&csTips); + UnregisterClass(UINFOBUTTONCLASS, hInst); +} + +VOID CtrlButtonLoadModule() +{ + WNDCLASSEX wc; + + ZeroMemory(&wc, sizeof(wc)); + wc.cbSize = sizeof(wc); + wc.lpszClassName = UINFOBUTTONCLASS; + wc.lpfnWndProc = Button_WndProc; + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.cbWndExtra = sizeof(LPBTNCTRL); + wc.style = CS_GLOBALCLASS; + RegisterClassEx(&wc); + InitializeCriticalSection(&csTips); +} + diff --git a/plugins/SendScreenshotPlus/src/ctrl_button.h b/plugins/SendScreenshotPlus/src/ctrl_button.h new file mode 100644 index 0000000000..dc77334b05 --- /dev/null +++ b/plugins/SendScreenshotPlus/src/ctrl_button.h @@ -0,0 +1,43 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +aLONG with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ +#ifndef _UINFOEX_BOTTONS_H_INCLUDED_ +#define _UINFOEX_BOTTONS_H_INCLUDED_ 1 + +// theme procedures +extern HANDLE (WINAPI *OpenThemeData)(HWND,LPCWSTR); +extern HRESULT (WINAPI *CloseThemeData)(HANDLE); +extern BOOL (WINAPI *IsThemeBackgroundPartiallyTransparent)(HANDLE,INT,INT); +extern HRESULT (WINAPI *DrawThemeParentBackground)(HWND,HDC,RECT *); +extern HRESULT (WINAPI *DrawThemeBackground)(HANDLE,HDC,INT,INT,const RECT *,const RECT *); +extern HRESULT (WINAPI *DrawThemeText)(HANDLE,HDC,INT,INT,LPCWSTR,INT,DWORD,DWORD,const RECT *); +extern HRESULT (WINAPI *GetThemeTextExtent)(HANDLE,HDC,INT,INT,LPCWSTR,INT,DWORD,OPTIONAL const RECT*, RECT *); +extern HRESULT (WINAPI *GetThemeBackgroundRegion)(HANDLE,HDC,INT,INT,const RECT *,HRGN *); + + +VOID CtrlButtonLoadModule(); +VOID CtrlButtonUnloadModule(); + +BOOLEAN __fastcall ThemeSupport(); + +#endif /* _UINFOEX_BOTTONS_H_INCLUDED_ */ \ No newline at end of file diff --git a/plugins/SendScreenshotPlus/src/dlg_msgbox.cpp b/plugins/SendScreenshotPlus/src/dlg_msgbox.cpp new file mode 100644 index 0000000000..f1b1535802 --- /dev/null +++ b/plugins/SendScreenshotPlus/src/dlg_msgbox.cpp @@ -0,0 +1,854 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +aLONG with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $HeadURL: https://userinfoex.googlecode.com/svn/trunk/dlg_msgbox.cpp $ +Revision : $Revision: 164 $ +Last change on : $Date: 2009-12-02 21:24:35 +0100 (Mi, 02. Dez 2009) $ +Last change by : $Author: ing.u.horn $ + +*/ + +#include "dlg_msgbox.h" + +typedef struct _MSGPOPUPDATA +{ + POPUPACTION pa[3]; + HWND hDialog; +} +MSGPOPUPDATA, *LPMSGPOPUPDATA; + +/** + * This helper function moves and resizes a dialog box's control element. + * + * @param hDlg - the dialog box's window handle + * @param idCtrl - the identication number of the control to move + * @param dx -ґnumber of pixels to horizontal move the control + * @param dy - number of pixels to vertical move the control + * @param dw - number of pixels to horizontal resize the control + * @param dh - number of pixels to vertical resize the control + * + * @return nothing + **/ +static FORCEINLINE VOID MoveCtrl(HWND hDlg, INT idCtrl, INT dx, INT dy, INT dw, INT dh) +{ + RECT ws; + HWND hCtrl = GetDlgItem(hDlg, idCtrl); + GetWindowRect(hCtrl, &ws); + OffsetRect(&ws, dx, dy); + MoveWindow(hCtrl, ws.left, ws.top, ws.right - ws.left + dw, ws.bottom - ws.top + dh, FALSE); +} + +/** + * This function loads the icon to display for the current message. + * + * @param pMsgBox - pointer to a MSGBOX structure, with information about the message to display. + * + * @retval HICON - The function returns an icon to display with the message. + * @retval NULL - There is no icon for the message. + **/ +HICON MsgLoadIcon(LPMSGBOX pMsgBox) +{ + HICON hIcon; + + // load the desired status icon + switch (pMsgBox->uType & MB_ICONMASK) + { + + // custom icon defined by caller function + case MB_ICON_OTHER: + { + hIcon = pMsgBox->hiMsg; + } + break; + + // default windows icons + case MB_ICON_ERROR: + case MB_ICON_QUESTION: + case MB_ICON_WARNING: + case MB_ICON_INFO: + { + LPCTSTR ico[] = { 0, IDI_ERROR, IDI_QUESTION, IDI_WARNING, IDI_INFORMATION }; + hIcon = LoadIcon(NULL, ico[MB_ICON_INDEX(pMsgBox->uType)]); + } + break; + + // no icon + default: + { + hIcon = NULL; + } + } + return hIcon; +} + +/** + * This function fills a given POPUPACTION structure with the data of a given message id, + * which is normally used by the message box. This is required to let the user interact + * with a popup in the same way as with a normal message dialog box. + * + * @param pa - reference to a POPUPACTION structure to fill + * @param id - the message id + * @param result - This parameter is passed to the POPUPACTION structure as is. + * + * @return nothing + **/ +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 IDOK: + { + pa.lchIcon = IcoLib_GetIcon(ICO_BTN_OK); + mir_strcpy(pa.lpzTitle, MODNAME"/Ok"); + } + break; + + case IDCLOSE: + case IDCANCEL: + { + pa.lchIcon = IcoLib_GetIcon(ICO_BTN_CANCEL); + mir_strcpy(pa.lpzTitle, MODNAME"/Cancel"); + } + break; + + case IDABORT: + { + pa.lchIcon = IcoLib_GetIcon(ICO_BTN_CANCEL); + mir_strcpy(pa.lpzTitle, MODNAME"/Abort"); + } + break; + + case IDRETRY: + { + pa.lchIcon = IcoLib_GetIcon(ICO_BTN_UPDATE); + mir_strcpy(pa.lpzTitle, MODNAME"/Retry"); + } + break; + + case IDIGNORE: + { + pa.lchIcon = IcoLib_GetIcon(ICO_BTN_OK); + mir_strcpy(pa.lpzTitle, MODNAME"/Ignore"); + } + break; + + case IDYES: + { + pa.lchIcon = IcoLib_GetIcon(ICO_BTN_OK); + mir_strcpy(pa.lpzTitle, MODNAME"/Yes"); + } + break; + + case IDNO: + { + pa.lchIcon = IcoLib_GetIcon(ICO_BTN_CANCEL); + mir_strcpy(pa.lpzTitle, MODNAME"/No"); + } + break; + + case IDHELP: + { + pa.lchIcon = IcoLib_GetIcon(ICO_BTN_CANCEL); + mir_strcpy(pa.lpzTitle, MODNAME"/Help"); + } + break; + + case IDALL: + { + pa.lchIcon = IcoLib_GetIcon(ICO_BTN_OK); + mir_strcpy(pa.lpzTitle, MODNAME"/All"); + } + break; + + case IDNONE: + { + pa.lchIcon = IcoLib_GetIcon(ICO_BTN_CANCEL); + mir_strcpy(pa.lpzTitle, MODNAME"/None"); + } + } +} + +/** + * This is the message procedure for my nice looking message box + * + * @param hDlg - window handle + * @param uMsg - message to handle + * @param wParam - message specific parameter + * @param lParam - message specific parameter + * + * @return TRUE, FALSE, IDOK, IDYES, IDALL, IDNO or IDCANCEL + **/ +INT_PTR CALLBACK MsgBoxProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + static INT retOk = IDOK; + static INT retAll = IDALL; + static INT retNon = IDNONE; + static INT retCancel = IDCANCEL; + + switch (uMsg) + { + case WM_INITDIALOG: + { + LPMSGBOX pMsgBox = (LPMSGBOX)lParam; + + if (PtrIsValid(pMsgBox)) + { + INT icoWidth = 0; + INT InfoBarHeight = 0; + HFONT hNormalFont; + + hNormalFont = (HFONT)SendDlgItemMessage(hDlg, TXT_NAME, WM_GETFONT, 0, 0); + if (pMsgBox->uType & MB_INFOBAR) + { + LOGFONT lf; + + // set bold font for name in description area + GetObject(hNormalFont, sizeof(lf), &lf); + lf.lfWeight = FW_BOLD; + hNormalFont = CreateFontIndirect(&lf); + + // set infobar's textfont + SendDlgItemMessage(hDlg, TXT_NAME, WM_SETFONT, (WPARAM)hNormalFont, 0); + + // set infobar's logo icon + SendDlgItemMessage(hDlg, ICO_DLGLOGO, STM_SETIMAGE, IMAGE_ICON, + (LPARAM)((pMsgBox->hiLogo) ? pMsgBox->hiLogo : IcoLib_GetIcon(ICO_DLG_DETAILS))); + + // anable headerbar + ShowWindow(GetDlgItem(hDlg, TXT_NAME), SW_SHOW); + ShowWindow(GetDlgItem(hDlg, ICO_DLGLOGO), SW_SHOW); + } + else + { + RECT rc; + GetClientRect(GetDlgItem(hDlg, TXT_NAME), &rc); + InfoBarHeight = rc.bottom; + + if (pMsgBox->hiLogo) + { + SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)pMsgBox->hiLogo); + } + } + + // draw the desired status icon + HICON hIcon = MsgLoadIcon(pMsgBox); + if (hIcon) + { + SendDlgItemMessage(hDlg, ICO_MSGDLG, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); + } + else + { + RECT ws; + GetWindowRect(GetDlgItem(hDlg, ICO_MSGDLG), &ws); + icoWidth = ws.right - ws.left; + ShowWindow(GetDlgItem(hDlg, ICO_MSGDLG), SW_HIDE); + } + + // resize the messagebox and reorganize the buttons + if (HDC hDC = GetDC(hDlg)) + { + POINT mpt = {0,0}; + RECT ws = {0,0,0,0}; + INT txtWidth, + txtHeight, + needX, needY; + RECT rcDlg; + SIZE ts; + LPTSTR h, rs; + + SelectObject(hDC, hNormalFont); + + for (rs = h = pMsgBox->ptszMsg, txtHeight = 0, txtWidth = 0; h; h++) + { + if (*h == '\n' || *h == '\0') + { + GetTextExtentPoint32(hDC, rs, h - rs, &ts); + if (ts.cx > txtWidth) + { + txtWidth = ts.cx; + } + txtHeight += ts.cy; + if (*h == '\0') + { + break; + } + rs = h + 1; + } + } + ReleaseDC(hDlg, hDC); + + // calc new dialog size + GetWindowRect(hDlg, &rcDlg); + GetWindowRect(GetDlgItem(hDlg, TXT_MESSAGE), &ws); + needX = txtWidth - (ws.right - ws.left) - icoWidth; + needY = max(0, txtHeight - (ws.bottom - ws.top) + 5); + rcDlg.left -= needX/2; rcDlg.right += needX/2; + rcDlg.top -= (needY-InfoBarHeight)/2; rcDlg.bottom += (needY-InfoBarHeight)/2; + + // resize dialog window + MoveWindow(hDlg, + rcDlg.left, rcDlg.top, + rcDlg.right - rcDlg.left, + rcDlg.bottom - rcDlg.top, + FALSE); + ClientToScreen(hDlg, &mpt); + + MoveCtrl(hDlg, STATIC_WHITERECT, -mpt.x, -mpt.y, needX, needY - InfoBarHeight); + MoveCtrl(hDlg, TXT_NAME, -mpt.x, -mpt.y, needX, 0); + MoveCtrl(hDlg, ICO_DLGLOGO, -mpt.x + needX, -mpt.y, 0, 0); + MoveCtrl(hDlg, ICO_MSGDLG, -mpt.x, -mpt.y - InfoBarHeight, 0, 0); + MoveCtrl(hDlg, TXT_MESSAGE, -mpt.x - icoWidth, -mpt.y - InfoBarHeight, needX, needY); + MoveCtrl(hDlg, STATIC_LINE2, -mpt.x, -mpt.y + needY - InfoBarHeight, needX, 0); + + // + // Do pushbutton positioning + // + { + RECT rcOk, rcAll, rcNone, rcCancel; + LONG okWidth, caWidth, allWidth, noneWidth, dlgMid; + + // get button rectangles + GetWindowRect(GetDlgItem(hDlg, IDOK), &rcOk); + OffsetRect(&rcOk, -mpt.x, -mpt.y + needY - InfoBarHeight); + + GetWindowRect(GetDlgItem(hDlg, IDALL), &rcAll); + OffsetRect(&rcAll, -mpt.x, -mpt.y + needY - InfoBarHeight); + + GetWindowRect(GetDlgItem(hDlg, IDNONE), &rcNone); + OffsetRect(&rcNone, -mpt.x, -mpt.y + needY - InfoBarHeight); + + GetWindowRect(GetDlgItem(hDlg, IDCANCEL), &rcCancel); + OffsetRect(&rcCancel, -mpt.x, -mpt.y + needY - InfoBarHeight); + + okWidth = rcOk.right - rcOk.left; + allWidth = rcAll.right - rcAll.left; + noneWidth = rcNone.right - rcNone.left; + caWidth = rcCancel.right - rcCancel.left; + dlgMid = (rcDlg.right - rcDlg.left) / 2; + + // load button configuration + switch (MB_TYPE(pMsgBox->uType)) + { + + case MB_OK: + { + rcOk.left = dlgMid - (okWidth / 2); + rcOk.right = rcOk.left + okWidth; + ShowWindow(GetDlgItem(hDlg, IDOK), SW_SHOW); + } + break; + + case MB_OKCANCEL: + { + retOk = IDRETRY; + SetDlgItemText(hDlg, IDOK, LPGENT("OK")); + retCancel = IDCANCEL; + SetDlgItemText(hDlg, IDCANCEL, LPGENT("Cancel")); + rcOk.left = dlgMid - okWidth - 10; + rcOk.right = rcOk.left + okWidth; + rcCancel.left = dlgMid + 10; + rcCancel.right = rcCancel.left + caWidth; + ShowWindow(GetDlgItem(hDlg, IDOK), SW_SHOW); + ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_SHOW); + } + break; + + case MB_RETRYCANCEL: + { + retOk = IDRETRY; + SetDlgItemText(hDlg, IDOK, LPGENT("Retry")); + retCancel = IDCANCEL; + SetDlgItemText(hDlg, IDCANCEL, LPGENT("Cancel")); + rcOk.left = dlgMid - okWidth - 10; + rcOk.right = rcOk.left + okWidth; + rcCancel.left = dlgMid + 10; + rcCancel.right = rcCancel.left + caWidth; + ShowWindow(GetDlgItem(hDlg, IDOK), SW_SHOW); + ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_SHOW); + } + break; + + case MB_YESNO: + { + retOk = IDYES; + SetDlgItemText(hDlg, IDOK, LPGENT("Yes")); + retCancel = IDNO; + SetDlgItemText(hDlg, IDCANCEL, LPGENT("No")); + rcOk.left = dlgMid - okWidth - 10; + rcOk.right = rcOk.left + okWidth; + rcCancel.left = dlgMid + 10; + rcCancel.right = rcCancel.left + caWidth; + ShowWindow(GetDlgItem(hDlg, IDOK), SW_SHOW); + ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_SHOW); + } + break; + + case MB_ABORTRETRYIGNORE: + { + retOk = IDABORT; + SetDlgItemText(hDlg, IDOK, LPGENT("Abord")); + retAll = IDABORT; + SetDlgItemText(hDlg, IDALL, LPGENT("Retry")); + retCancel = IDCANCEL; + SetDlgItemText(hDlg, IDCANCEL, LPGENT("Ignore")); + rcAll.left = dlgMid - (allWidth / 2); + rcAll.right = rcAll.left + allWidth; + rcOk.left = rcAll.left - okWidth - 5; + rcOk.right = rcOk.left + okWidth; + rcCancel.left = rcAll.right + 5; + rcCancel.right = rcCancel.left + caWidth; + ShowWindow(GetDlgItem(hDlg, IDOK), SW_SHOW); + ShowWindow(GetDlgItem(hDlg, IDALL), SW_SHOW); + ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_SHOW); + } + break; + + case MB_YESNOCANCEL: + { + retOk = IDYES; + SetDlgItemText(hDlg, IDOK, LPGENT("Yes")); + retAll = IDNO; + SetDlgItemText(hDlg, IDALL, LPGENT("No")); + retCancel = IDCANCEL; + SetDlgItemText(hDlg, IDCANCEL, LPGENT("Cancel")); + rcAll.left = dlgMid - (allWidth / 2); + rcAll.right = rcAll.left + allWidth; + rcOk.left = rcAll.left - okWidth - 5; + rcOk.right = rcOk.left + okWidth; + rcCancel.left = rcAll.right + 5; + rcCancel.right = rcCancel.left + caWidth; + ShowWindow(GetDlgItem(hDlg, IDOK), SW_SHOW); + ShowWindow(GetDlgItem(hDlg, IDALL), SW_SHOW); + ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_SHOW); + } + break; + + case MB_YESALLNO: + { + retOk = IDYES; + SetDlgItemText(hDlg, IDOK, LPGENT("Yes")); + retAll = IDALL; + SetDlgItemText(hDlg, IDALL, LPGENT("All")); + //retNon = IDNONE; + SetDlgItemText(hDlg, IDNONE, LPGENT("None")); + retCancel = IDNO; + SetDlgItemText(hDlg, IDCANCEL, LPGENT("No")); + rcCancel.right = rcDlg.right - rcDlg.left - 10; + rcCancel.left = rcCancel.right - caWidth; + rcNone.right = rcCancel.left - 5; + rcNone.left = rcNone.right - noneWidth; + rcAll.right = rcNone.left - 5; + rcAll.left = rcAll.right - allWidth; + rcOk.right = rcAll.left - 5; + rcOk.left = rcOk.right - okWidth; + // show buttons + ShowWindow(GetDlgItem(hDlg, IDOK), SW_SHOW); + ShowWindow(GetDlgItem(hDlg, IDALL), SW_SHOW); + ShowWindow(GetDlgItem(hDlg, IDNONE), SW_SHOW); + ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_SHOW); + } + break; + + default: + { + rcOk.left = dlgMid - (okWidth / 2); + rcOk.right = rcOk.left + okWidth; + } + } + // move ok button + MoveWindow(GetDlgItem(hDlg, IDOK), + rcOk.left, rcOk.top, + rcOk.right - rcOk.left, rcOk.bottom - rcOk.top, + FALSE); + // move all button + MoveWindow(GetDlgItem(hDlg, IDALL), + rcAll.left, rcAll.top, + rcAll.right - rcAll.left, rcAll.bottom - rcAll.top, + FALSE); + // move none button + MoveWindow(GetDlgItem(hDlg, IDNONE), + rcNone.left, rcNone.top, + rcNone.right - rcNone.left, rcNone.bottom - rcNone.top, + FALSE); + // move cancel button + MoveWindow(GetDlgItem(hDlg, IDCANCEL), + rcCancel.left, rcCancel.top, + rcCancel.right - rcCancel.left, rcCancel.bottom - rcCancel.top, + FALSE); + } // end* Do pushbutton positioning + } // end* resize the messagebox and reorganize the buttons + + TranslateDialogDefault(hDlg); + + // set text's + SetWindowText(hDlg, pMsgBox->ptszTitle); + SetDlgItemText(hDlg, TXT_NAME, pMsgBox->ptszInfoText); + SetDlgItemText(hDlg, TXT_MESSAGE, pMsgBox->ptszMsg); + + return TRUE; + } // end* PtrIsValid(pMsgBox) + } // end* WM_INITDIALOG: + break; + + case WM_CTLCOLORSTATIC: + { + switch (GetWindowLong((HWND)lParam, GWL_ID)) + { + case STATIC_WHITERECT: + case ICO_DLGLOGO: + case ICO_MSGDLG: + case TXT_MESSAGE: + case TXT_NAME: + { + SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT)); + return GetSysColor(COLOR_WINDOW); + } + } + } + break; + + case WM_COMMAND: + { + switch (LOWORD(wParam)) + { + case IDOK: + EndDialog(hDlg, retOk); + break; + case IDCANCEL: + EndDialog(hDlg, retCancel); + break; + case IDALL: + EndDialog(hDlg, retAll); + break; + case IDNONE: + EndDialog(hDlg, retNon); + } + } + break; + + case WM_DESTROY: + { + DeleteObject((HFONT)SendDlgItemMessage(hDlg, TXT_NAME, WM_GETFONT, 0, 0)); + } + break; + } + return FALSE; +} + + +/** + * Dummi modal MsgBox for popup, + * this set call function in wait stait and do not freece miranda main thread + * the window is outside the desktop + */ +INT_PTR CALLBACK MsgBoxPop(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch (uMsg) + { + case WM_INITDIALOG: + { + POPUPDATAT_V2 pd; + LPMSGPOPUPDATA pmpd; + LPMSGBOX pMsgBox = (LPMSGBOX)lParam; + + MoveWindow(hDlg,-10,-10,0,0,FALSE); + pmpd = (LPMSGPOPUPDATA)mir_alloc(sizeof(MSGPOPUPDATA)); + if (pmpd) + { + ZeroMemory(&pd, sizeof(pd)); + pd.cbSize = sizeof(POPUPDATAT); + pd.lchContact = NULL; //(HANDLE)wParam; + // icon + pd.lchIcon = MsgLoadIcon(pMsgBox); + mir_tcsncpy(pd.lptzContactName, pMsgBox->ptszTitle, SIZEOF(pd.lptzContactName)); + mir_tcsncpy(pd.lptzText, pMsgBox->ptszMsg, SIZEOF(pd.lptzText)); + + // CALLBAC Proc + pd.PluginWindowProc = (WNDPROC)PopupProc; + // + pd.PluginData = pmpd; + + pd.iSeconds = -1; + + pd.hNotification = NULL; + pd.lpActions = pmpd->pa; + + // set color of popup + switch (pMsgBox->uType & MB_ICONMASK) + { + case MB_ICON_ERROR: + { + pd.colorBack = RGB(200, 10, 0); + pd.colorText = RGB(255, 255, 255); + } + break; + + case MB_ICON_WARNING: + { + pd.colorBack = RGB(200, 100, 0); + pd.colorText = RGB(255, 255, 255); + } + break; + + default: + { + if (pMsgBox->uType & MB_CUSTOMCOLOR) + { + pd.colorBack = pMsgBox->colorBack; + pd.colorText = pMsgBox->colorText; + } + } + } + + // handle for MakePopupAction + pmpd->hDialog = hDlg; + + // active buttons + switch (MB_TYPE(pMsgBox->uType)) + { + case MB_OK: + { + MakePopupAction(pmpd->pa[pd.actionCount++], IDOK); + } + break; + + case MB_OKCANCEL: + { + MakePopupAction(pmpd->pa[pd.actionCount++], IDOK); + MakePopupAction(pmpd->pa[pd.actionCount++], IDCANCEL); + } + break; + + case MB_RETRYCANCEL: + { + MakePopupAction(pmpd->pa[pd.actionCount++], IDRETRY); + MakePopupAction(pmpd->pa[pd.actionCount++], IDCANCEL); + } + break; + + case MB_YESNO: + { + MakePopupAction(pmpd->pa[pd.actionCount++], IDYES); + MakePopupAction(pmpd->pa[pd.actionCount++], IDNO); + } + break; + + case MB_ABORTRETRYIGNORE: + { + MakePopupAction(pmpd->pa[pd.actionCount++], IDABORT); + MakePopupAction(pmpd->pa[pd.actionCount++], IDRETRY); + MakePopupAction(pmpd->pa[pd.actionCount++], IDIGNORE); + } + break; + + case MB_YESNOCANCEL: + { + MakePopupAction(pmpd->pa[pd.actionCount++], IDYES); + MakePopupAction(pmpd->pa[pd.actionCount++], IDNO); + MakePopupAction(pmpd->pa[pd.actionCount++], IDCANCEL); + } + break; + + case MB_YESALLNO: + { + MakePopupAction(pmpd->pa[pd.actionCount++], IDYES); + MakePopupAction(pmpd->pa[pd.actionCount++], IDALL); + MakePopupAction(pmpd->pa[pd.actionCount++], IDNO); + } + break; + + } // end* switch + + // create popup + CallService(MS_POPUP_ADDPOPUPT, (WPARAM) &pd, APF_NEWDATA); + if (MB_TYPE(pMsgBox->uType) == MB_OK) + { + EndDialog(hDlg, IDOK); + } + } // end*if (pmpd) + break; + } // end* WM_INITDIALOG: + } // end* switch (uMsg) + return FALSE; +} + +/** + * This is the message procedure for popup + * + * @param hDlg - window handle + * @param uMsg - message to handle + * @param wParam - message specific parameter + * @param lParam - message specific parameter + * + * @return TRUE, FALSE, IDOK, IDYES, IDALL, IDNO or IDCANCEL + **/ +INT_PTR CALLBACK PopupProc(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 IDOK: + case IDCANCEL: + case IDABORT: + case IDRETRY: + case IDIGNORE: + case IDYES: + case IDNO: + case IDALL: + case IDNONE: + { + if (IsWindow(pmpd->hDialog)) + EndDialog(pmpd->hDialog, LOWORD(wParam)); + } + break; + + default: + { + if (IsWindow(pmpd->hDialog)) + EndDialog(pmpd->hDialog, IDCANCEL); + } + } + } + PUDeletePopUp(hDlg); + } + } + break; + + case UM_FREEPLUGINDATA: + { + LPMSGPOPUPDATA pmpd = (LPMSGPOPUPDATA)PUGetPluginData(hDlg); + if (pmpd > 0) { + mir_freeAndNil(pmpd); + } + return TRUE; //TRUE or FALSE is the same, it gets ignored. + } + break; + + default: + break; + } + return DefWindowProc(hDlg, uMsg, wParam, lParam); +} + +/** + * This is the service function for external plugins to use the nice messagebox + * + * @param wParam - HANDLE hContact which can display an avatar for popups + * @param lParam - MSGBOX structure holding parameters + * + * @return The function returns the ID of the clicked button (IDOK, IDCANCEL, ...) + * or -1 on error. + **/ +INT_PTR MsgBoxService(WPARAM wParam, LPARAM lParam) +{ + INT rc = -1; + LPMSGBOX pMsgBox = (LPMSGBOX)lParam; + + // check input + if (PtrIsValid(pMsgBox) && pMsgBox->cbSize == sizeof(MSGBOX)) + { + // Shall the MessageBox displayed as popup? + if (!(pMsgBox->uType & (MB_INFOBAR|MB_NOPOPUP)) && // message box can be a popup? + ServiceExists(MS_POPUP_ADDPOPUPT) && // popups exist? + myGlobals.PopUpActionsExist == 1 && // popup support ext stuct? + (DBGetContactSettingDword(NULL, "PopUp","Actions", 0) & 1) && // popup++ actions on? + DBGetContactSettingByte(NULL, MODNAME, SET_POPUPMSGBOX, DEFVAL_POPUPMSGBOX) // user likes popups? + ) + { + rc = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_MSGBOXDUMMI), pMsgBox->hParent, (DLGPROC)MsgBoxPop, lParam); + } + else + { + rc = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_MSGBOX), pMsgBox->hParent, (DLGPROC)MsgBoxProc, lParam); + } + } + return rc; +} + +/** + * name: MsgBox + * desc: calls a messagebox + * param: + **/ +INT_PTR MsgBox(HWND hParent, UINT uType, LPTSTR pszTitle, LPTSTR pszInfo, LPTSTR pszFormat, ...) +{ + MSGBOX mb = {0}; + TCHAR tszMsg[MAX_SECONDLINE]; + va_list vl; + + va_start(vl, pszFormat); + mir_vsntprintf(tszMsg, SIZEOF(tszMsg), TranslateTS(pszFormat), vl); + va_end(vl); + + mb.cbSize = sizeof(MSGBOX); + mb.hParent = hParent; + mb.hiLogo = LoadIcon(hInst, MAKEINTRESOURCE(IDI_PLUG_MAIN)); + mb.hiMsg = NULL; + mb.ptszTitle = TranslateTS(pszTitle); + mb.ptszInfoText = TranslateTS(pszInfo); + mb.ptszMsg = tszMsg; + mb.uType = uType; + return MsgBoxService(NULL, (LPARAM)&mb); +} + +/** + * name: MsgErr + * desc: calls a messagebox + * param: + **/ +INT_PTR MsgErr(HWND hParent, LPCTSTR pszFormat, ...) +{ + if(!pszFormat) return -1; + MSGBOX mb = {0}; + TCHAR tszTitle[MAX_SECONDLINE]; + TCHAR tszMsg[MAX_SECONDLINE]; + va_list vl; + + mir_sntprintf(tszTitle, SIZEOF(tszMsg),_T("%s - %s") ,_T(MODNAME), TranslateT("Error")); + + va_start(vl, pszFormat); + mir_vsntprintf(tszMsg, SIZEOF(tszMsg), TranslateTS(pszFormat), vl); + va_end(vl); + + mb.cbSize = sizeof(MSGBOX); + mb.hParent = hParent; + mb.hiLogo = LoadIcon(hInst, MAKEINTRESOURCE(IDI_PLUG_MAIN)); + mb.hiMsg = NULL; + mb.ptszTitle = tszTitle; + mb.ptszMsg = tszMsg; + mb.uType = MB_OK|MB_ICON_ERROR; + return MsgBoxService(NULL, (LPARAM)&mb); +} diff --git a/plugins/SendScreenshotPlus/src/dlg_msgbox.h b/plugins/SendScreenshotPlus/src/dlg_msgbox.h new file mode 100644 index 0000000000..a6cd04c6b7 --- /dev/null +++ b/plugins/SendScreenshotPlus/src/dlg_msgbox.h @@ -0,0 +1,108 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +aLONG with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $HeadURL: https://userinfoex.googlecode.com/svn/trunk/dlg_msgbox.h $ +Revision : $Revision: 164 $ +Last change on : $Date: 2009-12-02 21:24:35 +0100 (Mi, 02. Dez 2009) $ +Last change by : $Author: ing.u.horn $ + +*/ + +#ifndef _DLG_MSGBOX +#define _DLG_MSGBOX 1 + +//--------------------------------------------------------------------------- +#include "global.h" + +//--------------------------------------------------------------------------- +#define SET_POPUPMSGBOX "PopupMsgBox" +#define DEFVAL_POPUPMSGBOX TRUE //FALSE + +/* UserInfo/MsgBox v0.1.0.3+ +Some little changed message box for nicer look of miranda's messages or questions :-) +wParam=hContact - can be null +lParam=(_MSGBOX*)pMsg - structure that holds information about the look of the message dialog +uType member of _MSGBOX can be a combination of the following values, where most of them are defined in winuser.h: +MB_OK +MB_OKCANCEL +MB_YESALLNO +MB_YESNO +For valid icon values use one of the following MB_ICON_... +Funktion returns: IDOK, IDYES, IDALL, IDNO or IDCANCEL +*/ + +/* + Defined in winuser.h + ******************** + +#define MB_OK 0x00000000L +#define MB_OKCANCEL 0x00000001L +#define MB_ABORTRETRYIGNORE 0x00000002L +#define MB_YESNOCANCEL 0x00000003L +#define MB_YESNO 0x00000004L +#define MB_RETRYCANCEL 0x00000005L +*/ +#define MB_YESALLNO 0x00000007L +#define MB_TYPE(p) ((p)&MB_TYPEMASK) + +/* +valid predefined icon values +*/ +#define MB_ICON_NONE 0x00000000L // 0 - no icon +#define MB_ICON_ERROR 0x00000010L // 16 - error icon +#define MB_ICON_QUESTION 0x00000020L // 32 - question mark +#define MB_ICON_WARNING 0x00000030L // 48 - warning +#define MB_ICON_INFO 0x00000040L // 64 - info +#define MB_ICON_OTHER 0x00000080L // 240 - use icon _MSGBOX->hiMsg +#define MB_ICON_INDEX(p) (((p)&MB_ICONMASK)>>4) + +/* +flags +*/ +#define MB_INFOBAR 0x00000100L +#define MB_NOPOPUP 0x00000200L +#define MB_CUSTOMCOLOR 0x00000300L + +typedef struct _MSGBOX +{ + UINT cbSize; // size of this structure + UINT uType; // parameters + HICON hiLogo; // right upper icon of the info bar + HICON hiMsg; // icon left next to the message text + LPTSTR ptszTitle; + LPTSTR ptszInfoText; + LPTSTR ptszMsg; + HWND hParent; // parent window for the messagebox + COLORREF colorBack; // valid if MB_CUSTOMCOLOR is set + COLORREF colorText; // valid if MB_CUSTOMCOLOR is set +} MSGBOX, *LPMSGBOX; + + +INT_PTR CALLBACK MsgBoxProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK MsgBoxPop (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK PopupProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); + +INT_PTR MsgBoxService(WPARAM wParam, LPARAM lParam); +INT_PTR MsgBox(HWND hParent, UINT uType, LPTSTR pszTitle, LPTSTR pszInfo, LPTSTR pszFormat, ...); +INT_PTR MsgErr(HWND hParent, LPCTSTR pszFormat, ...); + +#endif /* _DLG_MSGBOX */ \ No newline at end of file diff --git a/plugins/SendScreenshotPlus/src/global.h b/plugins/SendScreenshotPlus/src/global.h new file mode 100644 index 0000000000..48586f83d3 --- /dev/null +++ b/plugins/SendScreenshotPlus/src/global.h @@ -0,0 +1,189 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* +Copyright 2000-2009 Miranda ICQ/IM project, + +This file is part of Send Screenshot Plus, a Miranda IM plugin. +Copyright (c) 2010 Ing.U.Horn + +Parts of this file based on original sorce code +(c) 2004-2006 Sйrgio Vieira Rolanski (portet from Borland C++) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/global.h $ +Revision : $Revision: 22 $ +Last change on : $Date: 2010-05-02 21:25:02 +0400 (Р’СЃ, 02 май 2010) $ +Last change by : $Author: ing.u.horn $ + +*/ + +#ifndef _GLOBAL_H_ +#define _GLOBAL_H_ + +#define WINVER 0x0700 +#define _WIN32_WINNT 0x0700 +#define _WIN32_IE 0x0601 + +#define OEMRESOURCE +#define MIRANDA_VER 0x0A00 + +// Windows includes +#include +#include + +// Standard includes +#include +//#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; + +// Miranda IM SDK includes +#include +#include +#include +#include // This must be included first +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// plugins SDK +#include +#include +#include +#include +#include "icons.h" //from uiex icon pack + +// Project resources +#include "m_sendss.h" +#include "mir_string.h" +#include "mir_icolib.h" +#include "ctrl_button.h" +#include "dlg_msgbox.h" +#include "resource.h" +#include "version.h" + +#ifdef ComboBox_SelectItemData + // use Workaround for MS bug ComboBox_SelectItemData; + #undef ComboBox_SelectItemData +#endif + +#define UM_CLOSING WM_USER+1 +#define UM_EVENT WM_USER+2 +#define UM_TAB1 WM_USER+11 + +// Generic Message Box for Errors +#define MSGERROR(text) MessageBox(NULL, text, _T("SendSS"), MB_OK | MB_ICONERROR) +#define MSGINFO (text) MessageBox(NULL, text, _T("SendSS"), MB_OK | MB_ICONINFORMATION) + +typedef struct _MGLOBAL { + DWORD mirandaVersion; // mirandaVersion + BOOLEAN PopUpExist : 1; // Popup or MS_POPUP_ADDPOPUP exist + BOOLEAN PopUpActionsExist : 1; // Popup++ or MS_POPUP_REGISTERACTIONS exist + BOOLEAN PluginHTTPExist : 1; // HTTPServer or MS_HTTP_ACCEPT_CONNECTIONS exist + BOOLEAN PluginFTPExist : 1; // FTPFile or MS_FTPFILE_SHAREFILE exist + +} MGLOBAL, *LPMGLOBAL; + +//--------------------------------------------------------------------------- +#define ERROR_TITLE _T("SendScreenshot - Error") + +// Miranda Database Key +#define SZ_SENDSS "SendSS" +#define MODNAME "SendSS" + +extern HINSTANCE hInst; +extern MGLOBAL myGlobals; +extern HANDLE hNetlibUser; + +#define PtrIsValid(p) (((p)!=0)&&(((HANDLE)(p))!=INVALID_HANDLE_VALUE)) + +template +std::basic_string<_Elem> replace(const std::basic_string<_Elem> & Origninal, const std::basic_string<_Elem> & What, const std::basic_string<_Elem> & With) +{ + std::basic_string<_Elem> res; + size_t l = 0; + size_t p = 0; + + for (size_t p = Origninal.find(What.c_str(), 0); p != std::basic_string<_Elem>::npos; p = Origninal.find(What.c_str(), l)) + { + if (l != p) + res.append(Origninal.c_str() + l, p - l); + res.append(With); + l = p + What.length(); + } + if (l < Origninal.length()) + res.append(Origninal.c_str() + l); + + return res; +} + +#endif + +/************************************************************* + * Uinfobuttonclass module + */ + +// button styles +#define MBS_DEFBUTTON 0x00001000L // default button +#define MBS_PUSHBUTTON 0x00002000L // toggle button +#define MBS_FLAT 0x00004000L // flat button +#define MBS_DOWNARROW 0x00008000L // has arrow on the right + +#define MBF_UNICODE 1 +#ifdef _UNICODE + #define MBF_TCHAR MBF_UNICODE +#else + #define MBF_TCHAR 0 +#endif + +// BUTTONADDTOOLTIP +// use lParam=MBF_UNICODE to set unicode tooltips +// for lParam=0 the string is interpreted as ansi + +// message to explicitly translate the buttons text, +// as it is not done by default translation routine +// wParam=lParam=NULL +#define BUTTONTRANSLATE (WM_USER+6) + +/* UserInfo/MsgBox v0.1.0.4+ +Slightly modified version of MButtonClass, to draw both text and icon in a button control +*/ +#define UINFOBUTTONCLASS _T("UInfoButtonClass") + diff --git a/plugins/SendScreenshotPlus/src/icons.h b/plugins/SendScreenshotPlus/src/icons.h new file mode 100644 index 0000000000..46871836bd --- /dev/null +++ b/plugins/SendScreenshotPlus/src/icons.h @@ -0,0 +1,112 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by uinfoex_icons.rc +// +#define IDI_FIRST_ICON 101 + +// dialog inforbar +#define IDI_DLG_DETAILS 101 +#define IDI_DLG_PHONE 102 +#define IDI_DLG_EMAIL 103 + +// dialog infobar & buttons +#define IDI_ANNIVERSARY 104 +#define IDI_EXPORT 105 +#define IDI_IMPORT 106 +#define IDI_SEARCH 107 + +// common icons of details dialog pages +#define IDI_MIRANDA 108 +#define IDI_PASSWORD 109 +#define IDI_FEMALE 110 +#define IDI_MALE 111 +#define IDI_CLOCK 112 +#define IDI_MARITAL 113 + +// commonly used buttons +#define IDI_BTN_UPDATE 114 +#define IDI_BTN_OK 115 +#define IDI_BTN_CLOSE 116 +#define IDI_BTN_APPLY 117 +#define IDI_BTN_GOTO 118 +#define IDI_BTN_PHONE 119 +#define IDI_BTN_FAX 120 +#define IDI_BTN_CELLULAR 121 +#define IDI_BTN_CUSTOMPHONE 122 +#define IDI_BTN_EMAIL 123 +#define IDI_BTN_DOWNARROW 124 +#define IDI_BTN_ADD 125 +#define IDI_BTN_EDIT 126 +#define IDI_BTN_DELETE 127 +#define IDI_BTN_EXIMPORT 128 +#define IDI_BTN_BIRTHDAY_BACKUP 129 + +// details treeview icons +#define IDI_TREE_GENERAL 130 +#define IDI_TREE_ADVANCED 131 +#define IDI_TREE_COMPANY 132 +#define IDI_TREE_CONTACT 133 +#define IDI_TREE_ABOUT 134 +#define IDI_TREE_PHOTO 135 +#define IDI_TREE_ADDRESS 136 +#define IDI_TREE_NOTES 137 +#define IDI_TREE_PROFILE 138 + +// export: choose modules +#define IDI_LST_MODULES 139 +#define IDI_LST_FOLDER 140 + +// zodiac icons +#define IDI_ZOD_AQUARIUS 141 +#define IDI_ZOD_ARIES 142 +#define IDI_ZOD_CANCER 143 +#define IDI_ZOD_CAPRICORN 144 +#define IDI_ZOD_GEMINI 145 +#define IDI_ZOD_LEO 146 +#define IDI_ZOD_LIBRA 147 +#define IDI_ZOD_PISCES 148 +#define IDI_ZOD_SAGITTARIUS 149 +#define IDI_ZOD_SCORPIO 150 +#define IDI_ZOD_TAURUS 151 +#define IDI_ZOD_VIRGO 152 + +// reminder +#define IDI_BIRTHDAY 153 +#define IDI_RMD_DTB0 154 +#define IDI_RMD_DTB1 155 +#define IDI_RMD_DTB2 156 +#define IDI_RMD_DTB3 157 +#define IDI_RMD_DTB4 158 +#define IDI_RMD_DTB5 159 +#define IDI_RMD_DTB6 160 +#define IDI_RMD_DTB7 161 +#define IDI_RMD_DTB8 162 +#define IDI_RMD_DTB9 163 +#define IDI_RMD_DTBX 164 +#define IDI_RMD_DTA0 165 +#define IDI_RMD_DTA1 166 +#define IDI_RMD_DTA2 167 +#define IDI_RMD_DTA3 168 +#define IDI_RMD_DTA4 169 +#define IDI_RMD_DTA5 170 +#define IDI_RMD_DTA6 171 +#define IDI_RMD_DTA7 172 +#define IDI_RMD_DTA8 173 +#define IDI_RMD_DTA9 174 +#define IDI_RMD_DTAX 175 + +#define IDI_LASTICON 175 + +// version text +#define IDS_ICOPACKVERSION 1001 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 1002 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/plugins/SendScreenshotPlus/src/mir_icolib.cpp b/plugins/SendScreenshotPlus/src/mir_icolib.cpp new file mode 100644 index 0000000000..33718faf98 --- /dev/null +++ b/plugins/SendScreenshotPlus/src/mir_icolib.cpp @@ -0,0 +1,382 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +aLONG with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +this file is taken from UserinfoEx plugin and support UserinfoEx icon pack !!!! + +*/ + +#include "global.h" + + +typedef struct _ICODESC +{ + LPSTR pszName; + LPSTR pszDesc; + LPSTR pszSection; + BOOL bfromIconPack; + WORD idResource; + BYTE size; +} ICODESC; + +HICON ghDefIcon = NULL; + +//IDI_PLUG_MAIN must be the first icon from Plugin.dll, all other icon must be IDI_PLUG_MAIN+n +static ICODESC icoDesc[] = +{ + // common + { ICO_PLUG_SSWINDOW1, "Screenshot Icon1", SECT_COMMON, 0, IDI_PLUG_MAIN, -1 }, + { ICO_PLUG_SSWINDOW2, "Screenshot Icon2", SECT_COMMON, 0, IDI_PLUG_ICON1, 0 }, + { ICO_PLUG_SSTARGET, "Target Cursor", SECT_COMMON, 0, IDI_PLUG_ICON2, 1 }, + { ICO_PLUG_SSMONITOR, "Target Desktop", SECT_COMMON, 0, IDI_PLUG_ICON3, 1 }, + { ICO_PLUG_SSDEFAULT, "Default", SECT_COMMON, 0, IDI_PLUG_DEFAULT, 0 }, + + // overlays + { ICO_PLUG_OVERLAYON, "overlay on", SECT_OVERLAY, 0, IDI_PLUG_OVERLAYON, 0 }, + { ICO_PLUG_OVERLAYOFF, "overlay off", SECT_OVERLAY, 0, IDI_PLUG_OVERLAYOFF,0 }, + + // dialogs +// { ICO_DLG_DETAILS, "Details Infobar", SECT_DLG, 1, IDI_DLG_DETAILS, 48 }, +// { ICO_DLG_PHONE, "Phone Infobar", SECT_DLG, 1, IDI_DLG_PHONE, 1 }, +// { ICO_DLG_EMAIL, "E-Mail Infobar", SECT_DLG, 1, IDI_DLG_EMAIL, 1 }, + + // button icons + { ICO_PLUG_SSHELP, "Help", SECT_BUTTONS, 0, IDI_PLUG_HELP, 0 }, + { ICO_PLUG_SSFOLDERO, "Open Folder", SECT_BUTTONS, 0, IDI_PLUG_FOLDERO, 0 }, + { ICO_PLUG_SSDESKOFF, "description off", SECT_BUTTONS, 0, IDI_PLUG_DESKOFF, 0 }, + { ICO_PLUG_SSDESKON, "description on", SECT_BUTTONS, 0, IDI_PLUG_DESKON, 0 }, + { ICO_PLUG_SSDELOFF, "delete off", SECT_BUTTONS, 0, IDI_PLUG_DELOFF, 0 }, + { ICO_PLUG_SSDELON, "delete on", SECT_BUTTONS, 0, IDI_PLUG_DELON, 0 }, + { ICO_PLUG_ARROWL, "Prev", SECT_BUTTONS, 0, IDI_PLUG_ARROWL, 0 }, + { ICO_PLUG_ARROWR, "Next", SECT_BUTTONS, 0, IDI_PLUG_ARROWR, 0 }, + + { ICO_BTN_UPDATE, "Update", SECT_BUTTONS, 1, IDI_BTN_UPDATE, 0 }, + { ICO_BTN_OK, "Ok", SECT_BUTTONS, 1, IDI_BTN_OK, 0 }, + { ICO_BTN_CANCEL, "Cancel", SECT_BUTTONS, 1, IDI_BTN_CLOSE, 0 }, + { ICO_BTN_APPLY, "Apply", SECT_BUTTONS, 1, IDI_BTN_APPLY, 0 }, +// { ICO_BTN_GOTO, "Goto", SECT_BUTTONS, 1, IDI_BTN_GOTO, 0 }, +// { ICO_BTN_EMAIL, "e-mail", SECT_BUTTONS, 1, IDI_BTN_EMAIL, 0 }, +// { ICO_BTN_DOWNARROW, "Down arrow", SECT_BUTTONS, 1, IDI_BTN_DOWNARROW, 0 }, +// { ICO_BTN_ADD, "Add", SECT_BUTTONS, 1, IDI_BTN_ADD, 0 }, + { ICO_BTN_EDIT, "Edit", SECT_BUTTONS, 1, IDI_BTN_EDIT, 0 }, +// { ICO_BTN_DELETE, "Delete", SECT_BUTTONS, 1, IDI_BTN_DELETE, 0 }, +// { ICO_BTN_SEARCH, "Search", SECT_BUTTONS, 1, IDI_SEARCH, 0 }, +// { ICO_BTN_YES, "Yes", SECT_BUTTONS, 1, IDI_BTN_YES, 0 }, +// { ICO_BTN_NO, "No", SECT_BUTTONS, 1, IDI_BTN_NO, 0 }, +// { ICO_BTN_IGNORE, "Ignore", SECT_BUTTONS, 1, IDI_BTN_IGNORE, 0 }, + +}; + +/** + * This function finds the default iconpack file and return its path. + * + * @param - none + * + * @return This function returns the relative path to an existing icon pack. + **/ +LPTSTR IcoLib_GetDefaultIconFileName() +{ + static LPTSTR path[] = { + _T("Icons\\uinfoex_icons.dll"), + _T("Plugins\\uinfoex_icons.dll"), + _T("Customize\\Icons\\uinfoex_icons.dll") + }; + TCHAR absolute[MAX_PATH]; + + for (INT i = 0; i < SIZEOF(path); i++) + { + CallService(MS_UTILS_PATHTOABSOLUTET, (WPARAM)path[i], (LPARAM)absolute); + if (PathFileExists(absolute)) + { + return path[i]; + } + } + return NULL; +} + +/** + * This function checks the version of an iconpack. + * If the icon pack's version differs from the desired one, + * dialog with a warning is displayed. + * + * @param szIconPack - This is the path to the icon pack. + * It can be absolute or relative. + * + * @return nothing + **/ +static VOID IcoLib_CheckIconPackVersion(LPTSTR szIconPack) +{ + //if (DB::Setting::GetByte(SET_ICONS_CHECKFILEVERSION, TRUE)) + if (DBGetContactSettingByte(NULL,MODNAME,SET_ICONS_CHECKFILEVERSION, TRUE)) + { + if (szIconPack) + { + TCHAR szAbsolutePath[MAX_PATH]; + HMODULE hIconDll; + + CallService(MS_UTILS_PATHTOABSOLUTET, (WPARAM)szIconPack, (LPARAM)szAbsolutePath); + + hIconDll = LoadLibrary(szAbsolutePath); + if (hIconDll) + { + CHAR szFileVersion[64]; + + if (!LoadStringA(hIconDll, IDS_ICOPACKVERSION, szFileVersion, sizeof(szFileVersion)) || + mir_strcmp(szFileVersion, "__UserInfoEx_IconPack_1.2__")) + { + MsgErr(NULL, LPGENT("Warning: Your current IconPack's version differs from the one UserInfoEx is designed for.\nSome icons may not be displayed correctly")); + } + FreeLibrary(hIconDll); + } + } + else + { + MsgErr(NULL, LPGENT("Warning: No IconPack found in one of the following directories: 'customize\\icons', 'icons' or 'plugins'!")); + } + } +} + +/** + * Returns a icon, identified by a name + * + * @param pszIcon - name of the icon + * + * @return: HICON if the icon is loaded, NULL otherwise + **/ +HICON IcoLib_GetIcon(LPCSTR pszIcon, bool big) +{ + return (pszIcon) ? (HICON)CallService(MS_SKIN2_GETICON, (WPARAM)big, (LPARAM) pszIcon) : NULL; +} + +/** + * Returns a icon, identified by a name + * + * @param hIconItem - this is the pointer to an IconItem structure in icolib. + * + * @return: HICON if the icon is loaded, NULL otherwise + **/ +HICON IcoLib_GetIconByHandle(HANDLE hIconItem, bool big) +{ + return (HICON)CallService(MS_SKIN2_GETICONBYHANDLE, (WPARAM)big, (LPARAM) hIconItem); +} + +/** + * Set the icon of each control in the list + * + * @param hDlg - handle to the dialog control, that owns the controls + * @param pCtrl - list to all controls and its icon names + * @param numCtrls - number of elements in the pCtrl list + * + * @return nothing + **/ +VOID IcoLib_SetCtrlIcons(HWND hDlg, const ICONCTRL* pCtrl, BYTE numCtrls) +{ + HICON hIcon; + BYTE i; + HWND hCtrl; + + for (i = 0; i < numCtrls; i++) + { + hIcon = IcoLib_GetIcon(pCtrl[i].pszIcon); + if (pCtrl[i].idCtrl) + { + hCtrl = GetDlgItem(hDlg, pCtrl[i].idCtrl); + switch (pCtrl[i].Message) + { + case STM_SETICON: + case STM_SETIMAGE: + { + ShowWindow(hCtrl, hIcon ? SW_SHOW : SW_HIDE); + } + case BM_SETIMAGE: + { + SendMessage(hCtrl, pCtrl[i].Message, IMAGE_ICON, (LPARAM) hIcon); + } + } + } + else + { + SendMessage(hDlg, pCtrl[i].Message, ICON_BIG, (LPARAM) hIcon); + } + } +} + +/** + * This function manually registers a single icon from the default icon library. + * + * @param szIconID - This is the uniquely identifying string for an icon. + * This string is the setting name in the database and should + * only use ASCII characters. + * @param szDescription - This is the description displayed in the options dialog. + * @param szSection - This is the subsection, where the icon is organized in the options dialog. + * @param szDefaultFile - This is the validated path to the default icon file. + * @param idIcon - This is the ResourceID of the icon in the default file. + * @param Size - This is the desired size of the icon to load. + * 0: default size for small icons (16x16) + * 1: default size for normal icons (32x32) + * @param hDefIcon - This is the default icon to use if the default icon + * file does not exist and no custom icon is set up in the config. + * + * @return This function returns the HANDLE of the icon item. + **/ +static HANDLE IcoLib_RegisterIconHandleEx(LPSTR szIconID, LPSTR szDescription, LPSTR szSection, LPTSTR szDefaultFile, INT idIcon, INT Size, HICON hDefIcon) +{ + HANDLE hIconHandle = NULL; + + if (szIconID && szDescription && szSection) + { + SKINICONDESC sid; + + ZeroMemory(&sid, sizeof(sid)); + sid.cbSize = sizeof(sid); + sid.flags = SIDF_ALL_TCHAR; + sid.pszName = szIconID; + sid.ptszDescription = mir_a2t(szDescription); + sid.ptszSection = mir_a2t(szSection); + + if (sid.ptszDescription && sid.ptszSection) + { + switch (Size) + { + // small and big icons + case -1: + { + sid.cx = sid.cy = 0; + break; + } + // small icons (16x16) + case 0: + { + sid.cx = GetSystemMetrics(SM_CXSMICON); + sid.cy = GetSystemMetrics(SM_CYSMICON); + break; + } + // normal icons (32x32) + case 1: + { + sid.cx = GetSystemMetrics(SM_CXICON); + sid.cy = GetSystemMetrics(SM_CYICON); + break; + } + // custom icon size + default: + { + sid.cx = sid.cy = Size; + break; + } + } + + sid.ptszDefaultFile = szDefaultFile; + if (sid.ptszDefaultFile && sid.ptszDefaultFile[0]) + { + if(idIcon < IDI_FIRST_ICON || idIcon > IDI_LASTICON) { + // Icon from Plugin.dll + sid.iDefaultIndex = idIcon - IDI_PLUG_MAIN; + } + else{ + //UserinfoEx Icon pack + sid.iDefaultIndex = ICONINDEX(idIcon); + } + } + else + { + sid.hDefaultIcon = hDefIcon; + sid.iDefaultIndex = -1; + } + hIconHandle = Skin_AddIcon(&sid); + } + mir_freeAndNil(sid.ptszDescription); + mir_freeAndNil(sid.ptszSection); + } + return hIconHandle; +} + +/** + * This function manually registers a single icon from the default icon library. + * + * @param szIconID - This is the uniquely identifying string for an icon. + * This string is the setting name in the database and should + * only use ASCII characters. + * @param szDescription - This is the description displayed in the options dialog. + * @param szSection - This is the subsection, where the icon is organized in the options dialog. + * @param idIcon - This is the ResourceID of the icon in the default file + * @param Size - This is the desired size of the icon to load. + * 0: default size for small icons (16x16) + * 1: default size for normal icons (32x32) + * + * @return This function returns the HANDLE of the icon item. + **/ +HANDLE IcoLib_RegisterIconHandle(LPSTR szIconID, LPSTR szDescription, LPSTR szSection, INT idIcon, INT Size) +{ + return IcoLib_RegisterIconHandleEx(szIconID, szDescription, szSection, IcoLib_GetDefaultIconFileName(), idIcon, Size, ghDefIcon); +} + +/** + * This function manually registers a single icon from the default icon library. + * + * @param szIconID - This is the uniquely identifying string for an icon. + * This string is the setting name in the database and should + * only use ASCII characters. + * @param szDescription - This is the description displayed in the options dialog. + * @param szSection - This is the subsection, where the icon is organized in the options dialog. + * @param idIcon - This is the ResourceID of the icon in the default file + * @param Size - This is the desired size of the icon to load. + * 0: default size for small icons (16x16) + * 1: default size for normal icons (32x32) + * + * @return This function returns the HICON of the icon itself. + **/ +HICON IcoLib_RegisterIcon(LPSTR szIconID, LPSTR szDescription, LPSTR szSection, INT idIcon, INT Size) +{ + return IcoLib_GetIconByHandle(IcoLib_RegisterIconHandle(szIconID, szDescription, szSection, idIcon, Size)); +} + +/** + * Add default icons to the skin library or load customized icons + * + * @param none + * + * @return nothing + **/ +VOID IcoLib_LoadModule() +{ + LPTSTR szDefaultFile; + LPTSTR szPluginFile; + INT_PTR i; + + // search for default icon file + szDefaultFile = IcoLib_GetDefaultIconFileName(); + IcoLib_CheckIconPackVersion(szDefaultFile); + + szPluginFile = _T("Plugins\\")_T(__FILENAME); + + // load default icon if required + ghDefIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_PLUG_DEFAULT), IMAGE_ICON, + GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0); + + for (i = 0; i < SIZEOF(icoDesc); i++) + { + IcoLib_RegisterIconHandleEx( + icoDesc[i].pszName, icoDesc[i].pszDesc, icoDesc[i].pszSection, + icoDesc[i].bfromIconPack ? szDefaultFile : szPluginFile, icoDesc[i].idResource, icoDesc[i].size, ghDefIcon); + } +} + diff --git a/plugins/SendScreenshotPlus/src/mir_icolib.h b/plugins/SendScreenshotPlus/src/mir_icolib.h new file mode 100644 index 0000000000..b80c014a07 --- /dev/null +++ b/plugins/SendScreenshotPlus/src/mir_icolib.h @@ -0,0 +1,139 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +aLONG with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ +#ifndef _UINFOEX_ICONS_H_INCLUDED_ +#define _UINFOEX_ICONS_H_INCLUDED_ 1 + +#include "m_icolib.h" + +// sections +#define SECT_COMMON MODNAME +#define SECT_DLG MODNAME"/Dialogs" +#define SECT_BUTTONS MODNAME"/Buttons" +#define SECT_OVERLAY MODNAME"/overlays" +#define SECT_TOOLBAR "ToolBar" // global toolbar section as used by modern clist + +// icons +#define ICO_PLUG_SSWINDOW1 MODNAME"_plug_SSwindow1" +#define ICO_PLUG_SSWINDOW2 MODNAME"_plug_SSwindow2" +#define ICO_PLUG_SSMONITOR MODNAME"_plug_SSmonitor" +#define ICO_PLUG_SSDEFAULT MODNAME"_plug_SSdefault" +#define ICO_PLUG_SSTARGET MODNAME"_plug_SSTarget" +#define ICO_PLUG_SSHELP MODNAME"_plug_SSHelp" +#define ICO_PLUG_SSFOLDERO MODNAME"_plug_SSFolderOpen" +#define ICO_PLUG_ARROWL MODNAME"_plug_SSArrowL" +#define ICO_PLUG_ARROWR MODNAME"_plug_SSArrowR" +#define ICO_PLUG_SSDESKOFF MODNAME"_plug_SSDeskOff" +#define ICO_PLUG_SSDESKON MODNAME"_plug_SSDeskOn" +#define ICO_PLUG_SSDELOFF MODNAME"_plug_SSDelOff" +#define ICO_PLUG_SSDELON MODNAME"_plug_SSDelOn" + +#define ICO_PLUG_OVERLAYOFF MODNAME"_plug_SSOverlayOff" +#define ICO_PLUG_OVERLAYON MODNAME"_plug_SSOverlayOn" + +#define ICO_COMMON_IM MODNAME"_common_im" +#define ICO_COMMON_FEMALE MODNAME"_common_female" +#define ICO_COMMON_MALE MODNAME"_common_male" +#define ICO_COMMON_CLOCK MODNAME"_common_clock" +#define ICO_COMMON_MARITAL MODNAME"_common_marital" +#define ICO_COMMON_PASSWORD MODNAME"_common_password" +#define ICO_COMMON_ADDRESS MODNAME"_common_address" +#define ICO_TREE_DEFAULT MODNAME"_tree_default" +#define ICO_DLG_DETAILS MODNAME"_dlg_details" +#define ICO_DLG_PHONE MODNAME"_dlg_phone" +#define ICO_DLG_EMAIL MODNAME"_dlg_email" +#define ICO_DLG_EXPORT MODNAME"_dlg_export" +#define ICO_DLG_IMPORT MODNAME"_dlg_import" +#define ICO_DLG_SEARCH MODNAME"_dlg_search" +#define ICO_LST_MODULES MODNAME"_lst_modules" +#define ICO_LST_FOLDER MODNAME"_lst_folder" +#define ICO_BTN_UPDATE MODNAME"_btn_update" +#define ICO_BTN_OK MODNAME"_btn_ok" +#define ICO_BTN_CANCEL MODNAME"_btn_cancel" +#define ICO_BTN_APPLY MODNAME"_btn_apply" +#define ICO_BTN_GOTO MODNAME"_btn_goto" +#define ICO_BTN_ADD MODNAME"_btn_add" +#define ICO_BTN_EDIT MODNAME"_btn_edit" +#define ICO_BTN_DELETE MODNAME"_btn_delete" +#define ICO_BTN_IMPORT MODNAME"_btn_import" +#define ICO_BTN_EXPORT MODNAME"_btn_export" +#define ICO_BTN_NOTES MODNAME"_btn_notes" +#define ICO_BTN_ABOUT MODNAME"_btn_about" +#define ICO_BTN_PROFILE MODNAME"_btn_profile" +#define ICO_BTN_DOWNARROW MODNAME"_btn_downarrow" +#define ICO_BTN_PHONE MODNAME"_btn_phone" +#define ICO_BTN_FAX MODNAME"_btn_fax" +#define ICO_BTN_CELLULAR MODNAME"_btn_cellular" +#define ICO_BTN_EMAIL MODNAME"_btn_email" +#define ICO_BTN_SEARCH MODNAME"_btn_search" +#define ICO_BTN_YES MODNAME"_btn_yes" +#define ICO_BTN_NO MODNAME"_btn_no" +#define ICO_BTN_IGNORE MODNAME"_btn_ignore" + +#define ICO_RMD_DTB0 MODNAME"_rmd_dtb0" +#define ICO_RMD_DTB1 MODNAME"_rmd_dtb1" +#define ICO_RMD_DTB2 MODNAME"_rmd_dtb2" +#define ICO_RMD_DTB3 MODNAME"_rmd_dtb3" +#define ICO_RMD_DTB4 MODNAME"_rmd_dtb4" +#define ICO_RMD_DTB5 MODNAME"_rmd_dtb5" +#define ICO_RMD_DTB6 MODNAME"_rmd_dtb6" +#define ICO_RMD_DTB7 MODNAME"_rmd_dtb7" +#define ICO_RMD_DTB8 MODNAME"_rmd_dtb8" +#define ICO_RMD_DTB9 MODNAME"_rmd_dtb9" +#define ICO_RMD_DTBX MODNAME"_rmd_dtbx" + +#define ICO_RMD_DTA0 MODNAME"_rmd_dta0" +#define ICO_RMD_DTA1 MODNAME"_rmd_dta1" +#define ICO_RMD_DTA2 MODNAME"_rmd_dta2" +#define ICO_RMD_DTA3 MODNAME"_rmd_dta3" +#define ICO_RMD_DTA4 MODNAME"_rmd_dta4" +#define ICO_RMD_DTA5 MODNAME"_rmd_dta5" +#define ICO_RMD_DTA6 MODNAME"_rmd_dta6" +#define ICO_RMD_DTA7 MODNAME"_rmd_dta7" +#define ICO_RMD_DTA8 MODNAME"_rmd_dta8" +#define ICO_RMD_DTA9 MODNAME"_rmd_dta9" +#define ICO_RMD_DTAX MODNAME"_rmd_dtax" + +#define SET_ICONS_CHECKFILEVERSION "CheckIconPackVersion" +#define SET_ICONS_BUTTONS "ButtonIcons" + +#define ICONINDEX(id) max((min((id), IDI_LASTICON)) - IDI_FIRST_ICON, 0) + +typedef struct TIconCtrl +{ + LPCSTR pszIcon; + UINT Message; + WORD idCtrl; +} ICONCTRL, *LPICONCTRL; + +LPTSTR IcoLib_GetDefaultIconFileName(); +VOID IcoLib_SetCtrlIcons(HWND hDlg, const ICONCTRL* pCtrl, BYTE numCtrls); + +HANDLE IcoLib_RegisterIconHandle(LPSTR szName, LPSTR szDescription, LPSTR szSection, INT idIcon, INT Size); +HICON IcoLib_RegisterIcon(LPSTR szName, LPSTR szDescription, LPSTR szSection, INT idIcon, INT Size); +HICON IcoLib_GetIcon(LPCSTR pszIcon, bool big = false); +HICON IcoLib_GetIconByHandle(HANDLE hIconItem, bool big = false); + +VOID IcoLib_LoadModule(); + +#endif /* _UINFOEX_ICONS_H_INCLUDED_ */ diff --git a/plugins/SendScreenshotPlus/src/mir_string.cpp b/plugins/SendScreenshotPlus/src/mir_string.cpp new file mode 100644 index 0000000000..0ee154b7b9 --- /dev/null +++ b/plugins/SendScreenshotPlus/src/mir_string.cpp @@ -0,0 +1,179 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/IM project, + +This file is part of Send Screenshot Plus, a Miranda IM plugin. +Copyright (c) 2010 Ing.U.Horn + +Parts of this file based on original sorce code +from UserInfoEx Plugin + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/mir_string.cpp $ +Revision : $Revision: 13 $ +Last change on : $Date: 2010-04-02 02:54:30 +0400 (РџС‚, 02 апр 2010) $ +Last change by : $Author: ing.u.horn $ + +*/ + +#include "global.h" +#include "mir_string.h" + +char *mir_strncpy(char *pszDest, const char *pszSrc, const size_t cchDest) +{ + if (!pszDest || !pszSrc || !cchDest) + return NULL; + pszDest = strncpy(pszDest, pszSrc, cchDest-1); + pszDest[cchDest-1] = 0; + return pszDest; +} + +wchar_t *mir_wcsncpy(wchar_t *pszDest, const wchar_t *pszSrc, const size_t cchDest) +{ + if (!pszDest || !pszSrc || !cchDest) + return NULL; + pszDest = wcsncpy(pszDest, pszSrc, cchDest-1); + pszDest[cchDest-1] = 0; + return pszDest; +} + +char *mir_strncat(char *pszDest, const char *pszSrc, const size_t cchDest) +{ + if (!pszDest || !pszSrc || !cchDest) + return NULL; + strncat(pszDest, pszSrc, cchDest-1); + pszDest[cchDest-1] = 0; + return pszDest; +} + +wchar_t *mir_wcsncat(wchar_t *pszDest, const wchar_t *pszSrc, const size_t cchDest) +{ + if (!pszDest || !pszSrc || !cchDest) + return NULL; + pszDest = wcsncat(pszDest, pszSrc, cchDest-1); + pszDest[cchDest-1] = 0; + return pszDest; +} + +char *mir_strncat_c(char *pszDest, const char cSrc) { + size_t lenNew = strlen(pszDest) + 2; + if (!pszDest) + pszDest = (char *) mir_alloc(sizeof(char) * lenNew); + else + pszDest = (char *) mir_realloc(pszDest, sizeof(char) * lenNew); + pszDest[lenNew-2] = cSrc; + pszDest[lenNew-1] = 0; + return pszDest; +} + +wchar_t *mir_wcsncat_c(wchar_t *pwszDest, const wchar_t wcSrc) { + size_t lenNew = wcslen(pwszDest) + 2; + if (!pwszDest) + pwszDest = (wchar_t *) mir_alloc(sizeof(wchar_t) * lenNew); + else + pwszDest = (wchar_t *) mir_realloc(pwszDest, sizeof(wchar_t) * lenNew); + pwszDest[lenNew-2] = wcSrc; + pwszDest[lenNew-1] = 0; + return pwszDest; +} + +char *mir_strnerase(char *pszDest, size_t sizeFrom, size_t sizeTo) { + char *pszReturn = NULL; + size_t sizeNew, sizeLen = strlen(pszDest); + if (sizeFrom >= 0 && sizeFrom < sizeLen && sizeTo >= 0 && sizeTo <= sizeLen && sizeFrom < sizeTo) { + sizeNew = sizeLen - (sizeTo - sizeFrom); + size_t sizeCopy = sizeNew - sizeFrom; + pszReturn = (char *) mir_alloc(sizeNew + 1); + memcpy(pszReturn, pszDest, sizeFrom); + memcpy(pszReturn + sizeFrom, pszDest + sizeTo, sizeCopy); + pszReturn[sizeNew] = 0; + } + + pszDest = (char *) mir_realloc(pszDest, sizeNew + 1); + pszDest = mir_strcpy(pszDest, pszReturn); + mir_free(pszReturn); + return pszDest; +} + +size_t mir_vsnwprintf(wchar_t *pszDest, const size_t cchDest, const wchar_t *pszFormat, va_list& argList) +{ + size_t iRet, cchMax; + + if (!pszDest || !pszFormat || !*pszFormat) + return -1; + + cchMax = cchDest - 1; + iRet = _vsnwprintf(pszDest, cchMax, pszFormat, argList); + if (iRet < 0) pszDest[0] = 0; + else if (iRet >= cchMax) { + pszDest[cchMax] = 0; + iRet = cchMax; + } + return iRet; +} + +size_t mir_snwprintf(wchar_t *pszDest, const size_t cchDest, const wchar_t *pszFormat, ...) +{ + size_t iRet; + va_list argList; + + va_start(argList, pszFormat); + iRet = mir_vsnwprintf(pszDest, cchDest, pszFormat, argList); + va_end(argList); + return iRet; +} + +//--------------------------------------------------------------------------- +void mir_stradd(char* &pszDest, const char *pszSrc) +{ + if(!pszSrc) { + return; + } + else if(!pszDest) { + pszDest = mir_strdup(pszSrc); + } + else { + size_t lenDest = strlen(pszDest); + size_t lenSrc = strlen(pszSrc); + size_t lenNew = lenDest + lenSrc + 1; + pszDest = (char *) mir_realloc(pszDest, sizeof(char)* lenNew); + + strcpy(pszDest + lenDest, pszSrc); + pszDest[lenNew-1] = 0; + } +} + +void mir_wcsadd(wchar_t* &pszDest, const wchar_t *pszSrc) +{ + if(!pszSrc) { + return; + } + else if(!pszDest) { + pszDest = mir_wstrdup(pszSrc); + } + else { + size_t lenDest = wcslen(pszDest); + size_t lenSrc = wcslen(pszSrc); + size_t lenNew = lenDest + lenSrc + 1; + pszDest = (wchar_t *) mir_realloc(pszDest, sizeof(wchar_t)*lenNew); + + wcscpy(pszDest + lenDest, pszSrc); + pszDest[lenNew-1] = 0; + } +} + diff --git a/plugins/SendScreenshotPlus/src/mir_string.h b/plugins/SendScreenshotPlus/src/mir_string.h new file mode 100644 index 0000000000..882cd38896 --- /dev/null +++ b/plugins/SendScreenshotPlus/src/mir_string.h @@ -0,0 +1,107 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* +Copyright 2000-2009 Miranda ICQ/IM project, + +This file is part of Send Screenshot Plus, a Miranda IM plugin. +Copyright (c) 2010 Ing.U.Horn + +Parts of this file based on original sorce code +from UserInfoEx Plugin + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $HeadURL: http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSSPlus/mir_string.h $ +Revision : $Revision: 13 $ +Last change on : $Date: 2010-04-02 02:54:30 +0400 (РџС‚, 02 апр 2010) $ +Last change by : $Author: ing.u.horn $ + +*/ + +#ifndef _MIR_STRING_H_INCLUDED_ +#define _MIR_STRING_H_INCLUDED_ + +#define mir_wcsdup mir_wstrdup + +#ifdef _UNICODE + #define mir_tcslen mir_wcslen + #define mir_tcscpy mir_wcscpy + #define mir_tcsncpy mir_wcsncpy + #define mir_tcsncat mir_wcsncat + #define mir_tcsdup mir_wcsdup + #define mir_tcscmp mir_wcscmp + #define mir_tcsncmp mir_wcsncmp + #define mir_tcsicmp mir_wcsicmp + #define mir_tcsnicmp mir_wcsnicmp + #define mir_tcschr mir_wcschr + #define mir_tcsrchr mir_wcsrchr + #define mir_tcsncat_c mir_wcsncat_c + #define mir_tcsadd mir_wcsadd +#else + #define mir_tcslen mir_strlen + #define mir_tcscpy mir_strcpy + #define mir_tcsncpy mir_strncpy + #define mir_tcsncat mir_strncat + #define mir_tcsdup mir_strdup + #define mir_tcscmp mir_strcmp + #define mir_tcsncmp mir_strncmp + #define mir_tcsicmp mir_stricmp + #define mir_tcsnicmp mir_strnicmp + #define mir_tcschr mir_strchr + #define mir_tcsrchr mir_strrchr + #define mir_tcsncat_c mir_strncat_c + #define mir_tcsadd mir_stradd +#endif + + +#define mir_strlen(s) (((s)!=0)?strlen(s):0) +#define mir_strcpy(d,s) (((s)!=0&&(d)!=0)?strcpy(d,s):0) +#define mir_strcmp(s1,s2) ((s1)==0||(s2)==0||strcmp((s1),(s2))) +#define mir_strncmp(s1,s2,n) ((s1)==0||(s2)==0||strncmp((s1),(s2),(n))) +#define mir_stricmp(s1,s2) ((s1)==0||(s2)==0||_stricmp((s1),(s2))) +#define mir_strnicmp(s1,s2,n) ((s1)==0||(s2)==0||_strnicmp((s1),(s2),(n))) +#define mir_strchr(s,c) (((s)!=0)?strchr((s),(c)):0) +#define mir_strrchr(s,c) (((s)!=0)?strrchr((s),(c)):0) + +#define mir_wcslen(s) (((s)!=0)?wcslen(s):0) +#define mir_wcscpy(d,s) (((s)!=0&&(d)!=0)?wcscpy(d,s):0) +#define mir_wcscmp(s1,s2) ((s1)==0||(s2)==0||wcscmp((s1),(s2))) +#define mir_wcsncmp(s1,s2,n) ((s1)==0||(s2)==0||wcsncmp((s1),(s2),(n))) +#define mir_wcsicmp(s1,s2) ((s1)==0||(s2)==0||_wcsicmp((s1),(s2))) +#define mir_wcsnicmp(s1,s2,n) ((s1)==0||(s2)==0||_wcsnicmp((s1),(s2),(n))) +#define mir_wcschr(s,c) (((s)!=0)?wcschr((s),(c)):0) +#define mir_wcsrchr(s,c) (((s)!=0)?wcsrchr((s),(c)):0) + +//#define mir_free(ptr) (if (x) mmi.free(x); *(&(x)) = 0;} +#define mir_freeAndNil(ptr) {if(ptr) mir_free(ptr); ptr = NULL;} + +char * mir_strncpy(char *pszDest, const char *pszSrc, const size_t cchDest); +wchar_t * mir_wcsncpy(wchar_t *pszDest, const wchar_t *pszSrc, const size_t cchDest); + +char * mir_strncat(char *pszDest, const char *pszSrc, const size_t cchDest); +wchar_t * mir_wcsncat(wchar_t *pszDest, const wchar_t *pszSrc, const size_t cchDest); + +char * mir_strncat_c(char *pszDest, const char cSrc); +char * mir_wcsncat_c(char *pszDest, const char cSrc); + +size_t mir_vsnwprintf(wchar_t *pszDest, const size_t cchDest, const wchar_t *pszFormat, va_list& argList); +size_t mir_snwprintf(wchar_t *pszDest, const size_t cchDest, const wchar_t *pszFormat, ...); + +char * mir_strnerase(char *pszDest, size_t sizeFrom, size_t sizeTo); + +void mir_stradd(char * &pszDest, const char *pszSrc); +void mir_wcsadd(wchar_t * &pszDest, const wchar_t *pszSrc); + +#endif /* _MIR_STRING_H_INCLUDED_ */ \ No newline at end of file diff --git a/plugins/SendScreenshotPlus/src/resource.h b/plugins/SendScreenshotPlus/src/resource.h new file mode 100644 index 0000000000..6818f5b23f --- /dev/null +++ b/plugins/SendScreenshotPlus/src/resource.h @@ -0,0 +1,102 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by resource.rc +// +#define IDOK 1 +#define IDA_btnClose 1 +#define IDCANCEL 2 +#define IDB_Bmp1 2 +#define IDABORT 3 +#define IDB_Bmp2 3 +#define IDRETRY 4 +#define IDIGNORE 5 +#define IDYES 6 +#define IDNO 7 +#define IDCLOSE 8 +#define IDHELP 9 +#define IDTRYAGAIN 10 +#define IDCONTINUE 11 +#define IDALL 21 +#define IDD_UMainForm 101 +#define MAIN 102 +#define IDR_LICENSE 103 +#define IDD_UMain_CaptureWindow 107 +#define IDD_CAPTURE 111 +#define IDR_CREDIT 116 +#define IDI_PLUG_MAIN 190 +#define IDI_PLUG_DEFAULT 191 +#define IDI_PLUG_ICON1 192 +#define IDI_PLUG_ICON2 193 +#define IDI_PLUG_ICON3 194 +#define IDI_PLUG_HELP 195 +#define IDI_PLUG_FOLDERO 196 +#define IDI_PLUG_ARROWL 197 +#define IDI_PLUG_ARROWR 198 +#define IDI_PLUG_OVERLAYON 199 +#define IDI_PLUG_OVERLAYOFF 200 +#define IDD_UAboutForm 201 +#define IDI_PLUG_DESKOFF 201 +#define IDI_PLUG_DESKON 202 +#define IDI_PLUG_DELOFF 203 +#define IDI_PLUG_DELON 204 +#define IDD_UEditForm 301 +#define IDC_CAPTURETAB 1005 +#define IDD_MSGBOX 1008 +#define IDC_CREDIT 1009 +#define IDD_MSGBOXDUMMI 1024 +#define IDD_UMain_CaptureDesktop 1025 +#define STATIC_WHITERECT 1100 +#define STATIC_LINE2 1103 +#define ICO_DLGLOGO 1105 +#define ICO_MSGDLG 1106 +#define IDC_BUILDTIME 1108 +#define TXT_NAME 1114 +#define TXT_MESSAGE 1126 +#define ID_edtCaption 1201 +#define ID_edtSize 1202 +#define ID_edtQuality 1203 +#define ID_upQuality 1204 +#define ID_edtTimed 1205 +#define ID_upTimed 1206 +#define IDC_WHITERECT 1221 +#define ID_cboxFormat 1301 +#define ID_cboxSendBy 1302 +#define ID_lblFmtInfo 1501 +#define IDE_Image 1501 +#define ID_lblSendBy 1502 +#define IDE_imgSelection 1502 +#define ID_bvlTarget 1503 +#define IDC_COPYRIGHT 1503 +#define ID_lblDropInfo 1504 +#define ID_imgTarget 1505 +#define ID_edtCaptionLabel 1506 +#define ID_edtSizeLabel 1507 +#define ID_edtQualityLabel 1508 +#define ID_edtTimedLabel 1509 +#define IDNONE 1565 +#define IDA_CONTRIBLINK 1586 +#define IDC_LICENSE 1589 +#define ID_gboxAreaToTake 1602 +#define ID_gboxOptions 1603 +#define ID_chkEditor 1701 +#define ID_chkClientArea 1704 +#define ID_chkTimed 1708 +#define ID_chkOpenAgain 1710 +#define IDC_HEADERBAR 1734 +#define ID_btnAbout 2001 +#define ID_btnExplore 2002 +#define ID_btnDesc 2003 +#define ID_btnDeleteAfterSend 2004 +#define ID_btnCapture 2005 +#define IDE_StatusBar 2501 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 123 +#define _APS_NEXT_COMMAND_VALUE 40002 +#define _APS_NEXT_CONTROL_VALUE 1011 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/plugins/SendScreenshotPlus/src/version.h b/plugins/SendScreenshotPlus/src/version.h new file mode 100644 index 0000000000..a97e7aff37 --- /dev/null +++ b/plugins/SendScreenshotPlus/src/version.h @@ -0,0 +1,45 @@ +#define PLUGNAME "Send Screenshot+" +#define __MAJOR_VERSION 0 +#define __MINOR_VERSION 8 +#define __RELEASE_NUM 0 +#define __BUILD_NUM 0 + +#define __STRINGIFY(x) #x +#define __STRINGIFY2(x) __STRINGIFY(x) +#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM +#define __FILEVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM + +#define __VERSION_STRING __STRINGIFY2(__FILEVERSION_STRING) +#define __VERSION_STRING_DOT __STRINGIFY2(__FILEVERSION_STRING_DOTS) + +#define __FILENAME "SendSS.dll" +#define __DESC "Take a screenshot and send it to a contact." +#define __AUTHOR "Merlin" +#define __AUTHOREMAIL "ing.u.horn@googlemail.com" +#define __COPYRIGHT "© 2010 Merlin, © 2004-2006 Sergio Vieira Rolanski" +#define __AUTHORWEB "http://code.google.com/p/merlins-miranda" + +#ifndef MIID_PLUGIN // {ED39AF7C-BECD-404e-9499-4D04F711B9CB} +#define MIID_PLUGIN { 0xed39af7c, 0xbecd, 0x404e, { 0x94, 0x99, 0x4d, 0x04, 0xf7, 0x11, 0xb9, 0xcb } } +#endif + +#ifdef _UNICODE +#define __PLUGIN_NAME "Send Screenshot+ (Unicode)" +#define __FLVersionURL "http://nightly.miranda.im/" +#define __FLVersionPrefix "SendSS (Unicode) " +#define __FLUpdateURL "http://nightly.miranda.im/x32/sendss.zip" +#define __BetaUpdateURL "http://nightly.miranda.im/x32/sendss.zip" +#else +#define __PLUGIN_NAME "Send Screenshot+ (2in1)" +#define __FLVersionURL "http://nightly.miranda.im/" +#define __FLVersionPrefix "SendSS (2in1) " +#define __FLUpdateURL "http://nightly.miranda.im/x32/sendss.zip" +#define __BetaUpdateURL "http://nightly.miranda.im/x32/sendss.zip" +#endif + +#define __BetaVersionURL "http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSS/changelog.txt" +#define __BetaVersionPrefix "SendSS Plus: " +#define __BetaChangelogURL "http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSS/changelog.txt" + +#define __USER_AGENT_STRING __PLUGIN_NAME##" v"##__VERSION_STRING_DOT + diff --git a/plugins/SendScreenshotPlus/version.h b/plugins/SendScreenshotPlus/version.h deleted file mode 100644 index a97e7aff37..0000000000 --- a/plugins/SendScreenshotPlus/version.h +++ /dev/null @@ -1,45 +0,0 @@ -#define PLUGNAME "Send Screenshot+" -#define __MAJOR_VERSION 0 -#define __MINOR_VERSION 8 -#define __RELEASE_NUM 0 -#define __BUILD_NUM 0 - -#define __STRINGIFY(x) #x -#define __STRINGIFY2(x) __STRINGIFY(x) -#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM -#define __FILEVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM - -#define __VERSION_STRING __STRINGIFY2(__FILEVERSION_STRING) -#define __VERSION_STRING_DOT __STRINGIFY2(__FILEVERSION_STRING_DOTS) - -#define __FILENAME "SendSS.dll" -#define __DESC "Take a screenshot and send it to a contact." -#define __AUTHOR "Merlin" -#define __AUTHOREMAIL "ing.u.horn@googlemail.com" -#define __COPYRIGHT "© 2010 Merlin, © 2004-2006 Sergio Vieira Rolanski" -#define __AUTHORWEB "http://code.google.com/p/merlins-miranda" - -#ifndef MIID_PLUGIN // {ED39AF7C-BECD-404e-9499-4D04F711B9CB} -#define MIID_PLUGIN { 0xed39af7c, 0xbecd, 0x404e, { 0x94, 0x99, 0x4d, 0x04, 0xf7, 0x11, 0xb9, 0xcb } } -#endif - -#ifdef _UNICODE -#define __PLUGIN_NAME "Send Screenshot+ (Unicode)" -#define __FLVersionURL "http://nightly.miranda.im/" -#define __FLVersionPrefix "SendSS (Unicode) " -#define __FLUpdateURL "http://nightly.miranda.im/x32/sendss.zip" -#define __BetaUpdateURL "http://nightly.miranda.im/x32/sendss.zip" -#else -#define __PLUGIN_NAME "Send Screenshot+ (2in1)" -#define __FLVersionURL "http://nightly.miranda.im/" -#define __FLVersionPrefix "SendSS (2in1) " -#define __FLUpdateURL "http://nightly.miranda.im/x32/sendss.zip" -#define __BetaUpdateURL "http://nightly.miranda.im/x32/sendss.zip" -#endif - -#define __BetaVersionURL "http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSS/changelog.txt" -#define __BetaVersionPrefix "SendSS Plus: " -#define __BetaChangelogURL "http://merlins-miranda.googlecode.com/svn/trunk/miranda/plugins/SendSS/changelog.txt" - -#define __USER_AGENT_STRING __PLUGIN_NAME##" v"##__VERSION_STRING_DOT - diff --git a/plugins/SendScreenshotPlus/version.rc b/plugins/SendScreenshotPlus/version.rc deleted file mode 100644 index 13b9affcf7..0000000000 --- a/plugins/SendScreenshotPlus/version.rc +++ /dev/null @@ -1,42 +0,0 @@ -#ifdef APSTUDIO_INVOKED -#error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - -#include // include for version info constants -#include "version.h" - -// -// TO CHANGE VERSION INFORMATION, EDIT PROJECT OPTIONS... -// -VS_VERSION_INFO VERSIONINFO - FILEVERSION __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM - PRODUCTVERSION __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904E4" - BEGIN - VALUE "CompanyName", "" - VALUE "FileVersion", __VERSION_STRING_DOT - VALUE "FileDescription", __DESC - VALUE "InternalName", __PLUGIN_NAME - VALUE "LegalCopyright", __COPYRIGHT - VALUE "OriginalFilename", __FILENAME - VALUE "ProductName", __PLUGIN_NAME - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0409, 1252 - END -END - diff --git a/plugins/Sessions/Icons/Checked.ico b/plugins/Sessions/Icons/Checked.ico deleted file mode 100644 index e19208cdb3..0000000000 Binary files a/plugins/Sessions/Icons/Checked.ico and /dev/null differ diff --git a/plugins/Sessions/Icons/Load.ico b/plugins/Sessions/Icons/Load.ico deleted file mode 100644 index 448a2e907d..0000000000 Binary files a/plugins/Sessions/Icons/Load.ico and /dev/null differ diff --git a/plugins/Sessions/Icons/Loadlast.ico b/plugins/Sessions/Icons/Loadlast.ico deleted file mode 100644 index a86082e547..0000000000 Binary files a/plugins/Sessions/Icons/Loadlast.ico and /dev/null differ diff --git a/plugins/Sessions/Icons/Save.ico b/plugins/Sessions/Icons/Save.ico deleted file mode 100644 index 9d19bff626..0000000000 Binary files a/plugins/Sessions/Icons/Save.ico and /dev/null differ diff --git a/plugins/Sessions/Icons/Sessions.ico b/plugins/Sessions/Icons/Sessions.ico deleted file mode 100644 index 823c49aa17..0000000000 Binary files a/plugins/Sessions/Icons/Sessions.ico and /dev/null differ diff --git a/plugins/Sessions/Icons/Unchecked.ico b/plugins/Sessions/Icons/Unchecked.ico deleted file mode 100644 index 30331f14d8..0000000000 Binary files a/plugins/Sessions/Icons/Unchecked.ico and /dev/null differ diff --git a/plugins/Sessions/Resource.h b/plugins/Sessions/Resource.h deleted file mode 100644 index 0a70198bcf..0000000000 --- a/plugins/Sessions/Resource.h +++ /dev/null @@ -1,58 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by sessions.rc -// -#define IDD_OPTIONS 101 -#define IDI_SESSIONS 102 -#define IDI_SESSIONS_LOAD 103 -#define IDD_SESSIONS_SAVE 104 -#define IDD_SESSIONS_LOADLAST 105 - -#define IDD_SESSION_CHECKED 106 -#define IDD_SESSION_UNCHECKED 107 - -#define IDD_WLCMDIALOG 120 -#define IDD_SAVEDIALOG 121 -#define IDD_EXDIALOG 123 -#define IDC_LIST 1020 -#define IDC_STARTDIALOG 1021 -#define IDC_STARTDELAY 1022 -#define IDC_STATICMS 1023 -#define IDC_STATICOP 1024 -#define IDC_SANDCCHECK 1025 -#define IDC_SESSDEL 1026 -#define IDC_ADDTOMENU 1027 -#define IDC_SELCONTACTS 1029 -#define IDC_CLIST 1032 -#define IDC_ADDTBUTTON 1033 -#define IDC_OPCLIST 1034 -#define IDC_DEL 1036 -#define IDC_EDIT 1037 -#define IDC_SAVE 1038 -#define IDC_EMCLIST 1039 -#define IDC_REXSAVE 1040 -#define IDC_REXDSAVE 1041 -#define IDC_REXASK 1043 -#define IDC_RLOADLAST 1045 -#define IDC_RNOTHING 1047 -#define IDC_CHECKLAST 1049 -#define IDC_TRACK 1051 -#define IDC_SPIN1 1052 -#define IDC_EXSTATIC1 1054 -#define IDC_EXSTATIC2 1055 -#define IDC_EXCLHIDDEN 1056 -#define IDC_LASTHIDDENWARN 1057 -#define IDC_WARNINGS 1058 -#define IDC_CRASHRECOVERY 1059 -#define IDC_STATIC -1 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 124 -#define _APS_NEXT_COMMAND_VALUE 40015 -#define _APS_NEXT_CONTROL_VALUE 1059 -#define _APS_NEXT_SYMED_VALUE 1125 -#endif -#endif diff --git a/plugins/Sessions/Sessions.rc b/plugins/Sessions/Sessions.rc deleted file mode 100644 index 7f430930a0..0000000000 --- a/plugins/Sessions/Sessions.rc +++ /dev/null @@ -1,237 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Neutral resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) -#ifdef _WIN32 -LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL -#pragma code_page(1251) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" - "version.rc\0" -END - -2 TEXTINCLUDE -BEGIN - "#include \r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_OPTIONS DIALOGEX 0, 0, 303, 246 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - GROUPBOX "Action on Startup",IDC_STATIC,6,11,157,75 - CONTROL "Open Sessions Manager dialog",IDC_STARTDIALOG,"Button",BS_AUTORADIOBUTTON | WS_GROUP,9,21,144,10 - CONTROL "Restore Last Session",IDC_RLOADLAST,"Button",BS_AUTORADIOBUTTON,9,42,144,10 - CONTROL "Do nothing",IDC_RNOTHING,"Button",BS_AUTORADIOBUTTON,9,54,144,10 - CONTROL "Only if last session present",IDC_CHECKLAST,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,27,31,126,10 - EDITTEXT IDC_STARTDELAY,105,70,26,12,ES_AUTOHSCROLL | ES_NUMBER - LTEXT "Startup delay",IDC_STATICOP,51,72,54,8 - LTEXT "ms",IDC_STATICMS,136,72,16,8 - GROUPBOX "User Sessions Management",IDC_STATIC,6,96,157,129 - PUSHBUTTON "Edit",IDC_EDIT,119,132,42,13,WS_DISABLED - COMBOBOX IDC_LIST,9,107,107,30,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP - LISTBOX IDC_OPCLIST,9,122,107,100,LBS_NOINTEGRALHEIGHT | LBS_NOSEL | WS_VSCROLL - PUSHBUTTON "Delete",IDC_DEL,119,107,42,13 - PUSHBUTTON "Save",IDC_SAVE,119,145,42,13,WS_DISABLED - GROUPBOX "Action on Exit",IDC_STATIC,170,11,128,75 - CONTROL "Ask",IDC_REXASK,"Button",BS_AUTORADIOBUTTON | WS_GROUP,173,23,122,10 - CONTROL "Save Current Session",IDC_REXSAVE,"Button",BS_AUTORADIOBUTTON,173,37,122,10 - CONTROL "Do nothing",IDC_REXDSAVE,"Button",BS_AUTORADIOBUTTON,173,50,122,10 - EDITTEXT IDC_TRACK,224,70,27,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER - CONTROL "",IDC_SPIN1,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_TABSTOP,241,62,10,14 - LTEXT "Save only last",IDC_EXSTATIC1,173,72,48,8 - LTEXT "Sessions",IDC_EXSTATIC2,253,72,28,8 - GROUPBOX "Misc",IDC_STATIC,170,96,128,95 - CONTROL "Exclude hidden contacts from session on exit",IDC_EXCLHIDDEN, - "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,173,104,122,16 - CONTROL "Warn, when some of LastSession contacts are hidden",IDC_LASTHIDDENWARN, - "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,173,121,122,20 - CONTROL "Show other warnings (""session already opened"" etc...)",IDC_WARNINGS, - "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,173,143,122,17 - CONTROL "Crash Recovery mode",IDC_CRASHRECOVERY,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,173,162,122,17 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_OPTIONS, DIALOG - BEGIN - LEFTMARGIN, 3 - RIGHTMARGIN, 298 - VERTGUIDE, 9 - VERTGUIDE, 116 - VERTGUIDE, 119 - VERTGUIDE, 161 - VERTGUIDE, 170 - VERTGUIDE, 173 - VERTGUIDE, 285 - TOPMARGIN, 6 - BOTTOMMARGIN, 243 - HORZGUIDE, 96 - HORZGUIDE, 225 - END -END -#endif // APSTUDIO_INVOKED - -#endif // Neutral resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// Russian resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) -#ifdef _WIN32 -LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT -#pragma code_page(1251) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_WLCMDIALOG DIALOGEX 0, 0, 169, 80 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Restore Session" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - DEFPUSHBUTTON "&Restore Session",IDOK,46,58,61,14 - PUSHBUTTON "&Cancel",IDCANCEL,110,58,52,14 - LTEXT "Choose session to restore from the list:",IDC_STATIC,10,16,149,11 - COMBOBOX IDC_LIST,12,30,126,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Del",IDC_SESSDEL,140,31,22,11 -END - -IDD_SAVEDIALOG DIALOGEX 0, 0, 169, 80 -STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Save Session" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - DEFPUSHBUTTON "&Save Session",IDOK,44,58,61,14 - PUSHBUTTON "&Cancel",IDCANCEL,107,58,52,14 - LTEXT "Enter session name:",IDC_STATIC,13,16,123,11 - COMBOBOX IDC_LIST,12,30,148,65,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP - CONTROL "Save and Close",IDC_SANDCCHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,46,137,10 - CONTROL "adv.",IDC_SELCONTACTS,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | BS_FLAT | WS_TABSTOP,136,4,24,10 -END - -IDD_EXDIALOG DIALOGEX 0, 0, 170, 70 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Sessions Manager" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - DEFPUSHBUTTON "OK",IDOK,61,49,50,14 - PUSHBUTTON "Cancel",IDCANCEL,113,49,50,14 - LTEXT "Save your current session?",IDC_STATIC,15,22,135,8 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_WLCMDIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 162 - VERTGUIDE, 12 - TOPMARGIN, 7 - BOTTOMMARGIN, 73 - END - - IDD_SAVEDIALOG, DIALOG - BEGIN - RIGHTMARGIN, 168 - END - - IDD_EXDIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 163 - TOPMARGIN, 7 - BOTTOMMARGIN, 63 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_SESSIONS ICON "icons\\sessions.ico" -IDI_SESSIONS_LOAD ICON "icons\\load.ico" -IDD_SESSIONS_SAVE ICON "icons\\save.ico" -IDD_SESSIONS_LOADLAST ICON "icons\\loadlast.ico" -IDD_SESSION_CHECKED ICON "icons\\checked.ico" -IDD_SESSION_UNCHECKED ICON "icons\\unchecked.ico" - - -#endif // Russian resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/plugins/Sessions/Sessions_10.vcxproj b/plugins/Sessions/Sessions_10.vcxproj index 2a5d0fcf7f..b300532992 100644 --- a/plugins/Sessions/Sessions_10.vcxproj +++ b/plugins/Sessions/Sessions_10.vcxproj @@ -182,22 +182,14 @@ - + - + - - - - - - - - - - + + diff --git a/plugins/Sessions/Sessions_10.vcxproj.filters b/plugins/Sessions/Sessions_10.vcxproj.filters index 7a24363825..41b3127e59 100644 --- a/plugins/Sessions/Sessions_10.vcxproj.filters +++ b/plugins/Sessions/Sessions_10.vcxproj.filters @@ -26,10 +26,10 @@ - + Header Files - + Header Files @@ -40,30 +40,10 @@ - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - - + Resource Files - + Resource Files diff --git a/plugins/Sessions/Src/Resource.h b/plugins/Sessions/Src/Resource.h new file mode 100644 index 0000000000..0a70198bcf --- /dev/null +++ b/plugins/Sessions/Src/Resource.h @@ -0,0 +1,58 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by sessions.rc +// +#define IDD_OPTIONS 101 +#define IDI_SESSIONS 102 +#define IDI_SESSIONS_LOAD 103 +#define IDD_SESSIONS_SAVE 104 +#define IDD_SESSIONS_LOADLAST 105 + +#define IDD_SESSION_CHECKED 106 +#define IDD_SESSION_UNCHECKED 107 + +#define IDD_WLCMDIALOG 120 +#define IDD_SAVEDIALOG 121 +#define IDD_EXDIALOG 123 +#define IDC_LIST 1020 +#define IDC_STARTDIALOG 1021 +#define IDC_STARTDELAY 1022 +#define IDC_STATICMS 1023 +#define IDC_STATICOP 1024 +#define IDC_SANDCCHECK 1025 +#define IDC_SESSDEL 1026 +#define IDC_ADDTOMENU 1027 +#define IDC_SELCONTACTS 1029 +#define IDC_CLIST 1032 +#define IDC_ADDTBUTTON 1033 +#define IDC_OPCLIST 1034 +#define IDC_DEL 1036 +#define IDC_EDIT 1037 +#define IDC_SAVE 1038 +#define IDC_EMCLIST 1039 +#define IDC_REXSAVE 1040 +#define IDC_REXDSAVE 1041 +#define IDC_REXASK 1043 +#define IDC_RLOADLAST 1045 +#define IDC_RNOTHING 1047 +#define IDC_CHECKLAST 1049 +#define IDC_TRACK 1051 +#define IDC_SPIN1 1052 +#define IDC_EXSTATIC1 1054 +#define IDC_EXSTATIC2 1055 +#define IDC_EXCLHIDDEN 1056 +#define IDC_LASTHIDDENWARN 1057 +#define IDC_WARNINGS 1058 +#define IDC_CRASHRECOVERY 1059 +#define IDC_STATIC -1 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 124 +#define _APS_NEXT_COMMAND_VALUE 40015 +#define _APS_NEXT_CONTROL_VALUE 1059 +#define _APS_NEXT_SYMED_VALUE 1125 +#endif +#endif diff --git a/plugins/Sessions/Src/Sessions.h b/plugins/Sessions/Src/Sessions.h index 18c2878938..11883cae42 100644 --- a/plugins/Sessions/Src/Sessions.h +++ b/plugins/Sessions/Src/Sessions.h @@ -43,8 +43,8 @@ along with this program. If not, see . #include "m_sessions.h" #include "Utils.h" -#include "../Version.h" -#include "../Resource.h" +#include "Version.h" +#include "Resource.h" extern HANDLE hibChecked; extern HANDLE hibNotChecked; diff --git a/plugins/Sessions/Src/Version.h b/plugins/Sessions/Src/Version.h new file mode 100644 index 0000000000..44e6d972f4 --- /dev/null +++ b/plugins/Sessions/Src/Version.h @@ -0,0 +1,21 @@ +#define __MAJOR_VERSION 0 +#define __MINOR_VERSION 1 +#define __RELEASE_NUM 3 +#define __BUILD_NUM 0 + +#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM +#define __FILEVERSION_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM + +#define __STRINGIFY_IMPL(x) #x +#define __STRINGIFY(x) __STRINGIFY_IMPL(x) +#define __VERSION_STRING __STRINGIFY(__FILEVERSION_DOTS) + + +#define __PLUGIN_NAME "Sessions" +#define __INTERNAL_NAME "Sessions" +#define __FILENAME "Sessions.dll" +#define __DESCRIPTION "Sessions Manager for Miranda IM." +#define __AUTHOR "MaD_CLuSTeR" +#define __AUTHOREMAIL "daniok@yandex.ru" +#define __AUTHORWEB "http://miranda.radicaled.ru/index.php?plugin=2" +#define __COPYRIGHT "© 2007-2008 Danil Mozhar" diff --git a/plugins/Sessions/Version.h b/plugins/Sessions/Version.h deleted file mode 100644 index ee0f3f450b..0000000000 --- a/plugins/Sessions/Version.h +++ /dev/null @@ -1,21 +0,0 @@ -#define __MAJOR_VERSION 0 -#define __MINOR_VERSION 1 -#define __RELEASE_NUM 3 -#define __BUILD_NUM 0 - -#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM -#define __FILEVERSION_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM - -#define __STRINGIFY_IMPL(x) #x -#define __STRINGIFY(x) __STRINGIFY_IMPL(x) -#define __VERSION_STRING __STRINGIFY(__FILEVERSION_DOTS) - - -#define __PLUGIN_NAME "Sessions" -#define __INTERNAL_NAME "Sessions" -#define __FILENAME "Sessions.dll" -#define __DESCRIPTION "Sessions Manager for Miranda IM." -#define __AUTHOR "MaD_CLuSTeR" -#define __AUTHOREMAIL "daniok@yandex.ru" -#define __AUTHORWEB "http://nightly.miranda.im/" -#define __COPYRIGHT "© 2007-2008 Danil Mozhar" diff --git a/plugins/Sessions/Version.rc b/plugins/Sessions/Version.rc deleted file mode 100644 index d1da5e8d6a..0000000000 --- a/plugins/Sessions/Version.rc +++ /dev/null @@ -1,42 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#ifdef APSTUDIO_INVOKED -#error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - -#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/plugins/Sessions/docs/sessions-translation.txt b/plugins/Sessions/docs/sessions-translation.txt new file mode 100644 index 0000000000..96153c70d0 --- /dev/null +++ b/plugins/Sessions/docs/sessions-translation.txt @@ -0,0 +1,58 @@ +; Common strings that belong to many files +;[Edit] +;[Save Session] +;[Sessions Manager] + +; ../../plugins/Sessions/Sessions.rc +;[&Cancel] +;[&Restore Session] +;[&Save Session] +;[Action on Exit] +;[Action on Startup] +;[Ask] +;[Cancel] +;[Choose session to restore from the list:] +;[Crash Recovery mode] +;[Del] +;[Delete] +;[Do nothing] +;[Enter session name:] +;[Exclude hidden contacts from session on exit] +;[Misc] +;[OK] +;[Only if last session present] +;[Open Sessions Manager dialog] +;[Restore Last Session] +;[Restore Session] +;[Save] +;[Save Current Session] +;[Save and Close] +;[Save only last] +;[Save your current session?] +;[Sessions] +;[Show other warnings (\"session already opened\" etc...)] +;[Startup delay] +;[User Sessions Management] +;[Warn, when some of LastSession contacts are hidden] +;[adv.] +;[ms] + +; ../../plugins/Sessions/Src/Main.cpp +;[Current session is empty!] +;[Favorite Session] +;[Last Sessions is empty] +;[Load Session] +;[Load last Session] +;[No contacts to open] +;[No sessions to open] +;[Not favorite Session] +;[Session name is empty, enter the name and try again] +;[This Session already opened] +;[This Session already opened(but probably hidden)\nDo you want to show hidden contacts?] + +; ../../plugins/Sessions/Src/Options.cpp +;[Message Sessions] +;[View] + +; ../../plugins/Sessions/Src/Utils.cpp +;[Session Before Last Crash] diff --git a/plugins/Sessions/res/Checked.ico b/plugins/Sessions/res/Checked.ico new file mode 100644 index 0000000000..e19208cdb3 Binary files /dev/null and b/plugins/Sessions/res/Checked.ico differ diff --git a/plugins/Sessions/res/Load.ico b/plugins/Sessions/res/Load.ico new file mode 100644 index 0000000000..448a2e907d Binary files /dev/null and b/plugins/Sessions/res/Load.ico differ diff --git a/plugins/Sessions/res/Loadlast.ico b/plugins/Sessions/res/Loadlast.ico new file mode 100644 index 0000000000..a86082e547 Binary files /dev/null and b/plugins/Sessions/res/Loadlast.ico differ diff --git a/plugins/Sessions/res/Save.ico b/plugins/Sessions/res/Save.ico new file mode 100644 index 0000000000..9d19bff626 Binary files /dev/null and b/plugins/Sessions/res/Save.ico differ diff --git a/plugins/Sessions/res/Sessions.ico b/plugins/Sessions/res/Sessions.ico new file mode 100644 index 0000000000..823c49aa17 Binary files /dev/null and b/plugins/Sessions/res/Sessions.ico differ diff --git a/plugins/Sessions/res/Sessions.rc b/plugins/Sessions/res/Sessions.rc new file mode 100644 index 0000000000..746831c05a --- /dev/null +++ b/plugins/Sessions/res/Sessions.rc @@ -0,0 +1,236 @@ +// Microsoft Visual C++ generated resource script. +// +#include "..\src\resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Neutral resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) +#ifdef _WIN32 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +#pragma code_page(1251) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "..\\src\\resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include \r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_OPTIONS DIALOGEX 0, 0, 303, 246 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + GROUPBOX "Action on Startup",IDC_STATIC,6,11,157,75 + CONTROL "Open Sessions Manager dialog",IDC_STARTDIALOG,"Button",BS_AUTORADIOBUTTON | WS_GROUP,9,21,144,10 + CONTROL "Restore Last Session",IDC_RLOADLAST,"Button",BS_AUTORADIOBUTTON,9,42,144,10 + CONTROL "Do nothing",IDC_RNOTHING,"Button",BS_AUTORADIOBUTTON,9,54,144,10 + CONTROL "Only if last session present",IDC_CHECKLAST,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,27,31,126,10 + EDITTEXT IDC_STARTDELAY,105,70,26,12,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "Startup delay",IDC_STATICOP,51,72,54,8 + LTEXT "ms",IDC_STATICMS,136,72,16,8 + GROUPBOX "User Sessions Management",IDC_STATIC,6,96,157,129 + PUSHBUTTON "Edit",IDC_EDIT,119,132,42,13,WS_DISABLED + COMBOBOX IDC_LIST,9,107,107,30,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + LISTBOX IDC_OPCLIST,9,122,107,100,LBS_NOINTEGRALHEIGHT | LBS_NOSEL | WS_VSCROLL + PUSHBUTTON "Delete",IDC_DEL,119,107,42,13 + PUSHBUTTON "Save",IDC_SAVE,119,145,42,13,WS_DISABLED + GROUPBOX "Action on Exit",IDC_STATIC,170,11,128,75 + CONTROL "Ask",IDC_REXASK,"Button",BS_AUTORADIOBUTTON | WS_GROUP,173,23,122,10 + CONTROL "Save Current Session",IDC_REXSAVE,"Button",BS_AUTORADIOBUTTON,173,37,122,10 + CONTROL "Do nothing",IDC_REXDSAVE,"Button",BS_AUTORADIOBUTTON,173,50,122,10 + EDITTEXT IDC_TRACK,224,70,27,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER + CONTROL "",IDC_SPIN1,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_TABSTOP,241,62,10,14 + LTEXT "Save only last",IDC_EXSTATIC1,173,72,48,8 + LTEXT "Sessions",IDC_EXSTATIC2,253,72,28,8 + GROUPBOX "Misc",IDC_STATIC,170,96,128,95 + CONTROL "Exclude hidden contacts from session on exit",IDC_EXCLHIDDEN, + "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,173,104,122,16 + CONTROL "Warn, when some of LastSession contacts are hidden",IDC_LASTHIDDENWARN, + "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,173,121,122,20 + CONTROL "Show other warnings (""session already opened"" etc...)",IDC_WARNINGS, + "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,173,143,122,17 + CONTROL "Crash Recovery mode",IDC_CRASHRECOVERY,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,173,162,122,17 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_OPTIONS, DIALOG + BEGIN + LEFTMARGIN, 3 + RIGHTMARGIN, 298 + VERTGUIDE, 9 + VERTGUIDE, 116 + VERTGUIDE, 119 + VERTGUIDE, 161 + VERTGUIDE, 170 + VERTGUIDE, 173 + VERTGUIDE, 285 + TOPMARGIN, 6 + BOTTOMMARGIN, 243 + HORZGUIDE, 96 + HORZGUIDE, 225 + END +END +#endif // APSTUDIO_INVOKED + +#endif // Neutral resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// Russian resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) +#ifdef _WIN32 +LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT +#pragma code_page(1251) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_WLCMDIALOG DIALOGEX 0, 0, 169, 80 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Restore Session" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "&Restore Session",IDOK,46,58,61,14 + PUSHBUTTON "&Cancel",IDCANCEL,110,58,52,14 + LTEXT "Choose session to restore from the list:",IDC_STATIC,10,16,149,11 + COMBOBOX IDC_LIST,12,30,126,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "Del",IDC_SESSDEL,140,31,22,11 +END + +IDD_SAVEDIALOG DIALOGEX 0, 0, 169, 80 +STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Save Session" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "&Save Session",IDOK,44,58,61,14 + PUSHBUTTON "&Cancel",IDCANCEL,107,58,52,14 + LTEXT "Enter session name:",IDC_STATIC,13,16,123,11 + COMBOBOX IDC_LIST,12,30,148,65,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + CONTROL "Save and Close",IDC_SANDCCHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,46,137,10 + CONTROL "adv.",IDC_SELCONTACTS,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | BS_FLAT | WS_TABSTOP,136,4,24,10 +END + +IDD_EXDIALOG DIALOGEX 0, 0, 170, 70 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Sessions Manager" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "OK",IDOK,61,49,50,14 + PUSHBUTTON "Cancel",IDCANCEL,113,49,50,14 + LTEXT "Save your current session?",IDC_STATIC,15,22,135,8 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_WLCMDIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 162 + VERTGUIDE, 12 + TOPMARGIN, 7 + BOTTOMMARGIN, 73 + END + + IDD_SAVEDIALOG, DIALOG + BEGIN + RIGHTMARGIN, 168 + END + + IDD_EXDIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 163 + TOPMARGIN, 7 + BOTTOMMARGIN, 63 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_SESSIONS ICON "sessions.ico" +IDI_SESSIONS_LOAD ICON "load.ico" +IDD_SESSIONS_SAVE ICON "save.ico" +IDD_SESSIONS_LOADLAST ICON "loadlast.ico" +IDD_SESSION_CHECKED ICON "checked.ico" +IDD_SESSION_UNCHECKED ICON "unchecked.ico" + + +#endif // Russian resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/Sessions/res/Unchecked.ico b/plugins/Sessions/res/Unchecked.ico new file mode 100644 index 0000000000..30331f14d8 Binary files /dev/null and b/plugins/Sessions/res/Unchecked.ico differ diff --git a/plugins/Sessions/res/Version.rc b/plugins/Sessions/res/Version.rc new file mode 100644 index 0000000000..d741488c4f --- /dev/null +++ b/plugins/Sessions/res/Version.rc @@ -0,0 +1,42 @@ +// Microsoft Visual C++ generated resource script. +// +#ifdef APSTUDIO_INVOKED +#error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + +#include "afxres.h" +#include "..\src\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/plugins/Sessions/sessions-translation.txt b/plugins/Sessions/sessions-translation.txt deleted file mode 100644 index 96153c70d0..0000000000 --- a/plugins/Sessions/sessions-translation.txt +++ /dev/null @@ -1,58 +0,0 @@ -; Common strings that belong to many files -;[Edit] -;[Save Session] -;[Sessions Manager] - -; ../../plugins/Sessions/Sessions.rc -;[&Cancel] -;[&Restore Session] -;[&Save Session] -;[Action on Exit] -;[Action on Startup] -;[Ask] -;[Cancel] -;[Choose session to restore from the list:] -;[Crash Recovery mode] -;[Del] -;[Delete] -;[Do nothing] -;[Enter session name:] -;[Exclude hidden contacts from session on exit] -;[Misc] -;[OK] -;[Only if last session present] -;[Open Sessions Manager dialog] -;[Restore Last Session] -;[Restore Session] -;[Save] -;[Save Current Session] -;[Save and Close] -;[Save only last] -;[Save your current session?] -;[Sessions] -;[Show other warnings (\"session already opened\" etc...)] -;[Startup delay] -;[User Sessions Management] -;[Warn, when some of LastSession contacts are hidden] -;[adv.] -;[ms] - -; ../../plugins/Sessions/Src/Main.cpp -;[Current session is empty!] -;[Favorite Session] -;[Last Sessions is empty] -;[Load Session] -;[Load last Session] -;[No contacts to open] -;[No sessions to open] -;[Not favorite Session] -;[Session name is empty, enter the name and try again] -;[This Session already opened] -;[This Session already opened(but probably hidden)\nDo you want to show hidden contacts?] - -; ../../plugins/Sessions/Src/Options.cpp -;[Message Sessions] -;[View] - -; ../../plugins/Sessions/Src/Utils.cpp -;[Session Before Last Crash] -- cgit v1.2.3