diff options
author | George Hazan <george.hazan@gmail.com> | 2013-03-02 13:38:53 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-03-02 13:38:53 +0000 |
commit | 3d26dc75537137d829cc388abe0b9fe4b2df0d9d (patch) | |
tree | 61ee0925fca5f4d9ab10ef3ea5a8e14f213a1a11 /plugins/Folders | |
parent | 6d46936f5711c2b927b88f4c93cf1431a776bbba (diff) |
unicode folders custom names (gotten from szName by default, as usual)
git-svn-id: http://svn.miranda-ng.org/main/trunk@3835 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Folders')
-rw-r--r-- | plugins/Folders/folders_11.vcxproj | 1 | ||||
-rw-r--r-- | plugins/Folders/folders_11.vcxproj.filters | 3 | ||||
-rw-r--r-- | plugins/Folders/src/dlg_handlers.cpp | 29 | ||||
-rw-r--r-- | plugins/Folders/src/folderItem.cpp | 17 | ||||
-rw-r--r-- | plugins/Folders/src/folderItem.h | 10 | ||||
-rw-r--r-- | plugins/Folders/src/folders.cpp | 1 | ||||
-rw-r--r-- | plugins/Folders/src/foldersList.cpp | 22 | ||||
-rw-r--r-- | plugins/Folders/src/foldersList.h | 6 | ||||
-rw-r--r-- | plugins/Folders/src/services.cpp | 26 | ||||
-rw-r--r-- | plugins/Folders/src/services.h | 2 |
10 files changed, 58 insertions, 59 deletions
diff --git a/plugins/Folders/folders_11.vcxproj b/plugins/Folders/folders_11.vcxproj index 861ea373d2..4c0858773e 100644 --- a/plugins/Folders/folders_11.vcxproj +++ b/plugins/Folders/folders_11.vcxproj @@ -196,6 +196,7 @@ <ClCompile Include="src\utils.cpp" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="..\ExternalAPI\m_folders.h" />
<ClInclude Include="src\commonheaders.h" />
<ClInclude Include="src\dlg_handlers.h" />
<ClInclude Include="src\events.h" />
diff --git a/plugins/Folders/folders_11.vcxproj.filters b/plugins/Folders/folders_11.vcxproj.filters index 2a6e8eea72..30086fbee5 100644 --- a/plugins/Folders/folders_11.vcxproj.filters +++ b/plugins/Folders/folders_11.vcxproj.filters @@ -74,6 +74,9 @@ <ClInclude Include="src\version.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\ExternalAPI\m_folders.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\folders.rc">
diff --git a/plugins/Folders/src/dlg_handlers.cpp b/plugins/Folders/src/dlg_handlers.cpp index d36a68ebc3..8bd851f207 100644 --- a/plugins/Folders/src/dlg_handlers.cpp +++ b/plugins/Folders/src/dlg_handlers.cpp @@ -14,19 +14,11 @@ int GetCurrentSectionSelection(HWND hWnd) return SendDlgItemMessage(hWnd, IDC_FOLDERS_SECTIONS_LIST, LB_GETCURSEL, 0, 0);
}
-PFolderItem GetSelectedItem(HWND hWnd)
-{
- char section[MAX_FOLDER_SIZE], 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, char *buffer, int count)
+int GetCurrentItemText(HWND hWnd, TCHAR *buffer, int count)
{
int index = GetCurrentItemSelection(hWnd);
if (index != LB_ERR) {
- SendDlgItemMessageA(hWnd, IDC_FOLDERS_ITEMS_LIST, LB_GETTEXT, index, (LPARAM) buffer);
+ SendDlgItemMessage(hWnd, IDC_FOLDERS_ITEMS_LIST, LB_GETTEXT, index, (LPARAM)buffer);
return 1;
}
@@ -38,12 +30,21 @@ 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);
+ 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);
+}
+
static void GetEditText(HWND hWnd, TCHAR *buffer, int size)
{
GetWindowText( GetDlgItem(hWnd, IDC_FOLDER_EDIT), buffer, size);
@@ -87,10 +88,8 @@ void LoadRegisteredFolderItems(HWND hWnd) for (int i = 0; i < lstRegisteredFolders.Count(); i++) {
PFolderItem item = lstRegisteredFolders.Get(i + 1);
- if ( !strcmp(szSection, item->GetSection())) {
- mir_ptr<TCHAR> wide( mir_a2t( item->GetName()));
- SendDlgItemMessage(hWnd, IDC_FOLDERS_ITEMS_LIST, LB_ADDSTRING, 0, (LPARAM)TranslateTS(wide));
- }
+ if ( !strcmp(szSection, item->GetSection()))
+ SendDlgItemMessage(hWnd, IDC_FOLDERS_ITEMS_LIST, LB_ADDSTRING, 0, (LPARAM)TranslateTS(item->GetUserName()));
}
SendDlgItemMessage(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
diff --git a/plugins/Folders/src/folderItem.cpp b/plugins/Folders/src/folderItem.cpp index fe16f30d7a..4125d43d4a 100644 --- a/plugins/Folders/src/folderItem.cpp +++ b/plugins/Folders/src/folderItem.cpp @@ -20,13 +20,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "commonheaders.h"
-CFolderItem::CFolderItem(const char *sectionName, const char *name, const TCHAR *format, const DWORD flags)
+CFolderItem::CFolderItem(const char *sectionName, const char *name, const TCHAR *format, const TCHAR *userName)
{
m_szSection = mir_strdup(sectionName);
m_szName = mir_strdup(name);
+ if (userName)
+ m_tszUserName = mir_tstrdup(userName);
+ else
+ m_tszUserName = mir_a2t(name);
m_tszFormat = NULL;
m_tszOldFormat = NULL;
- m_flags = flags;
GetDataFromDatabase(format);
FolderCreateDirectory();
}
@@ -48,17 +51,17 @@ void CFolderItem::SetFormat(const TCHAR *newFormat) int CFolderItem::IsEqual(const CFolderItem *other)
{
- return (IsEqual(other->GetSection(), other->GetName()));
+ return (IsEqual(other->GetSection(), other->GetUserName()));
}
-int CFolderItem::IsEqual(const char *section, const char *name)
+int CFolderItem::IsEqual(const char *section, const TCHAR *name)
{
- return ((strcmp(m_szName, name) == 0) && (strcmp(m_szSection, section) == 0));
+ return !_tcscmp(m_tszUserName, name) && !strcmp(m_szSection, section);
}
-int CFolderItem::IsEqualTranslated(const char *trSection, const char *trName)
+int CFolderItem::IsEqualTranslated(const char *trSection, const TCHAR *trName)
{
- return ((strcmp(Translate(m_szName), trName) == 0) && (strcmp(Translate(m_szSection), trSection) == 0));
+ return !_tcscmp( TranslateTS(m_tszUserName), trName) && !strcmp(Translate(m_szSection), trSection);
}
int CFolderItem::operator ==(const CFolderItem *other)
diff --git a/plugins/Folders/src/folderItem.h b/plugins/Folders/src/folderItem.h index 89731b32be..1883cad207 100644 --- a/plugins/Folders/src/folderItem.h +++ b/plugins/Folders/src/folderItem.h @@ -39,8 +39,7 @@ class CFolderItem {
char *m_szSection;
char *m_szName;
- TCHAR *m_tszFormat, *m_tszOldFormat;
- DWORD m_flags;
+ TCHAR *m_tszFormat, *m_tszOldFormat, *m_tszUserName;
void GetDataFromDatabase(const TCHAR *szNotFound);
void WriteDataToDatabase();
@@ -48,19 +47,20 @@ class CFolderItem int FolderCreateDirectory(int showFolder = 0);
int FolderDeleteOldDirectory(int showFolder = 0);
public:
- CFolderItem(const char *sectionName, const char *name, const TCHAR *format, const DWORD flags);
+ CFolderItem(const char *sectionName, const char *name, const TCHAR *format, const TCHAR *userName);
virtual ~CFolderItem();
void Expand(TCHAR *buffer, int size);
void Save();
int IsEqual(const CFolderItem *other);
- int IsEqual(const char *section, const char *name);
- int IsEqualTranslated(const char *trSection, const char *trName);
+ int IsEqual(const char *section, const TCHAR *name);
+ int IsEqualTranslated(const char *trSection, const TCHAR *trName);
int operator ==(const CFolderItem *other);
__inline const char* GetSection() const { return m_szSection; }
__inline const char* GetName() const { return m_szName; }
+ __inline const TCHAR* GetUserName() const { return m_tszUserName; }
__inline const TCHAR* GetFormat() const { return m_tszFormat; }
void SetFormat(const TCHAR *newFormat);
};
diff --git a/plugins/Folders/src/folders.cpp b/plugins/Folders/src/folders.cpp index 638f539143..d9e61f675f 100644 --- a/plugins/Folders/src/folders.cpp +++ b/plugins/Folders/src/folders.cpp @@ -57,7 +57,6 @@ extern "C" __declspec(dllexport) int Load(void) extern "C" __declspec(dllexport) int Unload()
{
- DestroyServices();
DestroyEvents();
UnhookEvents();
return 0;
diff --git a/plugins/Folders/src/foldersList.cpp b/plugins/Folders/src/foldersList.cpp index e003ad81ab..1f7ab3aef5 100644 --- a/plugins/Folders/src/foldersList.cpp +++ b/plugins/Folders/src/foldersList.cpp @@ -67,7 +67,7 @@ PFolderItem CFoldersList::Get(int index) return list[index];
}
-PFolderItem CFoldersList::Get(const char *section, const char *name)
+PFolderItem CFoldersList::Get(const char *section, const TCHAR *name)
{
for (int i = 0; i < count; i++)
if (list[i]->IsEqual(section, name))
@@ -76,7 +76,7 @@ PFolderItem CFoldersList::Get(const char *section, const char *name) return NULL;
}
-PFolderItem CFoldersList::GetTranslated(const char *trSection, const char *trName)
+PFolderItem CFoldersList::GetTranslated(const char *trSection, const TCHAR *trName)
{
for (int i = 0; i < count; i++)
if (list[i]->IsEqualTranslated(trSection, trName))
@@ -112,13 +112,17 @@ int CFoldersList::Add(CFolderItem *item) int CFoldersList::Add(FOLDERSDATA* data)
{
- CFolderItem *item;
+ FOLDERSDATA tmp;
+ if (data->cbSize < sizeof(FOLDERSDATA)) {
+ memset(&tmp, 0, sizeof(FOLDERSDATA));
+ memcpy(&tmp, data, data->cbSize);
+ data = &tmp;
+ }
+
if (data->flags & FF_UNICODE)
- item = new CFolderItem(data->szSection, data->szName, data->szFormatW, data->flags);
- else
- item = new CFolderItem(data->szSection, data->szName, _A2T(data->szFormat), data->flags);
+ return Add( new CFolderItem(data->szSection, data->szName, data->szFormatW, data->szUserNameW));
- return Add(item);
+ return Add( new CFolderItem(data->szSection, data->szName, _A2T(data->szFormat), _A2T(data->szUserName)));
}
void CFoldersList::Remove(CFolderItem *item)
@@ -131,10 +135,10 @@ void CFoldersList::Remove(int uniqueID) int CFoldersList::Contains(CFolderItem *item)
{
- return Contains(item->GetSection(), item->GetName());
+ return Contains(item->GetSection(), item->GetUserName());
}
-int CFoldersList::Contains(const char *section, const char *name)
+int CFoldersList::Contains(const char *section, const TCHAR *name)
{
for (int i = 0; i < count; i++)
if (list[i]->IsEqual(section, name))
diff --git a/plugins/Folders/src/foldersList.h b/plugins/Folders/src/foldersList.h index 93ea38cc57..bbe789e5c5 100644 --- a/plugins/Folders/src/foldersList.h +++ b/plugins/Folders/src/foldersList.h @@ -51,14 +51,14 @@ class CFoldersList{ void Remove(CFolderItem *item);
void Remove(int uniqueID);
int Contains(CFolderItem *item);
- int Contains(const char *section, const char *name);
+ int Contains(const char *section, const TCHAR *name);
int Count();
int Capacity();
PFolderItem Get(int index);
- PFolderItem Get(const char *section, const char *name);
- PFolderItem GetTranslated(const char *trSection, const char *trName);
+ 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();
};
diff --git a/plugins/Folders/src/services.cpp b/plugins/Folders/src/services.cpp index 4178dd49e8..5fb4a404a8 100644 --- a/plugins/Folders/src/services.cpp +++ b/plugins/Folders/src/services.cpp @@ -27,11 +27,6 @@ TCHAR szCurrentProfile[MAX_FOLDERS_PATH]; TCHAR szMirandaPath[MAX_FOLDERS_PATH];
TCHAR szUserDataPath[MAX_FOLDERS_PATH];
-HANDLE hsFoldersGetPath;
-HANDLE hsFoldersGetSize;
-HANDLE hsFoldersGetPathAlloc;
-HANDLE hsFoldersRegisterPath;
-
INT_PTR ExpandPath(TCHAR *szResult, TCHAR *format, int size)
{
szResult[0] = '\0';
@@ -62,8 +57,11 @@ INT_PTR ExpandPath(TCHAR *szResult, TCHAR *format, int size) INT_PTR RegisterPathService(WPARAM wParam, LPARAM lParam)
{
- FOLDERSDATA *tmp = (FOLDERSDATA *) lParam;
- if (tmp == NULL || tmp->cbSize != sizeof(FOLDERSDATA))
+ FOLDERSDATA *tmp = (FOLDERSDATA*)lParam;
+ if (tmp == NULL)
+ return NULL;
+
+ if (tmp->cbSize != sizeof(FOLDERSDATA) && tmp->cbSize != FOLDERSDATA_SIZE_V1)
return NULL;
return lstRegisteredFolders.Add(tmp); //returns 1..n or 0 on error
@@ -113,16 +111,8 @@ int InitServices() mir_sntprintf(szUserDataPath, MAX_FOLDERS_PATH, szTemp);
mir_free(szTemp);
- hsFoldersGetPath = CreateServiceFunction(MS_FOLDERS_GET_PATH, GetPathService);
- hsFoldersGetSize = CreateServiceFunction(MS_FOLDERS_GET_SIZE, GetPathSizeService);
- hsFoldersRegisterPath = CreateServiceFunction(MS_FOLDERS_REGISTER_PATH, RegisterPathService);
- return 0;
-}
-
-int DestroyServices()
-{
- DestroyServiceFunction(hsFoldersGetPath);
- DestroyServiceFunction(hsFoldersGetSize);
- DestroyServiceFunction(hsFoldersRegisterPath);
+ CreateServiceFunction(MS_FOLDERS_GET_PATH, GetPathService);
+ CreateServiceFunction(MS_FOLDERS_GET_SIZE, GetPathSizeService);
+ CreateServiceFunction(MS_FOLDERS_REGISTER_PATH, RegisterPathService);
return 0;
}
diff --git a/plugins/Folders/src/services.h b/plugins/Folders/src/services.h index 2a96493193..b4fc3a8812 100644 --- a/plugins/Folders/src/services.h +++ b/plugins/Folders/src/services.h @@ -31,7 +31,7 @@ extern TCHAR szCurrentProfile[MAX_FOLDERS_PATH]; extern TCHAR szMirandaPath[MAX_FOLDERS_PATH];
int InitServices();
-int DestroyServices();
+
INT_PTR ExpandPath(TCHAR *szResult, TCHAR *format, int size);
INT_PTR GetPath(int hRegisteredFolder, TCHAR *szResult, int size);
|