summaryrefslogtreecommitdiff
path: root/plugins/Folders
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-03-09 10:01:40 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-03-09 10:01:40 +0000
commit8e161a2db88720840dc979cb9fe1f0c38742787d (patch)
tree04f7429264e4dbbb4da6e0c9ab71df0dec860aee /plugins/Folders
parent68e5eb0709241968a1b91fb53e4c4cba27581a4a (diff)
Folders:
- custom array class removed; - a lot of junk also removed; - version bump; git-svn-id: http://svn.miranda-ng.org/main/trunk@3931 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Folders')
-rw-r--r--plugins/Folders/folders_11.vcxproj4
-rw-r--r--plugins/Folders/folders_11.vcxproj.filters12
-rw-r--r--plugins/Folders/src/commonheaders.h7
-rw-r--r--plugins/Folders/src/dlg_handlers.cpp292
-rw-r--r--plugins/Folders/src/dlg_handlers.h26
-rw-r--r--plugins/Folders/src/folderItem.h3
-rw-r--r--plugins/Folders/src/folders.cpp10
-rw-r--r--plugins/Folders/src/foldersList.cpp161
-rw-r--r--plugins/Folders/src/foldersList.h67
-rw-r--r--plugins/Folders/src/hooked_events.cpp21
-rw-r--r--plugins/Folders/src/hooked_events.h32
-rw-r--r--plugins/Folders/src/services.cpp47
-rw-r--r--plugins/Folders/src/services.h2
-rw-r--r--plugins/Folders/src/version.h2
14 files changed, 176 insertions, 510 deletions
diff --git a/plugins/Folders/folders_11.vcxproj b/plugins/Folders/folders_11.vcxproj
index 4c0858773e..6cda62f9f2 100644
--- a/plugins/Folders/folders_11.vcxproj
+++ b/plugins/Folders/folders_11.vcxproj
@@ -187,7 +187,6 @@
<ClCompile Include="src\events.cpp" />
<ClCompile Include="src\folderItem.cpp" />
<ClCompile Include="src\folders.cpp" />
- <ClCompile Include="src\foldersList.cpp" />
<ClCompile Include="src\hooked_events.cpp" />
<ClCompile Include="src\services.cpp" />
<ClCompile Include="src\stdafx.cpp">
@@ -198,11 +197,8 @@
<ItemGroup>
<ClInclude Include="..\ExternalAPI\m_folders.h" />
<ClInclude Include="src\commonheaders.h" />
- <ClInclude Include="src\dlg_handlers.h" />
<ClInclude Include="src\events.h" />
<ClInclude Include="src\folderItem.h" />
- <ClInclude Include="src\foldersList.h" />
- <ClInclude Include="src\hooked_events.h" />
<ClInclude Include="src\resource.h" />
<ClInclude Include="src\services.h" />
<ClInclude Include="src\utils.h" />
diff --git a/plugins/Folders/folders_11.vcxproj.filters b/plugins/Folders/folders_11.vcxproj.filters
index 30086fbee5..b448912cca 100644
--- a/plugins/Folders/folders_11.vcxproj.filters
+++ b/plugins/Folders/folders_11.vcxproj.filters
@@ -27,9 +27,6 @@
<ClCompile Include="src\folders.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="src\foldersList.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="src\hooked_events.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -47,21 +44,12 @@
<ClInclude Include="src\commonheaders.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="src\dlg_handlers.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="src\events.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\folderItem.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="src\foldersList.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="src\hooked_events.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="src\resource.h">
<Filter>Header Files</Filter>
</ClInclude>
diff --git a/plugins/Folders/src/commonheaders.h b/plugins/Folders/src/commonheaders.h
index 0734f8db26..ea5965af69 100644
--- a/plugins/Folders/src/commonheaders.h
+++ b/plugins/Folders/src/commonheaders.h
@@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define MAX_FOLDER_SIZE 2048
#include <windows.h>
+#include <richedit.h>
#include <newpluginapi.h>
#include <m_database.h>
@@ -34,13 +35,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <m_variables.h>
#include <m_folders.h>
+#include <m_langpack.h>
#include "version.h"
#include "utils.h"
#include "resource.h"
-#include "foldersList.h"
-#include "dlg_handlers.h"
-#include "hooked_events.h"
#include "services.h"
#include "events.h"
#include "folderItem.h"
@@ -53,6 +52,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern char ModuleName[];
extern HINSTANCE hInstance;
-extern CFoldersList &lstRegisteredFolders;
+extern OBJLIST<CFolderItem> lstRegisteredFolders;
#endif //FOLDERS_COMMONHEADERS_H \ No newline at end of file
diff --git a/plugins/Folders/src/dlg_handlers.cpp b/plugins/Folders/src/dlg_handlers.cpp
index 8bd851f207..4419aeb6e1 100644
--- a/plugins/Folders/src/dlg_handlers.cpp
+++ b/plugins/Folders/src/dlg_handlers.cpp
@@ -4,45 +4,13 @@ PFolderItem lastItem = NULL;
static int bInitializing = 0;
-int GetCurrentItemSelection(HWND hWnd)
+static PFolderItem GetSelectedItem(HWND hWnd)
{
- return SendDlgItemMessage(hWnd, IDC_FOLDERS_ITEMS_LIST, LB_GETCURSEL, 0, 0);
-}
-
-int GetCurrentSectionSelection(HWND hWnd)
-{
- return SendDlgItemMessage(hWnd, IDC_FOLDERS_SECTIONS_LIST, LB_GETCURSEL, 0, 0);
-}
-
-int GetCurrentItemText(HWND hWnd, TCHAR *buffer, int count)
-{
- int index = GetCurrentItemSelection(hWnd);
- if (index != LB_ERR) {
- SendDlgItemMessage(hWnd, IDC_FOLDERS_ITEMS_LIST, LB_GETTEXT, index, (LPARAM)buffer);
- return 1;
- }
-
- buffer[0] = L'\0';
- return 0;
-}
-
-int GetCurrentSectionText(HWND hWnd, char *buffer, int count)
-{
- int index = GetCurrentSectionSelection(hWnd);
- if (index != LB_ERR)
- SendDlgItemMessageA(hWnd, IDC_FOLDERS_SECTIONS_LIST, LB_GETTEXT, index, (LPARAM)buffer);
- else
- buffer[0] = L'0';
- return index;
-}
-
-PFolderItem GetSelectedItem(HWND hWnd)
-{
- char section[MAX_FOLDER_SIZE];
- TCHAR item[MAX_FOLDER_SIZE];
- GetCurrentItemText(hWnd, item, MAX_FOLDER_SIZE);
- GetCurrentSectionText(hWnd, section, MAX_FOLDER_SIZE);
- return lstRegisteredFolders.GetTranslated(section, item);
+ int index = SendDlgItemMessage(hWnd, IDC_FOLDERS_ITEMS_LIST, LB_GETCURSEL, 0, 0);
+ if (index == LB_ERR)
+ return NULL;
+
+ return (PFolderItem)SendDlgItemMessage(hWnd, IDC_FOLDERS_ITEMS_LIST, LB_GETITEMDATA, index, 0);
}
static void GetEditText(HWND hWnd, TCHAR *buffer, int size)
@@ -50,60 +18,72 @@ static void GetEditText(HWND hWnd, TCHAR *buffer, int size)
GetWindowText( GetDlgItem(hWnd, IDC_FOLDER_EDIT), buffer, size);
}
-void SetEditText(HWND hWnd, const TCHAR *buffer)
+static void SetEditText(HWND hWnd, const TCHAR *buffer)
{
bInitializing = 1;
SetWindowText(GetDlgItem(hWnd, IDC_FOLDER_EDIT), buffer);
bInitializing = 0;
}
-int ContainsSection(HWND hWnd, const WCHAR *section)
+static int ContainsSection(HWND hWnd, const TCHAR *section)
{
- int index = SendDlgItemMessage(hWnd, IDC_FOLDERS_SECTIONS_LIST, LB_FINDSTRINGEXACT, -1, (LPARAM) section);
+ int index = SendDlgItemMessage(hWnd, IDC_FOLDERS_SECTIONS_LIST, LB_FINDSTRINGEXACT, -1, (LPARAM)section);
return (index != LB_ERR);
}
-void LoadRegisteredFolderSections(HWND hWnd)
+static void LoadRegisteredFolderSections(HWND hWnd)
{
HWND hwndList = GetDlgItem(hWnd, IDC_FOLDERS_SECTIONS_LIST);
- for (int i = 0; i < lstRegisteredFolders.Count(); i++) {
- PFolderItem tmp = lstRegisteredFolders.Get(i + 1);
- TCHAR *translated = mir_a2t( tmp->GetSection());
+ for (int i=0; i < lstRegisteredFolders.getCount(); i++) {
+ CFolderItem &tmp = lstRegisteredFolders[i];
+ TCHAR *translated = mir_a2t( tmp.GetSection());
if ( !ContainsSection(hWnd, TranslateTS(translated))) {
int idx = SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)TranslateTS(translated));
- SendMessage(hwndList, LB_SETITEMDATA, idx, (LPARAM)tmp->GetSection());
+ SendMessage(hwndList, LB_SETITEMDATA, idx, (LPARAM)tmp.GetSection());
}
mir_free(translated);
}
}
-void LoadRegisteredFolderItems(HWND hWnd)
+static void LoadRegisteredFolderItems(HWND hWnd)
{
- int idx = GetCurrentSectionSelection(hWnd);
+ int idx = SendDlgItemMessage(hWnd, IDC_FOLDERS_SECTIONS_LIST, LB_GETCURSEL, 0, 0);
char* szSection = (char*)SendDlgItemMessage(hWnd, IDC_FOLDERS_SECTIONS_LIST, LB_GETITEMDATA, idx, 0);
- SendDlgItemMessage(hWnd, IDC_FOLDERS_ITEMS_LIST, LB_RESETCONTENT, 0, 0);
+ HWND hwndItems = GetDlgItem(hWnd, IDC_FOLDERS_ITEMS_LIST);
+ SendMessage(hwndItems, LB_RESETCONTENT, 0, 0);
- for (int i = 0; i < lstRegisteredFolders.Count(); i++) {
- PFolderItem item = lstRegisteredFolders.Get(i + 1);
- if ( !strcmp(szSection, item->GetSection()))
- SendDlgItemMessage(hWnd, IDC_FOLDERS_ITEMS_LIST, LB_ADDSTRING, 0, (LPARAM)TranslateTS(item->GetUserName()));
+ for (int i=0; i < lstRegisteredFolders.getCount(); i++) {
+ CFolderItem &item = lstRegisteredFolders[i];
+ if ( !strcmp(szSection, item.GetSection())) {
+ int idx = SendMessage(hwndItems, LB_ADDSTRING, 0, (LPARAM)TranslateTS(item.GetUserName()));
+ SendMessage(hwndItems, LB_SETITEMDATA, idx, (LPARAM)&item);
+ }
}
- SendDlgItemMessage(hWnd, IDC_FOLDERS_ITEMS_LIST, LB_SETCURSEL, 0, 0); //select the first item
+ SendMessage(hwndItems, 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)
+static void RefreshPreview(HWND hWnd)
{
- if (item) {
- SetEditText(hWnd, item->GetFormat());
- RefreshPreview(hWnd);
- }
+ TCHAR tmp[MAX_FOLDER_SIZE], res[MAX_FOLDER_SIZE];
+ GetEditText(hWnd, tmp, MAX_FOLDER_SIZE);
+ ExpandPath(res, tmp, MAX_FOLDER_SIZE);
+ SetWindowText(GetDlgItem(hWnd, IDC_PREVIEW_EDIT), res);
+}
+
+static void LoadItem(HWND hWnd, PFolderItem item)
+{
+ if (!item)
+ return;
+
+ SetEditText(hWnd, item->GetFormat());
+ RefreshPreview(hWnd);
}
-void SaveItem(HWND hWnd, PFolderItem item, int bEnableApply)
+static void SaveItem(HWND hWnd, PFolderItem item, int bEnableApply)
{
if (!item)
return;
@@ -116,44 +96,84 @@ void SaveItem(HWND hWnd, PFolderItem item, int bEnableApply)
SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0);
}
-int ChangesNotSaved(HWND hWnd, PFolderItem item)
+static int ChangesNotSaved(HWND hWnd, PFolderItem item)
{
- int res = 0;
- if (item) {
- TCHAR buffer[MAX_FOLDER_SIZE];
- GetEditText(hWnd, buffer, MAX_FOLDER_SIZE);
- res = _tcscmp(item->GetFormat(), buffer) != 0;
- }
-
- return res;
+ if (!item)
+ return 0;
+
+ TCHAR buffer[MAX_FOLDER_SIZE];
+ GetEditText(hWnd, buffer, MAX_FOLDER_SIZE);
+ return _tcscmp(item->GetFormat(), buffer) != 0;
}
-void CheckForChanges(HWND hWnd, int bNeedConfirmation = 1)
+static void CheckForChanges(HWND hWnd, int bNeedConfirmation = 1)
{
if (ChangesNotSaved(hWnd, lastItem))
if ((!bNeedConfirmation) || MessageBox(hWnd, TranslateT("Some changes weren't saved. Apply the changes now ?"), TranslateT("Changes not saved"), MB_YESNO | MB_ICONINFORMATION) == IDYES)
- SaveItem(hWnd, lastItem);
+ SaveItem(hWnd, lastItem, TRUE);
}
-void RefreshPreview(HWND hWnd)
+/************************************** DIALOG HANDLERS *************************************/
+
+static INT_PTR CALLBACK DlgProcVariables(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- TCHAR tmp[MAX_FOLDER_SIZE], res[MAX_FOLDER_SIZE];
- GetEditText(hWnd, tmp, MAX_FOLDER_SIZE);
- ExpandPath(res, tmp, MAX_FOLDER_SIZE);
- SetWindowText(GetDlgItem(hWnd, IDC_PREVIEW_EDIT), res);
-}
+ TCHAR tszMessage[2048];
+ switch (msg) {
+ case WM_INITDIALOG:
+ mir_sntprintf(tszMessage, SIZEOF(tszMessage), _T("%s\r\n%s\r\n\r\n%s\t\t%s\r\n%%miranda_path%%\t\t%s\r\n%%profile_path%%\t\t%s\r\n\t\t\t%s\r\n%%current_profile%%\t\t%s\r\n\t\t\t%s\r\n\r\n\r\n%s\r\n%s\r\n%s\r\n%s\r\n%s\r\n%s\r\n\r\n%s\r\n%s\r\n%s\r\n%%miranda_path%%\t\t\t%s\r\n%%profile_path%%\t\t\t%s\r\n%%current_profile%%\t\t\t%s\r\n%%temp%%\t\t\t\t%s\r\n%%profile_path%%\\%%current_profile%%\t%s\r\n%%miranda_path%%\\plugins\\config\t%s\r\n\' %%miranda_path%%\\\\\\\\ \'\t\t%s\r\n\r\n%s"),
+ TranslateT("Don\'t forget to click on Apply to save the changes. If you don\'t then the changes won\'t"),
+ TranslateT("be saved to the database, they will only be valid for this session."),
+ TranslateT("Variable string"),
+ TranslateT("What it expands to:"),
+ TranslateT("Expands to your miranda path (e.g: c:\\program files\\miranda ng)."),
+ TranslateT("Expands to your profile path - the value found in mirandaboot.ini,"),
+ TranslateT("ProfileDir section (usually inside miranda\'s folder)."),
+ TranslateT("Expands to your current profile name without the extenstion."),
+ TranslateT("(e.g.default if your your profile is default.dat)."),
+ TranslateT("Environment variables"),
+ TranslateT("The plugin can also expand environment variables; the variables are specified like in any other"),
+ TranslateT("program that can use environment variables, i.e. %<env variable>%."),
+ TranslateT("Note: Environment variables are expanded before any Miranda variables. So if you have, for"),
+ TranslateT("example, %profile_path% defined as a system variable then it will be expanded to that value"),
+ TranslateT("instead of expanding to Miranda\'s profile path."),
+ TranslateT("Examples:"),
+ TranslateT("If the value for the ProfileDir inside mirandaboot.ini, ProfileDir section is \'.\\profiles\\', current"),
+ TranslateT("profile is \'default.dat\' and miranda\'s path is \'c:\\program files\\miranda ng\\' then:"),
+ TranslateT("will expand to \'c:\\program files\\miranda ng\'"),
+ TranslateT("will expand to \'c:\\program files\\miranda ng\\profiles\'"),
+ TranslateT("will expand to \'default\'"),
+ TranslateT("will expand to the temp folder of the current user."),
+ TranslateT("will expand to \'c:\\program files\\miranda ng\\profiles\\default\'"),
+ TranslateT("will expand to \'c:\\program files\\miranda ng\\plugins\\config\'"),
+ TranslateT("will expand to \'c:\\program files\\miranda ng\'"),
+ TranslateT("Notice that the spaces at the beginning and the end of the string are trimmed, as well as the last."));
+ SetDlgItemText(hWnd, IDC_HELP_RICHEDIT, tszMessage);
+ TranslateDialogDefault(hWnd);
+ break;
-/************************************** DIALOG HANDLERS *************************************/
-#include "commctrl.h"
+ case WM_CLOSE:
+ DestroyWindow(hWnd);
+ break;
+
+ case WM_COMMAND:
+ if (LOWORD(wParam) == IDCLOSE)
+ DestroyWindow(hWnd);
+ break;
+ }
+
+ return 0;
+}
-INT_PTR CALLBACK DlgProcOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+static INT_PTR CALLBACK DlgProcOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
+ PFolderItem item;
+
switch (msg) {
case WM_INITDIALOG:
- bInitializing = 1;
lastItem = NULL;
TranslateDialogDefault(hWnd);
+ bInitializing = 1;
LoadRegisteredFolderSections(hWnd);
bInitializing = 0;
break;
@@ -174,10 +194,7 @@ INT_PTR CALLBACK DlgProcOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
break;
case IDC_HELP_BUTTON:
- {
- HWND helpDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_VARIABLES_HELP), hWnd, DlgProcVariables);
- ShowWindow(helpDlg, SW_SHOW);
- }
+ ShowWindow( CreateDialog(hInstance, MAKEINTRESOURCE(IDD_VARIABLES_HELP), hWnd, DlgProcVariables), SW_SHOW);
break;
case IDC_FOLDERS_SECTIONS_LIST:
@@ -188,29 +205,20 @@ INT_PTR CALLBACK DlgProcOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
lastItem = NULL;
SetEditText(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;
+ item = GetSelectedItem(hWnd);
+ if (item != NULL) {
+ CheckForChanges(hWnd);
+ LoadItem(hWnd, item);
}
+ lastItem = item;
}
-
- break;
}
-
break;
case WM_NOTIFY:
@@ -218,18 +226,15 @@ INT_PTR CALLBACK DlgProcOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
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;
+ item = GetSelectedItem(hWnd);
+ if (item) {
+ SaveItem(hWnd, item, FALSE);
+ LoadItem(hWnd, item);
}
+
+ for (int i=0; i < lstRegisteredFolders.getCount(); i++)
+ lstRegisteredFolders[i].Save();
+ CallPathChangedEvents();
}
}
break;
@@ -238,56 +243,23 @@ INT_PTR CALLBACK DlgProcOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
return 0;
}
-INT_PTR CALLBACK DlgProcVariables(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+static int OnOptionsInitialize(WPARAM wParam, LPARAM lParam)
{
- switch (msg) {
- case WM_INITDIALOG:
- {
- TCHAR tszMessage[2048];
- mir_sntprintf(tszMessage, SIZEOF(tszMessage), _T("%s\r\n%s\r\n\r\n%s\t\t%s\r\n%%miranda_path%%\t\t%s\r\n%%profile_path%%\t\t%s\r\n\t\t\t%s\r\n%%current_profile%%\t\t%s\r\n\t\t\t%s\r\n\r\n\r\n%s\r\n%s\r\n%s\r\n%s\r\n%s\r\n%s\r\n\r\n%s\r\n%s\r\n%s\r\n%%miranda_path%%\t\t\t%s\r\n%%profile_path%%\t\t\t%s\r\n%%current_profile%%\t\t\t%s\r\n%%temp%%\t\t\t\t%s\r\n%%profile_path%%\\%%current_profile%%\t%s\r\n%%miranda_path%%\\plugins\\config\t%s\r\n\' %%miranda_path%%\\\\\\\\ \'\t\t%s\r\n\r\n%s"),
- TranslateT("Don\'t forget to click on Apply to save the changes. If you don\'t then the changes won\'t"),
- TranslateT("be saved to the database, they will only be valid for this session."),
- TranslateT("Variable string"),
- TranslateT("What it expands to:"),
- TranslateT("Expands to your miranda path (e.g: c:\\program files\\miranda ng)."),
- TranslateT("Expands to your profile path - the value found in mirandaboot.ini,"),
- TranslateT("ProfileDir section (usually inside miranda\'s folder)."),
- TranslateT("Expands to your current profile name without the extenstion."),
- TranslateT("(e.g.default if your your profile is default.dat)."),
- TranslateT("Environment variables"),
- TranslateT("The plugin can also expand environment variables; the variables are specified like in any other"),
- TranslateT("program that can use environment variables, i.e. %<env variable>%."),
- TranslateT("Note: Environment variables are expanded before any Miranda variables. So if you have, for"),
- TranslateT("example, %profile_path% defined as a system variable then it will be expanded to that value"),
- TranslateT("instead of expanding to Miranda\'s profile path."),
- TranslateT("Examples:"),
- TranslateT("If the value for the ProfileDir inside mirandaboot.ini, ProfileDir section is \'.\\profiles\\', current"),
- TranslateT("profile is \'default.dat\' and miranda\'s path is \'c:\\program files\\miranda ng\\' then:"),
- TranslateT("will expand to \'c:\\program files\\miranda ng\'"),
- TranslateT("will expand to \'c:\\program files\\miranda ng\\profiles\'"),
- TranslateT("will expand to \'default\'"),
- TranslateT("will expand to the temp folder of the current user."),
- TranslateT("will expand to \'c:\\program files\\miranda ng\\profiles\\default\'"),
- TranslateT("will expand to \'c:\\program files\\miranda ng\\plugins\\config\'"),
- TranslateT("will expand to \'c:\\program files\\miranda ng\'"),
- TranslateT("Notice that the spaces at the beginning and the end of the string are trimmed, as well as the last."));
- SetDlgItemText(hWnd, IDC_HELP_RICHEDIT, tszMessage);
- TranslateDialogDefault(hWnd);
- }
- break;
-
- case WM_CLOSE:
- DestroyWindow(hWnd);
- break;
-
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDCLOSE:
- DestroyWindow(hWnd);
- break;
- }
- break;
- }
-
+ OPTIONSDIALOGPAGE odp = { sizeof(odp) };
+ odp.position = 100000000;
+ odp.hInstance = hInstance;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_FOLDERS);
+ odp.pszTitle = LPGEN("Folders");
+ odp.pszGroup = LPGEN("Customize");
+ odp.groupPosition = 910000000;
+ odp.flags = ODPF_BOLDGROUPS;
+ odp.pfnDlgProc = DlgProcOpts;
+ Options_AddPage(wParam, &odp);
+
return 0;
}
+
+void InitOptions()
+{
+ HookEvent(ME_OPT_INITIALISE, OnOptionsInitialize);
+}
diff --git a/plugins/Folders/src/dlg_handlers.h b/plugins/Folders/src/dlg_handlers.h
deleted file mode 100644
index 18de486289..0000000000
--- a/plugins/Folders/src/dlg_handlers.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#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, char *buffer, int count);
-int GetCurrentItemText(HWND hWnd, char *buffer, int count);
-void GetEditText(HWND hWnd, TCHAR *buffer, int size);
-void SetEditText(HWND hWnd, const TCHAR *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/src/folderItem.h b/plugins/Folders/src/folderItem.h
index 1883cad207..385d7ae4a6 100644
--- a/plugins/Folders/src/folderItem.h
+++ b/plugins/Folders/src/folderItem.h
@@ -37,8 +37,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
class CFolderItem
{
- char *m_szSection;
- char *m_szName;
+ char *m_szSection, *m_szName;
TCHAR *m_tszFormat, *m_tszOldFormat, *m_tszUserName;
void GetDataFromDatabase(const TCHAR *szNotFound);
diff --git a/plugins/Folders/src/folders.cpp b/plugins/Folders/src/folders.cpp
index e44a7f7485..3abfef1f55 100644
--- a/plugins/Folders/src/folders.cpp
+++ b/plugins/Folders/src/folders.cpp
@@ -24,7 +24,7 @@ char ModuleName[] = "Folders";
HINSTANCE hInstance;
int hLangpack;
-CFoldersList &lstRegisteredFolders = CFoldersList(10); //the list
+OBJLIST<CFolderItem> lstRegisteredFolders(10, OBJLIST<CFolderItem>::FTSortFunc(PtrKeySortT));
PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
@@ -40,7 +40,7 @@ PLUGININFOEX pluginInfo = {
{0x2f129563, 0x2c7d, 0x4a9a, {0xb9, 0x48, 0x97, 0xdf, 0xcc, 0x0a, 0xfd, 0xd7}}
};
-extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD mirandaVersion)
+extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD mirandaVersion)
{
return &pluginInfo;
}
@@ -48,10 +48,10 @@ extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD miranda
extern "C" __declspec(dllexport) int Load(void)
{
mir_getLP(&pluginInfo);
-
+
InitServices();
InitEvents();
- HookEvents();
+ InitOptions();
return 0;
}
@@ -61,7 +61,7 @@ extern "C" __declspec(dllexport) int Unload()
return 0;
}
-bool WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
hInstance = hinstDLL;
return TRUE;
diff --git a/plugins/Folders/src/foldersList.cpp b/plugins/Folders/src/foldersList.cpp
deleted file mode 100644
index 1f7ab3aef5..0000000000
--- a/plugins/Folders/src/foldersList.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
-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"
-
-CFoldersList::CFoldersList(int initialSize)
-{
- capacity = 0;
- count = 0;
- list = NULL;
- Enlarge(initialSize);
-}
-
-CFoldersList::~CFoldersList()
-{
- Clear();
- free(list);
-}
-
-void CFoldersList::Clear()
-{
- for (int i = 0; i < count; i++)
- delete (list[i]);
-
- count = 0;
-}
-
-int CFoldersList::Count()
-{
- return count;
-}
-
-int CFoldersList::Capacity()
-{
- return capacity;
-}
-
-void CFoldersList::Save()
-{
- for (int 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 TCHAR *name)
-{
- for (int i = 0; i < count; i++)
- if (list[i]->IsEqual(section, name))
- return list[i];
-
- return NULL;
-}
-
-PFolderItem CFoldersList::GetTranslated(const char *trSection, const TCHAR *trName)
-{
- for (int i = 0; i < count; i++)
- if (list[i]->IsEqualTranslated(trSection, trName))
- return list[i];
-
- return NULL;
-}
-
-int CFoldersList::Expand(int index, TCHAR *szResult, int size)
-{
- PFolderItem tmp = Get(index);
- if (tmp) {
- tmp->Expand(szResult, size);
- return 0;
- }
-
- memset(szResult, 0, size);
- return 1;
-}
-
-int CFoldersList::Add(CFolderItem *item)
-{
- EnsureCapacity();
- int pos = Contains(item);
- if (!pos) {
- list[count++] = item;
- return count;
- }
-
- delete item;
- return 0;
-}
-
-int CFoldersList::Add(FOLDERSDATA* data)
-{
- FOLDERSDATA tmp;
- if (data->cbSize < sizeof(FOLDERSDATA)) {
- memset(&tmp, 0, sizeof(FOLDERSDATA));
- memcpy(&tmp, data, data->cbSize);
- data = &tmp;
- }
-
- if (data->flags & FF_UNICODE)
- return Add( new CFolderItem(data->szSection, data->szName, data->szFormatW, data->szUserNameW));
-
- return Add( new CFolderItem(data->szSection, data->szName, _A2T(data->szFormat), _A2T(data->szUserName)));
-}
-
-void CFoldersList::Remove(CFolderItem *item)
-{
-}
-
-void CFoldersList::Remove(int uniqueID)
-{
-}
-
-int CFoldersList::Contains(CFolderItem *item)
-{
- return Contains(item->GetSection(), item->GetUserName());
-}
-
-int CFoldersList::Contains(const char *section, const TCHAR *name)
-{
- for (int 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;
-}
diff --git a/plugins/Folders/src/foldersList.h b/plugins/Folders/src/foldersList.h
deleted file mode 100644
index bbe789e5c5..0000000000
--- a/plugins/Folders/src/foldersList.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
-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 TCHAR *name);
-
- int Count();
- int Capacity();
-
- PFolderItem Get(int index);
- PFolderItem Get(const char *section, const TCHAR *name);
- PFolderItem GetTranslated(const char *trSection, const TCHAR *trName);
- int Expand(int index, TCHAR *szResult, int size);
- void Save();
-};
-
-
-#endif \ No newline at end of file
diff --git a/plugins/Folders/src/hooked_events.cpp b/plugins/Folders/src/hooked_events.cpp
index 6846f33c04..caeeb697ff 100644
--- a/plugins/Folders/src/hooked_events.cpp
+++ b/plugins/Folders/src/hooked_events.cpp
@@ -20,24 +20,3 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "commonheaders.h"
-static int OnOptionsInitialize(WPARAM wParam, LPARAM lParam)
-{
- OPTIONSDIALOGPAGE odp = { sizeof(odp) };
- odp.position = 100000000;
- odp.hInstance = hInstance;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_FOLDERS);
- odp.pszTitle = LPGEN("Folders");
- odp.pszGroup = LPGEN("Customize");
- odp.groupPosition = 910000000;
- odp.flags = ODPF_BOLDGROUPS;
- odp.pfnDlgProc = DlgProcOpts;
- Options_AddPage(wParam, &odp);
-
- return 0;
-}
-
-int HookEvents()
-{
- HookEvent(ME_OPT_INITIALISE, OnOptionsInitialize);
- return 0;
-}
diff --git a/plugins/Folders/src/hooked_events.h b/plugins/Folders/src/hooked_events.h
deleted file mode 100644
index 0df8dc07ce..0000000000
--- a/plugins/Folders/src/hooked_events.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-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 hOptionsInitialize;
-
-int HookEvents();
-
-
-#endif \ No newline at end of file
diff --git a/plugins/Folders/src/services.cpp b/plugins/Folders/src/services.cpp
index 5fb4a404a8..75728b14fa 100644
--- a/plugins/Folders/src/services.cpp
+++ b/plugins/Folders/src/services.cpp
@@ -57,41 +57,58 @@ INT_PTR ExpandPath(TCHAR *szResult, TCHAR *format, int size)
INT_PTR RegisterPathService(WPARAM wParam, LPARAM lParam)
{
- FOLDERSDATA *tmp = (FOLDERSDATA*)lParam;
- if (tmp == NULL)
+ FOLDERSDATA *data = (FOLDERSDATA*)lParam;
+ if (data == NULL)
return NULL;
- if (tmp->cbSize != sizeof(FOLDERSDATA) && tmp->cbSize != FOLDERSDATA_SIZE_V1)
+ if (data->cbSize != sizeof(FOLDERSDATA))
return NULL;
- return lstRegisteredFolders.Add(tmp); //returns 1..n or 0 on error
+ CFolderItem *pNew;
+ if (data->flags & FF_UNICODE)
+ pNew = new CFolderItem(data->szSection, data->szName, data->szFormatW, data->szUserNameW);
+ else
+ pNew = new CFolderItem(data->szSection, data->szName, _A2T(data->szFormat), _A2T(data->szUserName));
+
+ lstRegisteredFolders.insert(pNew);
+ return (INT_PTR)pNew;
}
INT_PTR GetPathSizeService(WPARAM wParam, LPARAM lParam)
{
- TCHAR tmp[MAX_FOLDER_SIZE];
- int res = lstRegisteredFolders.Expand(wParam, tmp, SIZEOF(tmp));
- size_t len = _tcslen(tmp);
+ size_t len;
+
+ CFolderItem *p = (CFolderItem*)wParam;
+ if ( lstRegisteredFolders.getIndex(p) != -1) {
+ TCHAR tmp[MAX_FOLDER_SIZE];
+ p->Expand(tmp, SIZEOF(tmp));
+ len = _tcslen(tmp);
+ }
+ else len = 0;
if (lParam != NULL)
- *((size_t *) lParam) = len;
+ *((size_t*)lParam) = len;
return len;
}
INT_PTR GetPathService(WPARAM wParam, LPARAM lParam)
{
- FOLDERSGETDATA* data = (FOLDERSGETDATA *) lParam;
- if (data->cbSize != sizeof (FOLDERSGETDATA))
+ CFolderItem *p = (CFolderItem*)wParam;
+ if ( lstRegisteredFolders.getIndex(p) == -1)
return 1;
- if (data->flags & FF_UNICODE)
- return lstRegisteredFolders.Expand(wParam, data->szPathT, data->nMaxPathSize);
-
- TCHAR buf[MAX_FOLDER_SIZE];
- if ( lstRegisteredFolders.Expand(wParam, buf, MAX_FOLDER_SIZE))
+ FOLDERSGETDATA* data = (FOLDERSGETDATA*)lParam;
+ if (data->cbSize != sizeof(FOLDERSGETDATA))
return 1;
+ if (data->flags & FF_UNICODE) {
+ p->Expand(data->szPathT, data->nMaxPathSize);
+ return 0;
+ }
+
+ TCHAR buf[MAX_FOLDER_SIZE];
+ p->Expand(buf, SIZEOF(buf));
strncpy(data->szPath, _T2A(buf), data->nMaxPathSize);
return 0;
}
diff --git a/plugins/Folders/src/services.h b/plugins/Folders/src/services.h
index b4fc3a8812..6b71f10d8e 100644
--- a/plugins/Folders/src/services.h
+++ b/plugins/Folders/src/services.h
@@ -35,4 +35,6 @@ int InitServices();
INT_PTR ExpandPath(TCHAR *szResult, TCHAR *format, int size);
INT_PTR GetPath(int hRegisteredFolder, TCHAR *szResult, int size);
+void InitOptions();
+
#endif //M_FOLDERS_PROVIDED_SERVICES_H \ No newline at end of file
diff --git a/plugins/Folders/src/version.h b/plugins/Folders/src/version.h
index dd2d6f51b2..8ef331bb72 100644
--- a/plugins/Folders/src/version.h
+++ b/plugins/Folders/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 2
#define __RELEASE_NUM 0
-#define __BUILD_NUM 0
+#define __BUILD_NUM 1
#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM