diff options
author | Vadim Dashevskiy <watcherhd@gmail.com> | 2012-05-18 21:57:05 +0000 |
---|---|---|
committer | Vadim Dashevskiy <watcherhd@gmail.com> | 2012-05-18 21:57:05 +0000 |
commit | 6c3b0571f0678da0512069869afaa284c054377e (patch) | |
tree | f25e8401bb325ce93b543bd15f91065dda2a768e /plugins/Folders | |
parent | 0a62eb9bdccf5c6b1e83b7f025859e4ca005f4f2 (diff) |
Folders renamed
git-svn-id: http://svn.miranda-ng.org/main/trunk@59 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Folders')
38 files changed, 3379 insertions, 0 deletions
diff --git a/plugins/Folders/Folders.html b/plugins/Folders/Folders.html new file mode 100644 index 0000000000..5eb72d9d5e --- /dev/null +++ b/plugins/Folders/Folders.html @@ -0,0 +1,11 @@ +<html>
+ <head></head>
+ <body>
+ <center>
+ <h1>Custom profile folders Test Page</h1>
+
+ <p>Custom profile folders version 0.1.6.0</p>
+ <p><a href="Folders.zip">Folders.zip</a></p>
+ </center>
+ </body>
+</html>
diff --git a/plugins/Folders/docs/folders_readme.txt b/plugins/Folders/docs/folders_readme.txt new file mode 100644 index 0000000000..fb81a7431b --- /dev/null +++ b/plugins/Folders/docs/folders_readme.txt @@ -0,0 +1,226 @@ +Custom profile folders v.0.1.6.0
+Copyright © 2005-2010 Cristian Libotean
+
+This plugin allows users to select the folders where plugins save their data.
+It's a service plugin, it adds no functionality on it's own.
+See the included m_folders.h for help on how to make use of these services in your own plugins.
+Don't forget to click apply to allow the plugin to create the folder structure.
+When you click apply it will try to delete the old path (all the empty folders) and
+then create the new structure.
+!!! Make sure you don't have any of those folders open in explorer or any other program.
+The plugin also allows environment variables to be used. Environment variables
+are expanded before any miranda variables are expanded so if you have, for example, %profile_path%
+defined as a system variable it will use that value instead expanding to miranda's profile path.
+
+Changes:
+
++ : new feature
+* : changed
+! : bufgix
+- : feature removed or disabled because of pending bugs
+
+version 0.1.6.0 - 2012/03/22
+ ! Fixed m_folders.h declarations in unicode mode - Thanks Freak_TheMighty
+
+version 0.1.5.8 - 2011/08/23
+ * Patch from Kirill Volinsky - updated m_folders.h header file
+
+version 0.1.5.7 - 2011/08/23
+ + made x64 version updater aware
+
+version 0.1.5.6 - 2011/08/22
+ * Patch from Kirill Volinsky - use mir_free() instead of calling the services manually
+
+version 0.1.5.5 - 2011/05/16
+ * Patch from Kirill Volinsky - added mir_a2u mir_u2a support
+
+version 0.1.5.4 - 2011/04/14
+ * Patch from Kirill Volinsky - Fixed Folders debug service (it's for testing purposes)
+
+Version 0.1.5.3 - 2010/11/01
+ * Applied patch from IG_Vasilich - unicode dialogs
+
+Version 0.1.5.2 - 2010/11/01
+ ! Attempt to fix crash with Utils_ReplaceVarsW function.
+
+Version 0.1.5.1 - 2010/08/02
+ ! Fixed path retrieval - the path will no longer contain any trailing \ (as the help file suggests)
+ ! In previous versions Folders plugin did not remove spaces and \ although the help file said it did, but now they are removed.
+
+Version 0.1.5.0 - 2010/05/19
+ + Added support for Variables plugin.
+ + Added support for Miranda core variables.
+ * Environment variables are no longer expanded by Folders plugin, instead it relies on the core to expand these variables.
+ + The fields defined in Variables plugin are the first to get parsed, then the core variables and only after all these have been expanded will
+ Folders plugin expand the fields it defines itself (if they still need to be expanded) (Variables plugin -> Core -> Folders -> result).
+
+Version 0.1.4.5 - 2009/11/13
+ + x64 support - thanks to Nightwish for patch
+
+Version 0.1.4.4 - 2008/05/14
+ ! Only try to delete folders if they're not reparse points
+
+Version 0.1.4.3 - 2008/01/24
+ * Changed beta versions server.
+
+Version 0.1.4.2 - 2007/06/26
+ ! Fixes for the help text.
+
+Version 0.1.4.1 - 2007/06/24
+ ! Translation support for help text.
+ * Enabled unicode flag since plugin is 2in1.
+
+Version 0.1.4.0 - 2007/04/23
+ *Translation support for help text.
+ +Expand environment variables. Environment variables are expanded before any miranda variables.
+ So if you have, for example, %profile_path% defined as a system variable it will expand to that value
+ instead of expanding to miranda's profile path.
+
+Version 0.1.3.0 - 2007/04/11
+ +Section names and item names are now translateable. Plugins should NOT translate the strings themselves, they should let Folders plugin do it.
+
+Version 0.1.2.1 - 2007/03/27
+ *Fix for database plugins returning non standard profile path (dbxSA).
+
+Version 0.1.2.0 - 2007/03/06
+ +Added UUID ( {2f129563-2c7d-4a9a-b948-97dfcc0afdd7} )
+ +Added FOLDERS interface.
+
+Version 0.1.1.1 - 2007/01/31
+ *Changed beta URL.
+
+Version 0.1.1.0 - 2007/01/28
+ !In case of empty format string use miranda's main path instead.
+
+Version 0.1.0.7 - 2007/01/11
+ !Show sections and items as unicode.
+
+Version 0.1.0.6 - 2007/01/07
+ +New version resource file.
+ *Options cleanup. :)
+ +New extended helper function.
+ *Don't show old folder if it isn't empty.
+
+Version 0.1.0.5 - 2006/11/26
+ +Added dll version info.
+ *Changed controls tab order.
+
+Version 0.1.0.4 - 2006/11/07
+ *Select first child item when a section is selected.
+
+Version 0.1.0.3 - 2006/10/23
+ !Unicows needed on Windows 98.
+ *Don't show explorer windows when folders are changed.
+
+Version 0.1.0.2 - 2006/09/10
+ !Rebased the dll (0x2F000000)
+ +Updater support (beta versions)
+
+Version 0.1.0.1 - 2006/08/15
+ *Modified m_folders.h so it compiles with C.
+ +Modified helper functions so they use PATH_TOABSOLUTE when folders plugin is not installed. This should make the helper functions always return an absolute path.
+
+Version 0.1.0.0 - 2006/5/17
+ !Fixed helper functions (now they return 0 on error instead of 1). Also, the register functions how return a HANDLE, like they should.
+ !Destroy services the proper way.
+
+Version 0.0.0.8 - 2006/3/27
+ !Made MS_FOLDERS_GET_SIZE service unicode aware.
+ *Changed the way the helper functions behave - they should now work even when encountering old versions of folders plugin.
+ +Added new TCHAR helper functions.
+ +Preview window updates on every key press.
+
+Version 0.0.0.7 - 2006/3/24
+ !Fixed stupid include file in m_folders.h
+ *Preview window is always unicode aware ... might cause problems on 98 systems.
+ +Added helper functions.
+ +Added unicode support - alpha stages.
+ +Added TCHAR variables to structures.
+ +Fixed a bug with register path service - i wasn't following my own doc
+
+Version 0.0.0.6 - 2006/2/14:
+ +Changed the api (again). Unicode paths are now possible. The unicode part doesn't work yet and maybe
+ it never will - there are no *unicode* services to get the current profile path.
+ *Removed support for API from version 0.0.0.3. Only 0.0.0.6 API works now ...
+ +Added an event ME_FOLDERS_PATH_CHANGED.
+ +If the old directory isn't empty when changing a path then 2 explorer
+ windows will be opened, one for the old path and one for the new one,
+ so the user can copy the data.
+
+Version 0.0.0.5 - 2006/1/19:
+ +Rebased the dll (0x2F010000)
+ +Added the changes made by pescuma
+
+Version 0.0.0.4 - 2005/12/19:
+ *Api changes (sorry). Every entry now belongs
+ to a section. The old api (from version 0.0.0.3)
+ still works and folders registered with the old
+ api will be put in section "Unknown".
+ +Plugin will try to delete old path structure when
+ a new one is entered.
+ +Plugin will try to create the new path structure if
+ it doesn't exist.
+ *Minor cosmetic fixes
+
+Version 0.0.0.3 - 2005/12/17:
+ *Path string is trimmed now.
+ *Now it removes the last \ from the input
+ edit (if there was one)
+ *Added more information about variables.
+
+Version 0.0.0.2 - 2005/12/17:
+ *Changed the api, no loger requires defines for common folders.
+ +Plugins can now register their folders using the new api.
+ +Added options page to allow users to modify the folders.
+
+ This plugin still needs testing; i've done some testing
+ myself but i'm not sure it won't bork the results on some
+ weird cases. Please report any bugs you find on miranda's forum.
+
+version 0.0.0.1 - 2005/12/16:
+ First release ...
+
+
+
+
+Translation strings (updated for version 0.1.4.2)
+
+"Don't forget to click on \\i Apply\\i0 to save the changes. If you don't then the changes won't\\par be saved to the database, they will only be valid for this session.\n"
+"\\ul\\b Variable string\\ulnone\\b0\t\t\\ul\\b What it expands to:\\ulnone\\b0\n"
+"%miranda_path%\t Expands to your miranda path (e.g: c:\\\\program files\\\\miranda im).\n"
+"%profile_path%\t\t Expands to your profile path - the value found in mirandaboot.ini,\n"
+"\t\t\t\\ul ProfileDir\\ulnone section (usually inside miranda's folder).\n"
+"%current_profile%\t Expands to your current profile name without the extenstion.\n"
+"\t\t\t (e.g.\\b default\\b0 if your your profile is \\i default.dat\\i0 ).\n"
+"\n"
+"\n"
+"\\ul\\b Environment variables\n"
+"\\ulnone\\b0 The plugin can also expand environment variables; the variables are specified like in any other\\par program that can use environment variables, i.e. %<env variable>%.\n"
+"\\b Note\\b0 : Environment variables are expanded before any Miranda variables. So if you have, for\\par example, %profile_path% defined as a system variable then it will be expanded to that value\\par instead of expanding to Miranda's profile path.\n"
+"\n"
+"\\ul\\b Examples:\n"
+"\\ulnone\\b0 If the value for the ProfileDir inside \\i mirandaboot.ini\\i0 , \\ul ProfileDir\\ulnone section is '.\\\\profiles', current\\par profile is 'default.dat' and miranda's path is 'c:\\\\program files\\\\miranda im' then:\n"
+"\\b %miranda_path%\\b0 \t\t\t will expand to 'c:\\\\program files\\\\miranda im'\n"
+"\\b %profile_path%\\b0 \t\t\t will expand to 'c:\\\\program files\\\\miranda im\\\\profiles'\n"
+"\\b %current_profile%\\b0\t\t\t will expand to 'default'\n"
+"\\b %temp%\\b0\t\t\t\t will expand to the temp folder of the current user.\n"
+"\\b %profile_path%\\\\%current_profile%\\b0 will expand to 'c:\\\\program files\\\\miranda im\\\\profiles\\\\default'\n"
+"\\b %miranda_path%\\\\plugins\\\\config\\b0\t will expand to 'c:\\\\program files\\\\miranda im\\\\plugins\\\\config'\n"
+"\\b ' %miranda_path%\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ '\\b0\t will expand to 'c:\\\\program files\\\\miranda im'\n"
+"notice that the spaces at the beginning and the end of the string are trimmed, as well as the last \\\\\n"
+
+
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
diff --git a/plugins/Folders/files_release.txt b/plugins/Folders/files_release.txt new file mode 100644 index 0000000000..abc660e6b1 --- /dev/null +++ b/plugins/Folders/files_release.txt @@ -0,0 +1 @@ +folders\win32\Release\folders.dll
\ No newline at end of file diff --git a/plugins/Folders/files_releasex64.txt b/plugins/Folders/files_releasex64.txt new file mode 100644 index 0000000000..579757b872 --- /dev/null +++ b/plugins/Folders/files_releasex64.txt @@ -0,0 +1 @@ +folders\x64\Release\folders.dll
\ No newline at end of file diff --git a/plugins/Folders/files_source.txt b/plugins/Folders/files_source.txt new file mode 100644 index 0000000000..35cc4863ef --- /dev/null +++ b/plugins/Folders/files_source.txt @@ -0,0 +1,5 @@ +"rtf converter\*.*"
+folders\*.*
+folders\sdk\*.*
+docs\*.*
+*.*
diff --git a/plugins/Folders/folders.sln b/plugins/Folders/folders.sln new file mode 100644 index 0000000000..dc314bc490 --- /dev/null +++ b/plugins/Folders/folders.sln @@ -0,0 +1,26 @@ +
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "folders", "folders\folders.vcxproj", "{019FAEBD-BD7B-4470-A15B-A7DB1787E6BD}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {019FAEBD-BD7B-4470-A15B-A7DB1787E6BD}.Debug|Win32.ActiveCfg = Debug|Win32
+ {019FAEBD-BD7B-4470-A15B-A7DB1787E6BD}.Debug|Win32.Build.0 = Debug|Win32
+ {019FAEBD-BD7B-4470-A15B-A7DB1787E6BD}.Debug|x64.ActiveCfg = Debug|x64
+ {019FAEBD-BD7B-4470-A15B-A7DB1787E6BD}.Debug|x64.Build.0 = Debug|x64
+ {019FAEBD-BD7B-4470-A15B-A7DB1787E6BD}.Release|Win32.ActiveCfg = Release|Win32
+ {019FAEBD-BD7B-4470-A15B-A7DB1787E6BD}.Release|Win32.Build.0 = Release|Win32
+ {019FAEBD-BD7B-4470-A15B-A7DB1787E6BD}.Release|x64.ActiveCfg = Release|x64
+ {019FAEBD-BD7B-4470-A15B-A7DB1787E6BD}.Release|x64.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/plugins/Folders/folders/commonheaders.h b/plugins/Folders/folders/commonheaders.h new file mode 100644 index 0000000000..3cab4024b1 --- /dev/null +++ b/plugins/Folders/folders/commonheaders.h @@ -0,0 +1,80 @@ +/*
+Custom profile folders plugin for Miranda IM
+
+Copyright © 2005 Cristian Libotean
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef M_FOLDERS_COMMONHEADERS_H
+#define M_FOLDERS_COMMONHEADERS_H
+
+#define MAX_FOLDER_SIZE 2048
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <windows.h>
+
+#include "newpluginapi.h"
+#include "m_utils.h"
+#include "m_folders.h"
+
+#include "version.h"
+#include "utils.h"
+#include "resource.h"
+#include "foldersList.h"
+#include "dlg_handlers.h"
+
+#include "m_database.h"
+#include "m_system.h"
+#include "m_skin.h"
+#include "m_options.h"
+#include "m_clist.h"
+#include "m_langpack.h"
+#include "m_history.h"
+#include "m_contacts.h"
+#include "m_popup.h"
+#include "m_fontservice.h"
+#include "m_updater.h"
+#include "m_variables.h"
+
+#ifndef MS_DB_GETPROFILEPATH_BASIC //db3xSA
+#define MS_DB_GETPROFILEPATH_BASIC "DB/GetProfilePathBasic"
+#endif
+
+extern char ModuleName[];
+extern HINSTANCE hInstance;
+extern CFoldersList &lstRegisteredFolders;
+
+#define OLD_MIRANDAPLUGININFO_SUPPORT PLUGININFO oldPluginInfo = { \
+ sizeof(PLUGININFO), \
+ pluginInfo.shortName, \
+ pluginInfo.version, \
+ pluginInfo.description, \
+ pluginInfo.author, \
+ pluginInfo.authorEmail, \
+ pluginInfo.copyright, \
+ pluginInfo.homepage, \
+ pluginInfo.flags, \
+ pluginInfo.replacesDefaultModule \
+}; \
+\
+extern "C" __declspec(dllexport) PLUGININFO *MirandaPluginInfo(DWORD mirandaVersion) \
+{ \
+ return &oldPluginInfo; \
+}
+
+#endif //FOLDERS_COMMONHEADERS_H
\ No newline at end of file diff --git a/plugins/Folders/folders/dlg_handlers.cpp b/plugins/Folders/folders/dlg_handlers.cpp new file mode 100644 index 0000000000..74d3715835 --- /dev/null +++ b/plugins/Folders/folders/dlg_handlers.cpp @@ -0,0 +1,413 @@ +#include "dlg_handlers.h"
+
+PFolderItem lastItem = NULL;
+
+static int bInitializing = 0;
+
+int GetCurrentItemSelection(HWND hWnd)
+{
+ return SendDlgItemMessageW(hWnd, IDC_FOLDERS_ITEMS_LIST, LB_GETCURSEL, 0, 0);
+}
+
+int GetCurrentSectionSelection(HWND hWnd)
+{
+ return SendDlgItemMessageW(hWnd, IDC_FOLDERS_SECTIONS_LIST, LB_GETCURSEL, 0, 0);
+}
+
+PFolderItem GetSelectedItem(HWND hWnd)
+{
+ WCHAR section[MAX_FOLDER_SIZE];
+ WCHAR item[MAX_FOLDER_SIZE];
+ GetCurrentItemText(hWnd, item, MAX_FOLDER_SIZE);
+ GetCurrentSectionText(hWnd, section, MAX_FOLDER_SIZE);
+ return lstRegisteredFolders.GetTranslated(section, item);
+}
+
+int GetCurrentItemText(HWND hWnd, WCHAR *buffer, int count)
+{
+ int index = GetCurrentItemSelection(hWnd);
+ if (index != LB_ERR)
+ {
+ SendDlgItemMessageW(hWnd, IDC_FOLDERS_ITEMS_LIST, LB_GETTEXT, index, (LPARAM) buffer);
+ return 1;
+ }
+ else{
+ buffer[0] = L'\0';
+ return 0;
+ }
+}
+
+int GetCurrentSectionText(HWND hWnd, WCHAR *buffer, int count)
+{
+ int index = GetCurrentSectionSelection(hWnd);
+ if (index != LB_ERR)
+ {
+ SendDlgItemMessageW(hWnd, IDC_FOLDERS_SECTIONS_LIST, LB_GETTEXT, index, (LPARAM) buffer);
+ return 1;
+ }
+ else{
+ buffer[0] = L'0';
+ return 0;
+ }
+}
+
+//void GetEditText(HWND hWnd, char *buffer, int size)
+//{
+// GetWindowText(GetDlgItem(hWnd, IDC_FOLDER_EDIT), buffer, size);
+// StrTrim(buffer, "\\\t \n");
+//}
+
+void GetEditTextW(HWND hWnd, wchar_t *buffer, int size)
+{
+ GetWindowTextW(GetDlgItem(hWnd, IDC_FOLDER_EDIT), buffer, size);
+}
+
+//void SetEditText(HWND hWnd, const char *buffer)
+//{
+// bInitializing = 1;
+// SetWindowText(GetDlgItem(hWnd, IDC_FOLDER_EDIT), buffer);
+// bInitializing = 0;
+//// SendDlgItemMessage(hWnd, IDC_FOLDER_EDIT, WM_SETTEXT, 0, (LPARAM) buffer);
+//}
+
+void SetEditTextW(HWND hWnd, const wchar_t *buffer)
+{
+ bInitializing = 1;
+ SetWindowTextW(GetDlgItem(hWnd, IDC_FOLDER_EDIT), buffer);
+ bInitializing = 0;
+}
+
+int ContainsSection(HWND hWnd, const WCHAR *section)
+{
+ int index = SendDlgItemMessageW(hWnd, IDC_FOLDERS_SECTIONS_LIST, LB_FINDSTRINGEXACT, -1, (LPARAM) section);
+ return (index != LB_ERR);
+}
+
+void LoadRegisteredFolderSections(HWND hWnd)
+{
+ for (int i = 0; i < lstRegisteredFolders.Count(); i++)
+ {
+ PFolderItem tmp = lstRegisteredFolders.Get(i + 1);
+ WCHAR *translated = mir_a2u(Translate(tmp->GetSection()));
+ if (!ContainsSection(hWnd, translated))
+ {
+ SendDlgItemMessageW(hWnd, IDC_FOLDERS_SECTIONS_LIST, LB_ADDSTRING, 0, (LPARAM) translated);
+ }
+ mir_free(translated);
+ }
+}
+
+void LoadRegisteredFolderItems(HWND hWnd)
+{
+ WCHAR buffer[MAX_FOLDER_SIZE];
+ GetCurrentSectionText(hWnd, buffer, MAX_FOLDER_SIZE);
+ SendDlgItemMessageW(hWnd, IDC_FOLDERS_ITEMS_LIST, LB_RESETCONTENT, 0, 0);
+ for (int i = 0; i < lstRegisteredFolders.Count(); i++)
+ {
+ PFolderItem item = lstRegisteredFolders.Get(i + 1);
+ WCHAR *wide = mir_a2u(Translate(item->GetSection()));
+ if (wcscmp(buffer, wide) == 0)
+ {
+ mir_free(wide);
+ wide = mir_a2u(Translate(item->GetName()));
+ SendDlgItemMessageW(hWnd, IDC_FOLDERS_ITEMS_LIST, LB_ADDSTRING, 0, (LPARAM) wide);
+ }
+ mir_free(wide);
+ }
+ SendDlgItemMessageW(hWnd, IDC_FOLDERS_ITEMS_LIST, LB_SETCURSEL, 0, 0); //select the first item
+ PostMessage(hWnd, WM_COMMAND, MAKEWPARAM(IDC_FOLDERS_ITEMS_LIST, LBN_SELCHANGE), 0); //tell the dialog to refresh the preview
+}
+
+void LoadItem(HWND hWnd, PFolderItem item)
+{
+ if (item)
+ {
+ if (item->IsUnicode())
+ {
+ SetEditTextW(hWnd, item->GetFormatW());
+ }
+ else{
+ WCHAR *buffer = mir_a2u(item->GetFormat());
+ SetEditTextW(hWnd, buffer);
+ mir_free(buffer);
+ }
+ RefreshPreview(hWnd);
+ }
+}
+
+void SaveItem(HWND hWnd, PFolderItem item, int bEnableApply)
+{
+ if (item)
+ {
+ if (item->IsUnicode())
+ {
+ wchar_t buffer[MAX_FOLDER_SIZE];
+ GetEditTextW(hWnd, buffer, MAX_FOLDER_SIZE);
+ item->SetFormatW(buffer);
+ }
+ else{
+ WCHAR buffer[MAX_FOLDER_SIZE];
+ char ansi[MAX_FOLDER_SIZE];
+ GetEditTextW(hWnd, buffer, MAX_FOLDER_SIZE);
+ WideCharToMultiByte(CallService(MS_LANGPACK_GETCODEPAGE, 0, 0), 0, buffer, -1, ansi, MAX_FOLDER_SIZE, NULL, NULL);
+ item->SetFormat(ansi);
+ }
+ if (bEnableApply)
+ {
+ SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0);
+ }
+ }
+}
+
+int ChangesNotSaved(HWND hWnd, PFolderItem item)
+{
+ int res = 0;
+ if (item)
+ {
+ if (item->IsUnicode())
+ {
+ wchar_t buffer[MAX_FOLDER_SIZE];
+ GetEditTextW(hWnd, buffer, MAX_FOLDER_SIZE);
+ res = (wcscmp(item->GetFormatW(), buffer) != 0);
+ }
+ else{
+ WCHAR buffer[MAX_FOLDER_SIZE];
+ GetEditTextW(hWnd, buffer, MAX_FOLDER_SIZE);
+ char *ansi = mir_u2a(buffer);
+
+ res = (strcmp(item->GetFormat(), ansi) != 0);
+ mir_free(ansi);
+ }
+ }
+
+ return res;
+}
+
+void CheckForChanges(HWND hWnd, int bNeedConfirmation = 1)
+{
+ if (ChangesNotSaved(hWnd, lastItem))
+ {
+ if ((!bNeedConfirmation) || MessageBoxW(hWnd, TranslateW(L"Some changes weren't saved. Apply the changes now ?"), TranslateW(L"Changes not saved"), MB_YESNO | MB_ICONINFORMATION) == IDYES)
+ {
+ SaveItem(hWnd, lastItem);
+ }
+ }
+}
+
+void RefreshPreview(HWND hWnd)
+{
+ wchar_t tmp[MAX_FOLDER_SIZE];
+ wchar_t res[MAX_FOLDER_SIZE];
+ GetEditTextW(hWnd, tmp, MAX_FOLDER_SIZE);
+ ExpandPathW(res, tmp, MAX_FOLDER_SIZE);
+ SetWindowTextW(GetDlgItem(hWnd, IDC_PREVIEW_EDIT), res);
+ //SendDlgItemMessage(hWnd, IDC_PREVIEW_EDIT, WM_SETTEXT, 0, (LPARAM) res);
+}
+
+
+void LoadHelp(HWND hWnd)
+{
+ SETTEXTEX tmp = {0};
+ tmp.flags = ST_SELECTION;
+ tmp.codepage = CallService(MS_LANGPACK_GETCODEPAGE, 0, 0);
+ char *text =
+#include "variablesHelp.inc"
+;
+
+ char buffer[2048];
+ char line[2048];
+ int len;
+
+ char *p;
+ while ((p = strchr(text, '\n')))
+ {
+ len = p - text + 1;
+ memcpy(line, text, len);
+ line[len] = 0;
+
+ mir_snprintf(buffer, sizeof(buffer), "{\\rtf1\\ansi\\deff0\\pard\\li%u\\fi-%u\\ri%u\\tx%u\\fs19 %s\\par}", 60*15, 60*15, 5*15, 60*15, Translate(line));
+ text = p + 1;
+
+ SendDlgItemMessageW(hWnd, IDC_HELP_RICHEDIT, EM_SETTEXTEX, (WPARAM) &tmp, (LPARAM) buffer);
+ }
+
+
+}
+
+/************************************** DIALOG HANDLERS *************************************/
+#include "commctrl.h"
+
+INT_PTR CALLBACK DlgProcOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ bInitializing = 1;
+ lastItem = NULL;
+ TranslateDialogDefault(hWnd);
+ LoadRegisteredFolderSections(hWnd);
+ bInitializing = 0;
+
+ break;
+ }
+
+ case WM_COMMAND:
+ {
+ switch (LOWORD(wParam))
+ {
+ case IDC_FOLDER_EDIT:
+ {
+ switch (HIWORD(wParam))
+ {
+ case EN_CHANGE:
+ {
+ RefreshPreview(hWnd);
+ if (!bInitializing)
+ {
+ SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); //show the apply button.
+ }
+
+ break;
+ }
+ }
+
+ break;
+ }
+
+ case IDC_REFRESH_BUTTON:
+ {
+ RefreshPreview(hWnd);
+
+ break;
+ }
+
+ case IDC_HELP_BUTTON:
+ {
+ HWND helpDlg = CreateDialogW(hInstance, MAKEINTRESOURCEW(IDD_VARIABLES_HELP), hWnd, DlgProcVariables);
+ ShowWindow(helpDlg, SW_SHOW);
+
+ break;
+ }
+
+ case IDC_FOLDERS_SECTIONS_LIST:
+ {
+ switch (HIWORD(wParam))
+ {
+ case LBN_SELCHANGE:
+ {
+ CheckForChanges(hWnd);
+ LoadRegisteredFolderItems(hWnd);
+ lastItem = NULL;
+ SetEditTextW(hWnd, L"");
+ RefreshPreview(hWnd);
+
+ break;
+ }
+ }
+
+ break;
+ }
+
+ case IDC_FOLDERS_ITEMS_LIST:
+ {
+ switch (HIWORD(wParam))
+ {
+ case LBN_SELCHANGE:
+ {
+ PFolderItem item = GetSelectedItem(hWnd);
+ if (item != NULL)
+ {
+ CheckForChanges(hWnd);
+ LoadItem(hWnd, item);
+ }
+ lastItem = item;
+
+ break;
+ }
+ }
+
+ break;
+ }
+ }
+
+ break;
+ }
+
+ case WM_NOTIFY:
+ {
+// Log("WM_NOTIFY %d %d", wParam, lParam);
+ switch(((LPNMHDR)lParam)->idFrom)
+ {
+ case 0:
+ switch (((LPNMHDR)lParam)->code)
+ {
+ case PSN_APPLY:
+ {
+ PFolderItem item = GetSelectedItem(hWnd);
+ if (item)
+ {
+ SaveItem(hWnd, item, FALSE);
+ LoadItem(hWnd, item);
+ }
+
+ lstRegisteredFolders.Save();
+ CallPathChangedEvents();
+
+ break;
+ }
+ }
+
+ break;
+ }
+ }
+
+ break;
+
+ default:
+ {
+
+ break;
+ }
+ }
+
+ return 0;
+}
+
+INT_PTR CALLBACK DlgProcVariables(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hWnd);
+ LoadHelp(hWnd);
+
+ break;
+ }
+
+ case WM_CLOSE:
+ {
+ DestroyWindow(hWnd);
+
+ break;
+ }
+
+ case WM_COMMAND:
+ {
+ switch (LOWORD(wParam))
+ {
+ case IDCLOSE:
+ {
+ DestroyWindow(hWnd);
+
+ break;
+ }
+ }
+
+ break;
+ }
+ }
+
+ return 0;
+}
\ No newline at end of file diff --git a/plugins/Folders/folders/dlg_handlers.h b/plugins/Folders/folders/dlg_handlers.h new file mode 100644 index 0000000000..4f3a4f15ca --- /dev/null +++ b/plugins/Folders/folders/dlg_handlers.h @@ -0,0 +1,28 @@ +#ifndef M_FOLDERS_DLG_HANDLERS_H
+#define M_FOLDERS_DLG_HANDLERS_H
+
+//#include "commonheaders.h"
+#include "services.h"
+#include "events.h"
+#include <richedit.h>
+
+INT_PTR CALLBACK DlgProcOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK DlgProcVariables(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
+
+int GetCurrentItemSelection(HWND hWnd);
+int GetCurrentSectionSelection(HWND hWnd);
+PFolderItem GetSelectedItem(HWND hWnd);
+int GetCurrentSectionText(HWND hWnd, WCHAR *buffer, int count);
+int GetCurrentItemText(HWND hWnd, WCHAR *buffer, int count);
+//void GetEditText(HWND hWnd, char *buffer, int size);
+void GetEditTextW(HWND hWnd, wchar_t *buffer, int size);
+//void SetEditText(HWND hWnd, const char *buffer);
+void SetEditTextW(HWND hWnd, const wchar_t *buffer);
+void LoadRegisteredFolderSections(HWND hWnd);
+void LoadRegisteredFolderItems(HWND hWnd);
+void LoadItem(HWND hWnd, PFolderItem item);
+void SaveItem(HWND hWnd, PFolderItem item, int bEnableApply = TRUE);
+int ChangesNotSaved(HWND hWnd);
+void RefreshPreview(HWND hWnd);
+
+#endif //M_FOLDERS_DLG_HANDLERS_H
\ No newline at end of file diff --git a/plugins/Folders/folders/events.cpp b/plugins/Folders/folders/events.cpp new file mode 100644 index 0000000000..359ac81bf4 --- /dev/null +++ b/plugins/Folders/folders/events.cpp @@ -0,0 +1,41 @@ +/*
+Custom profile folders plugin for Miranda IM
+
+Copyright © 2005 Cristian Libotean
+
+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 "events.h"
+
+HANDLE hPathChanged;
+
+int InitEvents()
+{
+ hPathChanged = CreateHookableEvent(ME_FOLDERS_PATH_CHANGED);
+ return 0;
+}
+
+int DestroyEvents()
+{
+ DestroyHookableEvent(hPathChanged);
+ hPathChanged = 0;
+ return 0;
+}
+
+int CallPathChangedEvents()
+{
+ return NotifyEventHooks(hPathChanged, 0, 0);
+}
\ No newline at end of file diff --git a/plugins/Folders/folders/events.h b/plugins/Folders/folders/events.h new file mode 100644 index 0000000000..8f73ee7cfe --- /dev/null +++ b/plugins/Folders/folders/events.h @@ -0,0 +1,36 @@ +/*
+Custom profile folders plugin for Miranda IM
+
+Copyright © 2005 Cristian Libotean
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef M_FOLDERS_EVENTS_H
+#define M_FOLDERS_EVENTS_H
+
+#include "commonheaders.h"
+#include "m_folders.h"
+
+extern HANDLE hPathChanged;
+
+int InitEvents();
+int DestroyEvents();
+
+int CallPathChangedEvents();
+
+
+
+#endif //M_FOLDERS_EVENTS_H
\ No newline at end of file diff --git a/plugins/Folders/folders/folderItem.cpp b/plugins/Folders/folders/folderItem.cpp new file mode 100644 index 0000000000..cf58e5feac --- /dev/null +++ b/plugins/Folders/folders/folderItem.cpp @@ -0,0 +1,250 @@ +/*
+Custom profile folders plugin for Miranda IM
+
+Copyright © 2005 Cristian Libotean
+
+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 "folderItem.h"
+#include "commonheaders.h"
+#include "services.h"
+
+CFolderItem::CFolderItem(const char *sectionName, const char *name, const char *format, const DWORD flags)
+{
+ strncpy(szSection, sectionName, sizeof(szSection));
+ szFormat = NULL;
+ szOldFormat = NULL;
+ szFormatW = NULL;
+ szOldFormatW = NULL;
+ strncpy(szName, name, sizeof(szName));
+ this->flags = flags;
+ GetDataFromDatabase(format);
+ FolderCreateDirectory();
+}
+
+void MyFree(void *data)
+{
+ if (data)
+ {
+ free(data);
+ }
+}
+
+CFolderItem::~CFolderItem()
+{
+// WriteDataToDatabase();
+ if (IsUnicode())
+ {
+ MyFree(szFormatW);
+ MyFree(szOldFormatW);
+ }
+ else{
+ MyFree(szFormat);
+ MyFree(szOldFormat);
+ }
+}
+
+const char *CFolderItem::GetSection() const
+{
+ return szSection;
+}
+
+const char *CFolderItem::GetName() const
+{
+ return szName;
+}
+
+const char *CFolderItem::GetFormat() const
+{
+ return szFormat;
+}
+
+const wchar_t *CFolderItem::GetFormatW() const
+{
+ return szFormatW;
+}
+
+void CFolderItem::SetFormat(const char *newFormat)
+{
+ MyFree(szOldFormat);
+ szOldFormat = szFormat;
+ szFormat = _strdup((strlen(newFormat) > 0) ? newFormat : MIRANDA_PATH);
+}
+
+void CFolderItem::SetFormatW(const wchar_t *newFormat)
+{
+ MyFree(szOldFormatW);
+ szOldFormatW = szFormatW;
+ szFormatW = _wcsdup((wcslen(newFormat) > 0) ? newFormat : MIRANDA_PATHW);
+}
+
+int CFolderItem::IsUnicode() const
+{
+ return (flags & FF_UNICODE);
+}
+
+int CFolderItem::IsEqual(const CFolderItem *other)
+{
+ return (IsEqual(other->GetSection(), other->GetName()));
+}
+
+int CFolderItem::IsEqual(const char *section, const char *name)
+{
+ return ((strcmp(szName, name) == 0) && (strcmp(szSection, section) == 0));
+}
+
+int CFolderItem::IsEqualTranslated(const char *trSection, const char *trName)
+{
+ return ((strcmp(Translate(szName), trName) == 0) && (strcmp(Translate(szSection), trSection) == 0));
+}
+
+int CFolderItem::operator ==(const CFolderItem *other)
+{
+ return IsEqual(other);
+}
+
+void CFolderItem::Expand(char *buffer, int size)
+{
+ if (IsUnicode())
+ {
+ ExpandPathW((wchar_t *) buffer, szFormatW, size);
+ }
+ else{
+ ExpandPath(buffer, szFormat, size);
+ }
+}
+
+void CFolderItem::Save()
+{
+ int res = FolderDeleteOldDirectory(FALSE);
+ //FolderCreateDirectory(!res);
+ FolderCreateDirectory(FALSE);
+ WriteDataToDatabase();
+}
+
+int CFolderItem::FolderCreateDirectory(int showFolder)
+{
+ int res = FOLDER_SUCCESS;
+ if (IsUnicode())
+ {
+ wchar_t buffer[MAX_FOLDER_SIZE];
+ if (szFormatW)
+ {
+ ExpandPathW(buffer, szFormatW, MAX_FOLDER_SIZE);
+ CreateDirectories(buffer);
+ if (showFolder)
+ {
+ ShellExecuteW(NULL, L"explore", buffer, NULL, NULL, SW_SHOW);
+ }
+ res = (DirectoryExists(buffer)) ? FOLDER_SUCCESS : FOLDER_FAILURE;
+ }
+ }
+ else{
+ char buffer[MAX_FOLDER_SIZE];
+ if (szFormat)
+ {
+ ExpandPath(buffer, szFormat, MAX_FOLDER_SIZE);
+ CreateDirectories(buffer);
+ if (showFolder)
+ {
+ ShellExecuteA(NULL, "explore", buffer, NULL, NULL, SW_SHOW);
+ }
+ res = (DirectoryExists(buffer)) ? FOLDER_SUCCESS : FOLDER_FAILURE;
+ }
+ }
+ return res;
+}
+
+int CFolderItem::FolderDeleteOldDirectory(int showFolder)
+{
+ int res = FOLDER_SUCCESS;
+ if (IsUnicode())
+ {
+ wchar_t buffer[MAX_FOLDER_SIZE];
+ if (szOldFormatW)
+ {
+ if (wcscmp(szFormatW, szOldFormatW) == 0) //format wasn't changed
+ {
+ return res;
+ }
+ ExpandPathW(buffer, szOldFormatW, MAX_FOLDER_SIZE);
+ RemoveDirectories(buffer);
+ res = (DirectoryExists(buffer)) ? FOLDER_FAILURE : FOLDER_SUCCESS;
+ if ((res == FOLDER_FAILURE) && (showFolder))
+ {
+ ShellExecuteW(NULL, L"explore", buffer, NULL, NULL, SW_SHOW);
+ }
+ }
+ }
+ else{
+ char buffer[MAX_FOLDER_SIZE];
+ if (szOldFormat)
+ {
+ if (strcmp(szFormat, szOldFormat) == 0) //format wasn't changed
+ {
+ return res;
+ }
+ ExpandPath(buffer, szOldFormat, MAX_FOLDER_SIZE);
+ RemoveDirectories(buffer);
+ res = (DirectoryExists(buffer)) ? FOLDER_FAILURE : FOLDER_SUCCESS;
+ if ((res == FOLDER_FAILURE) && (showFolder))
+ {
+ ShellExecuteA(NULL, "explore", buffer, NULL, NULL, SW_SHOW);
+ }
+ }
+ }
+ return res;
+}
+
+void CFolderItem::GetDataFromDatabase(const char *szNotFound)
+{
+ char name[256];
+ strcpy(name, szSection);
+ strcat(name, szName);
+
+ if (IsUnicode())
+ {
+ wchar_t buffer[MAX_FOLDER_SIZE];
+ GetStringFromDatabase(name, (const wchar_t *) szNotFound, buffer, MAX_FOLDER_SIZE);
+ SetFormatW(buffer);
+ }
+ else{
+ char buffer[MAX_FOLDER_SIZE];
+ GetStringFromDatabase(name, szNotFound, buffer, MAX_FOLDER_SIZE);
+ SetFormat(buffer);
+ }
+}
+
+void CFolderItem::WriteDataToDatabase()
+{
+ char name[256];
+ strcpy(name, szSection);
+ strcat(name, szName);
+
+ if (IsUnicode())
+ {
+ if (szFormatW)
+ {
+ WriteStringToDatabase(name, szFormatW);
+ }
+ }
+ else{
+ if (szFormat)
+ {
+ WriteStringToDatabase(name, szFormat);
+ }
+ }
+}
\ No newline at end of file diff --git a/plugins/Folders/folders/folderItem.h b/plugins/Folders/folders/folderItem.h new file mode 100644 index 0000000000..b60891c2ff --- /dev/null +++ b/plugins/Folders/folders/folderItem.h @@ -0,0 +1,78 @@ +/*
+Custom profile folders plugin for Miranda IM
+
+Copyright © 2005 Cristian Libotean
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef M_FOLDERS_FOLDER_ITEM_H
+#define M_FOLDERS_FOLDER_ITEM_H
+
+#include <string.h>
+#include <malloc.h>
+#include <windows.h>
+
+#define FOLDERS_NO_HELPER_FUNCTIONS
+#include "m_folders.h"
+#undef FOLDERS_NO_HELPER_FUNCTIONS
+
+
+#define FOLDER_SUCCESS 1
+#define FOLDER_FAILURE 0
+
+class CFolderItem{
+ protected:
+ char szSection[FOLDERS_NAME_MAX_SIZE];
+ char szName[FOLDERS_NAME_MAX_SIZE]; //don't forget to modify in m_folders.h
+ union{
+ char *szFormat;
+ wchar_t *szFormatW;
+ };
+ union{
+ char *szOldFormat;
+ wchar_t *szOldFormatW;
+ };
+ DWORD flags;
+
+ void GetDataFromDatabase(const char *szNotFound);
+ void WriteDataToDatabase();
+
+ int FolderCreateDirectory(int showFolder = 0);
+ int FolderDeleteOldDirectory(int showFolder = 0);
+
+ public:
+ CFolderItem(const char *sectionName, const char *name, const char *format, const DWORD flags);
+ virtual ~CFolderItem();
+ void Expand(char *buffer, int size);
+ void Save();
+
+ int IsUnicode() const;
+ int IsEqual(const CFolderItem *other);
+ int IsEqual(const char *section, const char *name);
+ int IsEqualTranslated(const char *trSection, const char *trName);
+ int operator ==(const CFolderItem *other);
+
+ const char *GetSection() const;
+ const char *GetName() const;
+ const char *GetFormat() const;
+ const wchar_t *GetFormatW() const;
+ void SetFormat(const char *newFormat);
+ void SetFormatW(const wchar_t *newFormat);
+};
+
+typedef CFolderItem *PFolderItem;
+
+#endif //M_FOLDERS_FOLDER_ITEM_H
\ No newline at end of file diff --git a/plugins/Folders/folders/folders.cpp b/plugins/Folders/folders/folders.cpp new file mode 100644 index 0000000000..4628f2ffbc --- /dev/null +++ b/plugins/Folders/folders/folders.cpp @@ -0,0 +1,246 @@ +/*
+Custom profile folders plugin for Miranda IM
+
+Copyright © 2005 Cristian Libotean
+
+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 "commonheaders.h"
+#include "hooked_events.h"
+#include "services.h"
+#include "events.h"
+
+#include "m_folders.h"
+
+#define MS_FOLDERS_TEST_PLUGIN "Folders/Test/Plugin"
+
+char ModuleName[] = "Folders";
+HINSTANCE hInstance;
+int hLangpack;
+struct MM_INTERFACE mmi;
+
+CFoldersList &lstRegisteredFolders = CFoldersList(10); //the list
+
+PLUGINLINK *pluginLink;
+
+PLUGININFOEX pluginInfo = {
+ sizeof(PLUGININFOEX),
+ __PLUGIN_DISPLAY_NAME,
+ VERSION,
+ __DESC,
+ __AUTHOR,
+ __AUTHOREMAIL,
+ __COPYRIGHT,
+ __AUTHORWEB,
+ 1,
+ 0,
+ {0x2f129563, 0x2c7d, 0x4a9a, {0xb9, 0x48, 0x97, 0xdf, 0xcc, 0x0a, 0xfd, 0xd7}} //{2f129563-2c7d-4a9a-b948-97dfcc0afdd7}
+}; //not used
+
+OLD_MIRANDAPLUGININFO_SUPPORT;
+
+#ifdef _DEBUG
+
+typedef struct{
+ int cbSize; //size of struct
+ int nUniqueID; //unique id for this path. This ID should be unique for your plugin.
+ char szName[FOLDERS_NAME_MAX_SIZE]; //name to show in options
+} FOLDERSDATA_OLD;
+
+INT_PTR TestPlugin(WPARAM wParam, LPARAM lParam)
+{
+ char temp[MAX_PATH];
+ const int MAX = 20;
+ int i;
+ HANDLE handles[MAX][2];
+/* FOLDERSDATA caca;
+ caca.cbSize = sizeof(caca);
+ caca.szFormat = FOLDER_LOGS;*/
+ char *section;
+ for (i = 0; i < MAX; i++)
+ {
+ switch (i % 4)
+ {
+ case 0:
+ section = "Section 1";
+ break;
+ case 1:
+ section = "Section 2";
+ break;
+ case 2:
+ section = "Yet another section";
+ break;
+ case 3:
+ section = "Section no 4";
+ break;
+ default:
+ section = "Uhh ohh";
+ break;
+ }
+ //strcpy(caca.szSection, section);
+ _itoa(i, temp, 10);
+ //strcpy(caca.szName, temp);
+
+ handles[i][0] = FoldersRegisterCustomPathT(section, temp, FOLDER_LOGS); //CallService(MS_FOLDERS_REGISTER_PATH, 0, (LPARAM) &caca);
+ }
+ //caca.szFormatW = L"%profile_path%\\%current_profile%\\Ø";
+ //caca.flags = FF_UNICODE;
+ FoldersRegisterCustomPath("Unicode stuff", "non unicode", " %profile_path%\\%current_profile%\\Ø\\\\\\");
+ for (i = 0; i < MAX; i++)
+ {
+ //strcpy(caca.szSection, "Unicode stuff");
+ sprintf(temp, "Value %d", i);
+ //strcpy(caca.szName, temp);
+ handles[i][1] = FoldersRegisterCustomPathW("Unicode stuff", temp, L"%profile_path%\\%current_profile%\\\u1FA6"); //CallService(MS_FOLDERS_REGISTER_PATH, 0, (LPARAM) &caca);
+ }
+/*
+ FOLDERSAPPENDDATA data;
+ data.hRegisteredPath = handles[0];
+ data.szAppendData = "just an appended string";
+ char *cacat;
+ CallService(MS_FOLDERS_GET_PATH_ALLOC_APPEND, (WPARAM) &data, (LPARAM) &cacat);
+ Log("Append function returned : %s", cacat); */
+ /*FOLDERSGETDATA data = {0};
+ data.cbSize = sizeof(data);
+ data.nMaxPathSize = sizeof(temp);
+ data.szPath = temp; */
+ for (i = 0; i < MAX; i++)
+ {
+ //CallService(MS_FOLDERS_GET_PATH, handles[i][0], (LPARAM) &data);
+ FoldersGetCustomPath((HANDLE) handles[i][0], temp, sizeof(temp), "<not found>");
+ Log("Path function[%d] returned : %s", i, temp);
+ }
+ wchar_t buffer[MAX_PATH];
+ //data.szPathW = buffer;
+ for (i = 0; i < MAX; i++)
+ {
+ //CallService(MS_FOLDERS_GET_PATH, handles[i][0], (LPARAM) &data);
+ FoldersGetCustomPathW((HANDLE) handles[i][1], buffer, MAX_PATH, L"<not found>");
+ Log("Unicode path function[%d] returned: %S", i, buffer);
+ }
+// GetPathService(CONFIGURATION_PATH, (LPARAM) temp);
+// GetPathAllocService(AVATARS_PATH, (LPARAM) &caca);
+
+
+ for (i = 0; i < MAX; i++)
+ {
+ FoldersGetCustomPathEx((HANDLE) handles[i][0], temp, sizeof(temp), "<not found>", "test");
+ Log("Path function Ex (test) [%d] returned : %s", i, temp);
+ FoldersGetCustomPathEx((HANDLE) handles[i][0], temp, sizeof(temp), "<not found>", "");
+ Log("Path function Ex () [%d] returned : %s", i, temp);
+ FoldersGetCustomPathEx((HANDLE) handles[i][0], temp, sizeof(temp), "<not found>", NULL);
+ Log("Path function Ex (NULL) [%d] returned : %s", i, temp);
+ }
+
+ for (i = 0; i < MAX; i++)
+ {
+ FoldersGetCustomPathExW((HANDLE) handles[i][1], buffer, MAX_PATH, L"<not found>", L"test");
+ Log("Unicode path function Ex (test) [%d] returned : %S", i, buffer);
+ FoldersGetCustomPathExW((HANDLE) handles[i][1], buffer, MAX_PATH, L"<not found>", L"");
+ Log("Unicode path function Ex () [%d] returned : %S", i, buffer);
+ FoldersGetCustomPathExW((HANDLE) handles[i][1], buffer, MAX_PATH, L"<not found>", NULL);
+ Log("Unicode path function Ex (NULL) [%d] returned : %S", i, buffer);
+ }
+
+ return 0;
+}
+
+HANDLE hTestPlugin;
+#endif
+
+extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD mirandaVersion)
+{
+#if _MSC_VER >= 1300
+ Log("%s", "Entering function " __FUNCTION__);
+ Log("%s", "Leaving function " __FUNCTION__);
+#endif
+ pluginInfo.cbSize = sizeof(PLUGININFOEX);
+ return &pluginInfo;
+}
+
+static const MUUID interfaces[] = {MIID_FOLDERS, MIID_LAST};
+
+extern "C" __declspec(dllexport) const MUUID *MirandaPluginInterfaces()
+{
+ return interfaces;
+}
+
+extern "C" int __declspec(dllexport) Load(PLUGINLINK *link)
+{
+#if _MSC_VER >= 1300
+ Log("%s", "Entering function " __FUNCTION__);
+#endif
+ pluginLink = link;
+ mir_getLP(&pluginInfo);
+ mir_getMMI(&mmi);
+
+ Log("%s", "Creating service functions ...");
+ InitServices();
+ InitEvents();
+
+#ifdef _DEBUG
+ hTestPlugin = CreateServiceFunction(MS_FOLDERS_TEST_PLUGIN, TestPlugin);
+ CLISTMENUITEM mi = {0};
+
+ mi.cbSize=sizeof(mi);
+ mi.position=300050000;
+ mi.flags=0;
+ mi.hIcon=0;
+ mi.pszName=Translate("Test folders");
+ mi.pszService=MS_FOLDERS_TEST_PLUGIN;
+ CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&mi);
+#endif
+#if _MSC_VER >= 1300
+ Log("%s", "Hooking events ...");
+#endif
+ HookEvents();
+#if _MSC_VER >= 1300
+ Log("%s", "Leaving function " __FUNCTION__);
+#endif
+ return 0;
+}
+
+extern "C" int __declspec(dllexport) Unload()
+{
+#if _MSC_VER >= 1300
+ Log("%s", "Entering function " __FUNCTION__);
+ Log("%s", "Unhooking events ...");
+
+ Log("%s", "Destroying service functions ...");
+#endif
+// DestroyServiceFunction(MS_HISTORY_SHOWCONTACTHISTORY);
+ DestroyServices();
+ DestroyEvents();
+ UnhookEvents();
+#ifdef _DEBUG
+ DestroyServiceFunction(hTestPlugin);
+#endif
+
+#if _MSC_VER >= 1300
+ Log("%s", "Leaving function " __FUNCTION__);
+#endif
+ return 0;
+}
+
+bool WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
+{
+ hInstance = hinstDLL;
+ if (fdwReason == DLL_PROCESS_ATTACH)
+ {
+ DisableThreadLibraryCalls(hinstDLL);
+ }
+ return TRUE;
+}
\ No newline at end of file diff --git a/plugins/Folders/folders/folders.rc b/plugins/Folders/folders/folders.rc new file mode 100644 index 0000000000..b87bcd9447 --- /dev/null +++ b/plugins/Folders/folders/folders.rc @@ -0,0 +1,129 @@ +// 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
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_OPT_FOLDERS DIALOGEX 0, 0, 314, 254
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CONTROL | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Dialog"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ GROUPBOX "Custom folders",IDC_FOLDERS_GROUPBOX,0,1,313,250
+ LISTBOX IDC_FOLDERS_SECTIONS_LIST,14,12,77,116,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
+ LISTBOX IDC_FOLDERS_ITEMS_LIST,98,12,208,116,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
+ GROUPBOX "Preview",IDC_PREVIEW_GROUPBOX,6,131,300,55
+ EDITTEXT IDC_PREVIEW_EDIT,14,143,284,35,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | NOT WS_TABSTOP
+ GROUPBOX "Edit",IDC_EDIT_FOLDER_GROUPBOX,6,189,300,58
+ EDITTEXT IDC_FOLDER_EDIT,14,202,284,14,ES_AUTOHSCROLL
+ PUSHBUTTON "Refresh preview",IDC_REFRESH_BUTTON,14,227,71,14
+ PUSHBUTTON "Variables help",IDC_HELP_BUTTON,231,227,67,14
+END
+
+IDD_VARIABLES_HELP DIALOGEX 0, 0, 449, 237
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Custom folders variables help"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ DEFPUSHBUTTON "Close",IDCLOSE,392,216,50,14
+ CONTROL "",IDC_HELP_RICHEDIT,"RichEdit20A",ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP,7,7,435,203
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_OPT_FOLDERS, DIALOG
+ BEGIN
+ RIGHTMARGIN, 313
+ VERTGUIDE, 6
+ VERTGUIDE, 14
+ VERTGUIDE, 298
+ VERTGUIDE, 306
+ TOPMARGIN, 1
+ BOTTOMMARGIN, 251
+ HORZGUIDE, 12
+ HORZGUIDE, 128
+ HORZGUIDE, 202
+ HORZGUIDE, 241
+ HORZGUIDE, 247
+ END
+
+ IDD_VARIABLES_HELP, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 442
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 230
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/plugins/Folders/folders/folders.vcxproj b/plugins/Folders/folders/folders.vcxproj new file mode 100644 index 0000000000..b9d030fc3e --- /dev/null +++ b/plugins/Folders/folders/folders.vcxproj @@ -0,0 +1,218 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{019FAEBD-BD7B-4470-A15B-A7DB1787E6BD}</ProjectGuid>
+ <RootNamespace>folders</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>NotSet</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>NotSet</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)/Plugins\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)/Obj/$(ProjectName)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64/Plugins\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64/Obj/$(ProjectName)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)/Plugins\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)/Obj/$(ProjectName)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64/Plugins\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64/Obj/$(ProjectName)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>../../../include;../../ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;WIN32;_DEBUG;_WINDOWS;_USRDLL;FOLDERS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <BrowseInformation>
+ </BrowseInformation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <CompileAs>CompileAsCpp</CompileAs>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>unicows.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <GenerateMapFile>false</GenerateMapFile>
+ <SubSystem>Windows</SubSystem>
+ <BaseAddress>0x2F000000</BaseAddress>
+ <TargetMachine>MachineX86</TargetMachine>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>../../../include;../../ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;WIN64;_DEBUG;_WINDOWS;_USRDLL;FOLDERS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <BrowseInformation>
+ </BrowseInformation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <CompileAs>CompileAsCpp</CompileAs>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <GenerateMapFile>false</GenerateMapFile>
+ <SubSystem>Windows</SubSystem>
+ <BaseAddress>0x2F000000</BaseAddress>
+ <TargetMachine>MachineX64</TargetMachine>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <Optimization>Full</Optimization>
+ <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
+ <AdditionalIncludeDirectories>../../../include;../../ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;WIN32;NDEBUG;_WINDOWS;_USRDLL;FOLDERS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <BrowseInformation>
+ </BrowseInformation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>unicows.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <BaseAddress>0x2F000000</BaseAddress>
+ <TargetMachine>MachineX86</TargetMachine>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>Full</Optimization>
+ <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
+ <AdditionalIncludeDirectories>../../../include;../../ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;WIN64;NDEBUG;_WINDOWS;_USRDLL;FOLDERS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <BrowseInformation>
+ </BrowseInformation>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <BaseAddress>0x2F000000</BaseAddress>
+ <TargetMachine>MachineX64</TargetMachine>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="dlg_handlers.cpp" />
+ <ClCompile Include="events.cpp" />
+ <ClCompile Include="folderItem.cpp" />
+ <ClCompile Include="folders.cpp" />
+ <ClCompile Include="foldersList.cpp" />
+ <ClCompile Include="hooked_events.cpp" />
+ <ClCompile Include="services.cpp" />
+ <ClCompile Include="utils.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="commonheaders.h" />
+ <ClInclude Include="dlg_handlers.h" />
+ <ClInclude Include="events.h" />
+ <ClInclude Include="folderItem.h" />
+ <ClInclude Include="foldersList.h" />
+ <ClInclude Include="hooked_events.h" />
+ <ClInclude Include="m_folders.h" />
+ <ClInclude Include="resource.h" />
+ <ClInclude Include="services.h" />
+ <ClInclude Include="utils.h" />
+ <ClInclude Include="version.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="folders.rc" />
+ <ResourceCompile Include="version.rc" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="variablesHelp.inc" />
+ <None Include="..\docs\folders_readme.txt" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/plugins/Folders/folders/folders.vcxproj.filters b/plugins/Folders/folders/folders.vcxproj.filters new file mode 100644 index 0000000000..fae51320c3 --- /dev/null +++ b/plugins/Folders/folders/folders.vcxproj.filters @@ -0,0 +1,92 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="dlg_handlers.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="events.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="folderItem.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="folders.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="foldersList.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="hooked_events.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="services.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="utils.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="commonheaders.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="dlg_handlers.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="events.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="folderItem.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="foldersList.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="hooked_events.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="m_folders.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="resource.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="services.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="utils.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="version.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="folders.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ <ResourceCompile Include="version.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="variablesHelp.inc">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="..\docs\folders_readme.txt" />
+ </ItemGroup>
+</Project>
\ No newline at end of file diff --git a/plugins/Folders/folders/foldersList.cpp b/plugins/Folders/folders/foldersList.cpp new file mode 100644 index 0000000000..b13620fe71 --- /dev/null +++ b/plugins/Folders/folders/foldersList.cpp @@ -0,0 +1,232 @@ +/*
+Custom profile folders plugin for Miranda IM
+
+Copyright © 2005 Cristian Libotean
+
+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 "foldersList.h"
+
+CFoldersList::CFoldersList(int initialSize)
+{
+ capacity = 0;
+ count = 0;
+ list = NULL;
+ Enlarge(initialSize);
+}
+
+CFoldersList::~CFoldersList()
+{
+ Clear();
+ free(list);
+}
+
+void CFoldersList::Clear()
+{
+ int i;
+ for (i = 0; i < count; i++)
+ {
+ delete (list[i]);
+ }
+
+ count = 0;
+}
+
+int CFoldersList::Count()
+{
+ return count;
+}
+
+int CFoldersList::Capacity()
+{
+ return capacity;
+}
+
+void CFoldersList::Save()
+{
+ int i;
+ for (i = 0; i < count; i++)
+ {
+ list[i]->Save();
+ }
+}
+
+PFolderItem CFoldersList::Get(int index)
+{
+ index--;
+ if ((index < 0) || (index >= count))
+ {
+ return NULL;
+ }
+ return list[index];
+}
+
+PFolderItem CFoldersList::Get(const char *section, const char *name)
+{
+ int i;
+ for (i = 0; i < count; i++)
+ {
+ if (list[i]->IsEqual(section, name))
+ {
+ return list[i];
+ }
+ }
+ return NULL;
+}
+
+PFolderItem CFoldersList::Get(const WCHAR *section, const WCHAR *name)
+{
+ const int MAX_SIZE = 2048;
+ char aSection[MAX_SIZE];
+ char aName[MAX_SIZE];
+ UINT cp = static_cast<UINT>(CallService(MS_LANGPACK_GETCODEPAGE, 0, 0));
+
+ WideCharToMultiByte(cp, 0, section, -1, aSection, MAX_SIZE, NULL, NULL);
+ WideCharToMultiByte(cp, 0, name, -1, aName, MAX_SIZE, NULL, NULL);
+
+ return Get(aSection, aName);
+}
+
+PFolderItem CFoldersList::GetTranslated(const char *trSection, const char *trName)
+{
+ int i;
+ for (i = 0; i < count; i++)
+ {
+ if (list[i]->IsEqualTranslated(trSection, trName))
+ {
+ return list[i];
+ }
+ }
+
+ return NULL;
+}
+
+PFolderItem CFoldersList::GetTranslated(WCHAR *trSection, const WCHAR *trName)
+{
+ const int MAX_SIZE = 2048;
+ char aSection[MAX_SIZE];
+ char aName[MAX_SIZE];
+ UINT cp = static_cast<UINT>(CallService(MS_LANGPACK_GETCODEPAGE, 0, 0));
+
+ WideCharToMultiByte(cp, 0, trSection, -1, aSection, MAX_SIZE, NULL, NULL);
+ WideCharToMultiByte(cp, 0, trName, -1, aName, MAX_SIZE, NULL, NULL);
+
+ return GetTranslated(aSection, aName);
+}
+
+
+int CFoldersList::Expand(int index, char *szResult, int size)
+{
+ PFolderItem tmp = Get(index);
+ int res = 1;
+ if (tmp)
+ {
+ tmp->Expand(szResult, size);
+ res = 0;
+ }
+ else{
+ memset(szResult, 0, size);
+ }
+ return res;
+}
+
+int CFoldersList::Add(CFolderItem *item)
+{
+ EnsureCapacity();
+ int pos = Contains(item);
+ if (!pos)
+ {
+ list[count++] = item;
+ return count;
+ }
+ else{
+ delete item;
+ return pos;
+ }
+ return 0;
+}
+
+int CFoldersList::Add(FOLDERSDATA data)
+{
+ CFolderItem *item;
+ if (data.flags & FF_UNICODE)
+ {
+ item = new CFolderItem(data.szSection, data.szName, (char *) data.szFormatW, data.flags);
+ }
+ else{
+ item = new CFolderItem(data.szSection, data.szName, data.szFormat, data.flags);
+ }
+ return Add(item);
+}
+
+void CFoldersList::Remove(CFolderItem *item)
+{
+// Remove(item->GetUniqueID());
+}
+
+void CFoldersList::Remove(int uniqueID)
+{
+/* int i, j;
+ CFolderItem *tmp;
+ for (i = 0; i < count; i++)
+ {
+ if (list[i]->GetUniqueID() == uniqueID)
+ {
+ tmp = list[i];
+ for (j = i; j < count - 1; j++)
+ {
+ list[j] = list[j + 1];
+ }
+ count--;
+ delete tmp;
+ return;
+ }
+ }
+*/
+}
+
+int CFoldersList::Contains(CFolderItem *item)
+{
+ return Contains(item->GetSection(), item->GetName());
+}
+
+int CFoldersList::Contains(const char *section, const char *name)
+{
+ int i;
+ for (i = 0; i < count; i++)
+ {
+ if (list[i]->IsEqual(section, name))
+ {
+ return i + 1;
+ }
+ }
+ return 0;
+}
+
+void CFoldersList::EnsureCapacity()
+{
+ if (count >= capacity)
+ {
+ Enlarge(capacity / 2);
+ }
+}
+
+void CFoldersList::Enlarge(int increaseAmount)
+{
+ int newSize = capacity + increaseAmount;
+ list = (PFolderItem *) realloc(list, newSize * sizeof(PFolderItem));
+ capacity = newSize;
+}
\ No newline at end of file diff --git a/plugins/Folders/folders/foldersList.h b/plugins/Folders/folders/foldersList.h new file mode 100644 index 0000000000..854249b3a3 --- /dev/null +++ b/plugins/Folders/folders/foldersList.h @@ -0,0 +1,69 @@ +/*
+Custom profile folders plugin for Miranda IM
+
+Copyright © 2005 Cristian Libotean
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef M_FOLDERS_LIST_H
+#define M_FOLDERS_LIST_H
+
+#include <string.h>
+#include <malloc.h>
+
+#include "folderItem.h"
+
+#define FOLDERS_NO_HELPER_FUNCTIONS
+#include "m_folders.h"
+#undef FOLDERS_NO_HELPER_FUNCTIONS
+#include "newpluginapi.h"
+#include "m_langpack.h"
+
+class CFoldersList{
+ protected:
+ PFolderItem *list; //the list
+ int count;
+ int capacity;
+
+ void Enlarge(int increaseAmount);
+ void EnsureCapacity();
+
+ public:
+ CFoldersList(int initialSize = 10);
+ virtual ~CFoldersList();
+
+ void Clear();
+ int Add(CFolderItem *item);
+ int Add(FOLDERSDATA data);
+ void Remove(CFolderItem *item);
+ void Remove(int uniqueID);
+ int Contains(CFolderItem *item);
+ int Contains(const char *section, const char *name);
+
+ int Count();
+ int Capacity();
+
+ PFolderItem Get(int index);
+ PFolderItem Get(const char *section, const char *name);
+ PFolderItem Get(const WCHAR *section, const WCHAR *name);
+ PFolderItem GetTranslated(const char *trSection, const char *trName);
+ PFolderItem GetTranslated(WCHAR *trSection, const WCHAR *trName);
+ int Expand(int index, char *szResult, int size);
+ void Save();
+};
+
+
+#endif
\ No newline at end of file diff --git a/plugins/Folders/folders/hooked_events.cpp b/plugins/Folders/folders/hooked_events.cpp new file mode 100644 index 0000000000..78439bb3da --- /dev/null +++ b/plugins/Folders/folders/hooked_events.cpp @@ -0,0 +1,86 @@ +/*
+Custom profile folders plugin for Miranda IM
+
+Copyright © 2005 Cristian Libotean
+
+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 "hooked_events.h"
+#include "events.h"
+
+#define HOST "http://eblis.tla.ro/projects"
+
+#if defined(WIN64) || defined(_WIN64)
+#define FOLDERS_VERSION_URL HOST "/miranda/Folders/updater/x64/Folders.html"
+#define FOLDERS_UPDATE_URL HOST "/miranda/Folders/updater/x64/Folders.zip"
+#else
+#define FOLDERS_VERSION_URL HOST "/miranda/Folders/updater/Folders.html"
+#define FOLDERS_UPDATE_URL HOST "/miranda/Folders/updater/Folders.zip"
+#endif
+#define FOLDERS_VERSION_PREFIX "Custom profile folders version "
+
+HANDLE hModulesLoaded;
+HANDLE hOptionsInitialize;
+
+int HookEvents()
+{
+ hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
+ hOptionsInitialize = HookEvent(ME_OPT_INITIALISE, OnOptionsInitialize);
+ return 0;
+}
+
+int UnhookEvents()
+{
+ UnhookEvent(hModulesLoaded);
+ UnhookEvent(hOptionsInitialize);
+ return 0;
+}
+
+int OnModulesLoaded(WPARAM wParam, LPARAM lParam)
+{
+ char buffer[1024];
+ Update update = {0};
+ update.cbSize = sizeof(Update);
+ update.szComponentName = __PLUGIN_DISPLAY_NAME;
+ update.pbVersion = (BYTE *) CreateVersionString(VERSION, buffer);
+ update.cpbVersion = (int)strlen((char *) update.pbVersion);
+ update.szUpdateURL = UPDATER_AUTOREGISTER;
+ update.szBetaVersionURL = FOLDERS_VERSION_URL;
+ update.szBetaUpdateURL = FOLDERS_UPDATE_URL;
+ update.pbBetaVersionPrefix = (BYTE *) FOLDERS_VERSION_PREFIX;
+ update.cpbBetaVersionPrefix = (int)strlen(FOLDERS_VERSION_PREFIX);
+ CallService(MS_UPDATE_REGISTER, 0, (LPARAM) &update);
+
+ return 0;
+}
+
+int OnOptionsInitialize(WPARAM wParam, LPARAM lParam)
+{
+ OPTIONSDIALOGPAGE odp = { 0 };
+
+ odp.cbSize = sizeof(odp);
+ odp.position = 100000000;
+ odp.hInstance = hInstance;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_FOLDERS);
+ odp.pszTitle = Translate("Folders");
+ odp.pszGroup = Translate("Customize");
+ odp.groupPosition = 910000000;
+ odp.flags=ODPF_BOLDGROUPS;
+ odp.pfnDlgProc = DlgProcOpts;
+ CallService(MS_OPT_ADDPAGE, wParam, (LPARAM)&odp);
+
+ return 0;
+}
\ No newline at end of file diff --git a/plugins/Folders/folders/hooked_events.h b/plugins/Folders/folders/hooked_events.h new file mode 100644 index 0000000000..92401e9850 --- /dev/null +++ b/plugins/Folders/folders/hooked_events.h @@ -0,0 +1,36 @@ +/*
+Custom profile folders plugin for Miranda IM
+
+Copyright © 2005 Cristian Libotean
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef M_FOLDERS_HOOKED_EVENTS_H
+#define M_FOLDERS_HOOKED_EVENTS_H
+
+#include "commonheaders.h"
+#include "services.h"
+
+extern HANDLE hModulesLoaded;
+extern HANDLE hOptionsInitialize;
+
+int UnhookEvents();
+int HookEvents();
+
+int OnModulesLoaded(WPARAM wParam, LPARAM lParam);
+int OnOptionsInitialize(WPARAM wParam, LPARAM lParam);
+
+#endif
\ No newline at end of file diff --git a/plugins/Folders/folders/resource.h b/plugins/Folders/folders/resource.h new file mode 100644 index 0000000000..e8ff0247cf --- /dev/null +++ b/plugins/Folders/folders/resource.h @@ -0,0 +1,27 @@ +//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by folders.rc
+//
+#define IDD_OPT_FOLDERS 101
+#define IDD_VARIABLES_HELP 102
+#define IDC_FOLDERS_ITEMS_LIST 1002
+#define IDC_FOLDERS_GROUPBOX 1003
+#define IDC_EDIT_FOLDER_GROUPBOX 1004
+#define IDC_FOLDER_EDIT 1005
+#define IDC_REFRESH_BUTTON 1008
+#define IDC_PREVIEW_GROUPBOX 1009
+#define IDC_PREVIEW_EDIT 1010
+#define IDC_HELP_BUTTON 1011
+#define IDC_HELP_RICHEDIT 1012
+#define IDC_FOLDERS_SECTIONS_LIST 1013
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 105
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1014
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/plugins/Folders/folders/services.cpp b/plugins/Folders/folders/services.cpp new file mode 100644 index 0000000000..f811bf2246 --- /dev/null +++ b/plugins/Folders/folders/services.cpp @@ -0,0 +1,250 @@ +/*
+Custom profile folders plugin for Miranda IM
+
+Copyright © 2005 Cristian Libotean
+
+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 "services.h"
+
+#define DEFAULT_SECTION "Unknown"
+
+char szCurrentProfilePath[MAX_FOLDERS_PATH] = {0};
+char szCurrentProfile[MAX_FOLDERS_PATH] = {0};
+char szMirandaPath[MAX_FOLDERS_PATH] = {0};
+char szUserDataPath[MAX_FOLDERS_PATH] = {0};
+
+wchar_t szCurrentProfilePathW[MAX_FOLDERS_PATH] = {0};
+wchar_t szCurrentProfileW[MAX_FOLDERS_PATH] = {0};
+wchar_t szMirandaPathW[MAX_FOLDERS_PATH] = {0};
+wchar_t szUserDataPathW[MAX_FOLDERS_PATH] = {0};
+
+HANDLE hsFoldersGetPath;
+HANDLE hsFoldersGetSize;
+HANDLE hsFoldersGetPathAlloc;
+HANDLE hsFoldersRegisterPath;
+
+int InitServices()
+{
+ ServiceExists(MS_DB_GETPROFILEPATH_BASIC) ? CallService(MS_DB_GETPROFILEPATH_BASIC, sizeof(szCurrentProfilePath), (LPARAM) szCurrentProfilePath) : CallService(MS_DB_GETPROFILEPATH, sizeof(szCurrentProfilePath), (LPARAM) szCurrentProfilePath);
+ CallService(MS_DB_GETPROFILENAME, sizeof(szCurrentProfile), (LPARAM) szCurrentProfile);
+ char *pos = strrchr(szCurrentProfile, '.');
+ szCurrentProfile[pos - szCurrentProfile] = '\0'; //remove the extension (.dat)
+ GetModuleFileNameA(GetModuleHandleA(NULL), szMirandaPath, sizeof(szMirandaPath));
+ pos = strrchr(szMirandaPath, '\\');
+ szMirandaPath[pos - szMirandaPath] = '\0'; //remove '\miranda32.exe'
+
+ char *szTemp = Utils_ReplaceVars("%miranda_userdata%");
+ mir_snprintf(szUserDataPath, MAX_FOLDERS_PATH, szTemp);
+ mir_free(szTemp);
+
+ MultiByteToWideChar(CP_ACP, 0, szCurrentProfilePath, -1, szCurrentProfilePathW, MAX_FOLDERS_PATH);
+ MultiByteToWideChar(CP_ACP, 0, szCurrentProfile, -1, szCurrentProfileW, MAX_FOLDERS_PATH);
+ MultiByteToWideChar(CP_ACP, 0, szMirandaPath, -1, szMirandaPathW, MAX_FOLDERS_PATH);
+ MultiByteToWideChar(CP_ACP, 0, szUserDataPath, -1, szUserDataPathW, MAX_FOLDERS_PATH);
+
+ hsFoldersGetPath = CreateServiceFunction(MS_FOLDERS_GET_PATH, GetPathService);
+// CreateServiceFunction(MS_FOLDERS_GET_PATH_APPEND, GetPathAppendService);
+ hsFoldersGetSize = CreateServiceFunction(MS_FOLDERS_GET_SIZE, GetPathSizeService);
+ hsFoldersGetPathAlloc = CreateServiceFunction(MS_FOLDERS_GET_PATH_ALLOC, GetPathAllocService);
+// CreateServiceFunction(MS_FOLDERS_GET_PATH_ALLOC_APPEND, GetPathAllocAppendService);
+ hsFoldersRegisterPath = CreateServiceFunction(MS_FOLDERS_REGISTER_PATH, RegisterPathService);
+
+ return 0;
+}
+
+int DestroyServices()
+{
+ DestroyServiceFunction(hsFoldersGetPath);
+// DestroyServiceFunction(MS_FOLDERS_GET_PATH_APPEND);
+ DestroyServiceFunction(hsFoldersGetSize);
+ DestroyServiceFunction(hsFoldersGetPathAlloc);
+// DestroyServiceFunction(MS_FOLDERS_GET_PATH_ALLOC_APPEND);
+ DestroyServiceFunction(hsFoldersRegisterPath);
+ return 0;
+}
+
+INT_PTR ExpandPath(char *szResult, char *format, int size)
+{
+ szResult[0] = '\0';
+ char *input = NULL;
+
+ if (ServiceExists(MS_VARS_FORMATSTRING))
+ {
+ TCHAR* tmp_format = mir_a2t(format);
+ TCHAR *vars_result_tmp = variables_parse(tmp_format, NULL, NULL);
+ mir_free(tmp_format);
+ char *vars_result = mir_t2a(vars_result_tmp);
+
+ if (vars_result != NULL)
+ {
+ input = mir_strdup(vars_result);
+
+ variables_free(vars_result_tmp);
+ }
+ mir_free(vars_result);
+ }
+
+ if (input == NULL)
+ {
+ input = mir_strdup(format);
+ }
+
+ char *core_result = Utils_ReplaceVars(input);
+ strncpy(szResult, core_result, size);
+
+ mir_free(core_result);
+
+ StrReplace(szResult, PROFILE_PATH, szCurrentProfilePath);
+ StrReplace(szResult, CURRENT_PROFILE, szCurrentProfile);
+ StrReplace(szResult, MIRANDA_PATH, szMirandaPath);
+ StrReplace(szResult, MIRANDA_USERDATA, szUserDataPath);
+
+ StrTrim(szResult, "\t \\");
+
+ mir_free(input);
+
+ return strlen(szResult);
+}
+
+INT_PTR ExpandPathW(wchar_t *szResult, wchar_t *format, int size)
+{
+ szResult[0] = '\0';
+ wchar_t *input = NULL;
+
+ if (ServiceExists(MS_VARS_FORMATSTRING))
+ {
+ TCHAR* tmp_format = mir_u2t(format);
+ TCHAR *vars_result_tmp = variables_parse(tmp_format, NULL, NULL);
+ mir_free(tmp_format);
+ wchar_t *vars_result = mir_t2u(vars_result_tmp);
+
+ if (vars_result != NULL)
+ {
+ input = mir_wstrdup(vars_result);
+
+ variables_free(vars_result_tmp);
+ }
+ mir_free(vars_result);
+ }
+
+ if (input == NULL)
+ {
+ input = mir_wstrdup(format);
+ }
+
+ wchar_t *core_result = Utils_ReplaceVarsW(input);
+ if (core_result)
+ {
+ wcsncpy(szResult, core_result, size);
+ }
+ else {
+ wcsncpy(szResult, input, size);
+ }
+
+ mir_free(core_result);
+
+ StrReplace(szResult, PROFILE_PATHW, szCurrentProfilePathW);
+ StrReplace(szResult, CURRENT_PROFILEW, szCurrentProfileW);
+ StrReplace(szResult, MIRANDA_PATHW, szMirandaPathW);
+ StrReplace(szResult, MIRANDA_USERDATAW, szUserDataPathW);
+
+ StrTrim(szResult, L"\t \\");
+
+ mir_free(input);
+
+ return wcslen(szResult);
+}
+
+INT_PTR GetPath(int hRegisteredFolder, char *szResult, int size)
+{
+ return lstRegisteredFolders.Expand(hRegisteredFolder, szResult, size);
+ //return 0;
+}
+
+INT_PTR RegisterPathService(WPARAM wParam, LPARAM lParam)
+{
+ FOLDERSDATA tmp = *(FOLDERSDATA *) lParam;
+ int res = 0;
+ if (tmp.cbSize == sizeof(FOLDERSDATA))
+ {
+ res = lstRegisteredFolders.Add(tmp); //returns 1..n or 0 on error
+ }
+ return res;
+}
+
+INT_PTR GetPathSizeService(WPARAM wParam, LPARAM lParam)
+{
+ char tmp[MAX_FOLDER_SIZE * 4]; //dumb
+ int res = lstRegisteredFolders.Expand(wParam, tmp, sizeof(tmp));
+ size_t len = 0;
+ if ((lstRegisteredFolders.Get(wParam)) && (lstRegisteredFolders.Get(wParam)->IsUnicode()))
+ {
+ len = wcslen((wchar_t *)tmp);
+ }
+ else{
+ len = strlen(tmp);
+ }
+ if (lParam != NULL)
+ {
+ *((size_t *) lParam) = len;
+ }
+ return len;
+}
+
+INT_PTR GetPathService(WPARAM wParam, LPARAM lParam)
+{
+ FOLDERSGETDATA data = *(FOLDERSGETDATA *) lParam;
+ size_t res = 1;
+ if (data.cbSize == sizeof(FOLDERSGETDATA))
+ {
+ res = GetPath(wParam, data.szPath, data.nMaxPathSize); //dumb ...
+ }
+ return res;
+}
+
+INT_PTR GetPathAllocService(WPARAM wParam, LPARAM lParam)
+{
+ int size;
+ int res = 1;
+ FOLDERSGETALLOCDATA data = *(FOLDERSGETALLOCDATA *) lParam;
+ if (data.cbSize == sizeof(FOLDERSGETALLOCDATA))
+ {
+ size = GetPathSizeService(wParam, (LPARAM) &size);
+ char **buffer = data.szPath;
+ *buffer = (char *) mir_alloc(size + 1);
+ res = GetPath(wParam, *buffer, size);
+ }
+ return res;
+}
+/*
+int GetPathAppendService(WPARAM wParam, LPARAM lParam)
+{
+ FOLDERSAPPENDDATA data = *(FOLDERSAPPENDDATA *) wParam;
+ int res = GetPathService(data.hRegisteredPath, lParam);
+ strcat((char *) lParam, data.szAppendData);
+ return res;
+}
+*/
+/*
+int GetPathAllocAppendService(WPARAM wParam, LPARAM lParam)
+{
+ FOLDERSAPPENDDATA data = *(FOLDERSAPPENDDATA *) wParam;
+ int res = GetPathAllocService(data.hRegisteredPath, lParam);
+ strcat(*(char **) lParam, data.szAppendData);
+ return res;
+}
+*/
\ No newline at end of file diff --git a/plugins/Folders/folders/services.h b/plugins/Folders/folders/services.h new file mode 100644 index 0000000000..3a2ee1aa9f --- /dev/null +++ b/plugins/Folders/folders/services.h @@ -0,0 +1,50 @@ +/*
+Custom profile folders plugin for Miranda IM
+
+Copyright © 2005 Cristian Libotean
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef M_FOLDERS_PROVIDED_SERVICES_H
+#define M_FOLDERS_PROVIDED_SERVICES_H
+
+#include "commonheaders.h"
+#include "m_folders.h"
+
+#define MAX_FOLDERS_PATH 512
+
+extern char szCurrentProfilePath[MAX_FOLDERS_PATH];
+extern char szCurrentProfile[MAX_FOLDERS_PATH];
+extern char szMirandaPath[MAX_FOLDERS_PATH];
+
+extern wchar_t szCurrentProfilePathW[MAX_FOLDERS_PATH];
+extern wchar_t szCurrentProfileW[MAX_FOLDERS_PATH];
+extern wchar_t szMirandaPathW[MAX_FOLDERS_PATH];
+
+int InitServices();
+int DestroyServices();
+INT_PTR ExpandPath(char *szResult, char *format, int size);
+INT_PTR ExpandPathW(wchar_t *szResult, wchar_t *format, int size);
+INT_PTR GetPath(int hRegisteredFolder, char *szResult, int size);
+
+INT_PTR RegisterPathService(WPARAM wParam, LPARAM lParam);
+INT_PTR GetPathSizeService(WPARAM wParam, LPARAM lParam);
+INT_PTR GetPathService(WPARAM wParam, LPARAM lParam);
+INT_PTR GetPathAllocService(WPARAM wParam, LPARAM lParam);
+//int GetPathAppendService(WPARAM wParam, LPARAM lParam);
+//int GetPathAllocAppendService(WPARAM wParam, LPARAM lParam);
+
+#endif //M_FOLDERS_PROVIDED_SERVICES_H
\ No newline at end of file diff --git a/plugins/Folders/folders/utils.cpp b/plugins/Folders/folders/utils.cpp new file mode 100644 index 0000000000..64623b63f1 --- /dev/null +++ b/plugins/Folders/folders/utils.cpp @@ -0,0 +1,357 @@ +/*
+Custom profile folders plugin for Miranda IM
+
+Copyright © 2005 Cristian Libotean
+
+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 "utils.h"
+
+int Log(char *format, ...)
+{
+#ifdef _DEBUG
+ char str[4096];
+ va_list vararg;
+ int tBytes;
+ FILE *fout = fopen("folders.log", "at");
+
+ va_start(vararg, format);
+
+ tBytes = _vsnprintf(str, sizeof(str), format, vararg);
+ if (tBytes > 0)
+ {
+ str[tBytes] = 0;
+ }
+
+ va_end(vararg);
+ if (str[strlen(str) - 1] != '\n')
+ {
+ strcat(str, "\n");
+ }
+ fputs(str, fout);
+ fclose(fout);
+#endif
+ return 0;
+}
+
+char *StrCopy(char *source, size_t index, const char *what, size_t count)
+{
+ size_t i;
+ for (i = 0; i < count; i++)
+ {
+ source[index + i] = what[i];
+ }
+ return source;
+}
+
+wchar_t *StrCopy(wchar_t *source, size_t index, const wchar_t *what, size_t count)
+{
+ size_t i;
+ for (i = 0; i < count; i++)
+ {
+ source[index + i] = what[i];
+ }
+ return source;
+}
+
+char *StrDelete(char *source, size_t index, size_t count)
+{
+ size_t len = strlen(source);
+ size_t i;
+ count = (count + index > len) ? len - index : count;
+ for (i = index; i + count <= len; i++)
+ {
+ source[i] = source[i + count];
+ }
+ return source;
+}
+
+wchar_t *StrDelete(wchar_t *source, size_t index, size_t count)
+{
+ size_t len = wcslen(source);
+ size_t i;
+ count = (count + index > len) ? len - index : count;
+ for (i = index; i + count <= len; i++)
+ {
+ source[i] = source[i + count];
+ }
+ return source;
+}
+
+
+char *StrInsert(char *source, size_t index, const char *what)
+{
+ size_t whatLen = strlen(what);
+ size_t sourceLen = strlen(source);
+ size_t i;
+ for (i = sourceLen; i >= index; i--)
+ {
+ source[i + whatLen] = source[i];
+ }
+ for (i = 0; i < whatLen; i++)
+ {
+ source[index + i] = what[i];
+ }
+ return source;
+}
+
+wchar_t *StrInsert(wchar_t *source, size_t index, const wchar_t *what)
+{
+ size_t whatLen = wcslen(what);
+ size_t sourceLen = wcslen(source);
+ size_t i;
+ for (i = sourceLen; i >= index; i--)
+ {
+ source[i + whatLen] = source[i];
+ }
+ for (i = 0; i < whatLen; i++)
+ {
+ source[index + i] = what[i];
+ }
+ return source;
+}
+
+
+char *StrReplace(char *source, const char *what, const char *withWhat)
+{
+ char *pos;
+ size_t whatLen = strlen(what);
+ size_t withWhatLen = strlen(withWhat);
+ size_t minLen;
+ size_t index;
+
+ while ((pos = strstr(source, what)))
+ {
+ minLen = min(whatLen, withWhatLen);
+ StrCopy(source, pos - source, withWhat, minLen);
+ index = pos - source + minLen;
+ if (whatLen > withWhatLen)
+ {
+ StrDelete(source, index, whatLen - withWhatLen);
+ }
+ else{
+ if (whatLen < withWhatLen)
+ {
+ StrInsert(source, index, withWhat + minLen);
+ }
+ }
+ }
+ return source;
+}
+
+wchar_t *StrReplace(wchar_t *source, const wchar_t *what, const wchar_t *withWhat)
+{
+ wchar_t *pos;
+ size_t whatLen = wcslen(what);
+ size_t withWhatLen = wcslen(withWhat);
+ size_t minLen;
+ size_t index;
+
+ while ((pos = wcsstr(source, what)))
+ {
+ minLen = min(whatLen, withWhatLen);
+ StrCopy(source, pos - source, withWhat, minLen);
+ index = pos - source + minLen;
+ if (whatLen > withWhatLen)
+ {
+ StrDelete(source, index, whatLen - withWhatLen);
+ }
+ else{
+ if (whatLen < withWhatLen)
+ {
+ StrInsert(source, index, withWhat + minLen);
+ }
+ }
+ }
+ return source;
+}
+
+char *StrTrim(char *szText, const char *szTrimChars)
+{
+ size_t i = strlen(szText) - 1;
+ while ((i >= 0) && (strchr(szTrimChars, szText[i])))
+ {
+ szText[i--] = '\0';
+ }
+ i = 0;
+ while ((i < strlen(szText)) && (strchr(szTrimChars, szText[i])))
+ {
+ i++;
+ }
+ if (i)
+ {
+ StrDelete(szText, 0, i);
+ }
+ return szText;
+}
+
+wchar_t *StrTrim(wchar_t *szText, const wchar_t *szTrimChars)
+{
+ size_t i = wcslen(szText) - 1;
+ while ((i >= 0) && (wcschr(szTrimChars, szText[i])))
+ {
+ szText[i--] = '\0';
+ }
+ i = 0;
+ while ((i < wcslen(szText)) && (wcschr(szTrimChars, szText[i])))
+ {
+ i++;
+ }
+ if (i)
+ {
+ StrDelete(szText, 0, i);
+ }
+ return szText;
+}
+
+void CreateDirectories(char *path)
+{
+ char *pos = path;
+ char tmp;
+ while (pos = strchr(pos, '\\'))
+ {
+ tmp = pos[0];
+ pos[0] = '\0';
+ CreateDirectoryA(path, NULL);
+ pos[0] = tmp;
+ pos++;
+ }
+ CreateDirectoryA(path, NULL);
+ GetLastError();
+}
+
+void CreateDirectories(wchar_t *path)
+{
+ wchar_t *pos = path;
+ wchar_t tmp;
+ while (pos = wcschr(pos, '\\'))
+ {
+ tmp = pos[0];
+ pos[0] = '\0';
+ CreateDirectoryW(path, NULL);
+ pos[0] = tmp;
+ pos++;
+ }
+ CreateDirectoryW(path, NULL);
+ GetLastError();
+}
+
+void RemoveDirectories(char *path)
+{
+ char *pos;
+ char *buffer = _strdup(path);
+ if (!(GetFileAttributesA(buffer) & FILE_ATTRIBUTE_REPARSE_POINT)) { RemoveDirectoryA(buffer); }
+ while (pos = strrchr(buffer, '\\'))
+ {
+ pos[0] = '\0';
+ if (!(GetFileAttributesA(buffer) & FILE_ATTRIBUTE_REPARSE_POINT)) { RemoveDirectoryA(buffer); }
+ }
+ free(buffer);
+}
+
+void RemoveDirectories(wchar_t *path)
+{
+ wchar_t *pos;
+ wchar_t *buffer = _wcsdup(path);
+ if (!(GetFileAttributesW(buffer) & FILE_ATTRIBUTE_REPARSE_POINT)) { RemoveDirectoryW(buffer); }
+ while (pos = wcsrchr(buffer, '\\'))
+ {
+ pos[0] = '\0';
+ if (!(GetFileAttributesW(buffer) & FILE_ATTRIBUTE_REPARSE_POINT)) { RemoveDirectoryW(buffer); }
+ }
+ free(buffer);
+}
+
+int DirectoryExists(char *path)
+{
+ char buffer[4096];
+ GetCurrentDirectoryA(sizeof(buffer), buffer);
+ int res = SetCurrentDirectoryA(path);
+ SetCurrentDirectoryA(buffer);
+ return res;
+}
+
+int DirectoryExists(wchar_t *path)
+{
+ wchar_t buffer[4096];
+ GetCurrentDirectoryW(sizeof(buffer), buffer);
+ int res = SetCurrentDirectoryW(path);
+ SetCurrentDirectoryW(buffer);
+ return res;
+}
+
+
+int GetStringFromDatabase(char *szSettingName, const char *szError, char *szResult, size_t size)
+{
+ DBVARIANT dbv = {0};
+ int res = 1;
+ size_t len;
+ dbv.type = DBVT_ASCIIZ;
+ if (DBGetContactSetting(NULL, ModuleName, szSettingName, &dbv) == 0)
+ {
+ res = 0;
+ size_t tmp = strlen(dbv.pszVal);
+ len = (tmp < size - 1) ? tmp : size - 1;
+ strncpy(szResult, dbv.pszVal, len);
+ szResult[len] = '\0';
+ mir_free(dbv.pszVal);
+ }
+ else{
+ res = 1;
+ size_t tmp = strlen(szError);
+ len = (tmp < size - 1) ? tmp : size - 1;
+ strncpy(szResult, szError, len);
+ szResult[len] = '\0';
+ }
+ return res;
+}
+
+int GetStringFromDatabase(char *szSettingName, const wchar_t *szError, wchar_t *szResult, size_t size)
+{
+ DBVARIANT dbv = {0};
+ int res = 1;
+ size_t len;
+ dbv.type = DBVT_WCHAR;
+ if (DBGetContactSettingWString(NULL, ModuleName, szSettingName, &dbv) == 0)
+ //if (DBGetContactSetting(NULL, ModuleName, szSettingName, &dbv) == 0)
+ {
+ res = 0;
+ size_t tmp = wcslen(dbv.pwszVal);
+ len = (tmp < size - 1) ? tmp : size - 1;
+ wcsncpy(szResult, dbv.pwszVal, len);
+ szResult[len] = '\0';
+ mir_free(dbv.pwszVal);
+ }
+ else{
+ res = 1;
+ size_t tmp = wcslen(szError);
+ len = (tmp < size - 1) ? tmp : size - 1;
+ wcsncpy(szResult, szError, len);
+ szResult[len] = '\0';
+ }
+ return res;
+}
+
+
+int WriteStringToDatabase(char *szSettingName, const char *szValue)
+{
+ return DBWriteContactSettingString(NULL, ModuleName, szSettingName, szValue);
+}
+
+int WriteStringToDatabase(char *szSettingName, const wchar_t *szValue)
+{
+ return DBWriteContactSettingWString(NULL, ModuleName, szSettingName, szValue);
+}
\ No newline at end of file diff --git a/plugins/Folders/folders/utils.h b/plugins/Folders/folders/utils.h new file mode 100644 index 0000000000..066c822900 --- /dev/null +++ b/plugins/Folders/folders/utils.h @@ -0,0 +1,62 @@ +/*
+Custom profile folders plugin for Miranda IM
+
+Copyright © 2005 Cristian Libotean
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef M_FOLDERS_UTILS_H
+#define M_FOLDERS_UTILS_H
+
+#include <stdarg.h>
+#include "commonheaders.h"
+
+int Log(char *format, ...);
+
+char *StrReplace(char *source, const char *what, const char *withWhat);
+char *StrCopy(char *source, size_t index, const char *what, size_t count);
+char *StrDelete(char *source, size_t index, size_t count);
+char *StrInsert(char *source, size_t index, const char *what);
+char *StrTrim(char *szText, const char *szTrimChars);
+
+wchar_t *StrReplace(wchar_t *source, const wchar_t *what, const wchar_t *withWhat);
+wchar_t *StrCopy(wchar_t *source, size_t index, const wchar_t *what, size_t count);
+wchar_t *StrDelete(wchar_t *source, size_t index, size_t count);
+wchar_t *StrInsert(wchar_t *source, size_t index, const wchar_t *what);
+wchar_t *StrTrim(wchar_t *szText, const wchar_t *szTrimChars);
+
+void CreateDirectories(char *szPath);
+void RemoveDirectories(char *szPath);
+int DirectoryExists(char *szPath);
+
+void CreateDirectories(wchar_t *szPath);
+void RemoveDirectories(wchar_t *szPath);
+int DirectoryExists(wchar_t *szPath);
+
+int GetStringFromDatabase(char *szSettingName, const char *szError, char *szResult, size_t size);
+int WriteStringToDatabase(char *szSettingName, const char *szValue);
+
+int GetStringFromDatabase(char *szSettingName, const wchar_t *szError, wchar_t *szResult, size_t size);
+int WriteStringToDatabase(char *szSettingName, const wchar_t *szValue);
+
+__inline static wchar_t *Utils_ReplaceVarsW(wchar_t *szData) {
+ REPLACEVARSDATA dat = {0};
+ dat.cbSize = sizeof(dat);
+ dat.dwFlags = RVF_UNICODE;
+ return (wchar_t *) CallService(MS_UTILS_REPLACEVARS, (WPARAM) szData, (LPARAM) &dat);
+}
+
+#endif
\ No newline at end of file diff --git a/plugins/Folders/folders/variablesHelp.inc b/plugins/Folders/folders/variablesHelp.inc new file mode 100644 index 0000000000..bdc79692e6 --- /dev/null +++ b/plugins/Folders/folders/variablesHelp.inc @@ -0,0 +1,32 @@ +"{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033\\deflangfe1033{\\fonttbl{\\f0\\fswiss\\fprq2\\fcharset0 Arial;}}\n"
+"{\\*\\generator Msftedit 5.41.21.2500;}\\viewkind4\\uc1\\pard\\nowidctlpar\\ri-1686\\f0\\fs20 Don't forget to click on \\i Apply\\i0 to save the changes. If you don't then the changes won't\n"
+"be saved to the database, they will only be valid for this session.\\par"
+"\\pard\\nowidctlpar\\ul\\b\\par\n"
+"Variable string\\ulnone\\b0\\tab\\tab\\ul\\b What it expands to:\\ulnone\\b0\\par\n"
+"%miranda_userdata%\\tab Expands to the private profile data directory.\\par"
+"%miranda_path%\\tab Expands to your miranda path (e.g: c:\\\\program files\\\\miranda im).\\par"
+"%profile_path%\\tab\\tab Expands to your profile path - the value found in mirandaboot.ini,\\par"
+"\\tab\\tab\\tab\\ul ProfileDir\\ulnone section (usually inside miranda's folder).\\par"
+"\\pard\\nowidctlpar\\ri-696 %current_profile%\\tab Expands to your current profile name without the extenstion.\\par"
+"\\tab\\tab\\tab (e.g.\\b default\\b0 if your your profile is \\i default.dat\\i0 ).\\par"
+"\\par\n"
+"\\ul\\b Environment variables\\par\n"
+"\\ulnone\\b0 The plugin can also expand environment variables; the variables are specified like in any other\n"
+"program that can use environment variables, i.e. %<env variable>%.\n\n"
+"\\b Note\\b0 : Environment variables are expanded before any Miranda variables. So if you have, for\n"
+"example, %profile_path% defined as a system variable then it will be expanded to that value\\n"
+"instead of expanding to Miranda\\rquote s profile path.\\par\n"
+"\\ul\\b Examples:\\par\n"
+"\\ulnone\\b0 If the value for the ProfileDir inside \\i mirandaboot.ini\\i0 , \\ul ProfileDir\\ulnone section is '.\\\\profiles', current\n"
+"profile is 'default.dat' and miranda's path is 'c:\\\\program files\\\\miranda im' then:\\par\n"
+"\\b %miranda_path%\\b0 \\tab\\tab\\tab will expand to 'c:\\\\program files\\\\miranda im'\\par"
+"\\b %profile_path%\\b0 \\tab\\tab\\tab will expand to 'c:\\\\program files\\\\miranda im\\\\profiles'\\par"
+"\\b %current_profile%\\b0\\tab\\tab\\tab will expand to 'default'\\par"
+"\\b %temp%\\b0\\tab\\tab\\tab\\tab will expand to the temp folder of the current user.\\par"
+"\\b %profile_path%\\\\%current_profile%\\tab\\b0 will expand to 'c:\\\\program files\\\\miranda im\\\\profiles\\\\default'\\par"
+"\\b %miranda_path%\\\\plugins\\\\config\\b0\\tab will expand to 'c:\\\\program files\\\\miranda im\\\\plugins\\\\config'\\par"
+"\\b ' %miranda_path%\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ '\\b0\\tab will expand to 'c:\\\\program files\\\\miranda im'\\par\n"
+"notice that the spaces at the beginning and the end of the string are trimmed, as well as the last \\\\\\par\n"
+"}\n"
+"\n"
+"\n"
diff --git a/plugins/Folders/folders/version.h b/plugins/Folders/folders/version.h new file mode 100644 index 0000000000..77f4d886fa --- /dev/null +++ b/plugins/Folders/folders/version.h @@ -0,0 +1,49 @@ +/*
+Custom profile folders plugin for Miranda IM
+
+Copyright © 2005-2012 Cristian Libotean
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef M_FOLDERS_VERSION_H
+#define M_FOLDERS_VERSION_H
+
+#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 1
+#define __RELEASE_NUM 6
+#define __BUILD_NUM 0
+
+#define VERSION PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM)
+
+#define __PLUGINVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
+#define __PLUGINVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM
+#define __STRINGIFY_(x) #x
+#define __STRINGIFY(x) __STRINGIFY_(x)
+#define __VERSION_STRING __STRINGIFY(__PLUGINVERSION_STRING_DOTS)
+
+#define __DESC "Service plugin. Allows plugins to save their data to user selected folders; supports variables."
+#define __AUTHOR "Cristian Libotean"
+#define __AUTHOREMAIL "eblis102@yahoo.com"
+#define __COPYRIGHT "© 2005-2012 Cristian Libotean"
+#define __AUTHORWEB "http://www.miranda-im.org/"
+
+#if defined(WIN64) || defined(_WIN64)
+#define __PLUGIN_DISPLAY_NAME "Custom profile folders (x64)"
+#else
+#define __PLUGIN_DISPLAY_NAME "Custom profile folders"
+#endif
+
+#endif //M_FOLDERS_VERSION_H
diff --git a/plugins/Folders/folders/version.rc b/plugins/Folders/folders/version.rc new file mode 100644 index 0000000000..0f8fea03fc --- /dev/null +++ b/plugins/Folders/folders/version.rc @@ -0,0 +1,100 @@ +// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+#include "version.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
+ "resource1.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION __PLUGINVERSION_STRING
+ PRODUCTVERSION __PLUGINVERSION_STRING
+ FILEFLAGSMASK 0x17L
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "Author", __AUTHOR
+ VALUE "FileDescription", __DESC
+ VALUE "FileVersion", __VERSION_STRING
+ VALUE "InternalName", __PLUGIN_DISPLAY_NAME
+ VALUE "LegalCopyright", __COPYRIGHT
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/plugins/Folders/pack source.bat b/plugins/Folders/pack source.bat new file mode 100644 index 0000000000..3c501be7dc --- /dev/null +++ b/plugins/Folders/pack source.bat @@ -0,0 +1,8 @@ +for /F "tokens=5-9* delims=. " %%i in (docs\folders_readme.txt) do (call :Pack %%i %%j %%k %%l; exit)
+
+:Pack
+d:\usr\7z\7za.exe a -i@files_source.txt -xr!*.zip -xr!*.ncb -xr!*.user -xr!*.sdf "Folders src %1.%2.%3.%4.zip" @files_source.txt
+exit
+
+error:
+echo "Error packing Folders"
diff --git a/plugins/Folders/pack symbols.bat b/plugins/Folders/pack symbols.bat new file mode 100644 index 0000000000..49cdec46c7 --- /dev/null +++ b/plugins/Folders/pack symbols.bat @@ -0,0 +1,9 @@ +@echo off
+if NOT EXIST "symbols\%1 - %3" (
+ mkdir "symbols\%1 - %3"
+)
+xcopy "%2\win32\Release\*.pdb" "symbols\%1 - %3\win32\*" /EXCLUDE:symbols_exclude.txt /Y
+xcopy "%2\x64\Release\*.pdb" "symbols\%1 - %3\x64\*" /EXCLUDE:symbols_exclude.txt /Y
+
+d:\usr\7z\7za.exe u -i!symbols\*.* "symbols - %1.zip"
+rmdir "symbols\" /Q /S
\ No newline at end of file diff --git a/plugins/Folders/pack x64.bat b/plugins/Folders/pack x64.bat new file mode 100644 index 0000000000..befc247b4b --- /dev/null +++ b/plugins/Folders/pack x64.bat @@ -0,0 +1,13 @@ +copy folders\m_folders.h docs /y
+for /F "tokens=5-9* delims=. " %%i in (docs\folders_readme.txt) do (call :Pack %%i %%j %%k %%l; exit)
+
+:Pack
+xcopy folders\x64\release\folders.dll . /y
+xcopy folders\m_folders.h docs\m_folders.h /y
+d:\usr\7z\7za.exe a -i!docs\*.* -i!Folders.dll "Folders %1.%2.%3.%4 x64.zip"
+del folders.dll
+call "pack symbols.bat" Folders Folders %1.%2.%3.%4
+exit
+
+error:
+echo "Error packing Folders"
\ No newline at end of file diff --git a/plugins/Folders/pack.bat b/plugins/Folders/pack.bat new file mode 100644 index 0000000000..a0bb14ed37 --- /dev/null +++ b/plugins/Folders/pack.bat @@ -0,0 +1,13 @@ +copy folders\m_folders.h docs /y
+for /F "tokens=5-9* delims=. " %%i in (docs\folders_readme.txt) do (call :Pack %%i %%j %%k %%l; exit)
+
+:Pack
+xcopy folders\win32\release\folders.dll . /y
+xcopy folders\m_folders.h docs\m_folders.h /y
+d:\usr\7z\7za.exe a -i!docs\*.* -i!Folders.dll "Folders %1.%2.%3.%4 x32.zip"
+del folders.dll
+call "pack symbols.bat" Folders Folders %1.%2.%3.%4
+exit
+
+error:
+echo "Error packing Folders"
\ No newline at end of file diff --git a/plugins/Folders/rtf convert.bat b/plugins/Folders/rtf convert.bat new file mode 100644 index 0000000000..6a301622ab --- /dev/null +++ b/plugins/Folders/rtf convert.bat @@ -0,0 +1 @@ +"rtf converter.exe" "variables help.doc" ".\folders\variablesHelp.inc"
\ No newline at end of file diff --git a/plugins/Folders/rtf converter.exe b/plugins/Folders/rtf converter.exe Binary files differnew file mode 100644 index 0000000000..f932bbca43 --- /dev/null +++ b/plugins/Folders/rtf converter.exe diff --git a/plugins/Folders/rtf converter/rtf converter.cpp b/plugins/Folders/rtf converter/rtf converter.cpp new file mode 100644 index 0000000000..8d51c0d79a --- /dev/null +++ b/plugins/Folders/rtf converter/rtf converter.cpp @@ -0,0 +1,103 @@ +#define _CRT_SECURE_NO_DEPRECATE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define MAX_PATH 260
+#define DEFAULT_OUTPUT "output.inc"
+
+void PrintUsage(char *programPath)
+{
+ printf("Usage\n");
+ printf("%s input.doc [output.inc]\n", programPath);
+ printf("\nConverts a rtf text found in input.doc to a string that contains the rtf text and stores it in output.inc");
+}
+
+void Add(char *result, char *what)
+{
+ strcat(result, what);
+}
+
+void Add(char *result, char chr)
+{
+ int len = strlen(result);
+ result[len++] = chr;
+ result[len] = '\0';
+}
+
+void Convert(char *input, char *output)
+{
+ int len = strlen(input);
+ int i;
+ output[0] = '\0';
+ Add(output, '\"');
+ for (i = 0; i < len; i++)
+ {
+ switch (input[i])
+ {
+ case '\"':
+ Add(output, "\"\"");
+ break;
+ case '\\':
+ Add(output, "\\\\");
+ break;
+ case '\n':
+ Add(output, "\\n");
+ break;
+ default:
+ Add(output, input[i]);
+ }
+ }
+ Add(output, "\"\n");
+}
+
+void DoConversion(char *inFile, char *outFile)
+{
+ FILE *fin = fopen(inFile, "rt");
+ FILE *fout = fopen(outFile, "wt");
+ char buffer[2048];
+ char out[4096];
+ if ((fin) && (fout))
+ {
+ while (!feof(fin))
+ {
+ fgets(buffer, sizeof(buffer), fin);
+ if (strlen(buffer) > 0)
+ {
+ Convert(buffer, out);
+ fputs(out, fout);
+ }
+ }
+ }
+ if (fin)
+ {
+ fclose(fin);
+ }
+ if (fout)
+ {
+ fclose(fout);
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ char input[MAX_PATH];
+ char output[MAX_PATH];
+ if ((argc < 2) || (argc > 3))
+ {
+ PrintUsage(argv[0]);
+ return 0;
+ }
+ strcpy(input, argv[1]);
+ if (argc == 3)
+ {
+ strcpy(output, argv[2]);
+ }
+ else{
+ strcpy(output, DEFAULT_OUTPUT);
+ }
+ DoConversion(input, output);
+ return 0;
+}
+
diff --git a/plugins/Folders/symbols_exclude.txt b/plugins/Folders/symbols_exclude.txt new file mode 100644 index 0000000000..361cf2448b --- /dev/null +++ b/plugins/Folders/symbols_exclude.txt @@ -0,0 +1 @@ +vc80.pdb
\ No newline at end of file diff --git a/plugins/Folders/variables help.doc b/plugins/Folders/variables help.doc Binary files differnew file mode 100644 index 0000000000..5b9ba27a62 --- /dev/null +++ b/plugins/Folders/variables help.doc |