From e736ab21213b66669dde5d9a9003596706eee8bd Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Tue, 17 Jul 2012 08:44:50 +0000 Subject: CSList, CyrTranslit: changed folder structure git-svn-id: http://svn.miranda-ng.org/main/trunk@1002 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/CSList/Version.h | 22 - plugins/CSList/Version.rc | 42 - plugins/CSList/changelog.txt | 144 --- plugins/CSList/cslist-translation.txt | 175 --- plugins/CSList/cslist.cpp | 1349 -------------------- plugins/CSList/cslist.h | 665 ---------- plugins/CSList/cslist.rc | 182 --- plugins/CSList/cslist_10.vcxproj | 32 +- plugins/CSList/cslist_10.vcxproj.filters | 60 +- plugins/CSList/docs/changelog.txt | 144 +++ plugins/CSList/docs/cslist-translation.txt | 175 +++ plugins/CSList/legacy.h | 87 -- plugins/CSList/res/Version.rc | 42 + plugins/CSList/res/cslist.rc | 182 +++ plugins/CSList/resource.h | 49 - plugins/CSList/src/Version.h | 22 + plugins/CSList/src/cslist.cpp | 1349 ++++++++++++++++++++ plugins/CSList/src/cslist.h | 665 ++++++++++ plugins/CSList/src/legacy.h | 87 ++ plugins/CSList/src/resource.h | 49 + plugins/CSList/src/strpos.h | 70 + plugins/CSList/strpos.h | 70 - plugins/CyrTranslit/CyrTranslit-gpl.txt | 340 ----- plugins/CyrTranslit/CyrTranslit-readme.txt | 70 - plugins/CyrTranslit/CyrTranslit.rc | 113 -- plugins/CyrTranslit/CyrTranslit_10.vcxproj | 22 +- plugins/CyrTranslit/CyrTranslit_10.vcxproj.filters | 22 +- plugins/CyrTranslit/MirandaContact.cpp | 191 --- plugins/CyrTranslit/MirandaContact.h | 123 -- plugins/CyrTranslit/TransliterationMap.cpp | 247 ---- plugins/CyrTranslit/TransliterationMap.h | 73 -- plugins/CyrTranslit/TransliterationProtocol.cpp | 166 --- plugins/CyrTranslit/TransliterationProtocol.h | 64 - plugins/CyrTranslit/cyrtranslit-translation.txt | 2 - plugins/CyrTranslit/docs/CyrTranslit-gpl.txt | 340 +++++ plugins/CyrTranslit/docs/CyrTranslit-readme.txt | 70 + .../CyrTranslit/docs/cyrtranslit-translation.txt | 2 + plugins/CyrTranslit/main.cpp | 72 -- plugins/CyrTranslit/plugin.h | 62 - plugins/CyrTranslit/res/CyrTranslit.rc | 113 ++ plugins/CyrTranslit/resource.h | 15 - plugins/CyrTranslit/src/MirandaContact.cpp | 191 +++ plugins/CyrTranslit/src/MirandaContact.h | 123 ++ plugins/CyrTranslit/src/TransliterationMap.cpp | 247 ++++ plugins/CyrTranslit/src/TransliterationMap.h | 73 ++ .../CyrTranslit/src/TransliterationProtocol.cpp | 166 +++ plugins/CyrTranslit/src/TransliterationProtocol.h | 64 + plugins/CyrTranslit/src/main.cpp | 72 ++ plugins/CyrTranslit/src/plugin.h | 62 + plugins/CyrTranslit/src/resource.h | 15 + 50 files changed, 4361 insertions(+), 4421 deletions(-) delete mode 100644 plugins/CSList/Version.h delete mode 100644 plugins/CSList/Version.rc delete mode 100644 plugins/CSList/changelog.txt delete mode 100644 plugins/CSList/cslist-translation.txt delete mode 100644 plugins/CSList/cslist.cpp delete mode 100644 plugins/CSList/cslist.h delete mode 100644 plugins/CSList/cslist.rc create mode 100644 plugins/CSList/docs/changelog.txt create mode 100644 plugins/CSList/docs/cslist-translation.txt delete mode 100644 plugins/CSList/legacy.h create mode 100644 plugins/CSList/res/Version.rc create mode 100644 plugins/CSList/res/cslist.rc delete mode 100644 plugins/CSList/resource.h create mode 100644 plugins/CSList/src/Version.h create mode 100644 plugins/CSList/src/cslist.cpp create mode 100644 plugins/CSList/src/cslist.h create mode 100644 plugins/CSList/src/legacy.h create mode 100644 plugins/CSList/src/resource.h create mode 100644 plugins/CSList/src/strpos.h delete mode 100644 plugins/CSList/strpos.h delete mode 100644 plugins/CyrTranslit/CyrTranslit-gpl.txt delete mode 100644 plugins/CyrTranslit/CyrTranslit-readme.txt delete mode 100644 plugins/CyrTranslit/CyrTranslit.rc delete mode 100644 plugins/CyrTranslit/MirandaContact.cpp delete mode 100644 plugins/CyrTranslit/MirandaContact.h delete mode 100644 plugins/CyrTranslit/TransliterationMap.cpp delete mode 100644 plugins/CyrTranslit/TransliterationMap.h delete mode 100644 plugins/CyrTranslit/TransliterationProtocol.cpp delete mode 100644 plugins/CyrTranslit/TransliterationProtocol.h delete mode 100644 plugins/CyrTranslit/cyrtranslit-translation.txt create mode 100644 plugins/CyrTranslit/docs/CyrTranslit-gpl.txt create mode 100644 plugins/CyrTranslit/docs/CyrTranslit-readme.txt create mode 100644 plugins/CyrTranslit/docs/cyrtranslit-translation.txt delete mode 100644 plugins/CyrTranslit/main.cpp delete mode 100644 plugins/CyrTranslit/plugin.h create mode 100644 plugins/CyrTranslit/res/CyrTranslit.rc delete mode 100644 plugins/CyrTranslit/resource.h create mode 100644 plugins/CyrTranslit/src/MirandaContact.cpp create mode 100644 plugins/CyrTranslit/src/MirandaContact.h create mode 100644 plugins/CyrTranslit/src/TransliterationMap.cpp create mode 100644 plugins/CyrTranslit/src/TransliterationMap.h create mode 100644 plugins/CyrTranslit/src/TransliterationProtocol.cpp create mode 100644 plugins/CyrTranslit/src/TransliterationProtocol.h create mode 100644 plugins/CyrTranslit/src/main.cpp create mode 100644 plugins/CyrTranslit/src/plugin.h create mode 100644 plugins/CyrTranslit/src/resource.h diff --git a/plugins/CSList/Version.h b/plugins/CSList/Version.h deleted file mode 100644 index 8206c5c61f..0000000000 --- a/plugins/CSList/Version.h +++ /dev/null @@ -1,22 +0,0 @@ -#define __MAJOR_VERSION 0 -#define __MINOR_VERSION 1 -#define __RELEASE_NUM 0 -#define __BUILD_NUM 5 - -#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 "Custom Status List mod" -#define __INTERNAL_NAME "CSList" -#define __FILENAME "CSList.dll" -#define __DESCRIPTION "This plugin offers simple management functions to keep your extra statuses on one place." -#define __AUTHOR "Mataes, jarvis" -#define __AUTHOREMAIL "mataes2007@gmail.com" -#define __AUTHORWEB "http://mataes.googlecode.com/svn/Miranda/Plugins/Cslist/" -#define __COPYRIGHT "© 2011-10 Mataes, 2009-2007 jarvis" diff --git a/plugins/CSList/Version.rc b/plugins/CSList/Version.rc deleted file mode 100644 index d1da5e8d6a..0000000000 --- a/plugins/CSList/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/CSList/changelog.txt b/plugins/CSList/changelog.txt deleted file mode 100644 index a40a767491..0000000000 --- a/plugins/CSList/changelog.txt +++ /dev/null @@ -1,144 +0,0 @@ - - TODO - ---- - - all TODOs listed in this source x) - - feature requests maybe :) - ! settings changes - - mid-range rewrite - - force-replacing of Custom Status UI - - MAYBE-TODO - ---------- - - NOT-TODO - -------- - - setting Away/NA/DND/Occ - there are already many status managers :) - - watching statuses set by x-status menu - - 0.1.0.4 - Twix Fix - ------- - - Fixed showing menu items when not applicable - - Fixed toggling of controls when list item is removed - - Returned "Undo" function - - Returned "Import" function - - Returned multi-account functionality - - Added item focus selection & focus when added, modified or favourite-toggled - - "Inactive" focus fix - - Fixed occasional crash when trying to open multiple dialogs - - Fixed showing "Empty list" message when list is empty and undoing something from DB, not showing when undoing something with nothing in DB or showing message after importing into an empty list - - 0.1.0.3 - What's your favourite? - ------- - - Bugfixes - - 0.1.0.1 - After storm - ------- - - Favourites - - Virtualized structure - - Code refactorization - - Duplicities detection (partial) - - Saving window position - - 0.0.0.20 - calm before the storm Ox) - -------- - - some corrections of working with strings (ANSI/Unicode <-> TCHAR) - - simplified loading of list items :) - - the Options button replaced by the Undo button - - 0.0.0.19 - enjoy multi'ing, baby :) - -------- - - status is changing on all ICQ based accounts/protos - - when dialog is opened, and user tryes to open another one, forgotten dialog is brought to front instead - - menu placement optimalization - - removed old nasty GOTO because of double-clicking the list x) - - active checking of input data length during editing custom status - - optimalizations in translations - - support for Variables plugin - - other enhancements related to the possibility of using multiple ICQ accounts - - 0.0.0.18 - fixing trip :) - -------- - - icon selector shows only icons, that are supported by installed ICQ plugin - - fixed memory leak and possible crash when modifying status and then importing 0 DB entries (helpItem not nulled) - - merged Add/Modify processes together :) - - Unicode build, finally :) - - 0.0.0.17 - I become to be useful :) - -------- - - CSList menu item can be placed elsewhere, also instead of Xstatus menu (currently ICQ eternity/PlusPlus++ mod only) - - importing statuses from database (ICQ key) - - list sorting (Procedure + calls) - - dialog openable only once :) - - new icons by inducti0n :) - - no more infinite width when adding x-message - - new Options dialog - - 0.0.0.16 - rework - -------- - - code redesigned - - fix for Windows Vista crash (free) and ANSI Windows crash (init extended controls) - - preimplementation for new features that will come (favourites, ...) - - 0.0.0.15 - make me nice - -------- - - stage 1 of code revision - - Options dialog (in development) :) - - IcoLib group renamed to CSLIST_MODULE_LONG_NAME - - status titles in Add/Modify ComboBox were strangely corrected x) - - possibility to turn off "Release Notes" dialog - - 0.0.0.14 - will you use me? :) - -------- - - new lines in message input creatable via Enter - - NULLED XSTATUS now available :) - - 0.0.0.13 - oooops x)) - -------- - - hotfix for Miranda cores < 0.7 - - CSList appears in Main Menu - - fixed icons not loaded when IcoLib is missing - - 0.0.0.12 - goin' my way now x) - -------- - - DB saving method/format slightly modified - [+] multi-line messages now working - [-] LOST compatibility with HANAX's plugin (but is auto-imported if exists) - NOTE: I think "importing-only" of older releases will stay, - I have many Feature Requests that would need changing - DB format anyway, so this problem looks solved x) - - "Release notes" dialog on first run - - Updater support - - 0.0.0.11 - will this work? x) - -------- - - some similar procedures merged together :P - - another procedures more generalized 8) - - separated Add/Modify dialog finally in use :) - [+] solves some bahaviour problems x) - - 0.0.0.10 - ohhh, basics ]:) - -------- - - icons support - complete xstatus service :) - [+] no more static angry ;) :D - - iconized buttons - supporting IcoLib :) - - better method for DB entry format - old was little.."dizzy" x) :D - - TEMPORARILY DISABLED modifying of items - needs some fixes x)) - - 0.0.0.9 - working a little? O:) - ------- - - enhanced List Control behaviour (selecting, deselecting, editation, adding) - - LOADING from + SAVING to DB! - [+] my parser is also compatible with HANAX plugin's DB entries ;) - - 0.0.0.8 - behaviour testing :o) - ------- - - setting status by double-clicking list item - - much better procedures, debugging, better exceptions, dialog behaviour - - 0.0.0.7 - crash testing :o) - ------- - - basic functions coding - - 0.0.0.6 - resource testing - ------- - - basic resources modeling diff --git a/plugins/CSList/cslist-translation.txt b/plugins/CSList/cslist-translation.txt deleted file mode 100644 index bbd57fded5..0000000000 --- a/plugins/CSList/cslist-translation.txt +++ /dev/null @@ -1,175 +0,0 @@ -; Common strings that belong to many files -;[Add] -;[Add new item] -;[Custom Status List] -;[Modify] - -; ../../plugins/CSList/cslist.cpp -;[Do you really want to delete selected item?] -;[Do you want old database entries to be deleted after Import?] -;[Favourites] -;[Message] -;[Modify item] -;[Regular statuses] -;[Status] -;[This field doesn't accept string longer than %d characters. The string will be truncated.] -;[Title] -;[Warning] - -; ../../plugins/CSList/cslist.h -;[Afraid] -;[Amazed] -;[Amorous] -;[Angry] -;[Annoyed] -;[Anxious] -;[Aroused] -;[Ashamed] -;[Bored] -;[Brave] -;[Browsing] -;[Business] -;[Calm] -;[Cautious] -;[Clear] -;[Clear custom status (reset to None) and close] -;[Close without changing custom status] -;[Coffee] -;[Cold] -;[Confident] -;[Confused] -;[Contemplative] -;[Contented] -;[Cranky] -;[Crazy] -;[Creative] -;[Curious] -;[Dejected] -;[Delete selected item] -;[Depressed] -;[Disappointed] -;[Disgusted] -;[Dismayed] -;[Distracted] -;[Drinking beer] -;[Eating] -;[Embarrassed] -;[Envious] -;[Excited] -;[Favourite] -;[Feeling sick] -;[Filter] -;[Filter list] -;[Flirtatious] -;[Frustrated] -;[Gaming] -;[Grateful] -;[Grieving] -;[Grumpy] -;[Guilty] -;[Happy] -;[Having fun] -;[Hopeful] -;[Hot] -;[Humbled] -;[Humiliated] -;[Hungry] -;[Hurt] -;[I'm high] -;[Import] -;[Import statuses from database] -;[Impressed] -;[In awe] -;[In love] -;[Indignant] -;[Interested] -;[Intoxicated] -;[Invincible] -;[Jealous] -;[Journal] -;[Listening to music] -;[Lonely] -;[Lost] -;[Love] -;[Lucky] -;[Main Icon] -;[Main Menu] -;[Mean] -;[Meeting] -;[Modify selected item] -;[Moody] -;[Nervous] -;[Neutral] -;[No change] -;[Offended] -;[On WC] -;[On the phone] -;[Outraged] -;[PDA] -;[Party] -;[Picnic] -;[Playful] -;[Proud] -;[Relaxed] -;[Relieved] -;[Remorseful] -;[Remove] -;[Restless] -;[Sad] -;[Sarcastic] -;[Satisfied] -;[Searching] -;[Serious] -;[Set] -;[Set custom status to selected one and close] -;[Set/unset current item as favorite] -;[Sex] -;[Shocked] -;[Shooting] -;[Shopping] -;[Shy] -;[Sick] -;[Sleeping] -;[Sleepy] -;[Smoking] -;[Spontaneous] -;[Stressed] -;[Strong] -;[Studying] -;[Surfing] -;[Surprised] -;[Taking a bath] -;[Thankful] -;[Thinking] -;[Thirsty] -;[Tired] -;[To be or not to be] -;[Typing] -;[Undefined] -;[Undo changes] -;[Watching TV] -;[Watching pro7 on TV] -;[Weak] -;[Working] -;[Worried] - -; ../../plugins/CSList/cslist.rc -;[A] -;[Add/Modify] -;[Add/Modify Custom Status] -;[Allow extra ICQ Custom status items (ICQ Plus only)] -;[C] -;[Cancel] -;[Confirm deletion of items] -;[D] -;[Delete entries in ICQ Custom status menu after Import] -;[F] -;[I] -;[List settings] -;[M] -;[N] -;[No items available in the database.\nClick the Add button to define some.] -;[Note: Menu items are only visible when at least one ICQ account is properly set. Check if you have at least one account with UIN filled in.] -;[O] -;[Remember last window position] -;[U] diff --git a/plugins/CSList/cslist.cpp b/plugins/CSList/cslist.cpp deleted file mode 100644 index b8078ae1be..0000000000 --- a/plugins/CSList/cslist.cpp +++ /dev/null @@ -1,1349 +0,0 @@ -/* ======================================================================== - - Custom Status List - __________________ - - Custom Status List plugin for Miranda-IM (www.miranda-im.org) - Follower of Custom Status History List by HANAX - Copyright © 2006-2008 HANAX - Copyright © 2007-2009 jarvis - - 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$ - Revision : $Rev$ - Last change on : $Date$ - Last change by : $Author$ - - ============================================================================ - - - DESCRIPTION: - - Offers List of your Custom Statuses. - -// ======================================================================== */ - -#include "cslist.h" -#include "strpos.h" -#include "legacy.h" - -SortedList *servicesList; -int hLangpack; - -extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { PLUGIN_GUUID, MIID_LAST }; - -PLUGININFOEX pluginInfoEx = -{ - sizeof(PLUGININFOEX), - __PLUGIN_NAME, - PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), - __DESCRIPTION, - __AUTHOR, - __AUTHOREMAIL, - __COPYRIGHT, - __AUTHORWEB, - UNICODE_AWARE, - PLUGIN_GUUID -}; - -// ====[ MAIN ]=============================================================== - -BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) -{ - CSList::handle = hinstDLL; - return TRUE; -} - - -// ====[ PLUGIN INFO ]======================================================== - -extern "C" __declspec( dllexport ) PLUGININFOEX* MirandaPluginInfoEx( DWORD mirandaVersion ) -{ - CSList::dwMirandaVersion = mirandaVersion; - return &pluginInfoEx; -} - -// ====[ LOADER ]============================================================= - -extern "C" __declspec( dllexport ) int Load( ) -{ - mir_getLP(&pluginInfoEx); - servicesList = List_Create(0, 10); - - // support for ComboBoxEx - { - INITCOMMONCONTROLSEX icc; - icc.dwSize = sizeof(icc); - icc.dwICC = ICC_USEREX_CLASSES; - InitCommonControlsEx( &icc ); - } - - // set global variables - // we need 0.8.0.9 core which introduced accounts support for protocols - CSList::bAccountsSupported = ( CSList::dwMirandaVersion >= PLUGIN_MAKE_VERSION( 0, 8, 0, 9 )); - - // are we running under Unicode core? - { - char szVer[MAX_PATH]; - - CallService( MS_SYSTEM_GETVERSIONTEXT, MAX_PATH, ( LPARAM )szVer ); - _strlwr( szVer ); // make sure it is lowercase - - CSList::bUnicodeCore = ( strstr( szVer, "unicode" ) != NULL ); - } - - // TODO: Alerts with wrong combination of ANSI/Unicode Windows/core/plugin - - // create handler - cslist = new CSList( ); - - return FALSE; -} - - -// ====[ UNLOADER ]=========================================================== - -extern "C" __declspec( dllexport ) int Unload( void ) -{ - for (int i = servicesList->realCount-1; i >= 0; i--) - { - HANDLE *hService = (HANDLE *)servicesList->items[i]; - DestroyServiceFunction(hService); - } - List_Destroy(servicesList); - mir_free(servicesList); - delete cslist; - - return FALSE; -} - - -// ====[ FUN ]================================================================ - - -CSList::CSList( ) -{ - this->mainWindow = NULL; - this->initIcoLib( ); - this->hHookOnOptionsInit = HookEvent( ME_OPT_INITIALISE, this->initOptions ); - //this->hHookOnPluginsLoaded = HookEvent( ME_SYSTEM_MODULESLOADED, this->postLoading ); - this->hHookOnDBSettingChanged = HookEvent( ME_DB_CONTACT_SETTINGCHANGED, this->respondDBChange ); - this->hHookOnStatusMenuBuild = HookEvent( ME_CLIST_PREBUILDSTATUSMENU, this->createMenuItems ); -} - - -CSList::~CSList( ) -{ - // unhook events, destroy functions - UnhookEvent( this->hHookOnStatusMenuBuild ); - UnhookEvent( this->hHookOnPluginsLoaded ); - UnhookEvent( this->hHookOnOptionsInit ); - UnhookEvent( this->hHookOnDBSettingChanged ); - DestroyServiceFunction( this->hServiceShowList ); - - // clear IcoLib - for ( int i = 0; i < SIZEOF(forms); i++ ) - { - char iconName[64]; - mir_snprintf(iconName, SIZEOF(iconName), "%s_%s", __INTERNAL_NAME, forms[i].pszIconIcoLib); - CallService( MS_SKIN2_REMOVEICON, 0, ( LPARAM )iconName ); - } -} - - -int CSList::postLoading( WPARAM wparam, LPARAM lparam ) -{ - //cslist->registerHotkeys( ); - cslist->initIcoLib( ); // for < 0.7, but probably useless though :/ - return FALSE; -} - - -void CSList::registerHotkeys(char buf[200], TCHAR* accName, int Number) -{ - HOTKEYDESC hotkey = { 0 }; - hotkey.cbSize = sizeof(hotkey); - hotkey.dwFlags = HKD_TCHAR; - hotkey.pszName = buf; - hotkey.ptszDescription = accName; - hotkey.ptszSection = LPGENT("Custom Status List"); - hotkey.pszService = buf; - hotkey.DefHotKey = HOTKEYCODE( HOTKEYF_CONTROL | HOTKEYF_SHIFT, '0'+Number ); - Hotkey_Register(&hotkey); -} - -int CSList::initOptions( WPARAM wparam, LPARAM lparam ) -{ - OPTIONSDIALOGPAGE odp = { 0 }; - odp.cbSize = sizeof(odp); - odp.position = 955000000; - odp.hInstance = CSList::handle; - odp.pszTemplate = MAKEINTRESOURCEA( IDD_OPTIONS ); - odp.pszTitle = MODULENAME; - odp.pfnDlgProc = CSOptionsProc; - odp.pszGroup = LPGEN("Status"); - odp.flags = ODPF_BOLDGROUPS; - Options_AddPage(wparam, &odp); - return FALSE; -} - - -int CSList::respondDBChange( WPARAM wparam, LPARAM lparam ) -{ - HANDLE hContact = ( HANDLE )wparam; - DBCONTACTWRITESETTING *cws = ( DBCONTACTWRITESETTING* )lparam; - - // if user changes his UIN or JID on any account - if (hContact == NULL && (!lstrcmpA(cws->szSetting, "UIN") || !lstrcmpA(cws->szSetting, "jid"))) - { - cslist->rebuildMenuItems(); - return 0; - } - - // own setting or not a status-related setting - else if ( hContact == NULL || lstrcmpA( cws->szSetting, "Status" )) - return 0; - - DWORD dwEasteredUin = getDword( "EasterEggedUIN", 0x0 ); - if ( dwEasteredUin == 0x0 ) // no spyed UIN found - return 0; - - DBVARIANT dbv = { 0 }; - DBGetContactSettingString( hContact, "Protocol", "p", &dbv ); - - DWORD dwUin = DBGetContactSettingDword( hContact, dbv.pszVal, "UIN", 0x0 ); - - if ( dwUin != 0x0 ) // if this is an ICQ user - if ( dwUin == dwEasteredUin ) // if spyed UIN is equivalent to this contact - if ( DBGetContactSettingWord( hContact, "UserOnline", "OldStatus", 0 ) == ID_STATUS_OFFLINE ) - if ( cws->value.wVal > ID_STATUS_OFFLINE ) - cslist->setStatus( IDC_CANCEL, NULL, ""); - - return FALSE; -} - - -int CSList::createMenuItems( WPARAM wparam, LPARAM lparam ) -{ - int ProtoCount = 0; - - ForAllProtocols(countProtos, &ProtoCount); - - if (ProtoCount == 0) - return FALSE; - - ForAllProtocols(addProtoStatusMenuItem, 0); - - return FALSE; -} - - -void CSList::rebuildMenuItems( ) -{ - CLIST_INTERFACE* pcli; - pcli = ( CLIST_INTERFACE* )CallService( MS_CLIST_RETRIEVE_INTERFACE, 0, 0 ); - if ( pcli && pcli->version > 4 ) - pcli->pfnReloadProtoMenus( ); -} - - -void CSList::setStatus( WORD code, StatusItem* item, char* protoName) -{ - if ( code == IDCLOSE ) - return; - - PROTOACCOUNT* pdescr = (PROTOACCOUNT*)CallService(MS_PROTO_GETACCOUNT, 0, (LPARAM)protoName); - if (pdescr == NULL) - return; - int statusToSet = -1; - if (lstrcmpA(pdescr->szProtoName, "ICQ") == 0) - { - ICQ_CUSTOM_STATUS ics = {0}; - ics.cbSize = sizeof(ICQ_CUSTOM_STATUS); - ics.flags = CSSF_MASK_STATUS | CSSF_MASK_NAME | CSSF_MASK_MESSAGE | CSSF_TCHAR; - - if (code == IDC_CANCEL) - { - statusToSet = 0; - ics.ptszName = _T(""); - ics.ptszMessage = _T(""); - } - else if (code == IDOK && item != NULL) - { - statusToSet = item->iIcon + 1; - ics.ptszName = variables_parsedup(item->tszTitle, NULL, NULL); - ics.ptszMessage = variables_parsedup(item->tszMessage, NULL, NULL); - } - else return; - - ics.status = &statusToSet; - - char protoService[64]; - mir_snprintf(protoService, SIZEOF(protoService), "%s%s", protoName, PS_ICQ_SETCUSTOMSTATUSEX); - CallService(protoService, 0, (LPARAM)&ics); - } - if (lstrcmpA(pdescr->szProtoName, "JABBER") == 0) - { - JABBER_CUSTOM_STATUS ics = {0}; - ics.cbSize = sizeof(ICQ_CUSTOM_STATUS); - ics.flags = CSSF_MASK_STATUS | CSSF_MASK_NAME | CSSF_MASK_MESSAGE | CSSF_TCHAR; - - if (code == IDC_CANCEL) - { - statusToSet = 0; - ics.ptszMessage = _T(""); - } - else if (code == IDOK && item != NULL) - { - statusToSet = item->iIcon + 1; - ics.ptszMessage = variables_parsedup(item->tszMessage, NULL, NULL); - } - else return; - - ics.status = &statusToSet; - - char protoService[64]; - mir_snprintf(protoService, SIZEOF(protoService), "%s%s", protoName, JS_SETXSTATUSEX); - CallService(protoService, 0, (LPARAM)&ics); - } -} - -void CSList::initIcoLib( ) -{ - // init icons of buttons - TCHAR tszFile[MAX_PATH]; - GetModuleFileName( CSList::handle, tszFile, MAX_PATH ); - - SKINICONDESC sid = { 0 }; - sid.cbSize = sizeof(SKINICONDESC); - sid.ptszDefaultFile = tszFile; - sid.flags = SIDF_ALL_TCHAR; - sid.cx = sid.cy = 16; - sid.ptszSection = _T(MODULENAME); - - for (int i=0; i < SIZEOF(forms); i++ ) { - char szSettingName[64]; - mir_snprintf( szSettingName, SIZEOF(szSettingName), "%s_%s", __INTERNAL_NAME, forms[i].pszIconIcoLib ); - - sid.pszName = szSettingName; - sid.ptszDescription = forms[i].ptszDescr; - sid.iDefaultIndex = -forms[i].iconNoIcoLib; - forms[i].hIcoLibItem = Skin_AddIcon(&sid); - } -} - - -INT_PTR CSList::showList(WPARAM wparam, LPARAM lparam, LPARAM param) -{ - cslist->mainWindow = new CSWindow((char*)param); - ForkThread(&cslist->mainWindow->showWindow, cslist->mainWindow); - return 0; -} - - -void CSList::closeList( HWND hwnd ) -{ - ForkThread( &cslist->mainWindow->closeWindow, hwnd ); - delete cslist->mainWindow; - cslist->mainWindow = NULL; -} - - -void CSList::ForAllProtocols( pForAllProtosFunc pFunc, void* arg ) -{ - int protoCount; - PROTOACCOUNT** pdesc; - CallService( MS_PSEUDO_PROTO_PROTOACCSENUM, ( WPARAM )&protoCount, ( LPARAM )&pdesc ); - - for ( int i = 0; i < protoCount; i++ ) - { - if (lstrcmpA(pdesc[i]->szProtoName, "ICQ") == 0) - { - DWORD uin = 0; - uin = DBGetContactSettingDword(NULL, pdesc[i]->szModuleName, "UIN", 0); - if (uin == 0) - continue; - } - else if (lstrcmpA(pdesc[i]->szProtoName, "JABBER") == 0) - { - DBVARIANT dbv = {0}; - DBGetContactSettingTString(NULL, pdesc[i]->szModuleName, "jid", &dbv); - if (dbv.ptszVal == _T("")) - continue; - } - else - continue; - pFunc(pdesc[i]->szModuleName , arg); - } -} - - -void CSList::addProtoStatusMenuItem( char* protoName, void* arg ) -{ - char buf[200]; - PROTOACCOUNT* pdescr; - pdescr = (PROTOACCOUNT*)CallService(MS_PROTO_GETACCOUNT, 0, (LPARAM)protoName); - if (pdescr == NULL) - return; - - HANDLE hService; - mir_snprintf(buf, SIZEOF(buf), "CSList/ShowList/%s", protoName); - if (!ServiceExists(buf)) - hService = CreateServiceFunctionParam(buf, CSList::showList, (LPARAM)protoName); - List_Insert(servicesList, hService, servicesList->realCount); - - CLISTMENUITEM mi = {0}; - mi.cbSize = sizeof(mi); - mi.flags = CMIF_TCHAR; - if (ServiceExists(MS_SKIN2_GETICON)) - mi.icolibItem = (HANDLE)LoadIconExEx("icon", IDI_CSLIST); - else - mi.hIcon = LoadIconExEx("icon", IDI_CSLIST); - mi.ptszName = _T(MODULENAME); - mi.position = 2000040000; - mi.pszService = buf; - mi.ptszPopupName = pdescr->tszAccountName; - Menu_AddStatusMenuItem(&mi); - - cslist->registerHotkeys(buf, pdescr->tszAccountName, pdescr->iOrder); -} - - -void CSList::countProtos( char* protoName, void* arg ) -{ - int* protosEnabled = (int*)arg; - *protosEnabled = ( *protosEnabled )++; -} - - -void CSList::countPlusModProtos( char* protoName, void* arg ) -{ - int* protosExtraEnabled = ( int* )arg; - if ( DBGetContactSettingDword( NULL, protoName, "NonStandartXstatus", 0 ) || - DBGetContactSettingDword( NULL, protoName, "NonStandardXstatus", 0 )) - *protosExtraEnabled = ( *protosExtraEnabled )++; -} - -void CSList::importCustomStatusUIStatusesFromAllProtos( char* protoName, void* arg ) -{ - int* result = ( int* )arg; - - for ( int i = 1; i <= 37; i++ ) - { - DBVARIANT dbv = { 0 }; - char bufTitle[32], bufMessage[32]; - StatusItem* si = new StatusItem( ); - - si->iIcon = i - 1; - - mir_snprintf( bufTitle, 32, "XStatus%luName", i ); - DBGetContactSettingTString( NULL, protoName, bufTitle, &dbv ); - lstrcpy( si->tszTitle, dbv.ptszVal ); - - mir_snprintf( bufMessage, 32, "XStatus%luMsg", i ); - DBGetContactSettingTString( NULL, protoName, bufMessage, &dbv ); - lstrcpy( si->tszMessage, dbv.ptszVal ); - - if ( lstrlen( si->tszTitle ) || lstrlen( si->tszMessage )) - { - cslist->mainWindow->itemslist->list->add( si ); - cslist->mainWindow->bSomethingChanged = TRUE; - } - else - delete si; - - if ( *result == IDYES ) - { - DBDeleteContactSetting( NULL, protoName, bufTitle ); - DBDeleteContactSetting( NULL, protoName, bufMessage ); - } - } - cslist->mainWindow->listview->reinitItems( cslist->mainWindow->itemslist->list->getListHead( )); -} - - -CSWindow::CSWindow(char* protoName) -{ - this->protoName = protoName; - this->handle = NULL; - this->bExtraIcons = getByte( "AllowExtraIcons", DEFAULT_ALLOW_EXTRA_ICONS ); - this->itemslist = new CSItemsList(this->protoName); - this->listview = NULL; - this->addModifyDlg = NULL; - this->bSomethingChanged = FALSE; - this->filterString = NULL; -} - - -CSWindow::~CSWindow( ) -{ - delete this->itemslist; - SAFE_FREE( ( void** )&this->filterString ); -} - - -void CSWindow::showWindow( void* arg ) -{ - CSWindow* csw = ( CSWindow* )arg; - - while ( csw == NULL ) - SleepEx( 10, FALSE ); - - DialogBoxParam( CSList::handle, MAKEINTRESOURCE( IDD_CSLIST ), NULL, ( DLGPROC )CSWindowProc, ( LPARAM )csw ); -} - - -void CSWindow::closeWindow( void* arg ) -{ - HWND hwnd = ( HWND )arg; - EndDialog( hwnd, FALSE ); -} - - -void CSWindow::initIcons() -{ - PROTOACCOUNT* pdescr = (PROTOACCOUNT*)CallService(MS_PROTO_GETACCOUNT, 0, (LPARAM)protoName); - if (pdescr == NULL) - return; - - if (lstrcmpA(pdescr->szProtoName, "ICQ") == 0) - { - DWORD uin = 0; - uin = DBGetContactSettingDword(NULL, pdescr->szModuleName, "UIN", 0); - if (uin != 0) - { - this->icons = ImageList_Create( 16, 16, IsWinVerXPPlus( ) ? ILC_COLOR32 | ILC_MASK : ILC_COLOR16 | ILC_MASK, XSTATUS_COUNT_EXTENDED, 0 ); - if ( this->icons ) - { - for ( int i = 0; i < ( ( this->bExtraIcons ) ? XSTATUS_COUNT_EXTENDED : XSTATUS_COUNT ); i++ ) - { - char szTemp[MAX_PATH]; - mir_snprintf(szTemp, SIZEOF(szTemp), "%s_xstatus%d", protoName, i); - ImageList_AddIcon( this->icons, ( HICON )CallService( MS_SKIN2_GETICON, 0, ( LPARAM )szTemp )); - } - } - } - } - else if (lstrcmpA(pdescr->szProtoName, "JABBER") == 0) - { - DBVARIANT dbv = {0}; - DBGetContactSettingTString(NULL, pdescr->szModuleName, "jid", &dbv); - if (dbv.ptszVal != _T("")) - { - this->icons = ImageList_Create( 16, 16, IsWinVerXPPlus( ) ? ILC_COLOR32 | ILC_MASK : ILC_COLOR16 | ILC_MASK, MOODS_COUNT, 0 ); - if ( this->icons ) - { - for ( int i = 0; i < MOODS_COUNT; i++ ) - { - char szTemp[MAX_PATH]; - mir_snprintf(szTemp, SIZEOF(szTemp), "%s_%s", protoName, moods_names[i].szTag); - ImageList_AddIcon( this->icons, ( HICON )CallService( MS_SKIN2_GETICON, 0, ( LPARAM )szTemp )); - } - } - } - } -} - - -void CSWindow::deinitIcons( ) -{ - ImageList_Destroy( this->icons ); -} - - -void CSWindow::initButtons( ) -{ - for (int i = 0; i < SIZEOF(forms); i++) - { - if ( forms[i].idc < 0 ) - continue; - - SendDlgItemMessage( this->handle, forms[i].idc, BM_SETIMAGE, IMAGE_ICON, ( LPARAM )LoadIconExEx( forms[i].pszIconIcoLib, forms[i].iconNoIcoLib )); - SendDlgItemMessage( this->handle, forms[i].idc, BUTTONSETASFLATBTN, TRUE, 0 ); //maybe set as BUTTONSETDEFAULT? - SendDlgItemMessage( this->handle, forms[i].idc, BUTTONADDTOOLTIP, ( WPARAM )TranslateTS(forms[i].ptszTitle), BATF_TCHAR ); - } -} - -void CSWindow::loadWindowPosition( ) -{ - RECT rect = { 0 }; - int width = GetSystemMetrics( SM_CXSCREEN ); - int height = GetSystemMetrics( SM_CYSCREEN ); - GetWindowRect( this->handle, &rect ); - int x, y, defX, defY; - defX = x = ( width + 1 - ( rect.right - rect.left )) >> 1; - defY = y = ( height + 1 - ( rect.bottom - rect.top )) >> 1; - if ( getByte( "RememberWindowPosition", DEFAULT_REMEMBER_WINDOW_POSITION )) - { - x = getWord( "PositionX", defX ); - y = getWord( "PositionY", defY ); - } - if ( x > width || y > height || x < 0 || y < 0 ) - { - x = defX; - y = defY; - } - - MoveWindow( this->handle, - x, y, - ( rect.right - rect.left ), - ( rect.bottom - rect.top ), - TRUE ); -} - - -void CSWindow::toggleEmptyListMessage( ) -{ - HWND hwnd = GetDlgItem( this->handle, IDC_NO_ITEMS ); - ShowWindow( hwnd, ( ListView_GetItemCount( this->listview->handle ) > 0 ) ? FALSE : TRUE ); - SetForegroundWindow( hwnd ); - hwnd = GetDlgItem( this->handle, IDC_ADD_SAMPLE ); - ShowWindow( hwnd, ( ListView_GetItemCount( this->listview->handle ) > 0 ) ? FALSE : TRUE ); - SetForegroundWindow( hwnd ); -} - - -BOOL CSWindow::itemPassedFilter( ListItem< StatusItem >* li ) -{ - TCHAR filter[MAX_PATH]; - GetDlgItemText( this->handle, IDC_FILTER_FIELD, filter, MAX_PATH ); - - if ( lstrlen( filter )) - { - TCHAR title[EXTRASTATUS_TITLE_LIMIT], message[EXTRASTATUS_MESSAGE_LIMIT]; - lstrcpy( title, li->item->tszTitle ); lstrcpy( message, li->item->tszMessage ); - if ( strpos( _tcslwr( title ), _tcslwr( filter )) == -1 ) - if ( strpos( _tcslwr( message ), _tcslwr( filter )) == -1 ) - return FALSE; - } - - return TRUE; -} - - -void CSWindow::toggleFilter( ) -{ - HWND hFilter = GetDlgItem( this->handle, IDC_FILTER_FIELD ); - BOOL isEnabled = !IsWindowEnabled( hFilter ) ? TRUE : FALSE; // ! = + isEnabled = !isEnabled in one - EnableWindow( hFilter, isEnabled ); - ShowWindow( hFilter, isEnabled ); - CheckDlgButton( this->handle, IDC_FILTER, isEnabled ); - SetForegroundWindow( hFilter ); - if ( isEnabled ) - SetFocus( hFilter ); - else - { - TCHAR filterText[255]; - GetDlgItemText(this->handle, IDC_FILTER_FIELD, filterText, SIZEOF(filterText)); - if ( lstrlen( filterText ) > 0 ) - SetDlgItemText( this->handle, IDC_FILTER_FIELD, TEXT( "" )); - } -} - - -BOOL CSWindow::toggleButtons( ) -{ - int selection = ListView_GetSelectedItemMacro( this->listview->handle ); - BOOL validSelection = ( selection >= 0 && ( unsigned int )selection < this->itemslist->list->getCount( )) ? TRUE : FALSE; - BOOL filterEnabled = IsWindowVisible( GetDlgItem( this->handle, IDC_FILTER_FIELD )); - BOOL somethingChanged = this->bSomethingChanged; - - EnableWindow( GetDlgItem( this->handle, IDC_ADD ), !filterEnabled ); - EnableWindow( GetDlgItem( this->handle, IDC_MODIFY ), validSelection && !filterEnabled ); - EnableWindow( GetDlgItem( this->handle, IDC_REMOVE ), validSelection && !filterEnabled ); - EnableWindow( GetDlgItem( this->handle, IDC_FAVOURITE ), validSelection && !filterEnabled ); - EnableWindow( GetDlgItem( this->handle, IDC_UNDO ), somethingChanged && !filterEnabled ); - EnableWindow( GetDlgItem( this->handle, IDC_IMPORT ), !filterEnabled ); -// EnableWindow( GetDlgItem( this->handle, IDC_GLOBAL ), !filterEnabled ); - EnableWindow( GetDlgItem( this->handle, IDOK ), validSelection ); - - return validSelection; -} - - -CSAMWindow::CSAMWindow( WORD action, CSWindow* parent ) -{ - this->action = action; - this->parent = parent; - this->bChanged = FALSE; - this->hCombo = this->hMessage = NULL; - - if ( this->action == IDC_ADD ) - this->item = new StatusItem( ); - else - this->item = new StatusItem( *this->parent->itemslist->list->get( this->parent->listview->getPositionInList( )) ); - -} - - -CSAMWindow::~CSAMWindow( ) -{ - if ( ! this->bChanged ) - delete this->item; -} - - -void CSAMWindow::exec( ) -{ - DialogBoxParam( CSList::handle, MAKEINTRESOURCE( IDD_ADDMODIFY ), NULL, ( DLGPROC )CSAMWindowProc, ( LPARAM )this ); -} - - -void CSAMWindow::setCombo() -{ - PROTOACCOUNT* pdescr = (PROTOACCOUNT*)CallService(MS_PROTO_GETACCOUNT, 0, (LPARAM)this->parent->protoName); - if (pdescr == NULL) - return; - - if (lstrcmpA(pdescr->szProtoName, "ICQ") == 0) - { - DWORD uin = 0; - uin = DBGetContactSettingDword(NULL, pdescr->szModuleName, "UIN", 0); - if (uin != 0) - { - SendMessage( this->hCombo, CBEM_SETIMAGELIST, 0, ( LPARAM )this->parent->icons ); - for ( int i = 0; i < ( ( this->parent->bExtraIcons ) ? XSTATUS_COUNT_EXTENDED : XSTATUS_COUNT ); i++ ) - { - COMBOBOXEXITEM cbi = { 0 }; - cbi.mask = CBEIF_IMAGE | CBEIF_TEXT | CBEIF_SELECTEDIMAGE; - cbi.pszText = TranslateTS(xstatus_names[i].ptszTitle); - cbi.iImage = xstatus_names[i].iId - 1; - cbi.iItem = i; - cbi.iSelectedImage = i; - SendMessage( this->hCombo, CBEM_INSERTITEM, 0, ( LPARAM )&cbi ); - } - SendMessage( this->hCombo, CB_SETCURSEL, 0, 0 ); // first 0 sets selection to top - } - } - else if (lstrcmpA(pdescr->szProtoName, "JABBER") == 0) - { - DBVARIANT dbv = {0}; - DBGetContactSettingTString(NULL, pdescr->szModuleName, "jid", &dbv); - if (dbv.ptszVal != _T("")) - { - SendMessage( this->hCombo, CBEM_SETIMAGELIST, 0, ( LPARAM )this->parent->icons ); - for ( int i = 0; i < MOODS_COUNT; i++ ) - { - COMBOBOXEXITEM cbi = { 0 }; - cbi.mask = CBEIF_IMAGE | CBEIF_TEXT | CBEIF_SELECTEDIMAGE; - cbi.pszText = TranslateTS(moods_names[i].ptszTitle); - cbi.iImage = moods_names[i].iId - 1; - cbi.iItem = i; - cbi.iSelectedImage = i; - SendMessage( this->hCombo, CBEM_INSERTITEM, 0, ( LPARAM )&cbi ); - } - SendMessage( this->hCombo, CB_SETCURSEL, 0, 0 ); // first 0 sets selection to top - } - } -} - -void CSAMWindow::fillDialog( ) -{ - if ( this->action == IDC_ADD ) - { - SetWindowText( this->handle, TranslateT("Add new item")); - SetDlgItemText( this->handle, IDOK, TranslateT("Add")); - } - else - { - SetWindowText( this->handle, TranslateT("Modify item")); - SetDlgItemText( this->handle, IDOK, TranslateT("Modify")); - } - - SendMessage( this->hCombo, CB_SETCURSEL, this->item->iIcon, 0 ); - SetDlgItemText( this->handle, IDC_MESSAGE, this->item->tszMessage ); -} - - -void CSAMWindow::checkFieldLimit( WORD action, WORD item ) -{ - BOOL type = ( item == IDC_MESSAGE ) ? TRUE : FALSE; - unsigned int limit = type ? EXTRASTATUS_MESSAGE_LIMIT : EXTRASTATUS_TITLE_LIMIT; - - if ( action == EN_CHANGE ) - { - TCHAR* ptszInputText = (TCHAR*)mir_alloc((limit + 8) * sizeof(TCHAR)); - - GetDlgItemText( this->handle, item, ptszInputText, limit + 8 ); - - if ( _tcslen( ptszInputText ) > limit ) - { -#if ( WINVER >= 0x501 ) - TCHAR tszPopupTip[MAX_PATH]; - EDITBALLOONTIP ebt = { 0 }; - ebt.cbStruct = sizeof(ebt); - ebt.pszTitle = TranslateT("Warning"); - mir_sntprintf(tszPopupTip, SIZEOF(tszPopupTip), TranslateT("This field doesn't accept string longer than %d characters. The string will be truncated."), limit); - ebt.pszText = tszPopupTip; - ebt.ttiIcon = TTI_WARNING; - SendMessage( GetDlgItem( this->handle, item ), EM_SHOWBALLOONTIP, 0, ( LPARAM )&ebt ); -#endif - TCHAR* ptszOutputText = (TCHAR*)mir_alloc((limit + 1) * sizeof(TCHAR)); - GetDlgItemText( this->handle, item, ptszOutputText, limit + 1 ); - SetDlgItemText( this->handle, item, ptszOutputText ); - mir_free( ptszOutputText ); - } - mir_free( ptszInputText ); - } -} - - -void CSAMWindow::checkItemValidity() -{ - COMBOBOXEXITEM cbi = { 0 }; - cbi.mask = CBEIF_IMAGE; - cbi.iItem = SendDlgItemMessage( this->handle, IDC_COMBO, CB_GETCURSEL, 0, 0 ); - SendDlgItemMessage( this->handle, IDC_COMBO, CBEM_GETITEM, 0, ( LPARAM )&cbi ); - - if ( this->item->iIcon != cbi.iImage ) - ( this->item->iIcon = cbi.iImage ) && ( this->bChanged = TRUE ); - - TCHAR tszInputMessage[EXTRASTATUS_MESSAGE_LIMIT]; - - GetDlgItemText( this->handle, IDC_MESSAGE, tszInputMessage, EXTRASTATUS_MESSAGE_LIMIT ); - - PROTOACCOUNT* pdescr = (PROTOACCOUNT*)CallService(MS_PROTO_GETACCOUNT, 0, (LPARAM)this->parent->protoName); - if (pdescr == NULL) - return; - - if (lstrcmpA(pdescr->szProtoName, "ICQ") == 0) - { - int i = SendMessage(this->hCombo, CB_GETCURSEL, 0, 0); - lstrcpy(this->item->tszTitle, TranslateTS(xstatus_names[i].ptszTitle)); - } - if (lstrcmpA(pdescr->szProtoName, "JABBER") == 0) - { - int i = SendMessage(this->hCombo, CB_GETCURSEL, 0, 0); - lstrcpy(this->item->tszTitle, TranslateTS(moods_names[i].ptszTitle)); - } - if ( lstrcmp( this->item->tszMessage, tszInputMessage )) - ( lstrcpy( this->item->tszMessage, tszInputMessage )) && ( this->bChanged = TRUE ); -} - - -CSListView::CSListView( HWND hwnd, CSWindow* parent ) -{ - this->handle = hwnd; - this->parent = parent; - -#if (_WIN32_WINNT >= 0x501) - LVGROUP lg = { 0 }; - lg.cbSize = sizeof(LVGROUP); - lg.mask = LVGF_HEADER | LVGF_GROUPID; - - lg.pszHeader = TranslateT("Favourites"); - lg.iGroupId = 0; - ListView_InsertGroup( this->handle, -1, &lg ); - - lg.pszHeader = TranslateT("Regular statuses"); - lg.iGroupId = 1; - ListView_InsertGroup( this->handle, -1, &lg ); - ListView_EnableGroupView( this->handle, TRUE ); -#endif - - LVCOLUMN lvc = { 0 }; - lvc.mask = LVCF_TEXT | LVCF_FMT | LVCF_WIDTH | LVCF_SUBITEM; - lvc.fmt = LVCFMT_LEFT; - lvc.cx = 0x00; - lvc.pszText = TEXT( "" ); - lvc.cx = 0x16; - SendMessage( this->handle, LVM_INSERTCOLUMN, 0, ( LPARAM )&lvc ); - lvc.pszText = TranslateT("Title"); - lvc.cx = 0x64; - SendMessage( this->handle, LVM_INSERTCOLUMN, 1, ( LPARAM )&lvc ); - lvc.pszText = TranslateT("Message"); - lvc.cx = 0xa8; - SendMessage( this->handle, LVM_INSERTCOLUMN, 2, ( LPARAM )&lvc ); - -// ListView_SetExtendedListViewStyle( this->handle, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_HEADERDRAGDROP ); -#if (_WIN32_IE >= 0x0400) - ListView_SetExtendedListViewStyleEx( this->handle, 0, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_HEADERDRAGDROP | LVS_EX_INFOTIP ); -#endif - ListView_SetImageList( this->handle, this->parent->icons, LVSIL_SMALL ); -} - - -void CSListView::addItem( StatusItem* item, int itemNumber ) -{ - LVITEM lvi = { 0 }; - lvi.mask = LVIF_IMAGE | LVIF_GROUPID | LVIF_PARAM; - lvi.cchTextMax = 256; - lvi.iItem = ListView_GetItemCount( this->handle ); - lvi.lParam = itemNumber; -#if ( WINVER >= 0x501 ) - lvi.iGroupId = ( item->bFavourite == TRUE ) ? 0 : 1; -#endif - - // first column - lvi.iSubItem = 0; - lvi.iImage = item->iIcon; // use selected xicon - SendMessage( this->handle, LVM_INSERTITEM, 0, ( LPARAM )&lvi ); - - // second column - lvi.mask = LVIF_TEXT; - lvi.iSubItem = 1; - lvi.pszText = item->tszTitle; - SendMessage( this->handle, LVM_SETITEM, 0, ( LPARAM )&lvi ); - - // third column - lvi.iSubItem = 2; - lvi.pszText = item->tszMessage; - SendMessage( this->handle, LVM_SETITEM, 0, ( LPARAM )&lvi ); -} - - -void CSListView::initItems( ListItem< StatusItem >* items ) -{ - ListItem< StatusItem >* help = items; - for ( int i = 0; help != NULL; help = help->next, i++ ) - if ( parent->itemPassedFilter( help )) - addItem( help->item, i ); -} - - -void CSListView::reinitItems( ListItem< StatusItem >* items ) -{ - EnableWindow( this->handle, FALSE ); - this->removeItems( ); - this->initItems( items ); - EnableWindow( this->handle, TRUE ); -} - - -void CSListView::removeItems( ) -{ - ListView_DeleteAllItems( this->handle ); -} - - -int CSListView::getPositionInList( ) -{ - LVITEM lvi = { 0 }; - lvi.iItem = ListView_GetSelectedItemMacro( this->parent->listview->handle ); - lvi.iSubItem = 0; - lvi.mask = LVIF_PARAM; - ListView_GetItem( this->parent->listview->handle, &lvi ); - return lvi.lParam; -} - - -void CSListView::setFullFocusedSelection( int selection ) -{ - ListView_SetItemState( this->handle, -1, 0, LVIS_SELECTED ); - ListView_EnsureVisible( this->handle, selection, FALSE ); - ListView_SetItemState( this->handle, selection, LVIS_SELECTED, LVIS_SELECTED ); - ListView_SetItemState( this->handle, selection, LVIS_FOCUSED , LVIS_FOCUSED ); - SetFocus( this->handle ); -} - - -// ====[ THREAD FORK ]======================================================== - -void ForkThread( pThreadFunc pFunc, void* arg ) -{ - mir_forkthread( pFunc, arg ); -} - - -// ====[ LIST MANAGEMENT ]==================================================== - -CSItemsList::CSItemsList(char* protoName) -{ - this->list = new List< StatusItem >( this->compareItems ); - this->loadItems(protoName); -} - - -CSItemsList::~CSItemsList( ) -{ - delete this->list; -} - - -int CSItemsList::compareItems( const StatusItem* p1, const StatusItem* p2 ) -{ - int favRes = 0, icoRes = 0, ttlRes = 0, msgRes = 0; - - if ( p1->bFavourite < p2->bFavourite ) - favRes = 1; - else if ( p1->bFavourite > p2->bFavourite ) - favRes = -1; - - int result; - if ( p1->iIcon > p2->iIcon ) - icoRes = 1; - else if ( p1->iIcon < p2->iIcon ) - icoRes = -1; - - result = lstrcmp( p1->tszTitle, p2->tszTitle ); - ttlRes = result; - - result = lstrcmp( p1->tszMessage, p2->tszMessage ); - msgRes = result; - - if ( !icoRes && !ttlRes && !msgRes ) - return 0; - - if ( favRes != 0 ) - return favRes; - if ( icoRes != 0 ) - return icoRes; - if ( ttlRes != 0 ) - return ttlRes; - if ( msgRes != 0 ) - return msgRes; - - return 0; -} - - -void CSItemsList::loadItems(char* protoName) -{ - char dbSetting[32]; - mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_ItemsCount", protoName); - unsigned int itemsCount = getWord(dbSetting, DEFAULT_ITEMS_COUNT); - - for (unsigned int i = 1; i <= itemsCount; i++) - { - StatusItem* item = new StatusItem(); - DBVARIANT dbv = {DBVT_TCHAR}; - mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_Item%dIcon", protoName, i); - item->iIcon = getByte(dbSetting, DEFAULT_ITEM_ICON); - mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_Item%dTitle", protoName, i); - getTString(dbSetting, &dbv); - lstrcpy(item->tszTitle, dbv.ptszVal); - mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_Item%dMessage", protoName, i); - getTString(dbSetting, &dbv); - lstrcpy(item->tszMessage, dbv.ptszVal); - mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_Item%dFavourite", protoName, i); - item->bFavourite = (BOOL)getByte(dbSetting, DEFAULT_ITEM_IS_FAVOURITE); - this->list->add(item); - } -} - - -void CSItemsList::saveItems(char* protoName) -{ - unsigned int i; - char dbSetting[32]; - mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_ItemsCount", protoName); - unsigned int oldItemsCount = getWord(dbSetting, DEFAULT_ITEMS_COUNT); - - for (i = 1; i <= this->list->getCount(); i++) - { - StatusItem* item = this->list->get( i - 1 ); - mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_Item%dIcon", protoName, i); - setByte(dbSetting, item->iIcon); - mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_Item%dTitle", protoName, i); - setTString(dbSetting, item->tszTitle); - mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_Item%dMessage", protoName, i); - setTString(dbSetting, item->tszMessage); - mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_Item%dFavourite", protoName, i); - setByte(dbSetting, item->bFavourite); - } - - mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_ItemsCount", protoName); - setWord(dbSetting, this->list->getCount()); - - for ( ; i <= oldItemsCount; i++) - { - mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_Item%dIcon", protoName, i); - deleteSetting(dbSetting); - mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_Item%dTitle", protoName, i); - deleteSetting(dbSetting); - mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_Item%dMessage", protoName, i); - deleteSetting(dbSetting); - mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_Item%dFavourite", protoName, i); - deleteSetting(dbSetting); - } -} - - -// ====[ PROCEDURES ]========================================================= - -INT_PTR CALLBACK CSWindowProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam ) -{ - CSWindow* csw = ( CSWindow* )GetWindowLongPtr( hwnd, GWLP_USERDATA ); - - switch ( message ) - { - - case WM_INITDIALOG: - csw = ( CSWindow* )lparam; - SetWindowLongPtr( hwnd, GWLP_USERDATA, lparam ); - csw->handle = hwnd; - csw->initIcons(); - csw->initButtons( ); - csw->listview = new CSListView( GetDlgItem( hwnd, IDC_CSLIST ), csw ); - csw->listview->initItems( csw->itemslist->list->getListHead( )); - csw->toggleButtons( ); - csw->toggleEmptyListMessage( ); - csw->loadWindowPosition( ); - SetWindowText(hwnd, TranslateT(MODULENAME)); - TranslateDialogDefault(hwnd); - return TRUE; - - case WM_COMMAND: - switch ( LOWORD( wparam )) - { - case IDC_MODIFY: - case IDC_ADD: - csw->addModifyDlg = new CSAMWindow( LOWORD( wparam ), csw ); - csw->addModifyDlg->exec( ); - if ( csw->addModifyDlg->bChanged ) - { - if ( LOWORD( wparam ) == IDC_MODIFY ) - csw->itemslist->list->remove( csw->listview->getPositionInList( )); - - int selection = csw->itemslist->list->add( csw->addModifyDlg->item ); - csw->bSomethingChanged = TRUE; - csw->listview->reinitItems( csw->itemslist->list->getListHead( )); - csw->listview->setFullFocusedSelection( selection ); - csw->toggleButtons( ); - csw->toggleEmptyListMessage( ); - } - delete csw->addModifyDlg; - break; - - case IDC_REMOVE: - if ( getByte( "ConfirmDeletion", DEFAULT_PLUGIN_CONFIRM_ITEMS_DELETION )) - if ( MessageBox( hwnd, TranslateT("Do you really want to delete selected item?"), TranslateT(MODULENAME), MB_YESNO | MB_DEFBUTTON2 | MB_ICONQUESTION ) == IDNO ) - break; - csw->itemslist->list->remove( csw->listview->getPositionInList( )); - csw->bSomethingChanged = TRUE; - csw->listview->reinitItems( csw->itemslist->list->getListHead( )); - csw->toggleButtons( ); - csw->toggleEmptyListMessage( ); - break; - - case IDC_FAVOURITE: - { - int selection = csw->listview->getPositionInList( ); - StatusItem* f = new StatusItem( *csw->itemslist->list->get( selection )); - f->bFavourite = ! f->bFavourite; - csw->itemslist->list->remove( selection ); - selection = csw->itemslist->list->add( f ); - csw->bSomethingChanged = TRUE; - csw->listview->reinitItems( csw->itemslist->list->getListHead( )); - csw->listview->setFullFocusedSelection( selection ); - csw->toggleButtons( ); - } - break; - - case IDC_UNDO: - { - csw->itemslist->list->destroy( ); - csw->itemslist->loadItems(csw->protoName); - csw->bSomethingChanged = FALSE; - csw->listview->reinitItems( csw->itemslist->list->getListHead( )); - csw->toggleButtons( ); - csw->toggleEmptyListMessage( ); - break; - } - - case IDC_IMPORT: - { - int result = getByte( "DeleteAfterImport", DEFAULT_PLUGIN_DELETE_AFTER_IMPORT ); - if ( result == TRUE ) - result = IDYES; - else - { - result = MessageBox( hwnd, TranslateT("Do you want old database entries to be deleted after Import?"), - TranslateT(MODULENAME), MB_YESNOCANCEL | MB_DEFBUTTON2 | MB_ICONQUESTION ); - if ( result == IDCANCEL ) break; - } - - CSList::ForAllProtocols( CSList::importCustomStatusUIStatusesFromAllProtos, ( void* )&result ); - csw->bSomethingChanged = TRUE; - csw->toggleButtons( ); - csw->toggleEmptyListMessage( ); - } - break; - - case IDC_FILTER: - csw->toggleFilter( ); - csw->toggleButtons( ); - break; - - case IDC_FILTER_FIELD: - if ( HIWORD( wparam ) == EN_CHANGE ) - csw->listview->reinitItems( csw->itemslist->list->getListHead( )); - break; - - case IDCLOSE: // close and save, no custom status - case IDCANCEL: // close and save, no custom status - case IDC_CANCEL: // close and save, cancel custom status - case IDOK: // close and save, set selected custom status - if ( LOWORD( wparam ) == IDOK && csw->toggleButtons( )) - cslist->setStatus(IDOK, csw->itemslist->list->get(csw->listview->getPositionInList()), csw->protoName); - if ( LOWORD( wparam ) == IDC_CANCEL ) - cslist->setStatus(IDC_CANCEL, NULL, csw->protoName); - if ( csw->bSomethingChanged ) - if (csw->itemslist!=NULL) - csw->itemslist->saveItems(csw->protoName); - csw->saveWindowPosition( csw->handle ); - delete csw->listview; - csw->deinitIcons( ); - cslist->closeList( hwnd ); - break; - - } - return FALSE; - - case WM_NOTIFY: - if ( wparam == IDC_CSLIST ) - { - NMHDR* pnmh = ( NMHDR* )lparam; - switch ( pnmh->code ) - { - - case NM_DBLCLK: - PostMessage( hwnd, WM_COMMAND, IDOK, 0L ); - break; - - case LVN_ITEMCHANGED: - case NM_CLICK: - csw->toggleButtons( ); - break; - - } - } - return FALSE; - - case WM_CTLCOLORSTATIC: - SetTextColor( ( HDC )wparam, RGB( 174, 174, 174 )); - if ( ( ( HWND )lparam == GetDlgItem( hwnd, IDC_NO_ITEMS )) || - ( ( HWND )lparam == GetDlgItem( hwnd, IDC_ADD_SAMPLE )) ) - return ( BOOL )GetStockObject( WHITE_BRUSH ); - return FALSE; - } - return FALSE; -} - - -INT_PTR CALLBACK CSAMWindowProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam ) -{ - CSAMWindow* csamw = ( CSAMWindow* )GetWindowLongPtr( hwnd, GWLP_USERDATA ); - - switch ( message ) - { - - case WM_INITDIALOG: - { - csamw = ( CSAMWindow* )lparam; - SetWindowLongPtr( hwnd, GWLP_USERDATA, lparam ); - csamw->handle = hwnd; - EnableWindow( csamw->parent->handle, FALSE ); - csamw->hCombo = GetDlgItem( hwnd, IDC_COMBO ); - csamw->hMessage = GetDlgItem( hwnd, IDC_MESSAGE ); - csamw->setCombo(); - csamw->fillDialog(); - TranslateDialogDefault(hwnd); - } - break; - - case WM_COMMAND: - switch ( LOWORD( wparam )) - { - case IDC_MESSAGE: - csamw->checkFieldLimit( HIWORD( wparam ), LOWORD( wparam )); - break; - case IDOK: - csamw->checkItemValidity( ); - case IDCANCEL: - EnableWindow( csamw->parent->handle, TRUE ); - EndDialog( hwnd, LOWORD( wparam )); - break; - - } - break; - - } - return FALSE; -} - - -INT_PTR CALLBACK CSOptionsProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam ) -{ - switch ( message ) - { - - case WM_INITDIALOG: - { - CheckDlgButton( hwnd, IDC_CONFIRM_DELETION, - getByte( "ConfirmDeletion", DEFAULT_PLUGIN_CONFIRM_ITEMS_DELETION ) ? - BST_CHECKED : BST_UNCHECKED ); - - CheckDlgButton( hwnd, IDC_DELETE_AFTER_IMPORT, - getByte( "DeleteAfterImport", DEFAULT_PLUGIN_DELETE_AFTER_IMPORT ) ? - BST_CHECKED : BST_UNCHECKED ); - - CheckDlgButton( hwnd, IDC_REMEMBER_POSITION, - getByte( "RememberWindowPosition", DEFAULT_REMEMBER_WINDOW_POSITION ) ? - BST_CHECKED : BST_UNCHECKED ); - - unsigned int protosExtraEnabled = 1; - - CSList::ForAllProtocols( CSList::countPlusModProtos, ( void* )&protosExtraEnabled ); - - if ( protosExtraEnabled ) // some protocol(s) allow(s) use of extra icons - { - EnableWindow( GetDlgItem( hwnd, IDC_ALLOW_EXTRA_ICONS ), TRUE ); - CheckDlgButton( hwnd, IDC_ALLOW_EXTRA_ICONS, getByte( "AllowExtraIcons", - DEFAULT_ALLOW_EXTRA_ICONS )); - } - - TranslateDialogDefault(hwnd); - } - return TRUE; - - case WM_NOTIFY: - switch ( ( ( LPNMHDR )lparam )->code ) - { - - case PSN_APPLY: - { - setByte( "ConfirmDeletion", IsDlgButtonChecked( hwnd, IDC_CONFIRM_DELETION ) ? 1 : 0 ); - setByte( "DeleteAfterImport", IsDlgButtonChecked( hwnd, IDC_DELETE_AFTER_IMPORT ) ? 1 : 0 ); - setByte( "AllowExtraIcons", IsDlgButtonChecked( hwnd, IDC_ALLOW_EXTRA_ICONS ) ? 1 : 0 ); - setByte( "RememberWindowPosition", IsDlgButtonChecked( hwnd, IDC_REMEMBER_POSITION ) ? 1 : 0 ); - - cslist->rebuildMenuItems( ); - } - break; - - } - return TRUE; - - } - return FALSE; -} - - -// ====[ HELPERS ]============================================================ - -HICON LoadIconExEx( const char* IcoLibName, int NonIcoLibIcon ) -{ - if ( ServiceExists( MS_SKIN2_GETICON )) { - char szSettingName[64]; - mir_snprintf(szSettingName, SIZEOF(szSettingName), "%s_%s", __INTERNAL_NAME, IcoLibName); - return ( HICON )CallService( MS_SKIN2_GETICON, 0, ( LPARAM )szSettingName ); - } - else - return ( HICON )LoadImage( cslist->handle, MAKEINTRESOURCE( NonIcoLibIcon ), IMAGE_ICON, 0, 0, 0 ); -} diff --git a/plugins/CSList/cslist.h b/plugins/CSList/cslist.h deleted file mode 100644 index 7a4f0f8e75..0000000000 --- a/plugins/CSList/cslist.h +++ /dev/null @@ -1,665 +0,0 @@ -/* ======================================================================== - - Custom Status List - __________________ - - Custom Status List plugin for Miranda-IM (www.miranda-im.org) - Follower of Custom Status History List by HANAX - Copyright © 2006-2008 HANAX - Copyright © 2007-2009 jarvis - - 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$ - Revision : $Rev$ - Last change on : $Date$ - Last change by : $Author$ - - ============================================================================ - - - DESCRIPTION: - - Offers List of your Custom Statuses. - - ============================================================================ - -// ====[ INCLUDES AND DEFINITIONS ]======================================== */ - -#ifndef __CSLIST_H -#define __CSLIST_H 1 - - -#define WINVER 0x501 -#define _WIN32_WINNT 0x501 -#define _WIN32_IE 0x600 - -#define MIRANDA_VER 0x0A00 - -#pragma warning( disable: 4996 ) -#pragma comment( lib, "comctl32.lib" ) - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// ====[ BASIC DEFINITIONS ]================================================== - -#include "resource.h" -#include "version.h" - -#define MODULENAME "Custom Status List" - -// {C8CC7414-6507-4AF6-925A-83C1D2F7BE8C} -#define PLUGIN_GUUID { 0xc8cc7414, 0x6507, 0x4af6, { 0x92, 0x5a, 0x83, 0xc1, 0xd2, 0xf7, 0xbe, 0x8c } } - -// ====[ LIMITS ]============================================================= - -#define EXTRASTATUS_TITLE_LIMIT 64 // limit of chars for extra status title -#define EXTRASTATUS_MESSAGE_LIMIT 2048 // limit of chars for extra status message -#define XSTATUS_COUNT 32 -#define XSTATUS_COUNT_EXTENDED 37 -#define MOODS_COUNT 84 - -// ====[ SERVICES ]=========================================================== - -#define MS_PSEUDO_PROTO_PROTOACCSENUM ( CSList::bAccountsSupported ? MS_PROTO_ENUMACCOUNTS : MS_PROTO_ENUMPROTOCOLS ) - -// ====[ DEFAULT DB VALUES ]================================================== - -#define DEFAULT_ICQ_XSTATUS_ENABLED 1 -#define DEFAULT_PLUGIN_SHOW_RELNOTES 0 -#define DEFAULT_PLUGIN_SHOW_NONSTANDARD_XSTATUSES 1 -#define DEFAULT_PLUGIN_CONFIRM_ITEMS_DELETION 1 -#define DEFAULT_PLUGIN_DELETE_AFTER_IMPORT 0 -#define DEFAULT_ITEMS_COUNT 0 -#define DEFAULT_ITEM_ICON 0 -#define DEFAULT_ITEM_IS_FAVOURITE 0 -#define DEFAULT_ALLOW_EXTRA_ICONS 1 -#define DEFAULT_REMEMBER_WINDOW_POSITION 1 - - -// ====[ FUNCTION MACROS ]==================================================== - -// set which row is selected (cannot be only focused, but fully selected - second param ;)) -#define ListView_GetSelectedItemMacro( hwnd ) ListView_GetNextItem( hwnd, -1, LVNI_FOCUSED | LVNI_SELECTED ); -#ifndef ListView_SetSelectionMark - #define ListView_SetSelectionMark( x, y ) 0 -#endif - -#define getByte( setting, error ) DBGetContactSettingByte( NULL, __INTERNAL_NAME, setting, error ) -#define setByte( setting, value ) DBWriteContactSettingByte( NULL, __INTERNAL_NAME, setting, value ) -#define getWord( setting, error ) DBGetContactSettingWord( NULL, __INTERNAL_NAME, setting, error ) -#define setWord( setting, value ) DBWriteContactSettingWord( NULL, __INTERNAL_NAME, setting, value ) -#define getDword( setting, error ) DBGetContactSettingDword( NULL, __INTERNAL_NAME, setting, error ) -#define setDword( setting, value ) DBWriteContactSettingDword( NULL, __INTERNAL_NAME, setting, value ) -#define getTString( setting, dest ) DBGetContactSettingTString( NULL, __INTERNAL_NAME, setting, dest ) -#define setTString( setting, value ) DBWriteContactSettingTString( NULL, __INTERNAL_NAME, setting, value ) -#define deleteSetting( setting ) DBDeleteContactSetting( NULL, __INTERNAL_NAME, setting ) - -// -- -typedef void (__cdecl *pForAllProtosFunc)( char*, void* ); - - -// ====[ STRUCTURES ]========================================================= - -struct StatusItem { // list item structure - int iIcon; - TCHAR tszTitle[EXTRASTATUS_TITLE_LIMIT]; - TCHAR tszMessage[EXTRASTATUS_MESSAGE_LIMIT]; - BOOL bFavourite; - - StatusItem() - { - this->iIcon = 0; - lstrcpy(this->tszTitle, _T("")); - lstrcpy(this->tszMessage, _T("")); - this->bFavourite = FALSE; - } - - StatusItem( const StatusItem& p ) - { - this->iIcon = p.iIcon; - lstrcpy( this->tszTitle, p.tszTitle ); - lstrcpy( this->tszMessage, p.tszMessage ); - this->bFavourite = p.bFavourite; - } - - ~StatusItem( ) - { - } -}; - -static struct CSForm { // icons + buttons - int idc; - TCHAR* ptszTitle; - TCHAR* ptszDescr; - char* pszIconIcoLib; - int iconNoIcoLib; - HANDLE hIcoLibItem; - -} forms[] = { - - { -1, LPGENT( "Main Menu" ), LPGENT( "Main Icon" ), "icon", IDI_CSLIST, NULL }, - { IDC_ADD, LPGENT( "Add new item" ), LPGENT( "Add" ), "add", IDI_ADD, NULL }, - { IDC_MODIFY, LPGENT( "Modify selected item" ), LPGENT( "Modify" ), "modify", IDI_MODIFY, NULL }, - { IDC_REMOVE, LPGENT( "Delete selected item" ), LPGENT( "Remove" ), "remove", IDI_REMOVE, NULL }, - { IDC_FAVOURITE, LPGENT( "Set/unset current item as favorite" ), LPGENT( "Favourite" ), "favourite", IDI_FAVOURITE, NULL }, - { IDC_UNDO, LPGENT( "Undo changes" ), LPGENT( "Undo changes" ), "undo", IDI_UNDO, NULL }, - { IDC_IMPORT, LPGENT( "Import statuses from database" ), LPGENT( "Import" ), "import", IDI_IMPORT, NULL }, - { IDC_FILTER, LPGENT( "Filter list" ), LPGENT( "Filter" ), "filter", IDI_FILTER, NULL }, - { IDCLOSE, LPGENT( "Close without changing custom status" ), LPGENT( "No change" ), "nochng", IDI_CLOSE, NULL }, - { IDC_CANCEL, LPGENT( "Clear custom status (reset to None) and close" ), LPGENT( "Clear" ), "clear", IDI_UNSET, NULL }, - { IDOK, LPGENT( "Set custom status to selected one and close" ), LPGENT( "Set" ), "apply", IDI_APPLY, NULL }, -}; - -static struct CSXstatus { // combobox xstatus icons - int iId; - TCHAR* ptszTitle; - -} xstatus_names[] = { - - { 1, LPGENT( "Angry" ) }, - { 2, LPGENT( "Taking a bath" ) }, - { 3, LPGENT( "Tired" ) }, - { 4, LPGENT( "Party" ) }, - { 5, LPGENT( "Drinking beer" ) }, - { 6, LPGENT( "Thinking" ) }, - { 7, LPGENT( "Eating" ) }, - { 8, LPGENT( "Watching TV" ) }, - { 9, LPGENT( "Meeting" ) }, - { 10, LPGENT( "Coffee" ) }, - { 11, LPGENT( "Listening to music" ) }, - { 12, LPGENT( "Business" ) }, - { 13, LPGENT( "Shooting" ) }, - { 14, LPGENT( "Having fun" ) }, - { 15, LPGENT( "On the phone" ) }, - { 16, LPGENT( "Gaming" ) }, - { 17, LPGENT( "Studying" ) }, - { 18, LPGENT( "Shopping" ) }, - { 19, LPGENT( "Feeling sick" ) }, - { 20, LPGENT( "Sleeping" ) }, - { 21, LPGENT( "Surfing" ) }, - { 22, LPGENT( "Browsing" ) }, - { 23, LPGENT( "Working" ) }, - { 24, LPGENT( "Typing" ) }, - { 25, LPGENT( "Picnic" ) }, - { 26, LPGENT( "PDA" ) }, - { 27, LPGENT( "On the phone" ) }, - { 28, LPGENT( "I'm high" ) }, - { 29, LPGENT( "On WC" ) }, - { 30, LPGENT( "To be or not to be" ) }, - { 31, LPGENT( "Watching pro7 on TV" ) }, - { 32, LPGENT( "Love" ) }, - { 33, LPGENT( "Searching" ) }, - { 34, LPGENT( "Amorous" ) }, // I don't understand why this falls when 2 same named items appear O_o - { 35, LPGENT( "Journal" ) }, // edit: ..and now I REALLY don't understand why it's working now x)) - { 36, LPGENT( "Sex" ) }, - { 37, LPGENT( "Smoking" ) }, // -||- -}; - -static struct CSMoods { // combobox moods icons - int iId; - TCHAR* ptszTitle; - char* szTag; -} moods_names[] = { - { 1, LPGENT("Afraid"), "afraid" }, - { 2, LPGENT("Amazed"), "amazed" }, - { 3, LPGENT("Amorous"), "amorous" }, - { 4, LPGENT("Angry"), "angry" }, - { 5, LPGENT("Annoyed"), "annoyed" }, - { 6, LPGENT("Anxious"), "anxious" }, - { 7, LPGENT("Aroused"), "aroused" }, - { 8, LPGENT("Ashamed"), "ashamed" }, - { 9, LPGENT("Bored"), "bored" }, - { 10, LPGENT("Brave"), "brave" }, - { 11, LPGENT("Calm"), "calm" }, - { 12, LPGENT("Cautious"), "cautious" }, - { 13, LPGENT("Cold"), "cold" }, - { 14, LPGENT("Confident"), "confident" }, - { 15, LPGENT("Confused"), "confused" }, - { 16, LPGENT("Contemplative"),"contemplative" }, - { 17, LPGENT("Contented"), "contented" }, - { 18, LPGENT("Cranky"), "cranky" }, - { 19, LPGENT("Crazy"), "crazy" }, - { 20, LPGENT("Creative"), "creative" }, - { 21, LPGENT("Curious"), "curious" }, - { 22, LPGENT("Dejected"), "dejected" }, - { 23, LPGENT("Depressed"), "depressed" }, - { 24, LPGENT("Disappointed"), "disappointed" }, - { 25, LPGENT("Disgusted"), "disgusted" }, - { 26, LPGENT("Dismayed"), "dismayed" }, - { 27, LPGENT("Distracted"), "distracted" }, - { 28, LPGENT("Embarrassed"), "embarrassed" }, - { 29, LPGENT("Envious"), "envious" }, - { 30, LPGENT("Excited"), "excited" }, - { 31, LPGENT("Flirtatious"), "flirtatious" }, - { 32, LPGENT("Frustrated"), "frustrated" }, - { 33, LPGENT("Grateful"), "grateful" }, - { 34, LPGENT("Grieving"), "grieving" }, - { 35, LPGENT("Grumpy"), "grumpy" }, - { 36, LPGENT("Guilty"), "guilty" }, - { 37, LPGENT("Happy"), "happy" }, - { 38, LPGENT("Hopeful"), "hopeful" }, - { 39, LPGENT("Hot"), "hot" }, - { 40, LPGENT("Humbled"), "humbled" }, - { 41, LPGENT("Humiliated"), "humiliated" }, - { 42, LPGENT("Hungry"), "hungry" }, - { 43, LPGENT("Hurt"), "hurt" }, - { 44, LPGENT("Impressed"), "impressed" }, - { 45, LPGENT("In awe"), "in_awe" }, - { 46, LPGENT("In love"), "in_love" }, - { 47, LPGENT("Indignant"), "indignant" }, - { 48, LPGENT("Interested"), "interested" }, - { 49, LPGENT("Intoxicated"), "intoxicated" }, - { 50, LPGENT("Invincible"), "invincible" }, - { 51, LPGENT("Jealous"), "jealous" }, - { 52, LPGENT("Lonely"), "lonely" }, - { 53, LPGENT("Lost"), "lost" }, - { 54, LPGENT("Lucky"), "lucky" }, - { 55, LPGENT("Mean"), "mean" }, - { 56, LPGENT("Moody"), "moody" }, - { 57, LPGENT("Nervous"), "nervous" }, - { 58, LPGENT("Neutral"), "neutral" }, - { 59, LPGENT("Offended"), "offended" }, - { 60, LPGENT("Outraged"), "outraged" }, - { 61, LPGENT("Playful"), "playful" }, - { 62, LPGENT("Proud"), "proud" }, - { 63, LPGENT("Relaxed"), "relaxed" }, - { 64, LPGENT("Relieved"), "relieved" }, - { 65, LPGENT("Remorseful"), "remorseful" }, - { 66, LPGENT("Restless"), "restless" }, - { 67, LPGENT("Sad"), "sad" }, - { 68, LPGENT("Sarcastic"), "sarcastic" }, - { 69, LPGENT("Satisfied"), "satisfied" }, - { 70, LPGENT("Serious"), "serious" }, - { 71, LPGENT("Shocked"), "shocked" }, - { 72, LPGENT("Shy"), "shy" }, - { 73, LPGENT("Sick"), "sick" }, - { 74, LPGENT("Sleepy"), "sleepy" }, - { 75, LPGENT("Spontaneous"), "spontaneous" }, - { 76, LPGENT("Stressed"), "stressed" }, - { 77, LPGENT("Strong"), "strong" }, - { 78, LPGENT("Surprised"), "surprised" }, - { 79, LPGENT("Thankful"), "thankful" }, - { 80, LPGENT("Thirsty"), "thirsty" }, - { 81, LPGENT("Tired"), "tired" }, - { 82, LPGENT("Undefined"), "undefined" }, - { 83, LPGENT("Weak"), "weak" }, - { 84, LPGENT("Worried"), "worried" }, -}; -// ====[ MY BITCHY LIST IMPLEMENTATION x)) ]================================== -// TODO: Optimize it all x)) - -template< class T > struct ListItem -{ - T* item; - ListItem* next; - - ListItem( ) - { - this->item = NULL; - this->next = NULL; - } - - ~ListItem( ) - { - delete this->item; - } - - ListItem( StatusItem* si ) - { - this->item = si; - this->next = NULL; - } - - ListItem( const ListItem& p ) - { - this->item = p.item; - this->next = NULL; - } -}; - - -template< class T > struct List -{ -private: - ListItem< T >* items; - unsigned int count; - -public: - typedef int ( *compareFunc )( const T* p1, const T* p2 ); - compareFunc compare; - - List( compareFunc compFnc ) - { - this->items = NULL; - this->count = 0; - this->compare = compFnc; - } - - ~List( ) - { - this->destroy( ); - } - - ListItem< T >* getListHead( ) - { - return items; - } - - unsigned int getCount( ) - { - return count; - } - - int add( T* csi ) - { - int position = 0; - ListItem< T >* item = new ListItem< T >( csi ); - if ( this->items == NULL ) - this->items = item; - else - { - ListItem< T >* help = item; - item->next = items; - while ( help->next != NULL ) - { - int cmp = compare( item->item, help->next->item ); - if ( cmp == 1 ) - help = help->next; - else if ( cmp == 0 ) - { - delete item; - return -1; - } - else - break; - position++; - } - if ( help != item ) - { - item->next = help->next; - help->next = item; - } - else - items = item; - } - this->count++; - return position; - } - - int remove( const unsigned int item ) - { - int position = 0; - if ( item < 0 || item >= this->count ) - return -1; - - ListItem< T >* help = items; - ListItem< T >* removed; - if ( item == 0 ) - { - items = items->next; - removed = help; - } - else - { - for ( unsigned int i = 0; i < item - 1; i++ ) - { - help = help->next; - position++; - } - removed = help->next; - help->next = help->next->next; - } - delete removed; - this->count--; - return position; - } - - T* get( const unsigned int item ) - { - ListItem< T >* help = items; - for ( unsigned int i = 0; i < item; i++ ) - help = help->next; - return help->item; - } - - T* operator[]( const unsigned int item ) - { - return get( item ); - } - - void destroy( ) - { - while ( this->count > 0 ) - this->remove( 0 ); - } -}; - - -// ====[ CLASSING -- FUNNY STUFF :) ]========================================= - -struct CSList; -struct CSWindow; -struct CSAMWindow; -struct CSItemsList; -struct CSListView; - -// -------- - -struct CSListView -{ - HWND handle; - CSWindow* parent; - - CSListView( HWND, CSWindow* ); - - void addItem( StatusItem* item, int itemNumber ); - void initItems( ListItem< StatusItem >* items ); - void reinitItems( ListItem< StatusItem >* items ); - void removeItems( ); - int getPositionInList( ); - void setFullFocusedSelection( int selection ); -}; - - -struct CSItemsList -{ - List< StatusItem >* list; - - static int compareItems( const StatusItem* p1, const StatusItem* p2 ); - void loadItems(char* protoName); - void saveItems(char* protoName); - - CSItemsList(char* protoName); - ~CSItemsList(); -}; - - -struct CSAMWindow -{ - WORD action; - StatusItem* item; - CSWindow* parent; - BOOL bChanged; - - HWND handle; - HWND hCombo; - HWND hMessage; - - CSAMWindow( WORD action, CSWindow* parent ); - ~CSAMWindow( ); - - void exec( ); - void setCombo( ); - void fillDialog( ); - void checkFieldLimit( WORD action, WORD item ); - void checkItemValidity(); -}; - - -struct CSWindow -{ - HWND handle; - BOOL bExtraIcons; - CSItemsList* itemslist; - CSListView* listview; - CSAMWindow* addModifyDlg; - HIMAGELIST icons; - BOOL bSomethingChanged; - TCHAR* filterString; - char* protoName; - CSWindow(char* protoName); - ~CSWindow(); - - void initIcons( ); - void deinitIcons( ); - void initButtons( ); - static void __cdecl showWindow( void* arg ); - static void __cdecl closeWindow( void* arg ); - void loadWindowPosition( ); - BOOL toggleButtons( ); - void toggleEmptyListMessage( ); - void toggleFilter( ); - BOOL itemPassedFilter( ListItem< StatusItem >* li ); - - void __inline saveWindowPosition( HWND hwnd ) - { - if ( getByte( "RememberWindowPosition", DEFAULT_REMEMBER_WINDOW_POSITION ) == TRUE ) - { - RECT rect = { 0 }; - GetWindowRect( hwnd, &rect ); - setWord( "PositionX", rect.left ); - setWord( "PositionY", rect.top ); - } - } -}; - - -struct CSList -{ - // global variables - static HINSTANCE handle; - static DWORD dwMirandaVersion; - static BOOL bUnicodeCore; - static BOOL bAccountsSupported; - - // class components - CSWindow* mainWindow; - - // events - HANDLE hHookOnPluginsLoaded; - HANDLE hHookOnOptionsInit; - HANDLE hHookOnDBSettingChanged; - HANDLE hHookOnStatusMenuBuild; - - // services - HANDLE hServiceShowList; - - CSList( ); - ~CSList( ); - - // event functions - static int postLoading( WPARAM, LPARAM ); - static int initOptions( WPARAM, LPARAM ); - static int respondDBChange( WPARAM, LPARAM ); - static int createMenuItems( WPARAM, LPARAM ); - - // service functions - static INT_PTR __cdecl showList(WPARAM, LPARAM, LPARAM); - void closeList( HWND ); - - // protocols enumeration related functions - static void ForAllProtocols( pForAllProtosFunc pFunc, void* arg ); - static void __cdecl addProtoStatusMenuItem( char* protoName, void* arg ); - static void __cdecl countProtos( char* protoName, void* arg ); - static void __cdecl countPlusModProtos( char* protoName, void* arg ); - static void __cdecl importCustomStatusUIStatusesFromAllProtos( char* protoName, void* arg ); - - // other functions - void initIcoLib( ); - void registerHotkeys(char buf[200], TCHAR* accName, int Number); - void rebuildMenuItems( ); - void setStatus(WORD code, StatusItem* item, char* protoName); -}; - -HINSTANCE CSList::handle = NULL; -DWORD CSList::dwMirandaVersion = 0x00000000; -BOOL CSList::bUnicodeCore = FALSE; -BOOL CSList::bAccountsSupported = FALSE; - -// ====[ GLOBALS ]============================================================ - -CSList* cslist = NULL; - -// ====[ INIT STUFF ]========================================================= - -BOOL WINAPI DllMain( HINSTANCE, DWORD, LPVOID ); - -extern "C" __declspec( dllexport ) PLUGININFOEX* MirandaPluginInfoEx( DWORD ); - -extern "C" __declspec( dllexport ) int Load(void); -extern "C" __declspec( dllexport ) int Unload( void ); - - -// ====[ THREAD FORK ]======================================================== - -void ForkThread( pThreadFunc pFunc, void* arg ); - - -// ====[ PROCEDURES ]========================================================= - -INT_PTR CALLBACK CSWindowProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam ); -INT_PTR CALLBACK CSAMWindowProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam ); -INT_PTR CALLBACK CSRNWindowProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam ); -INT_PTR CALLBACK CSOptionsProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam ); - - -// ====[ HELPERS ]============================================================ - -HICON LoadIconExEx( const char*, int ); - -void __fastcall SAFE_FREE(void** p) -{ - if (*p) - { - free(*p); - *p = NULL; - } -} - - -#endif /* __CSLIST_H */ diff --git a/plugins/CSList/cslist.rc b/plugins/CSList/cslist.rc deleted file mode 100644 index de21946047..0000000000 --- a/plugins/CSList/cslist.rc +++ /dev/null @@ -1,182 +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 - -///////////////////////////////////////////////////////////////////////////// -// Английский (США) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_CSLIST ICON "res/cslist.ico" -IDI_ADD ICON "res/add.ico" -IDI_MODIFY ICON "res/modify.ico" -IDI_REMOVE ICON "res/remove.ico" -IDI_FAVOURITE ICON "res/favourite.ico" -IDI_IMPORT ICON "res/import.ico" -IDI_UNDO ICON "res/undo.ico" -IDI_FILTER ICON "res/filter.ico" -IDI_CLOSE ICON "res/close.ico" -IDI_UNSET ICON "res/unset.ico" -IDI_APPLY ICON "res/apply.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_CSLIST DIALOGEX 0, 0, 214, 227 -STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Custom Status List" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - CONTROL "",IDC_CSLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,3,3,207,204 - CONTROL "A",IDC_ADD,"MButtonClass",WS_TABSTOP,3,210,16,14 - CONTROL "M",IDC_MODIFY,"MButtonClass",WS_TABSTOP,23,210,16,14 - CONTROL "D",IDC_REMOVE,"MButtonClass",WS_TABSTOP,43,210,16,14 - CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,63,210,1,14 - CONTROL "F",IDC_FAVOURITE,"MButtonClass",WS_TABSTOP,67,210,16,14 - CONTROL "U",IDC_UNDO,"MButtonClass",WS_DISABLED | WS_TABSTOP,87,210,16,14 - CONTROL "I",IDC_IMPORT,"MButtonClass",WS_TABSTOP,107,210,16,14 - CONTROL "I",IDC_FILTER,"MButtonClass",WS_TABSTOP | 0x1000,127,210,16,14 - EDITTEXT IDC_FILTER_FIELD,3,210,120,14,ES_AUTOHSCROLL | NOT WS_VISIBLE | WS_DISABLED - CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,147,210,1,14 - CONTROL "N",IDCLOSE,"MButtonClass",WS_TABSTOP,153,210,16,14 - CONTROL "C",IDC_CANCEL,"MButtonClass",WS_TABSTOP,173,210,16,14 - CONTROL "O",IDOK,"MButtonClass",WS_TABSTOP,193,210,16,14 - ICON IDI_ADD,IDC_ADD_SAMPLE,102,90,20,20,SS_REALSIZEIMAGE - CTEXT "No items available in the database.\nClick the Add button to define some.",IDC_NO_ITEMS,43,101,130,49,0,WS_EX_TRANSPARENT -END - -IDD_ADDMODIFY DIALOGEX 100, 100, 187, 90 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Add/Modify Custom Status" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - CONTROL "",IDC_COMBO,"ComboBoxEx32",CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP,6,5,175,107 - EDITTEXT IDC_MESSAGE,6,21,175,50,ES_MULTILINE | ES_WANTRETURN | WS_VSCROLL - DEFPUSHBUTTON "Add/Modify",IDOK,6,74,104,14 - PUSHBUTTON "Cancel",IDCANCEL,116,74,65,14 -END - -IDD_OPTIONS DIALOGEX 0, 0, 300, 107 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_CLIPSIBLINGS -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - GROUPBOX "List settings",IDC_STATIC,4,4,292,73 - CONTROL "Confirm deletion of items",IDC_CONFIRM_DELETION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,24,20,253,10 - CONTROL "Delete entries in ICQ Custom status menu after Import",IDC_DELETE_AFTER_IMPORT, - "Button",BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE | WS_TABSTOP,24,32,253,10 - CONTROL "Allow extra ICQ Custom status items (ICQ Plus only)",IDC_ALLOW_EXTRA_ICONS, - "Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,24,44,253,10 - CONTROL "Remember last window position",IDC_REMEMBER_POSITION, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,24,56,253,10 - CTEXT "Note: Menu items are only visible when at least one ICQ account is properly set. Check if you have at least one account with UIN filled in.",IDC_STATIC,6,80,283,23 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_CSLIST, DIALOG - BEGIN - LEFTMARGIN, 3 - RIGHTMARGIN, 210 - VERTGUIDE, 23 - VERTGUIDE, 43 - VERTGUIDE, 67 - VERTGUIDE, 87 - VERTGUIDE, 107 - VERTGUIDE, 127 - VERTGUIDE, 153 - VERTGUIDE, 173 - VERTGUIDE, 193 - TOPMARGIN, 3 - BOTTOMMARGIN, 224 - HORZGUIDE, 207 - HORZGUIDE, 210 - END - - IDD_ADDMODIFY, DIALOG - BEGIN - LEFTMARGIN, 6 - RIGHTMARGIN, 181 - TOPMARGIN, 5 - BOTTOMMARGIN, 88 - END - - IDD_OPTIONS, DIALOG - BEGIN - LEFTMARGIN, 4 - RIGHTMARGIN, 296 - VERTGUIDE, 24 - VERTGUIDE, 34 - VERTGUIDE, 277 - TOPMARGIN, 4 - BOTTOMMARGIN, 103 - END -END -#endif // APSTUDIO_INVOKED - - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\0" -END - -#endif // APSTUDIO_INVOKED - -#endif // Английский (США) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/plugins/CSList/cslist_10.vcxproj b/plugins/CSList/cslist_10.vcxproj index 9897b8b73b..53baf0bab7 100644 --- a/plugins/CSList/cslist_10.vcxproj +++ b/plugins/CSList/cslist_10.vcxproj @@ -167,34 +167,18 @@ - + - - - - - + + + + + - - - - - - - - - - - - - - - - - - + + diff --git a/plugins/CSList/cslist_10.vcxproj.filters b/plugins/CSList/cslist_10.vcxproj.filters index ec0ad7695e..eb57988f85 100644 --- a/plugins/CSList/cslist_10.vcxproj.filters +++ b/plugins/CSList/cslist_10.vcxproj.filters @@ -18,76 +18,32 @@ - + Source Files - + Header Files - + Header Files - + Header Files - + Resource Files - + Header 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 - - - Other - - - - + Resource Files - + Resource Files diff --git a/plugins/CSList/docs/changelog.txt b/plugins/CSList/docs/changelog.txt new file mode 100644 index 0000000000..a40a767491 --- /dev/null +++ b/plugins/CSList/docs/changelog.txt @@ -0,0 +1,144 @@ + + TODO + ---- + - all TODOs listed in this source x) + - feature requests maybe :) + ! settings changes + - mid-range rewrite + - force-replacing of Custom Status UI + + MAYBE-TODO + ---------- + + NOT-TODO + -------- + - setting Away/NA/DND/Occ - there are already many status managers :) + - watching statuses set by x-status menu + + 0.1.0.4 - Twix Fix + ------- + - Fixed showing menu items when not applicable + - Fixed toggling of controls when list item is removed + - Returned "Undo" function + - Returned "Import" function + - Returned multi-account functionality + - Added item focus selection & focus when added, modified or favourite-toggled + - "Inactive" focus fix + - Fixed occasional crash when trying to open multiple dialogs + - Fixed showing "Empty list" message when list is empty and undoing something from DB, not showing when undoing something with nothing in DB or showing message after importing into an empty list + + 0.1.0.3 - What's your favourite? + ------- + - Bugfixes + + 0.1.0.1 - After storm + ------- + - Favourites + - Virtualized structure + - Code refactorization + - Duplicities detection (partial) + - Saving window position + + 0.0.0.20 - calm before the storm Ox) + -------- + - some corrections of working with strings (ANSI/Unicode <-> TCHAR) + - simplified loading of list items :) + - the Options button replaced by the Undo button + + 0.0.0.19 - enjoy multi'ing, baby :) + -------- + - status is changing on all ICQ based accounts/protos + - when dialog is opened, and user tryes to open another one, forgotten dialog is brought to front instead + - menu placement optimalization + - removed old nasty GOTO because of double-clicking the list x) + - active checking of input data length during editing custom status + - optimalizations in translations + - support for Variables plugin + - other enhancements related to the possibility of using multiple ICQ accounts + + 0.0.0.18 - fixing trip :) + -------- + - icon selector shows only icons, that are supported by installed ICQ plugin + - fixed memory leak and possible crash when modifying status and then importing 0 DB entries (helpItem not nulled) + - merged Add/Modify processes together :) + - Unicode build, finally :) + + 0.0.0.17 - I become to be useful :) + -------- + - CSList menu item can be placed elsewhere, also instead of Xstatus menu (currently ICQ eternity/PlusPlus++ mod only) + - importing statuses from database (ICQ key) + - list sorting (Procedure + calls) + - dialog openable only once :) + - new icons by inducti0n :) + - no more infinite width when adding x-message + - new Options dialog + + 0.0.0.16 - rework + -------- + - code redesigned + - fix for Windows Vista crash (free) and ANSI Windows crash (init extended controls) + - preimplementation for new features that will come (favourites, ...) + + 0.0.0.15 - make me nice + -------- + - stage 1 of code revision + - Options dialog (in development) :) + - IcoLib group renamed to CSLIST_MODULE_LONG_NAME + - status titles in Add/Modify ComboBox were strangely corrected x) + - possibility to turn off "Release Notes" dialog + + 0.0.0.14 - will you use me? :) + -------- + - new lines in message input creatable via Enter + - NULLED XSTATUS now available :) + + 0.0.0.13 - oooops x)) + -------- + - hotfix for Miranda cores < 0.7 + - CSList appears in Main Menu + - fixed icons not loaded when IcoLib is missing + + 0.0.0.12 - goin' my way now x) + -------- + - DB saving method/format slightly modified + [+] multi-line messages now working + [-] LOST compatibility with HANAX's plugin (but is auto-imported if exists) + NOTE: I think "importing-only" of older releases will stay, + I have many Feature Requests that would need changing + DB format anyway, so this problem looks solved x) + - "Release notes" dialog on first run + - Updater support + + 0.0.0.11 - will this work? x) + -------- + - some similar procedures merged together :P + - another procedures more generalized 8) + - separated Add/Modify dialog finally in use :) + [+] solves some bahaviour problems x) + + 0.0.0.10 - ohhh, basics ]:) + -------- + - icons support - complete xstatus service :) + [+] no more static angry ;) :D + - iconized buttons - supporting IcoLib :) + - better method for DB entry format - old was little.."dizzy" x) :D + - TEMPORARILY DISABLED modifying of items - needs some fixes x)) + + 0.0.0.9 - working a little? O:) + ------- + - enhanced List Control behaviour (selecting, deselecting, editation, adding) + - LOADING from + SAVING to DB! + [+] my parser is also compatible with HANAX plugin's DB entries ;) + + 0.0.0.8 - behaviour testing :o) + ------- + - setting status by double-clicking list item + - much better procedures, debugging, better exceptions, dialog behaviour + + 0.0.0.7 - crash testing :o) + ------- + - basic functions coding + + 0.0.0.6 - resource testing + ------- + - basic resources modeling diff --git a/plugins/CSList/docs/cslist-translation.txt b/plugins/CSList/docs/cslist-translation.txt new file mode 100644 index 0000000000..bbd57fded5 --- /dev/null +++ b/plugins/CSList/docs/cslist-translation.txt @@ -0,0 +1,175 @@ +; Common strings that belong to many files +;[Add] +;[Add new item] +;[Custom Status List] +;[Modify] + +; ../../plugins/CSList/cslist.cpp +;[Do you really want to delete selected item?] +;[Do you want old database entries to be deleted after Import?] +;[Favourites] +;[Message] +;[Modify item] +;[Regular statuses] +;[Status] +;[This field doesn't accept string longer than %d characters. The string will be truncated.] +;[Title] +;[Warning] + +; ../../plugins/CSList/cslist.h +;[Afraid] +;[Amazed] +;[Amorous] +;[Angry] +;[Annoyed] +;[Anxious] +;[Aroused] +;[Ashamed] +;[Bored] +;[Brave] +;[Browsing] +;[Business] +;[Calm] +;[Cautious] +;[Clear] +;[Clear custom status (reset to None) and close] +;[Close without changing custom status] +;[Coffee] +;[Cold] +;[Confident] +;[Confused] +;[Contemplative] +;[Contented] +;[Cranky] +;[Crazy] +;[Creative] +;[Curious] +;[Dejected] +;[Delete selected item] +;[Depressed] +;[Disappointed] +;[Disgusted] +;[Dismayed] +;[Distracted] +;[Drinking beer] +;[Eating] +;[Embarrassed] +;[Envious] +;[Excited] +;[Favourite] +;[Feeling sick] +;[Filter] +;[Filter list] +;[Flirtatious] +;[Frustrated] +;[Gaming] +;[Grateful] +;[Grieving] +;[Grumpy] +;[Guilty] +;[Happy] +;[Having fun] +;[Hopeful] +;[Hot] +;[Humbled] +;[Humiliated] +;[Hungry] +;[Hurt] +;[I'm high] +;[Import] +;[Import statuses from database] +;[Impressed] +;[In awe] +;[In love] +;[Indignant] +;[Interested] +;[Intoxicated] +;[Invincible] +;[Jealous] +;[Journal] +;[Listening to music] +;[Lonely] +;[Lost] +;[Love] +;[Lucky] +;[Main Icon] +;[Main Menu] +;[Mean] +;[Meeting] +;[Modify selected item] +;[Moody] +;[Nervous] +;[Neutral] +;[No change] +;[Offended] +;[On WC] +;[On the phone] +;[Outraged] +;[PDA] +;[Party] +;[Picnic] +;[Playful] +;[Proud] +;[Relaxed] +;[Relieved] +;[Remorseful] +;[Remove] +;[Restless] +;[Sad] +;[Sarcastic] +;[Satisfied] +;[Searching] +;[Serious] +;[Set] +;[Set custom status to selected one and close] +;[Set/unset current item as favorite] +;[Sex] +;[Shocked] +;[Shooting] +;[Shopping] +;[Shy] +;[Sick] +;[Sleeping] +;[Sleepy] +;[Smoking] +;[Spontaneous] +;[Stressed] +;[Strong] +;[Studying] +;[Surfing] +;[Surprised] +;[Taking a bath] +;[Thankful] +;[Thinking] +;[Thirsty] +;[Tired] +;[To be or not to be] +;[Typing] +;[Undefined] +;[Undo changes] +;[Watching TV] +;[Watching pro7 on TV] +;[Weak] +;[Working] +;[Worried] + +; ../../plugins/CSList/cslist.rc +;[A] +;[Add/Modify] +;[Add/Modify Custom Status] +;[Allow extra ICQ Custom status items (ICQ Plus only)] +;[C] +;[Cancel] +;[Confirm deletion of items] +;[D] +;[Delete entries in ICQ Custom status menu after Import] +;[F] +;[I] +;[List settings] +;[M] +;[N] +;[No items available in the database.\nClick the Add button to define some.] +;[Note: Menu items are only visible when at least one ICQ account is properly set. Check if you have at least one account with UIN filled in.] +;[O] +;[Remember last window position] +;[U] diff --git a/plugins/CSList/legacy.h b/plugins/CSList/legacy.h deleted file mode 100644 index 8ef63089d7..0000000000 --- a/plugins/CSList/legacy.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - - FILE INFO: Legacy functions of older Custom Status List versions - -*/ - -int cslist_import_v2_status_items( ); -int cslist_parse_row( TCHAR *row, int ord ); - -int cslist_import_v2_status_items( ) -{ - // get DB string, parse to statuses, add by helpItem - DBVARIANT dbv = { DBVT_TCHAR }; - int parseResult; - int dbLoadResult; - const TCHAR* rowDelim = _T( "" ); // new line - TCHAR *row = NULL; - - dbLoadResult = getTString( "listhistory", &dbv ); - if ( dbv.ptszVal ) - { - int i = getByte( "ItemsCount", DEFAULT_ITEMS_COUNT ); - row = _tcstok( dbv.ptszVal, rowDelim ); - while( row != NULL ) { - i++; - // process current row.. - parseResult = cslist_parse_row( row, i ); - // ..and go to the other, while some remains - row = _tcstok( NULL, rowDelim ); - } - setByte( "ItemsCount", i ); - } - //free( rowDelim ); - //free( row ); - return 0; -} - -int cslist_parse_row( TCHAR *row, int ord ) // parse + helpItem -{ - int pIconInt; - TCHAR pIcon[4], pTitle[EXTRASTATUS_TITLE_LIMIT+2], pMsg[EXTRASTATUS_MESSAGE_LIMIT+2], pFav[4]; - TCHAR scanfFormat[64]; - - lstrcpy( pTitle, _T( "" )); - lstrcpy( pMsg, _T( "" )); - - // database row format: "%2[^]%64[^]%2048[^]%2[^]" - - mir_sntprintf( - scanfFormat, - sizeof( scanfFormat ), - _T( "%%%d[^]%%%d[^]%%%d[^]%%%d[^]" ), // %% makes %, %d makes number :) - 2, - EXTRASTATUS_TITLE_LIMIT, - EXTRASTATUS_MESSAGE_LIMIT, - 2 - ); - - _tcscanf( row, scanfFormat, pIcon, pTitle, pMsg, pFav ); - - if ( lstrlen( pTitle ) + lstrlen( pMsg ) > 0 ) - { - char dbSetting[32]; - pIconInt = _ttoi( pIcon ); - mir_snprintf( dbSetting, sizeof( dbSetting ), "Item%dIcon", ord ); - setByte( dbSetting, pIconInt ); - mir_snprintf( dbSetting, sizeof( dbSetting ), "Item%dTitle", ord ); - setTString( dbSetting, pTitle ); - mir_snprintf( dbSetting, sizeof( dbSetting ), "Item%dMessage", ord ); - setTString( dbSetting, pMsg ); - mir_snprintf( dbSetting, sizeof( dbSetting ), "Item%dFavourite", ord ); - setByte( dbSetting, 0 ); - } - else { - return FALSE; - } - return TRUE; -} - - -void MessageBoxInt( int value1, int value2 ) -{ - TCHAR buf1[64], buf2[64]; - mir_sntprintf( buf1, SIZEOF( buf1 ), TEXT( "%d" ), value1 ); - mir_sntprintf( buf2, SIZEOF( buf2 ), TEXT( "%d" ), value2 ); - MessageBox( NULL, buf2, buf1, MB_OK ); -} diff --git a/plugins/CSList/res/Version.rc b/plugins/CSList/res/Version.rc new file mode 100644 index 0000000000..d741488c4f --- /dev/null +++ b/plugins/CSList/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/CSList/res/cslist.rc b/plugins/CSList/res/cslist.rc new file mode 100644 index 0000000000..9063d1c010 --- /dev/null +++ b/plugins/CSList/res/cslist.rc @@ -0,0 +1,182 @@ +// 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 + +///////////////////////////////////////////////////////////////////////////// +// Английский (США) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_CSLIST ICON "cslist.ico" +IDI_ADD ICON "add.ico" +IDI_MODIFY ICON "modify.ico" +IDI_REMOVE ICON "remove.ico" +IDI_FAVOURITE ICON "favourite.ico" +IDI_IMPORT ICON "import.ico" +IDI_UNDO ICON "undo.ico" +IDI_FILTER ICON "filter.ico" +IDI_CLOSE ICON "close.ico" +IDI_UNSET ICON "unset.ico" +IDI_APPLY ICON "apply.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_CSLIST DIALOGEX 0, 0, 214, 227 +STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Custom Status List" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + CONTROL "",IDC_CSLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,3,3,207,204 + CONTROL "A",IDC_ADD,"MButtonClass",WS_TABSTOP,3,210,16,14 + CONTROL "M",IDC_MODIFY,"MButtonClass",WS_TABSTOP,23,210,16,14 + CONTROL "D",IDC_REMOVE,"MButtonClass",WS_TABSTOP,43,210,16,14 + CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,63,210,1,14 + CONTROL "F",IDC_FAVOURITE,"MButtonClass",WS_TABSTOP,67,210,16,14 + CONTROL "U",IDC_UNDO,"MButtonClass",WS_DISABLED | WS_TABSTOP,87,210,16,14 + CONTROL "I",IDC_IMPORT,"MButtonClass",WS_TABSTOP,107,210,16,14 + CONTROL "I",IDC_FILTER,"MButtonClass",WS_TABSTOP | 0x1000,127,210,16,14 + EDITTEXT IDC_FILTER_FIELD,3,210,120,14,ES_AUTOHSCROLL | NOT WS_VISIBLE | WS_DISABLED + CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,147,210,1,14 + CONTROL "N",IDCLOSE,"MButtonClass",WS_TABSTOP,153,210,16,14 + CONTROL "C",IDC_CANCEL,"MButtonClass",WS_TABSTOP,173,210,16,14 + CONTROL "O",IDOK,"MButtonClass",WS_TABSTOP,193,210,16,14 + ICON IDI_ADD,IDC_ADD_SAMPLE,102,90,20,20,SS_REALSIZEIMAGE + CTEXT "No items available in the database.\nClick the Add button to define some.",IDC_NO_ITEMS,43,101,130,49,0,WS_EX_TRANSPARENT +END + +IDD_ADDMODIFY DIALOGEX 100, 100, 187, 90 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Add/Modify Custom Status" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + CONTROL "",IDC_COMBO,"ComboBoxEx32",CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP,6,5,175,107 + EDITTEXT IDC_MESSAGE,6,21,175,50,ES_MULTILINE | ES_WANTRETURN | WS_VSCROLL + DEFPUSHBUTTON "Add/Modify",IDOK,6,74,104,14 + PUSHBUTTON "Cancel",IDCANCEL,116,74,65,14 +END + +IDD_OPTIONS DIALOGEX 0, 0, 300, 107 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_CLIPSIBLINGS +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + GROUPBOX "List settings",IDC_STATIC,4,4,292,73 + CONTROL "Confirm deletion of items",IDC_CONFIRM_DELETION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,24,20,253,10 + CONTROL "Delete entries in ICQ Custom status menu after Import",IDC_DELETE_AFTER_IMPORT, + "Button",BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE | WS_TABSTOP,24,32,253,10 + CONTROL "Allow extra ICQ Custom status items (ICQ Plus only)",IDC_ALLOW_EXTRA_ICONS, + "Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,24,44,253,10 + CONTROL "Remember last window position",IDC_REMEMBER_POSITION, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,24,56,253,10 + CTEXT "Note: Menu items are only visible when at least one ICQ account is properly set. Check if you have at least one account with UIN filled in.",IDC_STATIC,6,80,283,23 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_CSLIST, DIALOG + BEGIN + LEFTMARGIN, 3 + RIGHTMARGIN, 210 + VERTGUIDE, 23 + VERTGUIDE, 43 + VERTGUIDE, 67 + VERTGUIDE, 87 + VERTGUIDE, 107 + VERTGUIDE, 127 + VERTGUIDE, 153 + VERTGUIDE, 173 + VERTGUIDE, 193 + TOPMARGIN, 3 + BOTTOMMARGIN, 224 + HORZGUIDE, 207 + HORZGUIDE, 210 + END + + IDD_ADDMODIFY, DIALOG + BEGIN + LEFTMARGIN, 6 + RIGHTMARGIN, 181 + TOPMARGIN, 5 + BOTTOMMARGIN, 88 + END + + IDD_OPTIONS, DIALOG + BEGIN + LEFTMARGIN, 4 + RIGHTMARGIN, 296 + VERTGUIDE, 24 + VERTGUIDE, 34 + VERTGUIDE, 277 + TOPMARGIN, 4 + BOTTOMMARGIN, 103 + END +END +#endif // APSTUDIO_INVOKED + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // Английский (США) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/CSList/resource.h b/plugins/CSList/resource.h deleted file mode 100644 index cec164739d..0000000000 --- a/plugins/CSList/resource.h +++ /dev/null @@ -1,49 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by cslist.rc -// -#define IDCLOSE 8 -#define IDC_CANCEL 9 -#define IDD_CSLIST 101 -#define IDD_ADDMODIFY 102 -#define IDD_OPTIONS 103 -#define IDI_CSLIST 121 -#define IDI_ADD 122 -#define IDI_MODIFY 123 -#define IDI_REMOVE 124 -#define IDI_FAVOURITE 125 -#define IDI_UNDO 126 -#define IDI_GLOBAL 127 -#define IDI_FILTER 128 -#define IDI_CLOSE 129 -#define IDI_UNSET 130 -#define IDI_APPLY 131 -#define IDI_IMPORT 132 -#define IDC_CSLIST 1001 -#define IDC_FILTER_FIELD 1011 -#define IDC_ADD_SAMPLE 1012 -#define IDC_NO_ITEMS 1013 -#define IDC_ADD 1021 -#define IDC_MODIFY 1022 -#define IDC_REMOVE 1023 -#define IDC_FAVOURITE 1024 -#define IDC_UNDO 1025 -#define IDC_FILTER 1027 -#define IDC_COMBO 1041 -#define IDC_MESSAGE 1042 -#define IDC_CONFIRM_DELETION 1051 -#define IDC_DELETE_AFTER_IMPORT 1052 -#define IDC_IMPORT 1071 -#define IDC_ALLOW_EXTRA_ICONS 1204 -#define IDC_REMEMBER_POSITION 1207 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 104 -#define _APS_NEXT_COMMAND_VALUE 40003 -#define _APS_NEXT_CONTROL_VALUE 1209 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/plugins/CSList/src/Version.h b/plugins/CSList/src/Version.h new file mode 100644 index 0000000000..8206c5c61f --- /dev/null +++ b/plugins/CSList/src/Version.h @@ -0,0 +1,22 @@ +#define __MAJOR_VERSION 0 +#define __MINOR_VERSION 1 +#define __RELEASE_NUM 0 +#define __BUILD_NUM 5 + +#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 "Custom Status List mod" +#define __INTERNAL_NAME "CSList" +#define __FILENAME "CSList.dll" +#define __DESCRIPTION "This plugin offers simple management functions to keep your extra statuses on one place." +#define __AUTHOR "Mataes, jarvis" +#define __AUTHOREMAIL "mataes2007@gmail.com" +#define __AUTHORWEB "http://mataes.googlecode.com/svn/Miranda/Plugins/Cslist/" +#define __COPYRIGHT "© 2011-10 Mataes, 2009-2007 jarvis" diff --git a/plugins/CSList/src/cslist.cpp b/plugins/CSList/src/cslist.cpp new file mode 100644 index 0000000000..b8078ae1be --- /dev/null +++ b/plugins/CSList/src/cslist.cpp @@ -0,0 +1,1349 @@ +/* ======================================================================== + + Custom Status List + __________________ + + Custom Status List plugin for Miranda-IM (www.miranda-im.org) + Follower of Custom Status History List by HANAX + Copyright © 2006-2008 HANAX + Copyright © 2007-2009 jarvis + + 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$ + Revision : $Rev$ + Last change on : $Date$ + Last change by : $Author$ + + ============================================================================ + + + DESCRIPTION: + + Offers List of your Custom Statuses. + +// ======================================================================== */ + +#include "cslist.h" +#include "strpos.h" +#include "legacy.h" + +SortedList *servicesList; +int hLangpack; + +extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { PLUGIN_GUUID, MIID_LAST }; + +PLUGININFOEX pluginInfoEx = +{ + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + PLUGIN_GUUID +}; + +// ====[ MAIN ]=============================================================== + +BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) +{ + CSList::handle = hinstDLL; + return TRUE; +} + + +// ====[ PLUGIN INFO ]======================================================== + +extern "C" __declspec( dllexport ) PLUGININFOEX* MirandaPluginInfoEx( DWORD mirandaVersion ) +{ + CSList::dwMirandaVersion = mirandaVersion; + return &pluginInfoEx; +} + +// ====[ LOADER ]============================================================= + +extern "C" __declspec( dllexport ) int Load( ) +{ + mir_getLP(&pluginInfoEx); + servicesList = List_Create(0, 10); + + // support for ComboBoxEx + { + INITCOMMONCONTROLSEX icc; + icc.dwSize = sizeof(icc); + icc.dwICC = ICC_USEREX_CLASSES; + InitCommonControlsEx( &icc ); + } + + // set global variables + // we need 0.8.0.9 core which introduced accounts support for protocols + CSList::bAccountsSupported = ( CSList::dwMirandaVersion >= PLUGIN_MAKE_VERSION( 0, 8, 0, 9 )); + + // are we running under Unicode core? + { + char szVer[MAX_PATH]; + + CallService( MS_SYSTEM_GETVERSIONTEXT, MAX_PATH, ( LPARAM )szVer ); + _strlwr( szVer ); // make sure it is lowercase + + CSList::bUnicodeCore = ( strstr( szVer, "unicode" ) != NULL ); + } + + // TODO: Alerts with wrong combination of ANSI/Unicode Windows/core/plugin + + // create handler + cslist = new CSList( ); + + return FALSE; +} + + +// ====[ UNLOADER ]=========================================================== + +extern "C" __declspec( dllexport ) int Unload( void ) +{ + for (int i = servicesList->realCount-1; i >= 0; i--) + { + HANDLE *hService = (HANDLE *)servicesList->items[i]; + DestroyServiceFunction(hService); + } + List_Destroy(servicesList); + mir_free(servicesList); + delete cslist; + + return FALSE; +} + + +// ====[ FUN ]================================================================ + + +CSList::CSList( ) +{ + this->mainWindow = NULL; + this->initIcoLib( ); + this->hHookOnOptionsInit = HookEvent( ME_OPT_INITIALISE, this->initOptions ); + //this->hHookOnPluginsLoaded = HookEvent( ME_SYSTEM_MODULESLOADED, this->postLoading ); + this->hHookOnDBSettingChanged = HookEvent( ME_DB_CONTACT_SETTINGCHANGED, this->respondDBChange ); + this->hHookOnStatusMenuBuild = HookEvent( ME_CLIST_PREBUILDSTATUSMENU, this->createMenuItems ); +} + + +CSList::~CSList( ) +{ + // unhook events, destroy functions + UnhookEvent( this->hHookOnStatusMenuBuild ); + UnhookEvent( this->hHookOnPluginsLoaded ); + UnhookEvent( this->hHookOnOptionsInit ); + UnhookEvent( this->hHookOnDBSettingChanged ); + DestroyServiceFunction( this->hServiceShowList ); + + // clear IcoLib + for ( int i = 0; i < SIZEOF(forms); i++ ) + { + char iconName[64]; + mir_snprintf(iconName, SIZEOF(iconName), "%s_%s", __INTERNAL_NAME, forms[i].pszIconIcoLib); + CallService( MS_SKIN2_REMOVEICON, 0, ( LPARAM )iconName ); + } +} + + +int CSList::postLoading( WPARAM wparam, LPARAM lparam ) +{ + //cslist->registerHotkeys( ); + cslist->initIcoLib( ); // for < 0.7, but probably useless though :/ + return FALSE; +} + + +void CSList::registerHotkeys(char buf[200], TCHAR* accName, int Number) +{ + HOTKEYDESC hotkey = { 0 }; + hotkey.cbSize = sizeof(hotkey); + hotkey.dwFlags = HKD_TCHAR; + hotkey.pszName = buf; + hotkey.ptszDescription = accName; + hotkey.ptszSection = LPGENT("Custom Status List"); + hotkey.pszService = buf; + hotkey.DefHotKey = HOTKEYCODE( HOTKEYF_CONTROL | HOTKEYF_SHIFT, '0'+Number ); + Hotkey_Register(&hotkey); +} + +int CSList::initOptions( WPARAM wparam, LPARAM lparam ) +{ + OPTIONSDIALOGPAGE odp = { 0 }; + odp.cbSize = sizeof(odp); + odp.position = 955000000; + odp.hInstance = CSList::handle; + odp.pszTemplate = MAKEINTRESOURCEA( IDD_OPTIONS ); + odp.pszTitle = MODULENAME; + odp.pfnDlgProc = CSOptionsProc; + odp.pszGroup = LPGEN("Status"); + odp.flags = ODPF_BOLDGROUPS; + Options_AddPage(wparam, &odp); + return FALSE; +} + + +int CSList::respondDBChange( WPARAM wparam, LPARAM lparam ) +{ + HANDLE hContact = ( HANDLE )wparam; + DBCONTACTWRITESETTING *cws = ( DBCONTACTWRITESETTING* )lparam; + + // if user changes his UIN or JID on any account + if (hContact == NULL && (!lstrcmpA(cws->szSetting, "UIN") || !lstrcmpA(cws->szSetting, "jid"))) + { + cslist->rebuildMenuItems(); + return 0; + } + + // own setting or not a status-related setting + else if ( hContact == NULL || lstrcmpA( cws->szSetting, "Status" )) + return 0; + + DWORD dwEasteredUin = getDword( "EasterEggedUIN", 0x0 ); + if ( dwEasteredUin == 0x0 ) // no spyed UIN found + return 0; + + DBVARIANT dbv = { 0 }; + DBGetContactSettingString( hContact, "Protocol", "p", &dbv ); + + DWORD dwUin = DBGetContactSettingDword( hContact, dbv.pszVal, "UIN", 0x0 ); + + if ( dwUin != 0x0 ) // if this is an ICQ user + if ( dwUin == dwEasteredUin ) // if spyed UIN is equivalent to this contact + if ( DBGetContactSettingWord( hContact, "UserOnline", "OldStatus", 0 ) == ID_STATUS_OFFLINE ) + if ( cws->value.wVal > ID_STATUS_OFFLINE ) + cslist->setStatus( IDC_CANCEL, NULL, ""); + + return FALSE; +} + + +int CSList::createMenuItems( WPARAM wparam, LPARAM lparam ) +{ + int ProtoCount = 0; + + ForAllProtocols(countProtos, &ProtoCount); + + if (ProtoCount == 0) + return FALSE; + + ForAllProtocols(addProtoStatusMenuItem, 0); + + return FALSE; +} + + +void CSList::rebuildMenuItems( ) +{ + CLIST_INTERFACE* pcli; + pcli = ( CLIST_INTERFACE* )CallService( MS_CLIST_RETRIEVE_INTERFACE, 0, 0 ); + if ( pcli && pcli->version > 4 ) + pcli->pfnReloadProtoMenus( ); +} + + +void CSList::setStatus( WORD code, StatusItem* item, char* protoName) +{ + if ( code == IDCLOSE ) + return; + + PROTOACCOUNT* pdescr = (PROTOACCOUNT*)CallService(MS_PROTO_GETACCOUNT, 0, (LPARAM)protoName); + if (pdescr == NULL) + return; + int statusToSet = -1; + if (lstrcmpA(pdescr->szProtoName, "ICQ") == 0) + { + ICQ_CUSTOM_STATUS ics = {0}; + ics.cbSize = sizeof(ICQ_CUSTOM_STATUS); + ics.flags = CSSF_MASK_STATUS | CSSF_MASK_NAME | CSSF_MASK_MESSAGE | CSSF_TCHAR; + + if (code == IDC_CANCEL) + { + statusToSet = 0; + ics.ptszName = _T(""); + ics.ptszMessage = _T(""); + } + else if (code == IDOK && item != NULL) + { + statusToSet = item->iIcon + 1; + ics.ptszName = variables_parsedup(item->tszTitle, NULL, NULL); + ics.ptszMessage = variables_parsedup(item->tszMessage, NULL, NULL); + } + else return; + + ics.status = &statusToSet; + + char protoService[64]; + mir_snprintf(protoService, SIZEOF(protoService), "%s%s", protoName, PS_ICQ_SETCUSTOMSTATUSEX); + CallService(protoService, 0, (LPARAM)&ics); + } + if (lstrcmpA(pdescr->szProtoName, "JABBER") == 0) + { + JABBER_CUSTOM_STATUS ics = {0}; + ics.cbSize = sizeof(ICQ_CUSTOM_STATUS); + ics.flags = CSSF_MASK_STATUS | CSSF_MASK_NAME | CSSF_MASK_MESSAGE | CSSF_TCHAR; + + if (code == IDC_CANCEL) + { + statusToSet = 0; + ics.ptszMessage = _T(""); + } + else if (code == IDOK && item != NULL) + { + statusToSet = item->iIcon + 1; + ics.ptszMessage = variables_parsedup(item->tszMessage, NULL, NULL); + } + else return; + + ics.status = &statusToSet; + + char protoService[64]; + mir_snprintf(protoService, SIZEOF(protoService), "%s%s", protoName, JS_SETXSTATUSEX); + CallService(protoService, 0, (LPARAM)&ics); + } +} + +void CSList::initIcoLib( ) +{ + // init icons of buttons + TCHAR tszFile[MAX_PATH]; + GetModuleFileName( CSList::handle, tszFile, MAX_PATH ); + + SKINICONDESC sid = { 0 }; + sid.cbSize = sizeof(SKINICONDESC); + sid.ptszDefaultFile = tszFile; + sid.flags = SIDF_ALL_TCHAR; + sid.cx = sid.cy = 16; + sid.ptszSection = _T(MODULENAME); + + for (int i=0; i < SIZEOF(forms); i++ ) { + char szSettingName[64]; + mir_snprintf( szSettingName, SIZEOF(szSettingName), "%s_%s", __INTERNAL_NAME, forms[i].pszIconIcoLib ); + + sid.pszName = szSettingName; + sid.ptszDescription = forms[i].ptszDescr; + sid.iDefaultIndex = -forms[i].iconNoIcoLib; + forms[i].hIcoLibItem = Skin_AddIcon(&sid); + } +} + + +INT_PTR CSList::showList(WPARAM wparam, LPARAM lparam, LPARAM param) +{ + cslist->mainWindow = new CSWindow((char*)param); + ForkThread(&cslist->mainWindow->showWindow, cslist->mainWindow); + return 0; +} + + +void CSList::closeList( HWND hwnd ) +{ + ForkThread( &cslist->mainWindow->closeWindow, hwnd ); + delete cslist->mainWindow; + cslist->mainWindow = NULL; +} + + +void CSList::ForAllProtocols( pForAllProtosFunc pFunc, void* arg ) +{ + int protoCount; + PROTOACCOUNT** pdesc; + CallService( MS_PSEUDO_PROTO_PROTOACCSENUM, ( WPARAM )&protoCount, ( LPARAM )&pdesc ); + + for ( int i = 0; i < protoCount; i++ ) + { + if (lstrcmpA(pdesc[i]->szProtoName, "ICQ") == 0) + { + DWORD uin = 0; + uin = DBGetContactSettingDword(NULL, pdesc[i]->szModuleName, "UIN", 0); + if (uin == 0) + continue; + } + else if (lstrcmpA(pdesc[i]->szProtoName, "JABBER") == 0) + { + DBVARIANT dbv = {0}; + DBGetContactSettingTString(NULL, pdesc[i]->szModuleName, "jid", &dbv); + if (dbv.ptszVal == _T("")) + continue; + } + else + continue; + pFunc(pdesc[i]->szModuleName , arg); + } +} + + +void CSList::addProtoStatusMenuItem( char* protoName, void* arg ) +{ + char buf[200]; + PROTOACCOUNT* pdescr; + pdescr = (PROTOACCOUNT*)CallService(MS_PROTO_GETACCOUNT, 0, (LPARAM)protoName); + if (pdescr == NULL) + return; + + HANDLE hService; + mir_snprintf(buf, SIZEOF(buf), "CSList/ShowList/%s", protoName); + if (!ServiceExists(buf)) + hService = CreateServiceFunctionParam(buf, CSList::showList, (LPARAM)protoName); + List_Insert(servicesList, hService, servicesList->realCount); + + CLISTMENUITEM mi = {0}; + mi.cbSize = sizeof(mi); + mi.flags = CMIF_TCHAR; + if (ServiceExists(MS_SKIN2_GETICON)) + mi.icolibItem = (HANDLE)LoadIconExEx("icon", IDI_CSLIST); + else + mi.hIcon = LoadIconExEx("icon", IDI_CSLIST); + mi.ptszName = _T(MODULENAME); + mi.position = 2000040000; + mi.pszService = buf; + mi.ptszPopupName = pdescr->tszAccountName; + Menu_AddStatusMenuItem(&mi); + + cslist->registerHotkeys(buf, pdescr->tszAccountName, pdescr->iOrder); +} + + +void CSList::countProtos( char* protoName, void* arg ) +{ + int* protosEnabled = (int*)arg; + *protosEnabled = ( *protosEnabled )++; +} + + +void CSList::countPlusModProtos( char* protoName, void* arg ) +{ + int* protosExtraEnabled = ( int* )arg; + if ( DBGetContactSettingDword( NULL, protoName, "NonStandartXstatus", 0 ) || + DBGetContactSettingDword( NULL, protoName, "NonStandardXstatus", 0 )) + *protosExtraEnabled = ( *protosExtraEnabled )++; +} + +void CSList::importCustomStatusUIStatusesFromAllProtos( char* protoName, void* arg ) +{ + int* result = ( int* )arg; + + for ( int i = 1; i <= 37; i++ ) + { + DBVARIANT dbv = { 0 }; + char bufTitle[32], bufMessage[32]; + StatusItem* si = new StatusItem( ); + + si->iIcon = i - 1; + + mir_snprintf( bufTitle, 32, "XStatus%luName", i ); + DBGetContactSettingTString( NULL, protoName, bufTitle, &dbv ); + lstrcpy( si->tszTitle, dbv.ptszVal ); + + mir_snprintf( bufMessage, 32, "XStatus%luMsg", i ); + DBGetContactSettingTString( NULL, protoName, bufMessage, &dbv ); + lstrcpy( si->tszMessage, dbv.ptszVal ); + + if ( lstrlen( si->tszTitle ) || lstrlen( si->tszMessage )) + { + cslist->mainWindow->itemslist->list->add( si ); + cslist->mainWindow->bSomethingChanged = TRUE; + } + else + delete si; + + if ( *result == IDYES ) + { + DBDeleteContactSetting( NULL, protoName, bufTitle ); + DBDeleteContactSetting( NULL, protoName, bufMessage ); + } + } + cslist->mainWindow->listview->reinitItems( cslist->mainWindow->itemslist->list->getListHead( )); +} + + +CSWindow::CSWindow(char* protoName) +{ + this->protoName = protoName; + this->handle = NULL; + this->bExtraIcons = getByte( "AllowExtraIcons", DEFAULT_ALLOW_EXTRA_ICONS ); + this->itemslist = new CSItemsList(this->protoName); + this->listview = NULL; + this->addModifyDlg = NULL; + this->bSomethingChanged = FALSE; + this->filterString = NULL; +} + + +CSWindow::~CSWindow( ) +{ + delete this->itemslist; + SAFE_FREE( ( void** )&this->filterString ); +} + + +void CSWindow::showWindow( void* arg ) +{ + CSWindow* csw = ( CSWindow* )arg; + + while ( csw == NULL ) + SleepEx( 10, FALSE ); + + DialogBoxParam( CSList::handle, MAKEINTRESOURCE( IDD_CSLIST ), NULL, ( DLGPROC )CSWindowProc, ( LPARAM )csw ); +} + + +void CSWindow::closeWindow( void* arg ) +{ + HWND hwnd = ( HWND )arg; + EndDialog( hwnd, FALSE ); +} + + +void CSWindow::initIcons() +{ + PROTOACCOUNT* pdescr = (PROTOACCOUNT*)CallService(MS_PROTO_GETACCOUNT, 0, (LPARAM)protoName); + if (pdescr == NULL) + return; + + if (lstrcmpA(pdescr->szProtoName, "ICQ") == 0) + { + DWORD uin = 0; + uin = DBGetContactSettingDword(NULL, pdescr->szModuleName, "UIN", 0); + if (uin != 0) + { + this->icons = ImageList_Create( 16, 16, IsWinVerXPPlus( ) ? ILC_COLOR32 | ILC_MASK : ILC_COLOR16 | ILC_MASK, XSTATUS_COUNT_EXTENDED, 0 ); + if ( this->icons ) + { + for ( int i = 0; i < ( ( this->bExtraIcons ) ? XSTATUS_COUNT_EXTENDED : XSTATUS_COUNT ); i++ ) + { + char szTemp[MAX_PATH]; + mir_snprintf(szTemp, SIZEOF(szTemp), "%s_xstatus%d", protoName, i); + ImageList_AddIcon( this->icons, ( HICON )CallService( MS_SKIN2_GETICON, 0, ( LPARAM )szTemp )); + } + } + } + } + else if (lstrcmpA(pdescr->szProtoName, "JABBER") == 0) + { + DBVARIANT dbv = {0}; + DBGetContactSettingTString(NULL, pdescr->szModuleName, "jid", &dbv); + if (dbv.ptszVal != _T("")) + { + this->icons = ImageList_Create( 16, 16, IsWinVerXPPlus( ) ? ILC_COLOR32 | ILC_MASK : ILC_COLOR16 | ILC_MASK, MOODS_COUNT, 0 ); + if ( this->icons ) + { + for ( int i = 0; i < MOODS_COUNT; i++ ) + { + char szTemp[MAX_PATH]; + mir_snprintf(szTemp, SIZEOF(szTemp), "%s_%s", protoName, moods_names[i].szTag); + ImageList_AddIcon( this->icons, ( HICON )CallService( MS_SKIN2_GETICON, 0, ( LPARAM )szTemp )); + } + } + } + } +} + + +void CSWindow::deinitIcons( ) +{ + ImageList_Destroy( this->icons ); +} + + +void CSWindow::initButtons( ) +{ + for (int i = 0; i < SIZEOF(forms); i++) + { + if ( forms[i].idc < 0 ) + continue; + + SendDlgItemMessage( this->handle, forms[i].idc, BM_SETIMAGE, IMAGE_ICON, ( LPARAM )LoadIconExEx( forms[i].pszIconIcoLib, forms[i].iconNoIcoLib )); + SendDlgItemMessage( this->handle, forms[i].idc, BUTTONSETASFLATBTN, TRUE, 0 ); //maybe set as BUTTONSETDEFAULT? + SendDlgItemMessage( this->handle, forms[i].idc, BUTTONADDTOOLTIP, ( WPARAM )TranslateTS(forms[i].ptszTitle), BATF_TCHAR ); + } +} + +void CSWindow::loadWindowPosition( ) +{ + RECT rect = { 0 }; + int width = GetSystemMetrics( SM_CXSCREEN ); + int height = GetSystemMetrics( SM_CYSCREEN ); + GetWindowRect( this->handle, &rect ); + int x, y, defX, defY; + defX = x = ( width + 1 - ( rect.right - rect.left )) >> 1; + defY = y = ( height + 1 - ( rect.bottom - rect.top )) >> 1; + if ( getByte( "RememberWindowPosition", DEFAULT_REMEMBER_WINDOW_POSITION )) + { + x = getWord( "PositionX", defX ); + y = getWord( "PositionY", defY ); + } + if ( x > width || y > height || x < 0 || y < 0 ) + { + x = defX; + y = defY; + } + + MoveWindow( this->handle, + x, y, + ( rect.right - rect.left ), + ( rect.bottom - rect.top ), + TRUE ); +} + + +void CSWindow::toggleEmptyListMessage( ) +{ + HWND hwnd = GetDlgItem( this->handle, IDC_NO_ITEMS ); + ShowWindow( hwnd, ( ListView_GetItemCount( this->listview->handle ) > 0 ) ? FALSE : TRUE ); + SetForegroundWindow( hwnd ); + hwnd = GetDlgItem( this->handle, IDC_ADD_SAMPLE ); + ShowWindow( hwnd, ( ListView_GetItemCount( this->listview->handle ) > 0 ) ? FALSE : TRUE ); + SetForegroundWindow( hwnd ); +} + + +BOOL CSWindow::itemPassedFilter( ListItem< StatusItem >* li ) +{ + TCHAR filter[MAX_PATH]; + GetDlgItemText( this->handle, IDC_FILTER_FIELD, filter, MAX_PATH ); + + if ( lstrlen( filter )) + { + TCHAR title[EXTRASTATUS_TITLE_LIMIT], message[EXTRASTATUS_MESSAGE_LIMIT]; + lstrcpy( title, li->item->tszTitle ); lstrcpy( message, li->item->tszMessage ); + if ( strpos( _tcslwr( title ), _tcslwr( filter )) == -1 ) + if ( strpos( _tcslwr( message ), _tcslwr( filter )) == -1 ) + return FALSE; + } + + return TRUE; +} + + +void CSWindow::toggleFilter( ) +{ + HWND hFilter = GetDlgItem( this->handle, IDC_FILTER_FIELD ); + BOOL isEnabled = !IsWindowEnabled( hFilter ) ? TRUE : FALSE; // ! = + isEnabled = !isEnabled in one + EnableWindow( hFilter, isEnabled ); + ShowWindow( hFilter, isEnabled ); + CheckDlgButton( this->handle, IDC_FILTER, isEnabled ); + SetForegroundWindow( hFilter ); + if ( isEnabled ) + SetFocus( hFilter ); + else + { + TCHAR filterText[255]; + GetDlgItemText(this->handle, IDC_FILTER_FIELD, filterText, SIZEOF(filterText)); + if ( lstrlen( filterText ) > 0 ) + SetDlgItemText( this->handle, IDC_FILTER_FIELD, TEXT( "" )); + } +} + + +BOOL CSWindow::toggleButtons( ) +{ + int selection = ListView_GetSelectedItemMacro( this->listview->handle ); + BOOL validSelection = ( selection >= 0 && ( unsigned int )selection < this->itemslist->list->getCount( )) ? TRUE : FALSE; + BOOL filterEnabled = IsWindowVisible( GetDlgItem( this->handle, IDC_FILTER_FIELD )); + BOOL somethingChanged = this->bSomethingChanged; + + EnableWindow( GetDlgItem( this->handle, IDC_ADD ), !filterEnabled ); + EnableWindow( GetDlgItem( this->handle, IDC_MODIFY ), validSelection && !filterEnabled ); + EnableWindow( GetDlgItem( this->handle, IDC_REMOVE ), validSelection && !filterEnabled ); + EnableWindow( GetDlgItem( this->handle, IDC_FAVOURITE ), validSelection && !filterEnabled ); + EnableWindow( GetDlgItem( this->handle, IDC_UNDO ), somethingChanged && !filterEnabled ); + EnableWindow( GetDlgItem( this->handle, IDC_IMPORT ), !filterEnabled ); +// EnableWindow( GetDlgItem( this->handle, IDC_GLOBAL ), !filterEnabled ); + EnableWindow( GetDlgItem( this->handle, IDOK ), validSelection ); + + return validSelection; +} + + +CSAMWindow::CSAMWindow( WORD action, CSWindow* parent ) +{ + this->action = action; + this->parent = parent; + this->bChanged = FALSE; + this->hCombo = this->hMessage = NULL; + + if ( this->action == IDC_ADD ) + this->item = new StatusItem( ); + else + this->item = new StatusItem( *this->parent->itemslist->list->get( this->parent->listview->getPositionInList( )) ); + +} + + +CSAMWindow::~CSAMWindow( ) +{ + if ( ! this->bChanged ) + delete this->item; +} + + +void CSAMWindow::exec( ) +{ + DialogBoxParam( CSList::handle, MAKEINTRESOURCE( IDD_ADDMODIFY ), NULL, ( DLGPROC )CSAMWindowProc, ( LPARAM )this ); +} + + +void CSAMWindow::setCombo() +{ + PROTOACCOUNT* pdescr = (PROTOACCOUNT*)CallService(MS_PROTO_GETACCOUNT, 0, (LPARAM)this->parent->protoName); + if (pdescr == NULL) + return; + + if (lstrcmpA(pdescr->szProtoName, "ICQ") == 0) + { + DWORD uin = 0; + uin = DBGetContactSettingDword(NULL, pdescr->szModuleName, "UIN", 0); + if (uin != 0) + { + SendMessage( this->hCombo, CBEM_SETIMAGELIST, 0, ( LPARAM )this->parent->icons ); + for ( int i = 0; i < ( ( this->parent->bExtraIcons ) ? XSTATUS_COUNT_EXTENDED : XSTATUS_COUNT ); i++ ) + { + COMBOBOXEXITEM cbi = { 0 }; + cbi.mask = CBEIF_IMAGE | CBEIF_TEXT | CBEIF_SELECTEDIMAGE; + cbi.pszText = TranslateTS(xstatus_names[i].ptszTitle); + cbi.iImage = xstatus_names[i].iId - 1; + cbi.iItem = i; + cbi.iSelectedImage = i; + SendMessage( this->hCombo, CBEM_INSERTITEM, 0, ( LPARAM )&cbi ); + } + SendMessage( this->hCombo, CB_SETCURSEL, 0, 0 ); // first 0 sets selection to top + } + } + else if (lstrcmpA(pdescr->szProtoName, "JABBER") == 0) + { + DBVARIANT dbv = {0}; + DBGetContactSettingTString(NULL, pdescr->szModuleName, "jid", &dbv); + if (dbv.ptszVal != _T("")) + { + SendMessage( this->hCombo, CBEM_SETIMAGELIST, 0, ( LPARAM )this->parent->icons ); + for ( int i = 0; i < MOODS_COUNT; i++ ) + { + COMBOBOXEXITEM cbi = { 0 }; + cbi.mask = CBEIF_IMAGE | CBEIF_TEXT | CBEIF_SELECTEDIMAGE; + cbi.pszText = TranslateTS(moods_names[i].ptszTitle); + cbi.iImage = moods_names[i].iId - 1; + cbi.iItem = i; + cbi.iSelectedImage = i; + SendMessage( this->hCombo, CBEM_INSERTITEM, 0, ( LPARAM )&cbi ); + } + SendMessage( this->hCombo, CB_SETCURSEL, 0, 0 ); // first 0 sets selection to top + } + } +} + +void CSAMWindow::fillDialog( ) +{ + if ( this->action == IDC_ADD ) + { + SetWindowText( this->handle, TranslateT("Add new item")); + SetDlgItemText( this->handle, IDOK, TranslateT("Add")); + } + else + { + SetWindowText( this->handle, TranslateT("Modify item")); + SetDlgItemText( this->handle, IDOK, TranslateT("Modify")); + } + + SendMessage( this->hCombo, CB_SETCURSEL, this->item->iIcon, 0 ); + SetDlgItemText( this->handle, IDC_MESSAGE, this->item->tszMessage ); +} + + +void CSAMWindow::checkFieldLimit( WORD action, WORD item ) +{ + BOOL type = ( item == IDC_MESSAGE ) ? TRUE : FALSE; + unsigned int limit = type ? EXTRASTATUS_MESSAGE_LIMIT : EXTRASTATUS_TITLE_LIMIT; + + if ( action == EN_CHANGE ) + { + TCHAR* ptszInputText = (TCHAR*)mir_alloc((limit + 8) * sizeof(TCHAR)); + + GetDlgItemText( this->handle, item, ptszInputText, limit + 8 ); + + if ( _tcslen( ptszInputText ) > limit ) + { +#if ( WINVER >= 0x501 ) + TCHAR tszPopupTip[MAX_PATH]; + EDITBALLOONTIP ebt = { 0 }; + ebt.cbStruct = sizeof(ebt); + ebt.pszTitle = TranslateT("Warning"); + mir_sntprintf(tszPopupTip, SIZEOF(tszPopupTip), TranslateT("This field doesn't accept string longer than %d characters. The string will be truncated."), limit); + ebt.pszText = tszPopupTip; + ebt.ttiIcon = TTI_WARNING; + SendMessage( GetDlgItem( this->handle, item ), EM_SHOWBALLOONTIP, 0, ( LPARAM )&ebt ); +#endif + TCHAR* ptszOutputText = (TCHAR*)mir_alloc((limit + 1) * sizeof(TCHAR)); + GetDlgItemText( this->handle, item, ptszOutputText, limit + 1 ); + SetDlgItemText( this->handle, item, ptszOutputText ); + mir_free( ptszOutputText ); + } + mir_free( ptszInputText ); + } +} + + +void CSAMWindow::checkItemValidity() +{ + COMBOBOXEXITEM cbi = { 0 }; + cbi.mask = CBEIF_IMAGE; + cbi.iItem = SendDlgItemMessage( this->handle, IDC_COMBO, CB_GETCURSEL, 0, 0 ); + SendDlgItemMessage( this->handle, IDC_COMBO, CBEM_GETITEM, 0, ( LPARAM )&cbi ); + + if ( this->item->iIcon != cbi.iImage ) + ( this->item->iIcon = cbi.iImage ) && ( this->bChanged = TRUE ); + + TCHAR tszInputMessage[EXTRASTATUS_MESSAGE_LIMIT]; + + GetDlgItemText( this->handle, IDC_MESSAGE, tszInputMessage, EXTRASTATUS_MESSAGE_LIMIT ); + + PROTOACCOUNT* pdescr = (PROTOACCOUNT*)CallService(MS_PROTO_GETACCOUNT, 0, (LPARAM)this->parent->protoName); + if (pdescr == NULL) + return; + + if (lstrcmpA(pdescr->szProtoName, "ICQ") == 0) + { + int i = SendMessage(this->hCombo, CB_GETCURSEL, 0, 0); + lstrcpy(this->item->tszTitle, TranslateTS(xstatus_names[i].ptszTitle)); + } + if (lstrcmpA(pdescr->szProtoName, "JABBER") == 0) + { + int i = SendMessage(this->hCombo, CB_GETCURSEL, 0, 0); + lstrcpy(this->item->tszTitle, TranslateTS(moods_names[i].ptszTitle)); + } + if ( lstrcmp( this->item->tszMessage, tszInputMessage )) + ( lstrcpy( this->item->tszMessage, tszInputMessage )) && ( this->bChanged = TRUE ); +} + + +CSListView::CSListView( HWND hwnd, CSWindow* parent ) +{ + this->handle = hwnd; + this->parent = parent; + +#if (_WIN32_WINNT >= 0x501) + LVGROUP lg = { 0 }; + lg.cbSize = sizeof(LVGROUP); + lg.mask = LVGF_HEADER | LVGF_GROUPID; + + lg.pszHeader = TranslateT("Favourites"); + lg.iGroupId = 0; + ListView_InsertGroup( this->handle, -1, &lg ); + + lg.pszHeader = TranslateT("Regular statuses"); + lg.iGroupId = 1; + ListView_InsertGroup( this->handle, -1, &lg ); + ListView_EnableGroupView( this->handle, TRUE ); +#endif + + LVCOLUMN lvc = { 0 }; + lvc.mask = LVCF_TEXT | LVCF_FMT | LVCF_WIDTH | LVCF_SUBITEM; + lvc.fmt = LVCFMT_LEFT; + lvc.cx = 0x00; + lvc.pszText = TEXT( "" ); + lvc.cx = 0x16; + SendMessage( this->handle, LVM_INSERTCOLUMN, 0, ( LPARAM )&lvc ); + lvc.pszText = TranslateT("Title"); + lvc.cx = 0x64; + SendMessage( this->handle, LVM_INSERTCOLUMN, 1, ( LPARAM )&lvc ); + lvc.pszText = TranslateT("Message"); + lvc.cx = 0xa8; + SendMessage( this->handle, LVM_INSERTCOLUMN, 2, ( LPARAM )&lvc ); + +// ListView_SetExtendedListViewStyle( this->handle, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_HEADERDRAGDROP ); +#if (_WIN32_IE >= 0x0400) + ListView_SetExtendedListViewStyleEx( this->handle, 0, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_HEADERDRAGDROP | LVS_EX_INFOTIP ); +#endif + ListView_SetImageList( this->handle, this->parent->icons, LVSIL_SMALL ); +} + + +void CSListView::addItem( StatusItem* item, int itemNumber ) +{ + LVITEM lvi = { 0 }; + lvi.mask = LVIF_IMAGE | LVIF_GROUPID | LVIF_PARAM; + lvi.cchTextMax = 256; + lvi.iItem = ListView_GetItemCount( this->handle ); + lvi.lParam = itemNumber; +#if ( WINVER >= 0x501 ) + lvi.iGroupId = ( item->bFavourite == TRUE ) ? 0 : 1; +#endif + + // first column + lvi.iSubItem = 0; + lvi.iImage = item->iIcon; // use selected xicon + SendMessage( this->handle, LVM_INSERTITEM, 0, ( LPARAM )&lvi ); + + // second column + lvi.mask = LVIF_TEXT; + lvi.iSubItem = 1; + lvi.pszText = item->tszTitle; + SendMessage( this->handle, LVM_SETITEM, 0, ( LPARAM )&lvi ); + + // third column + lvi.iSubItem = 2; + lvi.pszText = item->tszMessage; + SendMessage( this->handle, LVM_SETITEM, 0, ( LPARAM )&lvi ); +} + + +void CSListView::initItems( ListItem< StatusItem >* items ) +{ + ListItem< StatusItem >* help = items; + for ( int i = 0; help != NULL; help = help->next, i++ ) + if ( parent->itemPassedFilter( help )) + addItem( help->item, i ); +} + + +void CSListView::reinitItems( ListItem< StatusItem >* items ) +{ + EnableWindow( this->handle, FALSE ); + this->removeItems( ); + this->initItems( items ); + EnableWindow( this->handle, TRUE ); +} + + +void CSListView::removeItems( ) +{ + ListView_DeleteAllItems( this->handle ); +} + + +int CSListView::getPositionInList( ) +{ + LVITEM lvi = { 0 }; + lvi.iItem = ListView_GetSelectedItemMacro( this->parent->listview->handle ); + lvi.iSubItem = 0; + lvi.mask = LVIF_PARAM; + ListView_GetItem( this->parent->listview->handle, &lvi ); + return lvi.lParam; +} + + +void CSListView::setFullFocusedSelection( int selection ) +{ + ListView_SetItemState( this->handle, -1, 0, LVIS_SELECTED ); + ListView_EnsureVisible( this->handle, selection, FALSE ); + ListView_SetItemState( this->handle, selection, LVIS_SELECTED, LVIS_SELECTED ); + ListView_SetItemState( this->handle, selection, LVIS_FOCUSED , LVIS_FOCUSED ); + SetFocus( this->handle ); +} + + +// ====[ THREAD FORK ]======================================================== + +void ForkThread( pThreadFunc pFunc, void* arg ) +{ + mir_forkthread( pFunc, arg ); +} + + +// ====[ LIST MANAGEMENT ]==================================================== + +CSItemsList::CSItemsList(char* protoName) +{ + this->list = new List< StatusItem >( this->compareItems ); + this->loadItems(protoName); +} + + +CSItemsList::~CSItemsList( ) +{ + delete this->list; +} + + +int CSItemsList::compareItems( const StatusItem* p1, const StatusItem* p2 ) +{ + int favRes = 0, icoRes = 0, ttlRes = 0, msgRes = 0; + + if ( p1->bFavourite < p2->bFavourite ) + favRes = 1; + else if ( p1->bFavourite > p2->bFavourite ) + favRes = -1; + + int result; + if ( p1->iIcon > p2->iIcon ) + icoRes = 1; + else if ( p1->iIcon < p2->iIcon ) + icoRes = -1; + + result = lstrcmp( p1->tszTitle, p2->tszTitle ); + ttlRes = result; + + result = lstrcmp( p1->tszMessage, p2->tszMessage ); + msgRes = result; + + if ( !icoRes && !ttlRes && !msgRes ) + return 0; + + if ( favRes != 0 ) + return favRes; + if ( icoRes != 0 ) + return icoRes; + if ( ttlRes != 0 ) + return ttlRes; + if ( msgRes != 0 ) + return msgRes; + + return 0; +} + + +void CSItemsList::loadItems(char* protoName) +{ + char dbSetting[32]; + mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_ItemsCount", protoName); + unsigned int itemsCount = getWord(dbSetting, DEFAULT_ITEMS_COUNT); + + for (unsigned int i = 1; i <= itemsCount; i++) + { + StatusItem* item = new StatusItem(); + DBVARIANT dbv = {DBVT_TCHAR}; + mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_Item%dIcon", protoName, i); + item->iIcon = getByte(dbSetting, DEFAULT_ITEM_ICON); + mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_Item%dTitle", protoName, i); + getTString(dbSetting, &dbv); + lstrcpy(item->tszTitle, dbv.ptszVal); + mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_Item%dMessage", protoName, i); + getTString(dbSetting, &dbv); + lstrcpy(item->tszMessage, dbv.ptszVal); + mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_Item%dFavourite", protoName, i); + item->bFavourite = (BOOL)getByte(dbSetting, DEFAULT_ITEM_IS_FAVOURITE); + this->list->add(item); + } +} + + +void CSItemsList::saveItems(char* protoName) +{ + unsigned int i; + char dbSetting[32]; + mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_ItemsCount", protoName); + unsigned int oldItemsCount = getWord(dbSetting, DEFAULT_ITEMS_COUNT); + + for (i = 1; i <= this->list->getCount(); i++) + { + StatusItem* item = this->list->get( i - 1 ); + mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_Item%dIcon", protoName, i); + setByte(dbSetting, item->iIcon); + mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_Item%dTitle", protoName, i); + setTString(dbSetting, item->tszTitle); + mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_Item%dMessage", protoName, i); + setTString(dbSetting, item->tszMessage); + mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_Item%dFavourite", protoName, i); + setByte(dbSetting, item->bFavourite); + } + + mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_ItemsCount", protoName); + setWord(dbSetting, this->list->getCount()); + + for ( ; i <= oldItemsCount; i++) + { + mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_Item%dIcon", protoName, i); + deleteSetting(dbSetting); + mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_Item%dTitle", protoName, i); + deleteSetting(dbSetting); + mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_Item%dMessage", protoName, i); + deleteSetting(dbSetting); + mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_Item%dFavourite", protoName, i); + deleteSetting(dbSetting); + } +} + + +// ====[ PROCEDURES ]========================================================= + +INT_PTR CALLBACK CSWindowProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam ) +{ + CSWindow* csw = ( CSWindow* )GetWindowLongPtr( hwnd, GWLP_USERDATA ); + + switch ( message ) + { + + case WM_INITDIALOG: + csw = ( CSWindow* )lparam; + SetWindowLongPtr( hwnd, GWLP_USERDATA, lparam ); + csw->handle = hwnd; + csw->initIcons(); + csw->initButtons( ); + csw->listview = new CSListView( GetDlgItem( hwnd, IDC_CSLIST ), csw ); + csw->listview->initItems( csw->itemslist->list->getListHead( )); + csw->toggleButtons( ); + csw->toggleEmptyListMessage( ); + csw->loadWindowPosition( ); + SetWindowText(hwnd, TranslateT(MODULENAME)); + TranslateDialogDefault(hwnd); + return TRUE; + + case WM_COMMAND: + switch ( LOWORD( wparam )) + { + case IDC_MODIFY: + case IDC_ADD: + csw->addModifyDlg = new CSAMWindow( LOWORD( wparam ), csw ); + csw->addModifyDlg->exec( ); + if ( csw->addModifyDlg->bChanged ) + { + if ( LOWORD( wparam ) == IDC_MODIFY ) + csw->itemslist->list->remove( csw->listview->getPositionInList( )); + + int selection = csw->itemslist->list->add( csw->addModifyDlg->item ); + csw->bSomethingChanged = TRUE; + csw->listview->reinitItems( csw->itemslist->list->getListHead( )); + csw->listview->setFullFocusedSelection( selection ); + csw->toggleButtons( ); + csw->toggleEmptyListMessage( ); + } + delete csw->addModifyDlg; + break; + + case IDC_REMOVE: + if ( getByte( "ConfirmDeletion", DEFAULT_PLUGIN_CONFIRM_ITEMS_DELETION )) + if ( MessageBox( hwnd, TranslateT("Do you really want to delete selected item?"), TranslateT(MODULENAME), MB_YESNO | MB_DEFBUTTON2 | MB_ICONQUESTION ) == IDNO ) + break; + csw->itemslist->list->remove( csw->listview->getPositionInList( )); + csw->bSomethingChanged = TRUE; + csw->listview->reinitItems( csw->itemslist->list->getListHead( )); + csw->toggleButtons( ); + csw->toggleEmptyListMessage( ); + break; + + case IDC_FAVOURITE: + { + int selection = csw->listview->getPositionInList( ); + StatusItem* f = new StatusItem( *csw->itemslist->list->get( selection )); + f->bFavourite = ! f->bFavourite; + csw->itemslist->list->remove( selection ); + selection = csw->itemslist->list->add( f ); + csw->bSomethingChanged = TRUE; + csw->listview->reinitItems( csw->itemslist->list->getListHead( )); + csw->listview->setFullFocusedSelection( selection ); + csw->toggleButtons( ); + } + break; + + case IDC_UNDO: + { + csw->itemslist->list->destroy( ); + csw->itemslist->loadItems(csw->protoName); + csw->bSomethingChanged = FALSE; + csw->listview->reinitItems( csw->itemslist->list->getListHead( )); + csw->toggleButtons( ); + csw->toggleEmptyListMessage( ); + break; + } + + case IDC_IMPORT: + { + int result = getByte( "DeleteAfterImport", DEFAULT_PLUGIN_DELETE_AFTER_IMPORT ); + if ( result == TRUE ) + result = IDYES; + else + { + result = MessageBox( hwnd, TranslateT("Do you want old database entries to be deleted after Import?"), + TranslateT(MODULENAME), MB_YESNOCANCEL | MB_DEFBUTTON2 | MB_ICONQUESTION ); + if ( result == IDCANCEL ) break; + } + + CSList::ForAllProtocols( CSList::importCustomStatusUIStatusesFromAllProtos, ( void* )&result ); + csw->bSomethingChanged = TRUE; + csw->toggleButtons( ); + csw->toggleEmptyListMessage( ); + } + break; + + case IDC_FILTER: + csw->toggleFilter( ); + csw->toggleButtons( ); + break; + + case IDC_FILTER_FIELD: + if ( HIWORD( wparam ) == EN_CHANGE ) + csw->listview->reinitItems( csw->itemslist->list->getListHead( )); + break; + + case IDCLOSE: // close and save, no custom status + case IDCANCEL: // close and save, no custom status + case IDC_CANCEL: // close and save, cancel custom status + case IDOK: // close and save, set selected custom status + if ( LOWORD( wparam ) == IDOK && csw->toggleButtons( )) + cslist->setStatus(IDOK, csw->itemslist->list->get(csw->listview->getPositionInList()), csw->protoName); + if ( LOWORD( wparam ) == IDC_CANCEL ) + cslist->setStatus(IDC_CANCEL, NULL, csw->protoName); + if ( csw->bSomethingChanged ) + if (csw->itemslist!=NULL) + csw->itemslist->saveItems(csw->protoName); + csw->saveWindowPosition( csw->handle ); + delete csw->listview; + csw->deinitIcons( ); + cslist->closeList( hwnd ); + break; + + } + return FALSE; + + case WM_NOTIFY: + if ( wparam == IDC_CSLIST ) + { + NMHDR* pnmh = ( NMHDR* )lparam; + switch ( pnmh->code ) + { + + case NM_DBLCLK: + PostMessage( hwnd, WM_COMMAND, IDOK, 0L ); + break; + + case LVN_ITEMCHANGED: + case NM_CLICK: + csw->toggleButtons( ); + break; + + } + } + return FALSE; + + case WM_CTLCOLORSTATIC: + SetTextColor( ( HDC )wparam, RGB( 174, 174, 174 )); + if ( ( ( HWND )lparam == GetDlgItem( hwnd, IDC_NO_ITEMS )) || + ( ( HWND )lparam == GetDlgItem( hwnd, IDC_ADD_SAMPLE )) ) + return ( BOOL )GetStockObject( WHITE_BRUSH ); + return FALSE; + } + return FALSE; +} + + +INT_PTR CALLBACK CSAMWindowProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam ) +{ + CSAMWindow* csamw = ( CSAMWindow* )GetWindowLongPtr( hwnd, GWLP_USERDATA ); + + switch ( message ) + { + + case WM_INITDIALOG: + { + csamw = ( CSAMWindow* )lparam; + SetWindowLongPtr( hwnd, GWLP_USERDATA, lparam ); + csamw->handle = hwnd; + EnableWindow( csamw->parent->handle, FALSE ); + csamw->hCombo = GetDlgItem( hwnd, IDC_COMBO ); + csamw->hMessage = GetDlgItem( hwnd, IDC_MESSAGE ); + csamw->setCombo(); + csamw->fillDialog(); + TranslateDialogDefault(hwnd); + } + break; + + case WM_COMMAND: + switch ( LOWORD( wparam )) + { + case IDC_MESSAGE: + csamw->checkFieldLimit( HIWORD( wparam ), LOWORD( wparam )); + break; + case IDOK: + csamw->checkItemValidity( ); + case IDCANCEL: + EnableWindow( csamw->parent->handle, TRUE ); + EndDialog( hwnd, LOWORD( wparam )); + break; + + } + break; + + } + return FALSE; +} + + +INT_PTR CALLBACK CSOptionsProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam ) +{ + switch ( message ) + { + + case WM_INITDIALOG: + { + CheckDlgButton( hwnd, IDC_CONFIRM_DELETION, + getByte( "ConfirmDeletion", DEFAULT_PLUGIN_CONFIRM_ITEMS_DELETION ) ? + BST_CHECKED : BST_UNCHECKED ); + + CheckDlgButton( hwnd, IDC_DELETE_AFTER_IMPORT, + getByte( "DeleteAfterImport", DEFAULT_PLUGIN_DELETE_AFTER_IMPORT ) ? + BST_CHECKED : BST_UNCHECKED ); + + CheckDlgButton( hwnd, IDC_REMEMBER_POSITION, + getByte( "RememberWindowPosition", DEFAULT_REMEMBER_WINDOW_POSITION ) ? + BST_CHECKED : BST_UNCHECKED ); + + unsigned int protosExtraEnabled = 1; + + CSList::ForAllProtocols( CSList::countPlusModProtos, ( void* )&protosExtraEnabled ); + + if ( protosExtraEnabled ) // some protocol(s) allow(s) use of extra icons + { + EnableWindow( GetDlgItem( hwnd, IDC_ALLOW_EXTRA_ICONS ), TRUE ); + CheckDlgButton( hwnd, IDC_ALLOW_EXTRA_ICONS, getByte( "AllowExtraIcons", + DEFAULT_ALLOW_EXTRA_ICONS )); + } + + TranslateDialogDefault(hwnd); + } + return TRUE; + + case WM_NOTIFY: + switch ( ( ( LPNMHDR )lparam )->code ) + { + + case PSN_APPLY: + { + setByte( "ConfirmDeletion", IsDlgButtonChecked( hwnd, IDC_CONFIRM_DELETION ) ? 1 : 0 ); + setByte( "DeleteAfterImport", IsDlgButtonChecked( hwnd, IDC_DELETE_AFTER_IMPORT ) ? 1 : 0 ); + setByte( "AllowExtraIcons", IsDlgButtonChecked( hwnd, IDC_ALLOW_EXTRA_ICONS ) ? 1 : 0 ); + setByte( "RememberWindowPosition", IsDlgButtonChecked( hwnd, IDC_REMEMBER_POSITION ) ? 1 : 0 ); + + cslist->rebuildMenuItems( ); + } + break; + + } + return TRUE; + + } + return FALSE; +} + + +// ====[ HELPERS ]============================================================ + +HICON LoadIconExEx( const char* IcoLibName, int NonIcoLibIcon ) +{ + if ( ServiceExists( MS_SKIN2_GETICON )) { + char szSettingName[64]; + mir_snprintf(szSettingName, SIZEOF(szSettingName), "%s_%s", __INTERNAL_NAME, IcoLibName); + return ( HICON )CallService( MS_SKIN2_GETICON, 0, ( LPARAM )szSettingName ); + } + else + return ( HICON )LoadImage( cslist->handle, MAKEINTRESOURCE( NonIcoLibIcon ), IMAGE_ICON, 0, 0, 0 ); +} diff --git a/plugins/CSList/src/cslist.h b/plugins/CSList/src/cslist.h new file mode 100644 index 0000000000..7a4f0f8e75 --- /dev/null +++ b/plugins/CSList/src/cslist.h @@ -0,0 +1,665 @@ +/* ======================================================================== + + Custom Status List + __________________ + + Custom Status List plugin for Miranda-IM (www.miranda-im.org) + Follower of Custom Status History List by HANAX + Copyright © 2006-2008 HANAX + Copyright © 2007-2009 jarvis + + 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$ + Revision : $Rev$ + Last change on : $Date$ + Last change by : $Author$ + + ============================================================================ + + + DESCRIPTION: + + Offers List of your Custom Statuses. + + ============================================================================ + +// ====[ INCLUDES AND DEFINITIONS ]======================================== */ + +#ifndef __CSLIST_H +#define __CSLIST_H 1 + + +#define WINVER 0x501 +#define _WIN32_WINNT 0x501 +#define _WIN32_IE 0x600 + +#define MIRANDA_VER 0x0A00 + +#pragma warning( disable: 4996 ) +#pragma comment( lib, "comctl32.lib" ) + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// ====[ BASIC DEFINITIONS ]================================================== + +#include "resource.h" +#include "version.h" + +#define MODULENAME "Custom Status List" + +// {C8CC7414-6507-4AF6-925A-83C1D2F7BE8C} +#define PLUGIN_GUUID { 0xc8cc7414, 0x6507, 0x4af6, { 0x92, 0x5a, 0x83, 0xc1, 0xd2, 0xf7, 0xbe, 0x8c } } + +// ====[ LIMITS ]============================================================= + +#define EXTRASTATUS_TITLE_LIMIT 64 // limit of chars for extra status title +#define EXTRASTATUS_MESSAGE_LIMIT 2048 // limit of chars for extra status message +#define XSTATUS_COUNT 32 +#define XSTATUS_COUNT_EXTENDED 37 +#define MOODS_COUNT 84 + +// ====[ SERVICES ]=========================================================== + +#define MS_PSEUDO_PROTO_PROTOACCSENUM ( CSList::bAccountsSupported ? MS_PROTO_ENUMACCOUNTS : MS_PROTO_ENUMPROTOCOLS ) + +// ====[ DEFAULT DB VALUES ]================================================== + +#define DEFAULT_ICQ_XSTATUS_ENABLED 1 +#define DEFAULT_PLUGIN_SHOW_RELNOTES 0 +#define DEFAULT_PLUGIN_SHOW_NONSTANDARD_XSTATUSES 1 +#define DEFAULT_PLUGIN_CONFIRM_ITEMS_DELETION 1 +#define DEFAULT_PLUGIN_DELETE_AFTER_IMPORT 0 +#define DEFAULT_ITEMS_COUNT 0 +#define DEFAULT_ITEM_ICON 0 +#define DEFAULT_ITEM_IS_FAVOURITE 0 +#define DEFAULT_ALLOW_EXTRA_ICONS 1 +#define DEFAULT_REMEMBER_WINDOW_POSITION 1 + + +// ====[ FUNCTION MACROS ]==================================================== + +// set which row is selected (cannot be only focused, but fully selected - second param ;)) +#define ListView_GetSelectedItemMacro( hwnd ) ListView_GetNextItem( hwnd, -1, LVNI_FOCUSED | LVNI_SELECTED ); +#ifndef ListView_SetSelectionMark + #define ListView_SetSelectionMark( x, y ) 0 +#endif + +#define getByte( setting, error ) DBGetContactSettingByte( NULL, __INTERNAL_NAME, setting, error ) +#define setByte( setting, value ) DBWriteContactSettingByte( NULL, __INTERNAL_NAME, setting, value ) +#define getWord( setting, error ) DBGetContactSettingWord( NULL, __INTERNAL_NAME, setting, error ) +#define setWord( setting, value ) DBWriteContactSettingWord( NULL, __INTERNAL_NAME, setting, value ) +#define getDword( setting, error ) DBGetContactSettingDword( NULL, __INTERNAL_NAME, setting, error ) +#define setDword( setting, value ) DBWriteContactSettingDword( NULL, __INTERNAL_NAME, setting, value ) +#define getTString( setting, dest ) DBGetContactSettingTString( NULL, __INTERNAL_NAME, setting, dest ) +#define setTString( setting, value ) DBWriteContactSettingTString( NULL, __INTERNAL_NAME, setting, value ) +#define deleteSetting( setting ) DBDeleteContactSetting( NULL, __INTERNAL_NAME, setting ) + +// -- +typedef void (__cdecl *pForAllProtosFunc)( char*, void* ); + + +// ====[ STRUCTURES ]========================================================= + +struct StatusItem { // list item structure + int iIcon; + TCHAR tszTitle[EXTRASTATUS_TITLE_LIMIT]; + TCHAR tszMessage[EXTRASTATUS_MESSAGE_LIMIT]; + BOOL bFavourite; + + StatusItem() + { + this->iIcon = 0; + lstrcpy(this->tszTitle, _T("")); + lstrcpy(this->tszMessage, _T("")); + this->bFavourite = FALSE; + } + + StatusItem( const StatusItem& p ) + { + this->iIcon = p.iIcon; + lstrcpy( this->tszTitle, p.tszTitle ); + lstrcpy( this->tszMessage, p.tszMessage ); + this->bFavourite = p.bFavourite; + } + + ~StatusItem( ) + { + } +}; + +static struct CSForm { // icons + buttons + int idc; + TCHAR* ptszTitle; + TCHAR* ptszDescr; + char* pszIconIcoLib; + int iconNoIcoLib; + HANDLE hIcoLibItem; + +} forms[] = { + + { -1, LPGENT( "Main Menu" ), LPGENT( "Main Icon" ), "icon", IDI_CSLIST, NULL }, + { IDC_ADD, LPGENT( "Add new item" ), LPGENT( "Add" ), "add", IDI_ADD, NULL }, + { IDC_MODIFY, LPGENT( "Modify selected item" ), LPGENT( "Modify" ), "modify", IDI_MODIFY, NULL }, + { IDC_REMOVE, LPGENT( "Delete selected item" ), LPGENT( "Remove" ), "remove", IDI_REMOVE, NULL }, + { IDC_FAVOURITE, LPGENT( "Set/unset current item as favorite" ), LPGENT( "Favourite" ), "favourite", IDI_FAVOURITE, NULL }, + { IDC_UNDO, LPGENT( "Undo changes" ), LPGENT( "Undo changes" ), "undo", IDI_UNDO, NULL }, + { IDC_IMPORT, LPGENT( "Import statuses from database" ), LPGENT( "Import" ), "import", IDI_IMPORT, NULL }, + { IDC_FILTER, LPGENT( "Filter list" ), LPGENT( "Filter" ), "filter", IDI_FILTER, NULL }, + { IDCLOSE, LPGENT( "Close without changing custom status" ), LPGENT( "No change" ), "nochng", IDI_CLOSE, NULL }, + { IDC_CANCEL, LPGENT( "Clear custom status (reset to None) and close" ), LPGENT( "Clear" ), "clear", IDI_UNSET, NULL }, + { IDOK, LPGENT( "Set custom status to selected one and close" ), LPGENT( "Set" ), "apply", IDI_APPLY, NULL }, +}; + +static struct CSXstatus { // combobox xstatus icons + int iId; + TCHAR* ptszTitle; + +} xstatus_names[] = { + + { 1, LPGENT( "Angry" ) }, + { 2, LPGENT( "Taking a bath" ) }, + { 3, LPGENT( "Tired" ) }, + { 4, LPGENT( "Party" ) }, + { 5, LPGENT( "Drinking beer" ) }, + { 6, LPGENT( "Thinking" ) }, + { 7, LPGENT( "Eating" ) }, + { 8, LPGENT( "Watching TV" ) }, + { 9, LPGENT( "Meeting" ) }, + { 10, LPGENT( "Coffee" ) }, + { 11, LPGENT( "Listening to music" ) }, + { 12, LPGENT( "Business" ) }, + { 13, LPGENT( "Shooting" ) }, + { 14, LPGENT( "Having fun" ) }, + { 15, LPGENT( "On the phone" ) }, + { 16, LPGENT( "Gaming" ) }, + { 17, LPGENT( "Studying" ) }, + { 18, LPGENT( "Shopping" ) }, + { 19, LPGENT( "Feeling sick" ) }, + { 20, LPGENT( "Sleeping" ) }, + { 21, LPGENT( "Surfing" ) }, + { 22, LPGENT( "Browsing" ) }, + { 23, LPGENT( "Working" ) }, + { 24, LPGENT( "Typing" ) }, + { 25, LPGENT( "Picnic" ) }, + { 26, LPGENT( "PDA" ) }, + { 27, LPGENT( "On the phone" ) }, + { 28, LPGENT( "I'm high" ) }, + { 29, LPGENT( "On WC" ) }, + { 30, LPGENT( "To be or not to be" ) }, + { 31, LPGENT( "Watching pro7 on TV" ) }, + { 32, LPGENT( "Love" ) }, + { 33, LPGENT( "Searching" ) }, + { 34, LPGENT( "Amorous" ) }, // I don't understand why this falls when 2 same named items appear O_o + { 35, LPGENT( "Journal" ) }, // edit: ..and now I REALLY don't understand why it's working now x)) + { 36, LPGENT( "Sex" ) }, + { 37, LPGENT( "Smoking" ) }, // -||- +}; + +static struct CSMoods { // combobox moods icons + int iId; + TCHAR* ptszTitle; + char* szTag; +} moods_names[] = { + { 1, LPGENT("Afraid"), "afraid" }, + { 2, LPGENT("Amazed"), "amazed" }, + { 3, LPGENT("Amorous"), "amorous" }, + { 4, LPGENT("Angry"), "angry" }, + { 5, LPGENT("Annoyed"), "annoyed" }, + { 6, LPGENT("Anxious"), "anxious" }, + { 7, LPGENT("Aroused"), "aroused" }, + { 8, LPGENT("Ashamed"), "ashamed" }, + { 9, LPGENT("Bored"), "bored" }, + { 10, LPGENT("Brave"), "brave" }, + { 11, LPGENT("Calm"), "calm" }, + { 12, LPGENT("Cautious"), "cautious" }, + { 13, LPGENT("Cold"), "cold" }, + { 14, LPGENT("Confident"), "confident" }, + { 15, LPGENT("Confused"), "confused" }, + { 16, LPGENT("Contemplative"),"contemplative" }, + { 17, LPGENT("Contented"), "contented" }, + { 18, LPGENT("Cranky"), "cranky" }, + { 19, LPGENT("Crazy"), "crazy" }, + { 20, LPGENT("Creative"), "creative" }, + { 21, LPGENT("Curious"), "curious" }, + { 22, LPGENT("Dejected"), "dejected" }, + { 23, LPGENT("Depressed"), "depressed" }, + { 24, LPGENT("Disappointed"), "disappointed" }, + { 25, LPGENT("Disgusted"), "disgusted" }, + { 26, LPGENT("Dismayed"), "dismayed" }, + { 27, LPGENT("Distracted"), "distracted" }, + { 28, LPGENT("Embarrassed"), "embarrassed" }, + { 29, LPGENT("Envious"), "envious" }, + { 30, LPGENT("Excited"), "excited" }, + { 31, LPGENT("Flirtatious"), "flirtatious" }, + { 32, LPGENT("Frustrated"), "frustrated" }, + { 33, LPGENT("Grateful"), "grateful" }, + { 34, LPGENT("Grieving"), "grieving" }, + { 35, LPGENT("Grumpy"), "grumpy" }, + { 36, LPGENT("Guilty"), "guilty" }, + { 37, LPGENT("Happy"), "happy" }, + { 38, LPGENT("Hopeful"), "hopeful" }, + { 39, LPGENT("Hot"), "hot" }, + { 40, LPGENT("Humbled"), "humbled" }, + { 41, LPGENT("Humiliated"), "humiliated" }, + { 42, LPGENT("Hungry"), "hungry" }, + { 43, LPGENT("Hurt"), "hurt" }, + { 44, LPGENT("Impressed"), "impressed" }, + { 45, LPGENT("In awe"), "in_awe" }, + { 46, LPGENT("In love"), "in_love" }, + { 47, LPGENT("Indignant"), "indignant" }, + { 48, LPGENT("Interested"), "interested" }, + { 49, LPGENT("Intoxicated"), "intoxicated" }, + { 50, LPGENT("Invincible"), "invincible" }, + { 51, LPGENT("Jealous"), "jealous" }, + { 52, LPGENT("Lonely"), "lonely" }, + { 53, LPGENT("Lost"), "lost" }, + { 54, LPGENT("Lucky"), "lucky" }, + { 55, LPGENT("Mean"), "mean" }, + { 56, LPGENT("Moody"), "moody" }, + { 57, LPGENT("Nervous"), "nervous" }, + { 58, LPGENT("Neutral"), "neutral" }, + { 59, LPGENT("Offended"), "offended" }, + { 60, LPGENT("Outraged"), "outraged" }, + { 61, LPGENT("Playful"), "playful" }, + { 62, LPGENT("Proud"), "proud" }, + { 63, LPGENT("Relaxed"), "relaxed" }, + { 64, LPGENT("Relieved"), "relieved" }, + { 65, LPGENT("Remorseful"), "remorseful" }, + { 66, LPGENT("Restless"), "restless" }, + { 67, LPGENT("Sad"), "sad" }, + { 68, LPGENT("Sarcastic"), "sarcastic" }, + { 69, LPGENT("Satisfied"), "satisfied" }, + { 70, LPGENT("Serious"), "serious" }, + { 71, LPGENT("Shocked"), "shocked" }, + { 72, LPGENT("Shy"), "shy" }, + { 73, LPGENT("Sick"), "sick" }, + { 74, LPGENT("Sleepy"), "sleepy" }, + { 75, LPGENT("Spontaneous"), "spontaneous" }, + { 76, LPGENT("Stressed"), "stressed" }, + { 77, LPGENT("Strong"), "strong" }, + { 78, LPGENT("Surprised"), "surprised" }, + { 79, LPGENT("Thankful"), "thankful" }, + { 80, LPGENT("Thirsty"), "thirsty" }, + { 81, LPGENT("Tired"), "tired" }, + { 82, LPGENT("Undefined"), "undefined" }, + { 83, LPGENT("Weak"), "weak" }, + { 84, LPGENT("Worried"), "worried" }, +}; +// ====[ MY BITCHY LIST IMPLEMENTATION x)) ]================================== +// TODO: Optimize it all x)) + +template< class T > struct ListItem +{ + T* item; + ListItem* next; + + ListItem( ) + { + this->item = NULL; + this->next = NULL; + } + + ~ListItem( ) + { + delete this->item; + } + + ListItem( StatusItem* si ) + { + this->item = si; + this->next = NULL; + } + + ListItem( const ListItem& p ) + { + this->item = p.item; + this->next = NULL; + } +}; + + +template< class T > struct List +{ +private: + ListItem< T >* items; + unsigned int count; + +public: + typedef int ( *compareFunc )( const T* p1, const T* p2 ); + compareFunc compare; + + List( compareFunc compFnc ) + { + this->items = NULL; + this->count = 0; + this->compare = compFnc; + } + + ~List( ) + { + this->destroy( ); + } + + ListItem< T >* getListHead( ) + { + return items; + } + + unsigned int getCount( ) + { + return count; + } + + int add( T* csi ) + { + int position = 0; + ListItem< T >* item = new ListItem< T >( csi ); + if ( this->items == NULL ) + this->items = item; + else + { + ListItem< T >* help = item; + item->next = items; + while ( help->next != NULL ) + { + int cmp = compare( item->item, help->next->item ); + if ( cmp == 1 ) + help = help->next; + else if ( cmp == 0 ) + { + delete item; + return -1; + } + else + break; + position++; + } + if ( help != item ) + { + item->next = help->next; + help->next = item; + } + else + items = item; + } + this->count++; + return position; + } + + int remove( const unsigned int item ) + { + int position = 0; + if ( item < 0 || item >= this->count ) + return -1; + + ListItem< T >* help = items; + ListItem< T >* removed; + if ( item == 0 ) + { + items = items->next; + removed = help; + } + else + { + for ( unsigned int i = 0; i < item - 1; i++ ) + { + help = help->next; + position++; + } + removed = help->next; + help->next = help->next->next; + } + delete removed; + this->count--; + return position; + } + + T* get( const unsigned int item ) + { + ListItem< T >* help = items; + for ( unsigned int i = 0; i < item; i++ ) + help = help->next; + return help->item; + } + + T* operator[]( const unsigned int item ) + { + return get( item ); + } + + void destroy( ) + { + while ( this->count > 0 ) + this->remove( 0 ); + } +}; + + +// ====[ CLASSING -- FUNNY STUFF :) ]========================================= + +struct CSList; +struct CSWindow; +struct CSAMWindow; +struct CSItemsList; +struct CSListView; + +// -------- + +struct CSListView +{ + HWND handle; + CSWindow* parent; + + CSListView( HWND, CSWindow* ); + + void addItem( StatusItem* item, int itemNumber ); + void initItems( ListItem< StatusItem >* items ); + void reinitItems( ListItem< StatusItem >* items ); + void removeItems( ); + int getPositionInList( ); + void setFullFocusedSelection( int selection ); +}; + + +struct CSItemsList +{ + List< StatusItem >* list; + + static int compareItems( const StatusItem* p1, const StatusItem* p2 ); + void loadItems(char* protoName); + void saveItems(char* protoName); + + CSItemsList(char* protoName); + ~CSItemsList(); +}; + + +struct CSAMWindow +{ + WORD action; + StatusItem* item; + CSWindow* parent; + BOOL bChanged; + + HWND handle; + HWND hCombo; + HWND hMessage; + + CSAMWindow( WORD action, CSWindow* parent ); + ~CSAMWindow( ); + + void exec( ); + void setCombo( ); + void fillDialog( ); + void checkFieldLimit( WORD action, WORD item ); + void checkItemValidity(); +}; + + +struct CSWindow +{ + HWND handle; + BOOL bExtraIcons; + CSItemsList* itemslist; + CSListView* listview; + CSAMWindow* addModifyDlg; + HIMAGELIST icons; + BOOL bSomethingChanged; + TCHAR* filterString; + char* protoName; + CSWindow(char* protoName); + ~CSWindow(); + + void initIcons( ); + void deinitIcons( ); + void initButtons( ); + static void __cdecl showWindow( void* arg ); + static void __cdecl closeWindow( void* arg ); + void loadWindowPosition( ); + BOOL toggleButtons( ); + void toggleEmptyListMessage( ); + void toggleFilter( ); + BOOL itemPassedFilter( ListItem< StatusItem >* li ); + + void __inline saveWindowPosition( HWND hwnd ) + { + if ( getByte( "RememberWindowPosition", DEFAULT_REMEMBER_WINDOW_POSITION ) == TRUE ) + { + RECT rect = { 0 }; + GetWindowRect( hwnd, &rect ); + setWord( "PositionX", rect.left ); + setWord( "PositionY", rect.top ); + } + } +}; + + +struct CSList +{ + // global variables + static HINSTANCE handle; + static DWORD dwMirandaVersion; + static BOOL bUnicodeCore; + static BOOL bAccountsSupported; + + // class components + CSWindow* mainWindow; + + // events + HANDLE hHookOnPluginsLoaded; + HANDLE hHookOnOptionsInit; + HANDLE hHookOnDBSettingChanged; + HANDLE hHookOnStatusMenuBuild; + + // services + HANDLE hServiceShowList; + + CSList( ); + ~CSList( ); + + // event functions + static int postLoading( WPARAM, LPARAM ); + static int initOptions( WPARAM, LPARAM ); + static int respondDBChange( WPARAM, LPARAM ); + static int createMenuItems( WPARAM, LPARAM ); + + // service functions + static INT_PTR __cdecl showList(WPARAM, LPARAM, LPARAM); + void closeList( HWND ); + + // protocols enumeration related functions + static void ForAllProtocols( pForAllProtosFunc pFunc, void* arg ); + static void __cdecl addProtoStatusMenuItem( char* protoName, void* arg ); + static void __cdecl countProtos( char* protoName, void* arg ); + static void __cdecl countPlusModProtos( char* protoName, void* arg ); + static void __cdecl importCustomStatusUIStatusesFromAllProtos( char* protoName, void* arg ); + + // other functions + void initIcoLib( ); + void registerHotkeys(char buf[200], TCHAR* accName, int Number); + void rebuildMenuItems( ); + void setStatus(WORD code, StatusItem* item, char* protoName); +}; + +HINSTANCE CSList::handle = NULL; +DWORD CSList::dwMirandaVersion = 0x00000000; +BOOL CSList::bUnicodeCore = FALSE; +BOOL CSList::bAccountsSupported = FALSE; + +// ====[ GLOBALS ]============================================================ + +CSList* cslist = NULL; + +// ====[ INIT STUFF ]========================================================= + +BOOL WINAPI DllMain( HINSTANCE, DWORD, LPVOID ); + +extern "C" __declspec( dllexport ) PLUGININFOEX* MirandaPluginInfoEx( DWORD ); + +extern "C" __declspec( dllexport ) int Load(void); +extern "C" __declspec( dllexport ) int Unload( void ); + + +// ====[ THREAD FORK ]======================================================== + +void ForkThread( pThreadFunc pFunc, void* arg ); + + +// ====[ PROCEDURES ]========================================================= + +INT_PTR CALLBACK CSWindowProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam ); +INT_PTR CALLBACK CSAMWindowProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam ); +INT_PTR CALLBACK CSRNWindowProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam ); +INT_PTR CALLBACK CSOptionsProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam ); + + +// ====[ HELPERS ]============================================================ + +HICON LoadIconExEx( const char*, int ); + +void __fastcall SAFE_FREE(void** p) +{ + if (*p) + { + free(*p); + *p = NULL; + } +} + + +#endif /* __CSLIST_H */ diff --git a/plugins/CSList/src/legacy.h b/plugins/CSList/src/legacy.h new file mode 100644 index 0000000000..8ef63089d7 --- /dev/null +++ b/plugins/CSList/src/legacy.h @@ -0,0 +1,87 @@ +/* + + FILE INFO: Legacy functions of older Custom Status List versions + +*/ + +int cslist_import_v2_status_items( ); +int cslist_parse_row( TCHAR *row, int ord ); + +int cslist_import_v2_status_items( ) +{ + // get DB string, parse to statuses, add by helpItem + DBVARIANT dbv = { DBVT_TCHAR }; + int parseResult; + int dbLoadResult; + const TCHAR* rowDelim = _T( "" ); // new line + TCHAR *row = NULL; + + dbLoadResult = getTString( "listhistory", &dbv ); + if ( dbv.ptszVal ) + { + int i = getByte( "ItemsCount", DEFAULT_ITEMS_COUNT ); + row = _tcstok( dbv.ptszVal, rowDelim ); + while( row != NULL ) { + i++; + // process current row.. + parseResult = cslist_parse_row( row, i ); + // ..and go to the other, while some remains + row = _tcstok( NULL, rowDelim ); + } + setByte( "ItemsCount", i ); + } + //free( rowDelim ); + //free( row ); + return 0; +} + +int cslist_parse_row( TCHAR *row, int ord ) // parse + helpItem +{ + int pIconInt; + TCHAR pIcon[4], pTitle[EXTRASTATUS_TITLE_LIMIT+2], pMsg[EXTRASTATUS_MESSAGE_LIMIT+2], pFav[4]; + TCHAR scanfFormat[64]; + + lstrcpy( pTitle, _T( "" )); + lstrcpy( pMsg, _T( "" )); + + // database row format: "%2[^]%64[^]%2048[^]%2[^]" + + mir_sntprintf( + scanfFormat, + sizeof( scanfFormat ), + _T( "%%%d[^]%%%d[^]%%%d[^]%%%d[^]" ), // %% makes %, %d makes number :) + 2, + EXTRASTATUS_TITLE_LIMIT, + EXTRASTATUS_MESSAGE_LIMIT, + 2 + ); + + _tcscanf( row, scanfFormat, pIcon, pTitle, pMsg, pFav ); + + if ( lstrlen( pTitle ) + lstrlen( pMsg ) > 0 ) + { + char dbSetting[32]; + pIconInt = _ttoi( pIcon ); + mir_snprintf( dbSetting, sizeof( dbSetting ), "Item%dIcon", ord ); + setByte( dbSetting, pIconInt ); + mir_snprintf( dbSetting, sizeof( dbSetting ), "Item%dTitle", ord ); + setTString( dbSetting, pTitle ); + mir_snprintf( dbSetting, sizeof( dbSetting ), "Item%dMessage", ord ); + setTString( dbSetting, pMsg ); + mir_snprintf( dbSetting, sizeof( dbSetting ), "Item%dFavourite", ord ); + setByte( dbSetting, 0 ); + } + else { + return FALSE; + } + return TRUE; +} + + +void MessageBoxInt( int value1, int value2 ) +{ + TCHAR buf1[64], buf2[64]; + mir_sntprintf( buf1, SIZEOF( buf1 ), TEXT( "%d" ), value1 ); + mir_sntprintf( buf2, SIZEOF( buf2 ), TEXT( "%d" ), value2 ); + MessageBox( NULL, buf2, buf1, MB_OK ); +} diff --git a/plugins/CSList/src/resource.h b/plugins/CSList/src/resource.h new file mode 100644 index 0000000000..cec164739d --- /dev/null +++ b/plugins/CSList/src/resource.h @@ -0,0 +1,49 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by cslist.rc +// +#define IDCLOSE 8 +#define IDC_CANCEL 9 +#define IDD_CSLIST 101 +#define IDD_ADDMODIFY 102 +#define IDD_OPTIONS 103 +#define IDI_CSLIST 121 +#define IDI_ADD 122 +#define IDI_MODIFY 123 +#define IDI_REMOVE 124 +#define IDI_FAVOURITE 125 +#define IDI_UNDO 126 +#define IDI_GLOBAL 127 +#define IDI_FILTER 128 +#define IDI_CLOSE 129 +#define IDI_UNSET 130 +#define IDI_APPLY 131 +#define IDI_IMPORT 132 +#define IDC_CSLIST 1001 +#define IDC_FILTER_FIELD 1011 +#define IDC_ADD_SAMPLE 1012 +#define IDC_NO_ITEMS 1013 +#define IDC_ADD 1021 +#define IDC_MODIFY 1022 +#define IDC_REMOVE 1023 +#define IDC_FAVOURITE 1024 +#define IDC_UNDO 1025 +#define IDC_FILTER 1027 +#define IDC_COMBO 1041 +#define IDC_MESSAGE 1042 +#define IDC_CONFIRM_DELETION 1051 +#define IDC_DELETE_AFTER_IMPORT 1052 +#define IDC_IMPORT 1071 +#define IDC_ALLOW_EXTRA_ICONS 1204 +#define IDC_REMEMBER_POSITION 1207 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 104 +#define _APS_NEXT_COMMAND_VALUE 40003 +#define _APS_NEXT_CONTROL_VALUE 1209 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/plugins/CSList/src/strpos.h b/plugins/CSList/src/strpos.h new file mode 100644 index 0000000000..210bfddf0a --- /dev/null +++ b/plugins/CSList/src/strpos.h @@ -0,0 +1,70 @@ +/* + * strpos.c - Returns the offset of a string in a substring. + * + * Copyright (c) 2001, 2002 Andre Guibert de Bruet. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification, immediately at the beginning of the file. + * 2. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +/* + * You might want to place this next block in a header file somewhere: + */ + + +# ifndef TCHAR +# define TCHAR wchar_t +# endif /* TCHAR */ +# define STRING wchar_t * + + + + +int strpos( STRING haystack, STRING needle ) +{ + STRING pDest; + int position; + +#ifdef DEBUG_VERBOSE + TCHAR lpBuf[1024]; +#endif /* def DEBUG_VERBOSE */ + + pDest = (STRING) wcsstr( haystack, needle ); + + + if ( pDest ) + position = pDest - haystack; + else + { +#ifdef DEBUG_VERBOSE + printf( L"strpos(): Could not find '%s' in '%s'.\tFAIL.", needle, haystack ); +#endif /* def DEBUG_VERBOSE */ + return -1; + } + +#ifdef DEBUG_VERBOSE + printf( L"strpos(): Found '%s' at position: %d.\t\tOK.", needle, position ); +#endif /* def DEBUG_VERBOSE */ + + return position; +} diff --git a/plugins/CSList/strpos.h b/plugins/CSList/strpos.h deleted file mode 100644 index 210bfddf0a..0000000000 --- a/plugins/CSList/strpos.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * strpos.c - Returns the offset of a string in a substring. - * - * Copyright (c) 2001, 2002 Andre Guibert de Bruet. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification, immediately at the beginning of the file. - * 2. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -/* - * You might want to place this next block in a header file somewhere: - */ - - -# ifndef TCHAR -# define TCHAR wchar_t -# endif /* TCHAR */ -# define STRING wchar_t * - - - - -int strpos( STRING haystack, STRING needle ) -{ - STRING pDest; - int position; - -#ifdef DEBUG_VERBOSE - TCHAR lpBuf[1024]; -#endif /* def DEBUG_VERBOSE */ - - pDest = (STRING) wcsstr( haystack, needle ); - - - if ( pDest ) - position = pDest - haystack; - else - { -#ifdef DEBUG_VERBOSE - printf( L"strpos(): Could not find '%s' in '%s'.\tFAIL.", needle, haystack ); -#endif /* def DEBUG_VERBOSE */ - return -1; - } - -#ifdef DEBUG_VERBOSE - printf( L"strpos(): Found '%s' at position: %d.\t\tOK.", needle, position ); -#endif /* def DEBUG_VERBOSE */ - - return position; -} diff --git a/plugins/CyrTranslit/CyrTranslit-gpl.txt b/plugins/CyrTranslit/CyrTranslit-gpl.txt deleted file mode 100644 index 3912109b5c..0000000000 --- a/plugins/CyrTranslit/CyrTranslit-gpl.txt +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/plugins/CyrTranslit/CyrTranslit-readme.txt b/plugins/CyrTranslit/CyrTranslit-readme.txt deleted file mode 100644 index 6a06dae4a9..0000000000 --- a/plugins/CyrTranslit/CyrTranslit-readme.txt +++ /dev/null @@ -1,70 +0,0 @@ -+-------------------------------+ -| CyrTranslit Miranda IM plugin | -| Version 1.0.3.0 | -+-------------------------------+ - -Инструкцию на русском см. ниже/See instructions in Russian below - -SUMMARY - -Applies the Cyrillic to Latin transliteration for the sent instant messages. -What this plug-in does, is just replacing (for the selected contacts only) the -Cyrillic letters in the outgoing messages with the "phonetically equivalent" -Latin letter combinations. When transliteration is enabled for contact, -in the message log (and history) you see the cyrillic letters, but your contact, -on the other side, see a "phonetically equivalent" Latin letter combinations. -Plugins supports ANSI, UNICODE and UTF8 encodings of messages. -Plugin can work in ANSI and UNICODE version of Miranda. - -INSTALLATION - -1. Copy the "CyrTranslit.dll" file to the Miranda IM plugin directory (for -instance, on my computer this is "C:\Program Files\Miranda IM\Plugins\" folder). -2. Restart Miranda IM program. - -USAGE - -After you have install the plug-in, none of the contacts has the transliteration -switched on. To activate the transliteration for a contact who can not read -Cyrillic chars, open the contact menu (right mouse button on the contact entry -in the contact list, or the contact menu button in the message dialog), and -check on the "Transliterate" menu item. From now on, all the sent text messages -will be transliterated for the contact, until you uncheck the menu item in the -contact menu. - -LICENSE - -This is a free software coming under GPL 2.0. Please see the provided gpl.txt -for details. - -AUTHOR - -Ivan Krechetov -i.krechetov@ewi.utwente.nl -http://wwwhome.cs.utwente.nl/~krechetovi/ - -unicode and UTF8 support by ValeraVi -http://www.vi-soft.com.ua - --------------------------------------------------------------------------------- - -КРАТКО - -Производит транслитерацию кириллицы в латиницу для исходящих текстовых -сообщений. В результате вы видите собственные сообщения в логе (и истории) на -кириллице, ваш же собеседник получает транслит. - - -УСТАНОВКА - -1. Скопируйте файл "CyrTranslit.dll" в директорию модулей расщирения Miranda IM -(к примеру, на моём компьютере это папка "C:\Program Files\Miranda IM\Plugins\"). -2. Перезапустите программу Miranda IM. - -ИСПОЛЬЗОВАНИЕ - -Изначально транслитерация для всех контактов отключена. Чтобы активировать или -деактивировать автоматическую транслитерацию для определённого контакта, -выберете пункт "Transliterate" в меню контакта (появляется при нажатии правой -кнопки мыши в контакт-листе, либо кнопки вызова пользовательского меню в окне -сообщений). \ No newline at end of file diff --git a/plugins/CyrTranslit/CyrTranslit.rc b/plugins/CyrTranslit/CyrTranslit.rc deleted file mode 100644 index d8d06cade9..0000000000 --- a/plugins/CyrTranslit/CyrTranslit.rc +++ /dev/null @@ -1,113 +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 - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#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 - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// Dutch (Netherlands) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NLD) -#ifdef _WIN32 -LANGUAGE LANG_DUTCH, SUBLANG_DUTCH -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,3,0 - PRODUCTVERSION 1,0,3,0 - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "FileDescription", "CyrTrans Dynamic Link Library" - VALUE "FileVersion", "1, 0, 3, 0" - VALUE "InternalName", "CyrTrans" - VALUE "LegalCopyright", "Copyright (C) 2005 Ivan Krechetov, modified 2006-2009 by ValeraVi" - VALUE "OriginalFilename", "CyrTrans.dll" - VALUE "ProductName", " CyrTrans Dynamic Link Library" - VALUE "ProductVersion", "1, 0, 3, 0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // Dutch (Netherlands) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/plugins/CyrTranslit/CyrTranslit_10.vcxproj b/plugins/CyrTranslit/CyrTranslit_10.vcxproj index ed023e82d4..6ffc881f5d 100644 --- a/plugins/CyrTranslit/CyrTranslit_10.vcxproj +++ b/plugins/CyrTranslit/CyrTranslit_10.vcxproj @@ -158,23 +158,23 @@ - - - - + + + + - - - - - + + + + + - + - + diff --git a/plugins/CyrTranslit/CyrTranslit_10.vcxproj.filters b/plugins/CyrTranslit/CyrTranslit_10.vcxproj.filters index f25220d0f5..19885e96b5 100644 --- a/plugins/CyrTranslit/CyrTranslit_10.vcxproj.filters +++ b/plugins/CyrTranslit/CyrTranslit_10.vcxproj.filters @@ -15,42 +15,42 @@ - + Source Files - + Source Files - + Source Files - + Source Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Resource Files - + \ No newline at end of file diff --git a/plugins/CyrTranslit/MirandaContact.cpp b/plugins/CyrTranslit/MirandaContact.cpp deleted file mode 100644 index 1a0f149ef8..0000000000 --- a/plugins/CyrTranslit/MirandaContact.cpp +++ /dev/null @@ -1,191 +0,0 @@ -/** - * CyrTranslit: the Cyrillic transliteration plug-in for Miranda IM. - * Copyright 2005 Ivan Krechetov. - * - * 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 "plugin.h" -#include "MirandaContact.h" -#include "TransliterationProtocol.h" - -namespace CyrTranslit -{ - -const std::string MirandaContact::SETTINGS_MODULE = "CyrTranslit"; - -const std::string MirandaContact::SETTING_SHOULD_TRANSLITERATE - = "translit"; - -char *MirandaContact::MENU_ITEM_TEXT = "&Transliterate (ФЫВА->FYVA)"; - -char *MirandaContact::MENU_COMMAND_CALLBACK_SERVICE - = "CyrTranslit/ContactMenuCmd"; - -HANDLE MirandaContact::hTransliterateCmdMenuItem = 0; - -//------------------------------------------------------------------------------ - -MirandaContact::MirandaContact() - : handle(0), - transliterateOutgoingMessages(false) -{ -} - -//------------------------------------------------------------------------------ - -MirandaContact::~MirandaContact() -{ -} - -//------------------------------------------------------------------------------ - -void MirandaContact::initialize() -{ - CreateServiceFunction(MENU_COMMAND_CALLBACK_SERVICE,onMenuCommandTransliterate); - generateMenuItemsForAllContacts(); - - HookEvent(ME_CLIST_PREBUILDCONTACTMENU, onPreBuildContactMenu); - - TransliterationProtocol::initialize(); - activateTransliterationProtocolForSubscribedContacts(); -} - -//------------------------------------------------------------------------------ - -MirandaContact MirandaContact::getContact(HANDLE hContact) -{ - int b = DBGetContactSettingByte( - hContact, - SETTINGS_MODULE.c_str(), - SETTING_SHOULD_TRANSLITERATE.c_str(), - 0); - - MirandaContact ret; - ret.handle = hContact; - ret.transliterateOutgoingMessages = (b != 0); - - return ret; -} - -//------------------------------------------------------------------------------ - -void MirandaContact::save() const -{ - DBWriteContactSettingByte( - handle, - SETTINGS_MODULE.c_str(), - SETTING_SHOULD_TRANSLITERATE.c_str(), - transliterateOutgoingMessages? 1 : 0); -} - -//------------------------------------------------------------------------------ - -bool MirandaContact::shouldTransliterateOutgoingMessages() const -{ - return transliterateOutgoingMessages; -} - -//------------------------------------------------------------------------------ - -void MirandaContact::fillInMenuItem(CLISTMENUITEM &mi) -{ - mi.cbSize = sizeof(CLISTMENUITEM); - mi.pszName = MENU_ITEM_TEXT; - mi.flags = 0; - mi.position = 65535; - mi.hIcon = NULL; - mi.pszService = MENU_COMMAND_CALLBACK_SERVICE; - mi.pszPopupName = NULL; - mi.popupPosition = 0; - mi.hotKey = 0; - mi.pszContactOwner = NULL; -} - -//------------------------------------------------------------------------------ - -void MirandaContact::generateMenuItemsForAllContacts() -{ - CLISTMENUITEM mi; - fillInMenuItem(mi); - hTransliterateCmdMenuItem = Menu_AddContactMenuItem(&mi); -} - -//------------------------------------------------------------------------------ - -void MirandaContact::activateTransliterationProtocolForSubscribedContacts() -{ - int hContact = CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - if(!hContact) return; - - do - { - MirandaContact mc = getContact(reinterpret_cast(hContact)); - - if(mc.shouldTransliterateOutgoingMessages()) - { - TransliterationProtocol::activateForContact(mc.handle); - } - } while(hContact = CallService(MS_DB_CONTACT_FINDNEXT, hContact, 0)); -} - -//------------------------------------------------------------------------------ - -INT_PTR MirandaContact::onMenuCommandTransliterate(WPARAM wParam, LPARAM lParam) -{ - HANDLE hContact = reinterpret_cast(wParam); - if(!CallService(MS_DB_CONTACT_IS, wParam, 0)) return 0; - - MirandaContact mc = getContact(hContact); - mc.transliterateOutgoingMessages = !mc.transliterateOutgoingMessages; - mc.save(); - - if(mc.shouldTransliterateOutgoingMessages()) - { - TransliterationProtocol::activateForContact(mc.handle); - } - else - { - TransliterationProtocol::deactivateForContact(mc.handle); - } - - return 0; -} - -//------------------------------------------------------------------------------ - -int MirandaContact::onPreBuildContactMenu(WPARAM wParam, LPARAM lParam) -{ - if(!hTransliterateCmdMenuItem) return 0; - HANDLE hContact = reinterpret_cast(wParam); - if(!CallService(MS_DB_CONTACT_IS, wParam, 0)) return 0; - - MirandaContact mc = getContact(hContact); - - CLISTMENUITEM mi; - fillInMenuItem(mi); - - DWORD toSet = mc.shouldTransliterateOutgoingMessages()? CMIF_CHECKED : 0; - mi.flags = CMIM_FLAGS | toSet; - - CallService( - MS_CLIST_MODIFYMENUITEM, - reinterpret_cast(hTransliterateCmdMenuItem), - reinterpret_cast(&mi)); - - return 0; -} - -} \ No newline at end of file diff --git a/plugins/CyrTranslit/MirandaContact.h b/plugins/CyrTranslit/MirandaContact.h deleted file mode 100644 index 0e29f3d74e..0000000000 --- a/plugins/CyrTranslit/MirandaContact.h +++ /dev/null @@ -1,123 +0,0 @@ -/** - * CyrTranslit: the Cyrillic transliteration plug-in for Miranda IM. - * Copyright 2005 Ivan Krechetov. - * - * 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. - */ - -#pragma once - -#include "plugin.h" - -namespace CyrTranslit -{ - -/** - * The Miranda IM contact abstraction in respect to the transliteration process. - */ -class MirandaContact -{ -public: - /** - * This message must be sent on Miranda startup. - */ - static void initialize(); - - /** - * A factory method which instantiates new MirandaContact objects, loading - * its data from the Miranda database. - * - * @param hContact The handle of the contact object to be instantiated. - * @return The Miranda IM contact having the passed handle. - */ - static MirandaContact getContact(HANDLE hContact); - - /** - * Saves this object's data to the persistent storage -- the Miranda - * database. This information may be retreived later on by means of - * getContact() factory method invocation. - */ - void save() const; - - /** - * @return True only if the Cyrillic transliteration is on for this contact. - */ - bool shouldTransliterateOutgoingMessages() const; - - ~MirandaContact(); - -private: - static const std::string SETTINGS_MODULE; - static const std::string SETTING_SHOULD_TRANSLITERATE; - - static char *MENU_ITEM_TEXT; - - MirandaContact(); - - /** - * Must be called on Miranda start-up to generate the transliteration - * command menu items for all the contacts (a contact-specific menu). - */ - static void generateMenuItemsForAllContacts(); - - static void activateTransliterationProtocolForSubscribedContacts(); - - /** - * This is a callback function for the transliteration command menu item. - * This menu item is contact-specific. - * - * @param wParam The HANDLE of the contact that owns the activated menu - * item. - * @param lParam hwndContactList - * @return Always returns 0. - */ - static INT_PTR onMenuCommandTransliterate(WPARAM wParam, LPARAM lParam); - - /** - * This is a service name to bind the onMenuCommandTransliterate() method to - * within the Miranda IM framework. - */ - static char *MENU_COMMAND_CALLBACK_SERVICE; - - /** - * Stores the handle to a single user menu item shared by all the contacts. - * This menu item has a contact-specific state -- checked or unchecked, as - * far as for some contacts transliteration may be on, and for others it may - * be off. - * - * MirandaContact class makes the necessary update just before a menu is - * shown for a contact: it checks or unchecks the transliteration menu item. - * - * When the transliteration menu item is activated by a user, the - * transliteration setting (on or off) is inverted for the contact owing the - * menu. - */ - static HANDLE hTransliterateCmdMenuItem; - - /** - * @param wParam The HANDLE of the contact that owns the menu item being - * built. - * @param lParam = 0. - * @return Always returns 0. - */ - static int onPreBuildContactMenu(WPARAM wParam, LPARAM lParam); - - static void fillInMenuItem(CLISTMENUITEM &mi); - - HANDLE handle; - bool transliterateOutgoingMessages; -}; - -} \ No newline at end of file diff --git a/plugins/CyrTranslit/TransliterationMap.cpp b/plugins/CyrTranslit/TransliterationMap.cpp deleted file mode 100644 index f678c0a16e..0000000000 --- a/plugins/CyrTranslit/TransliterationMap.cpp +++ /dev/null @@ -1,247 +0,0 @@ -/** - * CyrTranslit: the Cyrillic transliteration plug-in for Miranda IM. - * Copyright 2005 Ivan Krechetov. - * - * 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 "plugin.h" -#include "TransliterationMap.h" - -namespace CyrTranslit -{ - -TransliterationMap::Guard TransliterationMap::guard; -const TransliterationMap *TransliterationMap::pInstance = 0; - -//------------------------------------------------------------------------------ - -TransliterationMap::Guard::~Guard() -{ - delete TransliterationMap::pInstance; -} - -//------------------------------------------------------------------------------ - -const TransliterationMap& TransliterationMap::getInstance() -{ - if(!pInstance) - { - pInstance = new TransliterationMap(); - } - return *pInstance; -} - -//------------------------------------------------------------------------------ - -TransliterationMap::TransliterationMap() -{ - theMap['а'] = "a"; - theMap['б'] = "b"; - theMap['в'] = "v"; - theMap['г'] = "g"; - theMap['д'] = "d"; - theMap['е'] = "e"; - theMap['ё'] = "e"; - theMap['ж'] = "zh"; - theMap['з'] = "z"; - theMap['и'] = "i"; - theMap['й'] = "i"; - theMap['к'] = "k"; - theMap['л'] = "l"; - theMap['м'] = "m"; - theMap['н'] = "n"; - theMap['о'] = "o"; - theMap['п'] = "p"; - theMap['р'] = "r"; - theMap['с'] = "s"; - theMap['т'] = "t"; - theMap['у'] = "u"; - theMap['ф'] = "f"; - theMap['х'] = "kh"; - theMap['ц'] = "ts"; - theMap['ч'] = "ch"; - theMap['ш'] = "sh"; - theMap['щ'] = "sch"; - theMap['ъ'] = "`"; - theMap['ы'] = "y"; - theMap['ь'] = "'"; - theMap['э'] = "e"; - theMap['ю'] = "yu"; - theMap['я'] = "ya"; - - theMap['А'] = "A"; - theMap['Б'] = "B"; - theMap['В'] = "V"; - theMap['Г'] = "G"; - theMap['Д'] = "D"; - theMap['Е'] = "E"; - theMap['Ё'] = "E"; - theMap['Ж'] = "ZH"; - theMap['З'] = "Z"; - theMap['И'] = "I"; - theMap['Й'] = "I"; - theMap['К'] = "K"; - theMap['Л'] = "L"; - theMap['М'] = "M"; - theMap['Н'] = "N"; - theMap['О'] = "O"; - theMap['П'] = "P"; - theMap['Р'] = "R"; - theMap['С'] = "S"; - theMap['Т'] = "T"; - theMap['У'] = "U"; - theMap['Ф'] = "F"; - theMap['Х'] = "KH"; - theMap['Ц'] = "TS"; - theMap['Ч'] = "CH"; - theMap['Ш'] = "SH"; - theMap['Щ'] = "SCH"; - theMap['Ъ'] = "`"; - theMap['Ы'] = "Y"; - theMap['Ь'] = "'"; - theMap['Э'] = "E"; - theMap['Ю'] = "YU"; - theMap['Я'] = "YA"; - - - - - theMapW[L'а'] = L"a"; - theMapW[L'б'] = L"b"; - theMapW[L'в'] = L"v"; - theMapW[L'г'] = L"g"; - theMapW[L'д'] = L"d"; - theMapW[L'е'] = L"e"; - theMapW[L'ё'] = L"e"; - theMapW[L'ж'] = L"zh"; - theMapW[L'з'] = L"z"; - theMapW[L'и'] = L"i"; - theMapW[L'й'] = L"i"; - theMapW[L'к'] = L"k"; - theMapW[L'л'] = L"l"; - theMapW[L'м'] = L"m"; - theMapW[L'н'] = L"n"; - theMapW[L'о'] = L"o"; - theMapW[L'п'] = L"p"; - theMapW[L'р'] = L"r"; - theMapW[L'с'] = L"s"; - theMapW[L'т'] = L"t"; - theMapW[L'у'] = L"u"; - theMapW[L'ф'] = L"f"; - theMapW[L'х'] = L"kh"; - theMapW[L'ц'] = L"ts"; - theMapW[L'ч'] = L"ch"; - theMapW[L'ш'] = L"sh"; - theMapW[L'щ'] = L"sch"; - theMapW[L'ъ'] = L"`"; - theMapW[L'ы'] = L"y"; - theMapW[L'ь'] = L"'"; - theMapW[L'э'] = L"e"; - theMapW[L'ю'] = L"yu"; - theMapW[L'я'] = L"ya"; - - theMapW[L'А'] = L"A"; - theMapW[L'Б'] = L"B"; - theMapW[L'В'] = L"V"; - theMapW[L'Г'] = L"G"; - theMapW[L'Д'] = L"D"; - theMapW[L'Е'] = L"E"; - theMapW[L'Ё'] = L"E"; - theMapW[L'Ж'] = L"ZH"; - theMapW[L'З'] = L"Z"; - theMapW[L'И'] = L"I"; - theMapW[L'Й'] = L"I"; - theMapW[L'К'] = L"K"; - theMapW[L'Л'] = L"L"; - theMapW[L'М'] = L"M"; - theMapW[L'Н'] = L"N"; - theMapW[L'О'] = L"O"; - theMapW[L'П'] = L"P"; - theMapW[L'Р'] = L"R"; - theMapW[L'С'] = L"S"; - theMapW[L'Т'] = L"T"; - theMapW[L'У'] = L"U"; - theMapW[L'Ф'] = L"F"; - theMapW[L'Х'] = L"KH"; - theMapW[L'Ц'] = L"TS"; - theMapW[L'Ч'] = L"CH"; - theMapW[L'Ш'] = L"SH"; - theMapW[L'Щ'] = L"SCH"; - theMapW[L'Ъ'] = L"`"; - theMapW[L'Ы'] = L"Y"; - theMapW[L'Ь'] = L"'"; - theMapW[L'Э'] = L"E"; - theMapW[L'Ю'] = L"YU"; - theMapW[L'Я'] = L"YA"; -} - -//------------------------------------------------------------------------------ - -std::string TransliterationMap::cyrillicToLatin(char c) const -{ - std::string ret(1, c); - - CharMap::const_iterator it = theMap.find(c); - if(it != theMap.end()) - { - ret = (*it).second; - } - - return ret; -} -//------------------------------------------------------------------------------ - -std::wstring TransliterationMap::cyrillicToLatin(wchar_t c) const -{ - std::wstring ret(1, c); - - WCharMap::const_iterator it = theMapW.find(c); - if(it != theMapW.end()) - { - ret = (*it).second; - } - - return ret; -} - -//------------------------------------------------------------------------------ - -std::string TransliterationMap::cyrillicToLatin(const std::string &src) const -{ - std::string ret; - - for(std::string::const_iterator i = src.begin(); i != src.end(); ++i) - { - ret += cyrillicToLatin(*i); - } - - return ret; -} -//------------------------------------------------------------------------------ - -std::wstring TransliterationMap::cyrillicToLatin(const std::wstring &src) const -{ - std::wstring ret; - - for(std::wstring::const_iterator i = src.begin(); i != src.end(); ++i) - { - ret += cyrillicToLatin(*i); - } - - return ret; -} - -} \ No newline at end of file diff --git a/plugins/CyrTranslit/TransliterationMap.h b/plugins/CyrTranslit/TransliterationMap.h deleted file mode 100644 index 596e9d3e8f..0000000000 --- a/plugins/CyrTranslit/TransliterationMap.h +++ /dev/null @@ -1,73 +0,0 @@ -/** - * CyrTranslit: the Cyrillic transliteration plug-in for Miranda IM. - * Copyright 2005 Ivan Krechetov. - * - * 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. - */ - -#pragma once - -#include "plugin.h" - -namespace CyrTranslit -{ - -/** - * Maps the Cyrillic letters to the phonetically equivalent latin character - * sequences. That's what transliteration is. - */ -class TransliterationMap -{ -public: - /** - * Gives an access to the singleton object of this class. - * - * @return One and only instance of TransliterationMap class. - */ - static const TransliterationMap& getInstance(); - - /** - * Performs the transliteration from Cyrillic to Latin. - * - * @param src The source string that may contain Cyrillic characters. - * - * @return The transliterated source string in which all the occurences of - * Cyrillic letters are replaced by the phonetically equivalent Latin - * sequences (1-3 letters for a single Cyrillic leter). - */ - std::string cyrillicToLatin(const std::string &src) const; - std::wstring cyrillicToLatin(const std::wstring &src) const; - -private: - class Guard - { - public: - ~Guard(); - }; - - TransliterationMap(); - std::string cyrillicToLatin(char c) const; - std::wstring cyrillicToLatin(wchar_t c) const; - - static const TransliterationMap *pInstance; - static Guard guard; - - typedef std::map CharMap; - typedef std::map WCharMap; - CharMap theMap; - WCharMap theMapW; -}; - -} \ No newline at end of file diff --git a/plugins/CyrTranslit/TransliterationProtocol.cpp b/plugins/CyrTranslit/TransliterationProtocol.cpp deleted file mode 100644 index 1738aa818d..0000000000 --- a/plugins/CyrTranslit/TransliterationProtocol.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/** - * CyrTranslit: the Cyrillic transliteration plug-in for Miranda IM. - * Copyright 2005 Ivan Krechetov. - * - * 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 "plugin.h" -#include "TransliterationProtocol.h" -#include "TransliterationMap.h" - -namespace CyrTranslit -{ - -char *TransliterationProtocol::MODULE_NAME = "ProtoCyrTranslitByIKR"; - -//------------------------------------------------------------------------------ - -void TransliterationProtocol::initialize() -{ - PROTOCOLDESCRIPTOR desc; - desc.cbSize = sizeof(desc); - desc.szName = MODULE_NAME; - desc.type = PROTOTYPE_TRANSLATION; - - CallService( - MS_PROTO_REGISTERMODULE, - 0, - reinterpret_cast(&desc)); - - CreateProtoServiceFunction(MODULE_NAME, PSS_MESSAGE, sendMessageA); - CreateProtoServiceFunction(MODULE_NAME, PSS_MESSAGE"W", sendMessageW); -} - -//------------------------------------------------------------------------------ -void TransliterationProtocol::TranslateMessageUTF(WPARAM wParam, LPARAM lParam) -{ - CCSDATA *ccs = reinterpret_cast(lParam); - - wchar_t* txtWdecoded = mir_utf8decodeW(reinterpret_cast(ccs->lParam)); - std::wstring txtW = txtWdecoded; - mir_free(txtWdecoded); - - txtW = TransliterationMap::getInstance().cyrillicToLatin(txtW); - - char* txtUTFencoded = mir_utf8encodeW(txtW.c_str()); - std::string txtUTF = txtUTFencoded; - mir_free(txtUTFencoded); - - ccs->lParam = reinterpret_cast(mir_alloc(txtUTF.length())); - strcpy(reinterpret_cast(ccs->lParam), txtUTF.c_str()); -} - -void TransliterationProtocol::TranslateMessageW(WPARAM wParam, LPARAM lParam) -{ - CCSDATA *ccs = reinterpret_cast(lParam); - - std::string txtA = reinterpret_cast(ccs->lParam); - int txtAlen = (int)(sizeof(txtA[0]) * (txtA.length() + 1)); - txtA = TransliterationMap::getInstance().cyrillicToLatin(txtA); - - std::wstring txtW = reinterpret_cast(ccs->lParam + txtAlen); - txtW = TransliterationMap::getInstance().cyrillicToLatin(txtW); - - txtAlen = (int)(sizeof(txtA[0]) * (txtA.length() + 1)); - const DWORD newSize = static_cast(txtAlen + (sizeof(txtW[0]) * (txtW.length() + 1))); - - ccs->lParam = reinterpret_cast(mir_alloc(newSize)); - - strcpy(reinterpret_cast(ccs->lParam), txtA.c_str()); - wcscpy(reinterpret_cast(ccs->lParam + txtAlen), txtW.c_str()); -} - -void TransliterationProtocol::TranslateMessageA(WPARAM wParam, LPARAM lParam) -{ - CCSDATA *ccs = reinterpret_cast(lParam); - - std::string txt = reinterpret_cast(ccs->lParam); - txt = TransliterationMap::getInstance().cyrillicToLatin(txt); - - const DWORD newSize = static_cast(txt.length() + 1); - - ccs->lParam = reinterpret_cast(mir_alloc(newSize)); - - strcpy(reinterpret_cast(ccs->lParam), txt.c_str()); -} - -INT_PTR TransliterationProtocol::sendMessageW(WPARAM wParam, LPARAM lParam) -{ - CCSDATA *ccs = reinterpret_cast(lParam); - LPARAM oldlParam = ccs->lParam; - - TranslateMessageW(wParam, lParam); - - int ret = CallService(MS_PROTO_CHAINSEND /* "W" */, wParam, lParam); - - mir_free(reinterpret_cast(ccs->lParam)); - ccs->lParam = oldlParam; - - return ret; -} -//------------------------------------------------------------------------------ - -INT_PTR TransliterationProtocol::sendMessageA(WPARAM wParam, LPARAM lParam) -{ - CCSDATA *ccs = reinterpret_cast(lParam); - LPARAM oldlParam = ccs->lParam; - bool msgProcessed = true; - - if(ccs->wParam & PREF_UTF) - { - TranslateMessageUTF(wParam, lParam); - } - else if(ccs->wParam & PREF_UNICODE) - { - TranslateMessageW(wParam, lParam); - } - else - { - TranslateMessageA(wParam, lParam); - } - - int ret = CallService(MS_PROTO_CHAINSEND, wParam, lParam); - - if(msgProcessed) - { - mir_free(reinterpret_cast(ccs->lParam)); - ccs->lParam = oldlParam; - } - - return ret; -} - -//------------------------------------------------------------------------------ - -void TransliterationProtocol::activateForContact(HANDLE hContact) -{ - CallService( - MS_PROTO_ADDTOCONTACT, - reinterpret_cast(hContact), - reinterpret_cast(MODULE_NAME)); -} - -//------------------------------------------------------------------------------ - -void TransliterationProtocol::deactivateForContact(HANDLE hContact) -{ - CallService( - MS_PROTO_REMOVEFROMCONTACT, - reinterpret_cast(hContact), - reinterpret_cast(MODULE_NAME)); -} - -} diff --git a/plugins/CyrTranslit/TransliterationProtocol.h b/plugins/CyrTranslit/TransliterationProtocol.h deleted file mode 100644 index 52d9fc0e74..0000000000 --- a/plugins/CyrTranslit/TransliterationProtocol.h +++ /dev/null @@ -1,64 +0,0 @@ -/** - * CyrTranslit: the Cyrillic transliteration plug-in for Miranda IM. - * Copyright 2005 Ivan Krechetov. - * - * 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. - */ - -#pragma once - -#include "plugin.h" - -namespace CyrTranslit -{ - -/** - * A simnple TRANSLATION-type Miranda protocol which performs the - * transliteration of Cyrillic text for selected contacts. - */ -class TransliterationProtocol -{ -public: - /** - * Initializes this protocol on Miranda start-up. - */ - static void initialize(); - - /** - * A call-back function called when a new outgoing message must be - * transferred by this protocol. - * - * @param wParam flags - * @param lParam (LPARAM)(const char*)szMessage - * @return a hProcess corresponding to the one in the ack event. - */ - static INT_PTR sendMessageA(WPARAM wParam, LPARAM lParam); - static INT_PTR sendMessageW(WPARAM wParam, LPARAM lParam); - - static void TranslateMessageA(WPARAM wParam, LPARAM lParam); - static void TranslateMessageW(WPARAM wParam, LPARAM lParam); - static void TranslateMessageUTF(WPARAM wParam, LPARAM lParam); - - static void activateForContact(HANDLE hContact); - static void deactivateForContact(HANDLE hContact); - -private: - static char *MODULE_NAME; - - TransliterationProtocol(); - ~TransliterationProtocol(); -}; - -} \ No newline at end of file diff --git a/plugins/CyrTranslit/cyrtranslit-translation.txt b/plugins/CyrTranslit/cyrtranslit-translation.txt deleted file mode 100644 index 52329c17db..0000000000 --- a/plugins/CyrTranslit/cyrtranslit-translation.txt +++ /dev/null @@ -1,2 +0,0 @@ -; Common strings that belong to many files -;[] diff --git a/plugins/CyrTranslit/docs/CyrTranslit-gpl.txt b/plugins/CyrTranslit/docs/CyrTranslit-gpl.txt new file mode 100644 index 0000000000..3912109b5c --- /dev/null +++ b/plugins/CyrTranslit/docs/CyrTranslit-gpl.txt @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/plugins/CyrTranslit/docs/CyrTranslit-readme.txt b/plugins/CyrTranslit/docs/CyrTranslit-readme.txt new file mode 100644 index 0000000000..6a06dae4a9 --- /dev/null +++ b/plugins/CyrTranslit/docs/CyrTranslit-readme.txt @@ -0,0 +1,70 @@ ++-------------------------------+ +| CyrTranslit Miranda IM plugin | +| Version 1.0.3.0 | ++-------------------------------+ + +Инструкцию на русском см. ниже/See instructions in Russian below + +SUMMARY + +Applies the Cyrillic to Latin transliteration for the sent instant messages. +What this plug-in does, is just replacing (for the selected contacts only) the +Cyrillic letters in the outgoing messages with the "phonetically equivalent" +Latin letter combinations. When transliteration is enabled for contact, +in the message log (and history) you see the cyrillic letters, but your contact, +on the other side, see a "phonetically equivalent" Latin letter combinations. +Plugins supports ANSI, UNICODE and UTF8 encodings of messages. +Plugin can work in ANSI and UNICODE version of Miranda. + +INSTALLATION + +1. Copy the "CyrTranslit.dll" file to the Miranda IM plugin directory (for +instance, on my computer this is "C:\Program Files\Miranda IM\Plugins\" folder). +2. Restart Miranda IM program. + +USAGE + +After you have install the plug-in, none of the contacts has the transliteration +switched on. To activate the transliteration for a contact who can not read +Cyrillic chars, open the contact menu (right mouse button on the contact entry +in the contact list, or the contact menu button in the message dialog), and +check on the "Transliterate" menu item. From now on, all the sent text messages +will be transliterated for the contact, until you uncheck the menu item in the +contact menu. + +LICENSE + +This is a free software coming under GPL 2.0. Please see the provided gpl.txt +for details. + +AUTHOR + +Ivan Krechetov +i.krechetov@ewi.utwente.nl +http://wwwhome.cs.utwente.nl/~krechetovi/ + +unicode and UTF8 support by ValeraVi +http://www.vi-soft.com.ua + +-------------------------------------------------------------------------------- + +КРАТКО + +Производит транслитерацию кириллицы в латиницу для исходящих текстовых +сообщений. В результате вы видите собственные сообщения в логе (и истории) на +кириллице, ваш же собеседник получает транслит. + + +УСТАНОВКА + +1. Скопируйте файл "CyrTranslit.dll" в директорию модулей расщирения Miranda IM +(к примеру, на моём компьютере это папка "C:\Program Files\Miranda IM\Plugins\"). +2. Перезапустите программу Miranda IM. + +ИСПОЛЬЗОВАНИЕ + +Изначально транслитерация для всех контактов отключена. Чтобы активировать или +деактивировать автоматическую транслитерацию для определённого контакта, +выберете пункт "Transliterate" в меню контакта (появляется при нажатии правой +кнопки мыши в контакт-листе, либо кнопки вызова пользовательского меню в окне +сообщений). \ No newline at end of file diff --git a/plugins/CyrTranslit/docs/cyrtranslit-translation.txt b/plugins/CyrTranslit/docs/cyrtranslit-translation.txt new file mode 100644 index 0000000000..52329c17db --- /dev/null +++ b/plugins/CyrTranslit/docs/cyrtranslit-translation.txt @@ -0,0 +1,2 @@ +; Common strings that belong to many files +;[] diff --git a/plugins/CyrTranslit/main.cpp b/plugins/CyrTranslit/main.cpp deleted file mode 100644 index 49761dc305..0000000000 --- a/plugins/CyrTranslit/main.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/** - * CyrTranslit: the Cyrillic transliteration plug-in for Miranda IM. - * Copyright 2005 Ivan Krechetov. - * - * 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 "plugin.h" -#include "MirandaContact.h" - -HINSTANCE hInst; -int hLangpack = 0; - -PLUGININFOEX pluginInfoEx={ - sizeof(PLUGININFOEX), - PLG_SHORTNAME, - PLG_VERSION, - PLG_DESCRIPTION, - PLG_AUTHOR, - PLG_AUTHOREMAIL, - PLG_COPYRIGHT, - PLG_HOMEPAGE, - PLG_FLAGS, - MIID_V_CYRTRANSLIT -}; - -//------------------------------------------------------------------------------ - -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - hInst = hinstDLL; - return TRUE; -} - -//------------------------------------------------------------------------------ - -extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) -{ - return &pluginInfoEx; -} - - -//------------------------------------------------------------------------------ - -extern "C" __declspec(dllexport) int Load(void) -{ - mir_getLP(&pluginInfoEx); - - //plugin inits: PLACE IT ONLY AFTER THIS LINE - - CyrTranslit::MirandaContact::initialize(); - return 0; -} - -//------------------------------------------------------------------------------ - -extern "C" __declspec(dllexport) int Unload(void) -{ - return 0; -} \ No newline at end of file diff --git a/plugins/CyrTranslit/plugin.h b/plugins/CyrTranslit/plugin.h deleted file mode 100644 index 866ec60bb8..0000000000 --- a/plugins/CyrTranslit/plugin.h +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Plugin.H: Main common header of MirandaIM plugin - * Copyright 2009 Valeriy V. Vyshnyak. - * - * 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. - */ -#pragma once - - -/****** SYSTEM OPTIONS *******************************************************/ - -// set compatibility lever for Miranda 0.4.x -#define MIRANDA_VER 0x0400 - -// for windows: -#define _CRT_SECURE_NO_WARNINGS -#pragma warning (disable : 4312) /*C4312: 'type cast' : conversion from 'int' to 'char *' of greater size */ - - - -/****** INCLUDES *************************************************************/ - -#include -#include -#include -#include "newpluginapi.h" -#include "m_database.h" -#include "m_protomod.h" -#include "m_protosvc.h" -#include "m_system.h" -#include "m_clist.h" -#include "m_langpack.h" - - -/****** PLUGIN DEFINES *******************************************************/ - -// pluginInfo: -#define PLG_SHORTNAME "CyrTranslit" -#define PLG_VERSION PLUGIN_MAKE_VERSION(1, 0, 3, 0) -#define PLG_DESCRIPTION "Replaces (for the selected contacts only) the Cyrillic letters in the "\ - "outgoing messages with the phonetically equivalent Latin letter "\ - "combinations." -#define PLG_AUTHOR "ValeraVi, Ivan Krechetov" -#define PLG_AUTHOREMAIL "valeravi@vi-soft.com.ua" -#define PLG_COPYRIGHT "© 2005-2009 ValeraVi, Ivan Krechetov" -#define PLG_HOMEPAGE "http://www.vi-soft.com.ua" -#define PLG_FLAGS 0 /*UNICODE_AWARE, will be set dynamically*/ -#define MIID_V_CYRTRANSLIT {0xbcec0bd7, 0xca59, 0x44b2, {0x9a, 0x14, 0x3a, 0x14, 0x98, 0x0f, 0x52, 0x4a}} - - diff --git a/plugins/CyrTranslit/res/CyrTranslit.rc b/plugins/CyrTranslit/res/CyrTranslit.rc new file mode 100644 index 0000000000..06afb7cb44 --- /dev/null +++ b/plugins/CyrTranslit/res/CyrTranslit.rc @@ -0,0 +1,113 @@ +// 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 + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#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 + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// Dutch (Netherlands) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NLD) +#ifdef _WIN32 +LANGUAGE LANG_DUTCH, SUBLANG_DUTCH +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,3,0 + PRODUCTVERSION 1,0,3,0 + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "CyrTrans Dynamic Link Library" + VALUE "FileVersion", "1, 0, 3, 0" + VALUE "InternalName", "CyrTrans" + VALUE "LegalCopyright", "Copyright (C) 2005 Ivan Krechetov, modified 2006-2009 by ValeraVi" + VALUE "OriginalFilename", "CyrTrans.dll" + VALUE "ProductName", " CyrTrans Dynamic Link Library" + VALUE "ProductVersion", "1, 0, 3, 0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // Dutch (Netherlands) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/CyrTranslit/resource.h b/plugins/CyrTranslit/resource.h deleted file mode 100644 index e17dce6b19..0000000000 --- a/plugins/CyrTranslit/resource.h +++ /dev/null @@ -1,15 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by CyrTranslit.rc -// - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/plugins/CyrTranslit/src/MirandaContact.cpp b/plugins/CyrTranslit/src/MirandaContact.cpp new file mode 100644 index 0000000000..1a0f149ef8 --- /dev/null +++ b/plugins/CyrTranslit/src/MirandaContact.cpp @@ -0,0 +1,191 @@ +/** + * CyrTranslit: the Cyrillic transliteration plug-in for Miranda IM. + * Copyright 2005 Ivan Krechetov. + * + * 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 "plugin.h" +#include "MirandaContact.h" +#include "TransliterationProtocol.h" + +namespace CyrTranslit +{ + +const std::string MirandaContact::SETTINGS_MODULE = "CyrTranslit"; + +const std::string MirandaContact::SETTING_SHOULD_TRANSLITERATE + = "translit"; + +char *MirandaContact::MENU_ITEM_TEXT = "&Transliterate (ФЫВА->FYVA)"; + +char *MirandaContact::MENU_COMMAND_CALLBACK_SERVICE + = "CyrTranslit/ContactMenuCmd"; + +HANDLE MirandaContact::hTransliterateCmdMenuItem = 0; + +//------------------------------------------------------------------------------ + +MirandaContact::MirandaContact() + : handle(0), + transliterateOutgoingMessages(false) +{ +} + +//------------------------------------------------------------------------------ + +MirandaContact::~MirandaContact() +{ +} + +//------------------------------------------------------------------------------ + +void MirandaContact::initialize() +{ + CreateServiceFunction(MENU_COMMAND_CALLBACK_SERVICE,onMenuCommandTransliterate); + generateMenuItemsForAllContacts(); + + HookEvent(ME_CLIST_PREBUILDCONTACTMENU, onPreBuildContactMenu); + + TransliterationProtocol::initialize(); + activateTransliterationProtocolForSubscribedContacts(); +} + +//------------------------------------------------------------------------------ + +MirandaContact MirandaContact::getContact(HANDLE hContact) +{ + int b = DBGetContactSettingByte( + hContact, + SETTINGS_MODULE.c_str(), + SETTING_SHOULD_TRANSLITERATE.c_str(), + 0); + + MirandaContact ret; + ret.handle = hContact; + ret.transliterateOutgoingMessages = (b != 0); + + return ret; +} + +//------------------------------------------------------------------------------ + +void MirandaContact::save() const +{ + DBWriteContactSettingByte( + handle, + SETTINGS_MODULE.c_str(), + SETTING_SHOULD_TRANSLITERATE.c_str(), + transliterateOutgoingMessages? 1 : 0); +} + +//------------------------------------------------------------------------------ + +bool MirandaContact::shouldTransliterateOutgoingMessages() const +{ + return transliterateOutgoingMessages; +} + +//------------------------------------------------------------------------------ + +void MirandaContact::fillInMenuItem(CLISTMENUITEM &mi) +{ + mi.cbSize = sizeof(CLISTMENUITEM); + mi.pszName = MENU_ITEM_TEXT; + mi.flags = 0; + mi.position = 65535; + mi.hIcon = NULL; + mi.pszService = MENU_COMMAND_CALLBACK_SERVICE; + mi.pszPopupName = NULL; + mi.popupPosition = 0; + mi.hotKey = 0; + mi.pszContactOwner = NULL; +} + +//------------------------------------------------------------------------------ + +void MirandaContact::generateMenuItemsForAllContacts() +{ + CLISTMENUITEM mi; + fillInMenuItem(mi); + hTransliterateCmdMenuItem = Menu_AddContactMenuItem(&mi); +} + +//------------------------------------------------------------------------------ + +void MirandaContact::activateTransliterationProtocolForSubscribedContacts() +{ + int hContact = CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + if(!hContact) return; + + do + { + MirandaContact mc = getContact(reinterpret_cast(hContact)); + + if(mc.shouldTransliterateOutgoingMessages()) + { + TransliterationProtocol::activateForContact(mc.handle); + } + } while(hContact = CallService(MS_DB_CONTACT_FINDNEXT, hContact, 0)); +} + +//------------------------------------------------------------------------------ + +INT_PTR MirandaContact::onMenuCommandTransliterate(WPARAM wParam, LPARAM lParam) +{ + HANDLE hContact = reinterpret_cast(wParam); + if(!CallService(MS_DB_CONTACT_IS, wParam, 0)) return 0; + + MirandaContact mc = getContact(hContact); + mc.transliterateOutgoingMessages = !mc.transliterateOutgoingMessages; + mc.save(); + + if(mc.shouldTransliterateOutgoingMessages()) + { + TransliterationProtocol::activateForContact(mc.handle); + } + else + { + TransliterationProtocol::deactivateForContact(mc.handle); + } + + return 0; +} + +//------------------------------------------------------------------------------ + +int MirandaContact::onPreBuildContactMenu(WPARAM wParam, LPARAM lParam) +{ + if(!hTransliterateCmdMenuItem) return 0; + HANDLE hContact = reinterpret_cast(wParam); + if(!CallService(MS_DB_CONTACT_IS, wParam, 0)) return 0; + + MirandaContact mc = getContact(hContact); + + CLISTMENUITEM mi; + fillInMenuItem(mi); + + DWORD toSet = mc.shouldTransliterateOutgoingMessages()? CMIF_CHECKED : 0; + mi.flags = CMIM_FLAGS | toSet; + + CallService( + MS_CLIST_MODIFYMENUITEM, + reinterpret_cast(hTransliterateCmdMenuItem), + reinterpret_cast(&mi)); + + return 0; +} + +} \ No newline at end of file diff --git a/plugins/CyrTranslit/src/MirandaContact.h b/plugins/CyrTranslit/src/MirandaContact.h new file mode 100644 index 0000000000..0e29f3d74e --- /dev/null +++ b/plugins/CyrTranslit/src/MirandaContact.h @@ -0,0 +1,123 @@ +/** + * CyrTranslit: the Cyrillic transliteration plug-in for Miranda IM. + * Copyright 2005 Ivan Krechetov. + * + * 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. + */ + +#pragma once + +#include "plugin.h" + +namespace CyrTranslit +{ + +/** + * The Miranda IM contact abstraction in respect to the transliteration process. + */ +class MirandaContact +{ +public: + /** + * This message must be sent on Miranda startup. + */ + static void initialize(); + + /** + * A factory method which instantiates new MirandaContact objects, loading + * its data from the Miranda database. + * + * @param hContact The handle of the contact object to be instantiated. + * @return The Miranda IM contact having the passed handle. + */ + static MirandaContact getContact(HANDLE hContact); + + /** + * Saves this object's data to the persistent storage -- the Miranda + * database. This information may be retreived later on by means of + * getContact() factory method invocation. + */ + void save() const; + + /** + * @return True only if the Cyrillic transliteration is on for this contact. + */ + bool shouldTransliterateOutgoingMessages() const; + + ~MirandaContact(); + +private: + static const std::string SETTINGS_MODULE; + static const std::string SETTING_SHOULD_TRANSLITERATE; + + static char *MENU_ITEM_TEXT; + + MirandaContact(); + + /** + * Must be called on Miranda start-up to generate the transliteration + * command menu items for all the contacts (a contact-specific menu). + */ + static void generateMenuItemsForAllContacts(); + + static void activateTransliterationProtocolForSubscribedContacts(); + + /** + * This is a callback function for the transliteration command menu item. + * This menu item is contact-specific. + * + * @param wParam The HANDLE of the contact that owns the activated menu + * item. + * @param lParam hwndContactList + * @return Always returns 0. + */ + static INT_PTR onMenuCommandTransliterate(WPARAM wParam, LPARAM lParam); + + /** + * This is a service name to bind the onMenuCommandTransliterate() method to + * within the Miranda IM framework. + */ + static char *MENU_COMMAND_CALLBACK_SERVICE; + + /** + * Stores the handle to a single user menu item shared by all the contacts. + * This menu item has a contact-specific state -- checked or unchecked, as + * far as for some contacts transliteration may be on, and for others it may + * be off. + * + * MirandaContact class makes the necessary update just before a menu is + * shown for a contact: it checks or unchecks the transliteration menu item. + * + * When the transliteration menu item is activated by a user, the + * transliteration setting (on or off) is inverted for the contact owing the + * menu. + */ + static HANDLE hTransliterateCmdMenuItem; + + /** + * @param wParam The HANDLE of the contact that owns the menu item being + * built. + * @param lParam = 0. + * @return Always returns 0. + */ + static int onPreBuildContactMenu(WPARAM wParam, LPARAM lParam); + + static void fillInMenuItem(CLISTMENUITEM &mi); + + HANDLE handle; + bool transliterateOutgoingMessages; +}; + +} \ No newline at end of file diff --git a/plugins/CyrTranslit/src/TransliterationMap.cpp b/plugins/CyrTranslit/src/TransliterationMap.cpp new file mode 100644 index 0000000000..f678c0a16e --- /dev/null +++ b/plugins/CyrTranslit/src/TransliterationMap.cpp @@ -0,0 +1,247 @@ +/** + * CyrTranslit: the Cyrillic transliteration plug-in for Miranda IM. + * Copyright 2005 Ivan Krechetov. + * + * 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 "plugin.h" +#include "TransliterationMap.h" + +namespace CyrTranslit +{ + +TransliterationMap::Guard TransliterationMap::guard; +const TransliterationMap *TransliterationMap::pInstance = 0; + +//------------------------------------------------------------------------------ + +TransliterationMap::Guard::~Guard() +{ + delete TransliterationMap::pInstance; +} + +//------------------------------------------------------------------------------ + +const TransliterationMap& TransliterationMap::getInstance() +{ + if(!pInstance) + { + pInstance = new TransliterationMap(); + } + return *pInstance; +} + +//------------------------------------------------------------------------------ + +TransliterationMap::TransliterationMap() +{ + theMap['а'] = "a"; + theMap['б'] = "b"; + theMap['в'] = "v"; + theMap['г'] = "g"; + theMap['д'] = "d"; + theMap['е'] = "e"; + theMap['ё'] = "e"; + theMap['ж'] = "zh"; + theMap['з'] = "z"; + theMap['и'] = "i"; + theMap['й'] = "i"; + theMap['к'] = "k"; + theMap['л'] = "l"; + theMap['м'] = "m"; + theMap['н'] = "n"; + theMap['о'] = "o"; + theMap['п'] = "p"; + theMap['р'] = "r"; + theMap['с'] = "s"; + theMap['т'] = "t"; + theMap['у'] = "u"; + theMap['ф'] = "f"; + theMap['х'] = "kh"; + theMap['ц'] = "ts"; + theMap['ч'] = "ch"; + theMap['ш'] = "sh"; + theMap['щ'] = "sch"; + theMap['ъ'] = "`"; + theMap['ы'] = "y"; + theMap['ь'] = "'"; + theMap['э'] = "e"; + theMap['ю'] = "yu"; + theMap['я'] = "ya"; + + theMap['А'] = "A"; + theMap['Б'] = "B"; + theMap['В'] = "V"; + theMap['Г'] = "G"; + theMap['Д'] = "D"; + theMap['Е'] = "E"; + theMap['Ё'] = "E"; + theMap['Ж'] = "ZH"; + theMap['З'] = "Z"; + theMap['И'] = "I"; + theMap['Й'] = "I"; + theMap['К'] = "K"; + theMap['Л'] = "L"; + theMap['М'] = "M"; + theMap['Н'] = "N"; + theMap['О'] = "O"; + theMap['П'] = "P"; + theMap['Р'] = "R"; + theMap['С'] = "S"; + theMap['Т'] = "T"; + theMap['У'] = "U"; + theMap['Ф'] = "F"; + theMap['Х'] = "KH"; + theMap['Ц'] = "TS"; + theMap['Ч'] = "CH"; + theMap['Ш'] = "SH"; + theMap['Щ'] = "SCH"; + theMap['Ъ'] = "`"; + theMap['Ы'] = "Y"; + theMap['Ь'] = "'"; + theMap['Э'] = "E"; + theMap['Ю'] = "YU"; + theMap['Я'] = "YA"; + + + + + theMapW[L'а'] = L"a"; + theMapW[L'б'] = L"b"; + theMapW[L'в'] = L"v"; + theMapW[L'г'] = L"g"; + theMapW[L'д'] = L"d"; + theMapW[L'е'] = L"e"; + theMapW[L'ё'] = L"e"; + theMapW[L'ж'] = L"zh"; + theMapW[L'з'] = L"z"; + theMapW[L'и'] = L"i"; + theMapW[L'й'] = L"i"; + theMapW[L'к'] = L"k"; + theMapW[L'л'] = L"l"; + theMapW[L'м'] = L"m"; + theMapW[L'н'] = L"n"; + theMapW[L'о'] = L"o"; + theMapW[L'п'] = L"p"; + theMapW[L'р'] = L"r"; + theMapW[L'с'] = L"s"; + theMapW[L'т'] = L"t"; + theMapW[L'у'] = L"u"; + theMapW[L'ф'] = L"f"; + theMapW[L'х'] = L"kh"; + theMapW[L'ц'] = L"ts"; + theMapW[L'ч'] = L"ch"; + theMapW[L'ш'] = L"sh"; + theMapW[L'щ'] = L"sch"; + theMapW[L'ъ'] = L"`"; + theMapW[L'ы'] = L"y"; + theMapW[L'ь'] = L"'"; + theMapW[L'э'] = L"e"; + theMapW[L'ю'] = L"yu"; + theMapW[L'я'] = L"ya"; + + theMapW[L'А'] = L"A"; + theMapW[L'Б'] = L"B"; + theMapW[L'В'] = L"V"; + theMapW[L'Г'] = L"G"; + theMapW[L'Д'] = L"D"; + theMapW[L'Е'] = L"E"; + theMapW[L'Ё'] = L"E"; + theMapW[L'Ж'] = L"ZH"; + theMapW[L'З'] = L"Z"; + theMapW[L'И'] = L"I"; + theMapW[L'Й'] = L"I"; + theMapW[L'К'] = L"K"; + theMapW[L'Л'] = L"L"; + theMapW[L'М'] = L"M"; + theMapW[L'Н'] = L"N"; + theMapW[L'О'] = L"O"; + theMapW[L'П'] = L"P"; + theMapW[L'Р'] = L"R"; + theMapW[L'С'] = L"S"; + theMapW[L'Т'] = L"T"; + theMapW[L'У'] = L"U"; + theMapW[L'Ф'] = L"F"; + theMapW[L'Х'] = L"KH"; + theMapW[L'Ц'] = L"TS"; + theMapW[L'Ч'] = L"CH"; + theMapW[L'Ш'] = L"SH"; + theMapW[L'Щ'] = L"SCH"; + theMapW[L'Ъ'] = L"`"; + theMapW[L'Ы'] = L"Y"; + theMapW[L'Ь'] = L"'"; + theMapW[L'Э'] = L"E"; + theMapW[L'Ю'] = L"YU"; + theMapW[L'Я'] = L"YA"; +} + +//------------------------------------------------------------------------------ + +std::string TransliterationMap::cyrillicToLatin(char c) const +{ + std::string ret(1, c); + + CharMap::const_iterator it = theMap.find(c); + if(it != theMap.end()) + { + ret = (*it).second; + } + + return ret; +} +//------------------------------------------------------------------------------ + +std::wstring TransliterationMap::cyrillicToLatin(wchar_t c) const +{ + std::wstring ret(1, c); + + WCharMap::const_iterator it = theMapW.find(c); + if(it != theMapW.end()) + { + ret = (*it).second; + } + + return ret; +} + +//------------------------------------------------------------------------------ + +std::string TransliterationMap::cyrillicToLatin(const std::string &src) const +{ + std::string ret; + + for(std::string::const_iterator i = src.begin(); i != src.end(); ++i) + { + ret += cyrillicToLatin(*i); + } + + return ret; +} +//------------------------------------------------------------------------------ + +std::wstring TransliterationMap::cyrillicToLatin(const std::wstring &src) const +{ + std::wstring ret; + + for(std::wstring::const_iterator i = src.begin(); i != src.end(); ++i) + { + ret += cyrillicToLatin(*i); + } + + return ret; +} + +} \ No newline at end of file diff --git a/plugins/CyrTranslit/src/TransliterationMap.h b/plugins/CyrTranslit/src/TransliterationMap.h new file mode 100644 index 0000000000..596e9d3e8f --- /dev/null +++ b/plugins/CyrTranslit/src/TransliterationMap.h @@ -0,0 +1,73 @@ +/** + * CyrTranslit: the Cyrillic transliteration plug-in for Miranda IM. + * Copyright 2005 Ivan Krechetov. + * + * 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. + */ + +#pragma once + +#include "plugin.h" + +namespace CyrTranslit +{ + +/** + * Maps the Cyrillic letters to the phonetically equivalent latin character + * sequences. That's what transliteration is. + */ +class TransliterationMap +{ +public: + /** + * Gives an access to the singleton object of this class. + * + * @return One and only instance of TransliterationMap class. + */ + static const TransliterationMap& getInstance(); + + /** + * Performs the transliteration from Cyrillic to Latin. + * + * @param src The source string that may contain Cyrillic characters. + * + * @return The transliterated source string in which all the occurences of + * Cyrillic letters are replaced by the phonetically equivalent Latin + * sequences (1-3 letters for a single Cyrillic leter). + */ + std::string cyrillicToLatin(const std::string &src) const; + std::wstring cyrillicToLatin(const std::wstring &src) const; + +private: + class Guard + { + public: + ~Guard(); + }; + + TransliterationMap(); + std::string cyrillicToLatin(char c) const; + std::wstring cyrillicToLatin(wchar_t c) const; + + static const TransliterationMap *pInstance; + static Guard guard; + + typedef std::map CharMap; + typedef std::map WCharMap; + CharMap theMap; + WCharMap theMapW; +}; + +} \ No newline at end of file diff --git a/plugins/CyrTranslit/src/TransliterationProtocol.cpp b/plugins/CyrTranslit/src/TransliterationProtocol.cpp new file mode 100644 index 0000000000..1738aa818d --- /dev/null +++ b/plugins/CyrTranslit/src/TransliterationProtocol.cpp @@ -0,0 +1,166 @@ +/** + * CyrTranslit: the Cyrillic transliteration plug-in for Miranda IM. + * Copyright 2005 Ivan Krechetov. + * + * 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 "plugin.h" +#include "TransliterationProtocol.h" +#include "TransliterationMap.h" + +namespace CyrTranslit +{ + +char *TransliterationProtocol::MODULE_NAME = "ProtoCyrTranslitByIKR"; + +//------------------------------------------------------------------------------ + +void TransliterationProtocol::initialize() +{ + PROTOCOLDESCRIPTOR desc; + desc.cbSize = sizeof(desc); + desc.szName = MODULE_NAME; + desc.type = PROTOTYPE_TRANSLATION; + + CallService( + MS_PROTO_REGISTERMODULE, + 0, + reinterpret_cast(&desc)); + + CreateProtoServiceFunction(MODULE_NAME, PSS_MESSAGE, sendMessageA); + CreateProtoServiceFunction(MODULE_NAME, PSS_MESSAGE"W", sendMessageW); +} + +//------------------------------------------------------------------------------ +void TransliterationProtocol::TranslateMessageUTF(WPARAM wParam, LPARAM lParam) +{ + CCSDATA *ccs = reinterpret_cast(lParam); + + wchar_t* txtWdecoded = mir_utf8decodeW(reinterpret_cast(ccs->lParam)); + std::wstring txtW = txtWdecoded; + mir_free(txtWdecoded); + + txtW = TransliterationMap::getInstance().cyrillicToLatin(txtW); + + char* txtUTFencoded = mir_utf8encodeW(txtW.c_str()); + std::string txtUTF = txtUTFencoded; + mir_free(txtUTFencoded); + + ccs->lParam = reinterpret_cast(mir_alloc(txtUTF.length())); + strcpy(reinterpret_cast(ccs->lParam), txtUTF.c_str()); +} + +void TransliterationProtocol::TranslateMessageW(WPARAM wParam, LPARAM lParam) +{ + CCSDATA *ccs = reinterpret_cast(lParam); + + std::string txtA = reinterpret_cast(ccs->lParam); + int txtAlen = (int)(sizeof(txtA[0]) * (txtA.length() + 1)); + txtA = TransliterationMap::getInstance().cyrillicToLatin(txtA); + + std::wstring txtW = reinterpret_cast(ccs->lParam + txtAlen); + txtW = TransliterationMap::getInstance().cyrillicToLatin(txtW); + + txtAlen = (int)(sizeof(txtA[0]) * (txtA.length() + 1)); + const DWORD newSize = static_cast(txtAlen + (sizeof(txtW[0]) * (txtW.length() + 1))); + + ccs->lParam = reinterpret_cast(mir_alloc(newSize)); + + strcpy(reinterpret_cast(ccs->lParam), txtA.c_str()); + wcscpy(reinterpret_cast(ccs->lParam + txtAlen), txtW.c_str()); +} + +void TransliterationProtocol::TranslateMessageA(WPARAM wParam, LPARAM lParam) +{ + CCSDATA *ccs = reinterpret_cast(lParam); + + std::string txt = reinterpret_cast(ccs->lParam); + txt = TransliterationMap::getInstance().cyrillicToLatin(txt); + + const DWORD newSize = static_cast(txt.length() + 1); + + ccs->lParam = reinterpret_cast(mir_alloc(newSize)); + + strcpy(reinterpret_cast(ccs->lParam), txt.c_str()); +} + +INT_PTR TransliterationProtocol::sendMessageW(WPARAM wParam, LPARAM lParam) +{ + CCSDATA *ccs = reinterpret_cast(lParam); + LPARAM oldlParam = ccs->lParam; + + TranslateMessageW(wParam, lParam); + + int ret = CallService(MS_PROTO_CHAINSEND /* "W" */, wParam, lParam); + + mir_free(reinterpret_cast(ccs->lParam)); + ccs->lParam = oldlParam; + + return ret; +} +//------------------------------------------------------------------------------ + +INT_PTR TransliterationProtocol::sendMessageA(WPARAM wParam, LPARAM lParam) +{ + CCSDATA *ccs = reinterpret_cast(lParam); + LPARAM oldlParam = ccs->lParam; + bool msgProcessed = true; + + if(ccs->wParam & PREF_UTF) + { + TranslateMessageUTF(wParam, lParam); + } + else if(ccs->wParam & PREF_UNICODE) + { + TranslateMessageW(wParam, lParam); + } + else + { + TranslateMessageA(wParam, lParam); + } + + int ret = CallService(MS_PROTO_CHAINSEND, wParam, lParam); + + if(msgProcessed) + { + mir_free(reinterpret_cast(ccs->lParam)); + ccs->lParam = oldlParam; + } + + return ret; +} + +//------------------------------------------------------------------------------ + +void TransliterationProtocol::activateForContact(HANDLE hContact) +{ + CallService( + MS_PROTO_ADDTOCONTACT, + reinterpret_cast(hContact), + reinterpret_cast(MODULE_NAME)); +} + +//------------------------------------------------------------------------------ + +void TransliterationProtocol::deactivateForContact(HANDLE hContact) +{ + CallService( + MS_PROTO_REMOVEFROMCONTACT, + reinterpret_cast(hContact), + reinterpret_cast(MODULE_NAME)); +} + +} diff --git a/plugins/CyrTranslit/src/TransliterationProtocol.h b/plugins/CyrTranslit/src/TransliterationProtocol.h new file mode 100644 index 0000000000..52d9fc0e74 --- /dev/null +++ b/plugins/CyrTranslit/src/TransliterationProtocol.h @@ -0,0 +1,64 @@ +/** + * CyrTranslit: the Cyrillic transliteration plug-in for Miranda IM. + * Copyright 2005 Ivan Krechetov. + * + * 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. + */ + +#pragma once + +#include "plugin.h" + +namespace CyrTranslit +{ + +/** + * A simnple TRANSLATION-type Miranda protocol which performs the + * transliteration of Cyrillic text for selected contacts. + */ +class TransliterationProtocol +{ +public: + /** + * Initializes this protocol on Miranda start-up. + */ + static void initialize(); + + /** + * A call-back function called when a new outgoing message must be + * transferred by this protocol. + * + * @param wParam flags + * @param lParam (LPARAM)(const char*)szMessage + * @return a hProcess corresponding to the one in the ack event. + */ + static INT_PTR sendMessageA(WPARAM wParam, LPARAM lParam); + static INT_PTR sendMessageW(WPARAM wParam, LPARAM lParam); + + static void TranslateMessageA(WPARAM wParam, LPARAM lParam); + static void TranslateMessageW(WPARAM wParam, LPARAM lParam); + static void TranslateMessageUTF(WPARAM wParam, LPARAM lParam); + + static void activateForContact(HANDLE hContact); + static void deactivateForContact(HANDLE hContact); + +private: + static char *MODULE_NAME; + + TransliterationProtocol(); + ~TransliterationProtocol(); +}; + +} \ No newline at end of file diff --git a/plugins/CyrTranslit/src/main.cpp b/plugins/CyrTranslit/src/main.cpp new file mode 100644 index 0000000000..49761dc305 --- /dev/null +++ b/plugins/CyrTranslit/src/main.cpp @@ -0,0 +1,72 @@ +/** + * CyrTranslit: the Cyrillic transliteration plug-in for Miranda IM. + * Copyright 2005 Ivan Krechetov. + * + * 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 "plugin.h" +#include "MirandaContact.h" + +HINSTANCE hInst; +int hLangpack = 0; + +PLUGININFOEX pluginInfoEx={ + sizeof(PLUGININFOEX), + PLG_SHORTNAME, + PLG_VERSION, + PLG_DESCRIPTION, + PLG_AUTHOR, + PLG_AUTHOREMAIL, + PLG_COPYRIGHT, + PLG_HOMEPAGE, + PLG_FLAGS, + MIID_V_CYRTRANSLIT +}; + +//------------------------------------------------------------------------------ + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + hInst = hinstDLL; + return TRUE; +} + +//------------------------------------------------------------------------------ + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfoEx; +} + + +//------------------------------------------------------------------------------ + +extern "C" __declspec(dllexport) int Load(void) +{ + mir_getLP(&pluginInfoEx); + + //plugin inits: PLACE IT ONLY AFTER THIS LINE + + CyrTranslit::MirandaContact::initialize(); + return 0; +} + +//------------------------------------------------------------------------------ + +extern "C" __declspec(dllexport) int Unload(void) +{ + return 0; +} \ No newline at end of file diff --git a/plugins/CyrTranslit/src/plugin.h b/plugins/CyrTranslit/src/plugin.h new file mode 100644 index 0000000000..866ec60bb8 --- /dev/null +++ b/plugins/CyrTranslit/src/plugin.h @@ -0,0 +1,62 @@ +/** + * Plugin.H: Main common header of MirandaIM plugin + * Copyright 2009 Valeriy V. Vyshnyak. + * + * 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. + */ +#pragma once + + +/****** SYSTEM OPTIONS *******************************************************/ + +// set compatibility lever for Miranda 0.4.x +#define MIRANDA_VER 0x0400 + +// for windows: +#define _CRT_SECURE_NO_WARNINGS +#pragma warning (disable : 4312) /*C4312: 'type cast' : conversion from 'int' to 'char *' of greater size */ + + + +/****** INCLUDES *************************************************************/ + +#include +#include +#include +#include "newpluginapi.h" +#include "m_database.h" +#include "m_protomod.h" +#include "m_protosvc.h" +#include "m_system.h" +#include "m_clist.h" +#include "m_langpack.h" + + +/****** PLUGIN DEFINES *******************************************************/ + +// pluginInfo: +#define PLG_SHORTNAME "CyrTranslit" +#define PLG_VERSION PLUGIN_MAKE_VERSION(1, 0, 3, 0) +#define PLG_DESCRIPTION "Replaces (for the selected contacts only) the Cyrillic letters in the "\ + "outgoing messages with the phonetically equivalent Latin letter "\ + "combinations." +#define PLG_AUTHOR "ValeraVi, Ivan Krechetov" +#define PLG_AUTHOREMAIL "valeravi@vi-soft.com.ua" +#define PLG_COPYRIGHT "© 2005-2009 ValeraVi, Ivan Krechetov" +#define PLG_HOMEPAGE "http://www.vi-soft.com.ua" +#define PLG_FLAGS 0 /*UNICODE_AWARE, will be set dynamically*/ +#define MIID_V_CYRTRANSLIT {0xbcec0bd7, 0xca59, 0x44b2, {0x9a, 0x14, 0x3a, 0x14, 0x98, 0x0f, 0x52, 0x4a}} + + diff --git a/plugins/CyrTranslit/src/resource.h b/plugins/CyrTranslit/src/resource.h new file mode 100644 index 0000000000..e17dce6b19 --- /dev/null +++ b/plugins/CyrTranslit/src/resource.h @@ -0,0 +1,15 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by CyrTranslit.rc +// + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif -- cgit v1.2.3