summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Import/res/resource.rc220
-rw-r--r--plugins/Import/src/import.cpp230
-rw-r--r--plugins/Import/src/miranda.cpp4
-rw-r--r--plugins/Import/src/resource.h7
-rw-r--r--plugins/Import/src/utils.cpp2
5 files changed, 325 insertions, 138 deletions
diff --git a/plugins/Import/res/resource.rc b/plugins/Import/res/resource.rc
index bc89df7fa1..af948610fc 100644
--- a/plugins/Import/res/resource.rc
+++ b/plugins/Import/res/resource.rc
@@ -13,48 +13,11 @@
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
-// English (U.K.) resources
+// Neutral resources
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
-#ifdef _WIN32
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
-#pragma code_page(1252)
-#endif //_WIN32
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "..\\src\\resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include <windows.h>\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Icon
-//
-
-// Icon with lowest ID value placed first to ensure application icon
-// remains consistent on all systems.
-IDI_IMPORT ICON "import.ico"
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
+LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+#pragma code_page(1251)
/////////////////////////////////////////////////////////////////////////////
//
@@ -62,67 +25,53 @@ IDI_IMPORT ICON "import.ico"
//
IDD_IMPORTTYPE DIALOGEX 0, 0, 220, 114
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_3DLOOK | DS_CONTROL | WS_CHILD
+STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- LTEXT "Choose how you would like to import:",IDC_STATIC,5,16,
- 210,8
- CONTROL "From a Miranda NG database.",IDC_MIRANDA,"Button",
- BS_AUTORADIOBUTTON,11,31,204,10
+ LTEXT "Choose how you would like to import:",IDC_STATIC,5,16,210,8
+ CONTROL "From a Miranda NG database.",IDC_MIRANDA,"Button",BS_AUTORADIOBUTTON,11,31,204,10
END
IDD_WIZARDINTRO DIALOGEX 0, 0, 220, 114
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_3DLOOK | DS_CONTROL | WS_CHILD
+STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- LTEXT "This wizard will help you import contacts and message history from another Miranda profile or from an external program.",
- IDC_STATIC,33,12,182,32
+ LTEXT "This wizard will help you import contacts and message history from another Miranda profile or from an external program.",IDC_STATIC,33,12,182,32
ICON IDI_IMPORT,IDC_STATIC,5,12,20,20
- LTEXT "Click ""Next"" to choose the information you wish to import, or click ""Cancel"" to exit the wizard and continue using Miranda.",
- IDC_STATIC,33,49,182,25
- LTEXT "It is recommended that you create a backup of your current Miranda profile before importing.",
- IDC_STATIC,33,81,182,21
+ LTEXT "Click ""Next"" to choose the information you wish to import, or click ""Cancel"" to exit the wizard and continue using Miranda.",IDC_STATIC,33,49,182,25
+ LTEXT "It is recommended that you create a backup of your current Miranda profile before importing.",IDC_STATIC,33,81,182,21
END
IDD_FINISHED DIALOGEX 0, 0, 220, 114
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_3DLOOK | DS_CONTROL | WS_CHILD
+STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- LTEXT "If you wish to import more information, click ""Next"" to return to the start of the wizard, otherwise click ""Finish"" to start using Miranda.",
- IDC_STATIC,5,20,210,16
- LTEXT "You will probably never need to use this wizard again, so you can save memory by not loading it every time you start Miranda. This will mean that the import menu item will no longer be available.",
- IDC_STATIC,5,41,210,24
- CONTROL "Do not load the import plugin at startup again",
- IDC_DONTLOADPLUGIN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
- 6,97,210,10
+ LTEXT "If you wish to import more information, click ""Next"" to return to the start of the wizard, otherwise click ""Finish"" to start using Miranda.",IDC_STATIC,5,20,210,16
+ LTEXT "You will probably never need to use this wizard again, so you can save memory by not loading it every time you start Miranda. This will mean that the import menu item will no longer be available.",IDC_STATIC,5,41,210,24
+ CONTROL "Do not load the import plugin at startup again",IDC_DONTLOADPLUGIN,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,97,210,10
LTEXT "Import completed",IDC_STATIC,5,7,210,8
- LTEXT "If at a future date you wish to use the wizard again, you can make it load again by going to the Plugins section of the Options dialog box.",
- IDC_STATIC,5,69,210,24
+ LTEXT "If at a future date you wish to use the wizard again, you can make it load again by going to the Plugins section of the Options dialog box.",IDC_STATIC,5,69,210,24
END
IDD_MIRANDADB DIALOGEX 0, 0, 220, 114
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_3DLOOK | DS_CONTROL | WS_CHILD
+STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- LTEXT "Miranda has found Miranda profiles with the following names. Please select the one you wish to import, or click ""Other Profile"" if your profile is not listed, or if the list is empty.",
- IDC_STATIC,5,10,210,24
- LISTBOX IDC_LIST,5,36,210,36,LBS_SORT | LBS_NOINTEGRALHEIGHT |
- WS_VSCROLL | WS_TABSTOP
+ LTEXT "Miranda has found Miranda profiles with the following names. Please select the one you wish to import, or click ""Other Profile"" if your profile is not listed, or if the list is empty.",IDC_STATIC,5,10,210,24
+ LISTBOX IDC_LIST,5,36,210,36,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "&Other Profile...",IDC_OTHER,149,74,66,14
RTEXT "&Filename:",IDC_STATIC,5,93,34,8
EDITTEXT IDC_FILENAME,41,91,174,12,ES_AUTOHSCROLL
END
IDD_PROGRESS DIALOGEX 0, 0, 220, 114
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_3DLOOK | DS_CONTROL | WS_CHILD
+STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
LTEXT "Now importing...",IDC_STATIC,5,11,62,8
- CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",PBS_SMOOTH |
- WS_BORDER,5,24,210,10
- LISTBOX IDC_STATUS,5,38,210,61,NOT LBS_NOTIFY |
- LBS_NOINTEGRALHEIGHT | LBS_DISABLENOSCROLL | LBS_NOSEL |
- WS_VSCROLL | WS_TABSTOP
+ CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",PBS_SMOOTH | WS_BORDER,5,24,210,10
+ LISTBOX IDC_STATUS,5,38,210,61,NOT LBS_NOTIFY | LBS_NOINTEGRALHEIGHT | LBS_DISABLENOSCROLL | LBS_NOSEL | WS_VSCROLL | WS_TABSTOP
END
IDD_WIZARD DIALOGEX 0, 0, 220, 143
@@ -137,55 +86,37 @@ BEGIN
END
IDD_OPTIONS DIALOGEX 0, 0, 220, 114
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_3DLOOK | DS_CONTROL | WS_CHILD
+STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
CONTROL "Import all contacts and all messages",IDC_RADIO_ALL,
- "Button",BS_AUTORADIOBUTTON | WS_TABSTOP | BS_LEFT | BS_TOP,7,10,206,
- 11
- CONTROL "Only import contacts",IDC_RADIO_CONTACTS,"Button",
- BS_AUTORADIOBUTTON | WS_TABSTOP,7,42,206,10
- CONTROL "Custom import",IDC_RADIO_CUSTOM,"Button",
- BS_AUTORADIOBUTTON | WS_TABSTOP | WS_DISABLED,7,74,206,10
- LTEXT "Select this if you want to import as much data as possible. This is the recommended option.",
- IDC_STATIC_ALL,26,20,187,16
- LTEXT "Select this if you want to import contacts but don't want to import any message history.",
- IDC_STATIC_CONTACTS,26,52,187,16
- LTEXT "Select this if you want to customize what to import.",
- IDC_STATIC_CUSTOM,26,84,187,16,WS_DISABLED
+ "Button",BS_AUTORADIOBUTTON | BS_LEFT | BS_TOP | WS_TABSTOP,7,10,206,11
+ CONTROL "Only import contacts",IDC_RADIO_CONTACTS,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,7,42,206,10
+ CONTROL "Custom import",IDC_RADIO_CUSTOM,"Button",BS_AUTORADIOBUTTON | WS_DISABLED | WS_TABSTOP,7,74,206,10
+ LTEXT "Select this if you want to import as much data as possible. This is the recommended option.",IDC_STATIC_ALL,26,20,187,16
+ LTEXT "Select this if you want to import contacts but don't want to import any message history.",IDC_STATIC_CONTACTS,26,52,187,16
+ LTEXT "Select this if you want to customize what to import.",IDC_STATIC_CUSTOM,26,84,187,16,WS_DISABLED
END
IDD_ADVOPTIONS DIALOGEX 0, 0, 220, 114
STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
- CONTROL "New contacts && groups",IDC_CONTACTS,"Button",
- BS_AUTOCHECKBOX | WS_TABSTOP,10,16,100,10
- CONTROL "System history",IDC_SYSTEM,"Button",BS_AUTOCHECKBOX |
- WS_TABSTOP,120,16,98,10
+ CONTROL "New contacts && groups",IDC_CONTACTS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,16,100,10
+ CONTROL "System history",IDC_SYSTEM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,120,16,98,10
LTEXT "Select items to import:",IDC_ALL,10,3,201,10,SS_NOTIFY
CTEXT "Incoming",IDC_INCOMING,2,34,86,10,SS_NOTIFY
CTEXT "Outgoing",IDC_OUTGOING,132,34,86,10,SS_NOTIFY
- CONTROL "",IDC_IN_MSG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,40,
- 44,10,10
- CONTROL "",IDC_IN_URL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,40,
- 56,10,10
- CONTROL "",IDC_IN_FT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,40,68,
- 10,10
- CONTROL "",IDC_IN_OTHER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,40,
- 80,10,10
- CONTROL "",IDC_OUT_MSG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,
- 44,10,10
- CONTROL "",IDC_OUT_URL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,
- 56,10,10
- CONTROL "",IDC_OUT_FT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,
- 68,10,10
- CONTROL "",IDC_OUT_OTHER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
- 170,80,10,10
- CONTROL "Only since:",IDC_SINCE,"Button",BS_AUTOCHECKBOX |
- WS_TABSTOP,10,99,100,10
- CONTROL "",IDC_DATETIMEPICKER,"SysDateTimePick32",DTS_RIGHTALIGN |
- WS_DISABLED | WS_TABSTOP,120,97,81,15
+ CONTROL "",IDC_IN_MSG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,40,44,10,10
+ CONTROL "",IDC_IN_URL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,40,56,10,10
+ CONTROL "",IDC_IN_FT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,40,68,10,10
+ CONTROL "",IDC_IN_OTHER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,40,80,10,10
+ CONTROL "",IDC_OUT_MSG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,44,10,10
+ CONTROL "",IDC_OUT_URL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,56,10,10
+ CONTROL "",IDC_OUT_FT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,68,10,10
+ CONTROL "",IDC_OUT_OTHER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,80,10,10
+ CONTROL "Only since:",IDC_SINCE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,99,100,10
+ CONTROL "",IDC_DATETIMEPICKER,"SysDateTimePick32",DTS_RIGHTALIGN | WS_DISABLED | WS_TABSTOP,120,97,81,15
CTEXT "Messages",IDC_MSG,54,44,112,8,SS_NOTIFY
CTEXT "URLs",IDC_URL,54,56,112,8,SS_NOTIFY
CTEXT "File Transfers",IDC_FT,54,68,112,8,SS_NOTIFY
@@ -194,6 +125,16 @@ BEGIN
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,0,31,223,1
END
+IDD_ACCMERGE DIALOGEX 0, 0, 312, 150
+STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Account merge"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ DEFPUSHBUTTON "OK",IDOK,204,132,50,16
+ PUSHBUTTON "Cancel",IDCANCEL,258,132,50,16
+ CONTROL "",IDC_LIST,"SysListView32",LVS_REPORT | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,4,4,304,124
+END
+
/////////////////////////////////////////////////////////////////////////////
//
@@ -271,13 +212,67 @@ BEGIN
HORZGUIDE, 34
HORZGUIDE, 104
END
+
+ IDD_ACCMERGE, DIALOG
+ BEGIN
+ LEFTMARGIN, 4
+ RIGHTMARGIN, 307
+ TOPMARGIN, 4
+ BOTTOMMARGIN, 146
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+#endif // Neutral resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// English (United Kingdom) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
+#pragma code_page(1252)
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "..\\src\\resource.h\0"
END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include <windows.h>\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
#endif // APSTUDIO_INVOKED
-#endif // English (U.K.) resources
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_IMPORT ICON "import.ico"
+#endif // English (United Kingdom) resources
/////////////////////////////////////////////////////////////////////////////
+
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
@@ -287,3 +282,4 @@ END
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
+
diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp
index adf7609965..507936a201 100644
--- a/plugins/Import/src/import.cpp
+++ b/plugins/Import/src/import.cpp
@@ -26,14 +26,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
struct AccountMap
{
- AccountMap(const char *_src, const char *_dst) :
+ AccountMap(const char *_src, const TCHAR *_srcName, PROTOACCOUNT *_dst) :
szSrcAcc(mir_strdup(_src)),
- szDstAcc(mir_strdup(_dst))
+ tszSrcName(mir_tstrdup(_srcName)),
+ szDstAcc(mir_strdup(_dst->szModuleName)),
+ pa(_dst)
{}
~AccountMap() {}
ptrA szSrcAcc, szDstAcc;
+ ptrT tszSrcName;
+ PROTOACCOUNT *pa;
};
static int CompareAccs(const AccountMap *p1, const AccountMap *p2)
@@ -126,7 +130,7 @@ static MCONTACT HContactFromNumericID(char *pszProtoName, char *pszSetting, DWOR
for (MCONTACT hContact = dstDb->FindFirstContact(); hContact; hContact = dstDb->FindNextContact(hContact)) {
if (db_get_dw(hContact, pszProtoName, pszSetting, 0) == dwID) {
char* szProto = GetContactProto(hContact);
- if (szProto != NULL && !lstrcmpA(szProto, pszProtoName))
+ if (szProto != NULL && !mir_strcmp(szProto, pszProtoName))
return hContact;
}
}
@@ -137,9 +141,9 @@ static MCONTACT HContactFromID(char *pszProtoName, char *pszSetting, TCHAR *pwsz
{
for (MCONTACT hContact = dstDb->FindFirstContact(); hContact; hContact = dstDb->FindNextContact(hContact)) {
char *szProto = GetContactProto(hContact);
- if (!lstrcmpA(szProto, pszProtoName)) {
+ if (!mir_strcmp(szProto, pszProtoName)) {
ptrW id(db_get_tsa(hContact, pszProtoName, pszSetting));
- if (!lstrcmp(pwszID, id))
+ if (!mir_tstrcmp(pwszID, id))
return hContact;
}
}
@@ -195,6 +199,169 @@ void CopySettings(MCONTACT srcID, const char *szSrcModule, MCONTACT dstID, const
}
/////////////////////////////////////////////////////////////////////////////////////////
+// accounts matcher dialog
+
+static HWND hwndList, hwndCombo;
+static int iPrevIndex = -1;
+
+static void SetAccountName(int idx, PROTOACCOUNT *pa)
+{
+ ListView_SetItemText(hwndList, idx, 1, (pa == NULL) ? TranslateT("<New account>") : pa->tszAccountName);
+}
+
+static LRESULT CALLBACK ComboWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ if (uMsg == WM_KILLFOCUS && LPARAM(hwnd) == lParam) {
+ if (iPrevIndex != -1) {
+ AccountMap *pMap = (AccountMap*)SendMessage(hwnd, CB_GETITEMDATA, 0, 0);
+
+ int idx = SendMessage(hwnd, CB_GETCURSEL, 0, 0);
+ if (idx == 0) {
+ pMap->tszSrcName = NULL;
+ pMap->pa = NULL;
+ }
+ else {
+ PROTOACCOUNT *pa = (PROTOACCOUNT*)SendMessage(hwnd, CB_GETITEMDATA, idx, 0);
+ pMap->pa = pa;
+ pMap->tszSrcName = mir_tstrdup(pa->tszAccountName);
+ }
+ SetAccountName(iPrevIndex, pMap->pa);
+ iPrevIndex = -1;
+ }
+
+ DestroyWindow(hwnd);
+ hwndCombo = 0;
+ }
+ return mir_callNextSubclass(hwnd, ComboWndProc, uMsg, wParam, lParam);
+}
+
+static LRESULT CALLBACK ListWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ switch (uMsg) {
+ case WM_LBUTTONDOWN:
+ long x = (long)LOWORD(lParam), y = (long)HIWORD(lParam);
+
+ LVHITTESTINFO hit;
+ hit.pt.x = x;
+ hit.pt.y = y;
+ int lResult = ListView_SubItemHitTest(hwnd, &hit);
+ if (lResult == -1 || hit.iSubItem != 1) {
+ SendMessage(hwndCombo, WM_KILLFOCUS, 0, (LPARAM)hwndCombo);
+ break;
+ }
+
+ RECT r;
+ ListView_GetSubItemRect(hwnd, hit.iItem, 1, LVIR_BOUNDS, &r);
+ r.top--; r.bottom--;
+
+ TCHAR tszText[100];
+ ListView_GetItemText(hwnd, hit.iItem, 1, tszText, SIZEOF(tszText));
+
+ LVITEM lvitem;
+ lvitem.iItem = hit.iItem;
+ lvitem.iSubItem = 0;
+ lvitem.mask = LVIF_PARAM;
+ ListView_GetItem(hwnd, &lvitem);
+
+ if (hwndCombo != NULL)
+ SendMessage(hwndCombo, WM_KILLFOCUS, 0, (LPARAM)hwndCombo);
+
+ hwndCombo = CreateWindowEx(WS_EX_CLIENTEDGE, WC_COMBOBOX, _T(""), WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST,
+ r.left+3, r.top, r.right - r.left - 3, r.bottom - r.top, hwnd, 0, hInst, NULL);
+
+ // copy a font from listview
+ HFONT hFont = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0);
+ SendMessage(hwndCombo, WM_SETFONT, (WPARAM)hFont, 0);
+
+ SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)TranslateT("<New account>"));
+ SendMessage(hwndCombo, CB_SETITEMDATA, 0, lvitem.lParam);
+
+ int protoCount, iSel = 0;
+ PROTOACCOUNT **accs;
+ ProtoEnumAccounts(&protoCount, &accs);
+ for (int i = 0; i < protoCount; i++) {
+ int idx = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)accs[i]->tszAccountName);
+ SendMessage(hwndCombo, CB_SETITEMDATA, idx, (LPARAM)accs[i]);
+
+ if (!mir_tstrcmpi(accs[i]->tszAccountName, tszText))
+ iSel = idx;
+ }
+
+ SendMessage(hwndCombo, CB_SETCURSEL, iSel, 0);
+
+ SetFocus(hwndCombo);
+ mir_subclassWindow(hwndCombo, ComboWndProc);
+
+ iPrevIndex = hit.iItem;
+ }
+
+ return mir_callNextSubclass(hwnd, ListWndProc, uMsg, wParam, lParam);
+}
+
+static INT_PTR CALLBACK AccountsMatcherProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ switch (uMsg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ hwndList = GetDlgItem(hwndDlg, IDC_LIST);
+ {
+ LVCOLUMN col = { 0 };
+ col.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_FMT | LVCF_SUBITEM;
+ col.fmt = LVCFMT_LEFT;
+ col.cx = 100;
+ col.pszText = TranslateT("Old account");
+ ListView_InsertColumn(hwndList, 0, &col);
+
+ col.iSubItem = 1;
+ col.pszText = TranslateT("New account");
+ ListView_InsertColumn(hwndList, 1, &col);
+
+ LVITEM lvi = { 0 };
+ lvi.mask = LVIF_TEXT | LVIF_PARAM;
+ for (int i = 0; i < arAccountMap.getCount(); i++) {
+ AccountMap &p = arAccountMap[i];
+ lvi.iItem = i;
+ lvi.iSubItem = 0;
+ lvi.pszText = p.tszSrcName;
+ lvi.lParam = (LPARAM)&p;
+ ListView_InsertItem(hwndList, &lvi);
+
+ SetAccountName(i, p.pa);
+ }
+ mir_subclassWindow(hwndList, ListWndProc);
+ }
+ return TRUE;
+
+ case WM_COMMAND:
+ if (HIWORD(wParam) != BN_CLICKED)
+ break; // Only clicks of buttons are relevant, let other COMMANDs through
+
+ switch (LOWORD(wParam)) {
+ case IDOK:
+ EndDialog(hwndDlg, IDOK);
+ break;
+
+ case IDCANCEL:
+ EndDialog(hwndDlg, IDCANCEL);
+ }
+ break;
+
+ case WM_NOTIFY:
+ LPNMHDR hdr = (LPNMHDR)lParam;
+ if (hdr->idFrom != IDC_LIST)
+ break;
+
+ switch (hdr->code) {
+ case LVN_ITEMCHANGED:
+ case LVN_ITEMACTIVATE:
+ ;
+ }
+ }
+
+ return FALSE;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
static bool FindDestAccount(const char *szProto)
{
@@ -210,7 +377,7 @@ static bool FindDestAccount(const char *szProto)
return false;
}
-static PROTOACCOUNT* FindMyAccount(const char *szProto, const char *szBaseProto, const TCHAR *ptszName)
+static PROTOACCOUNT* FindMyAccount(const char *szProto, const char *szBaseProto, const TCHAR *ptszName, bool bStrict)
{
int destProtoCount;
PROTOACCOUNT **destAccs;
@@ -224,7 +391,7 @@ static PROTOACCOUNT* FindMyAccount(const char *szProto, const char *szBaseProto,
continue;
// different base protocotol type -> skip
- if (lstrcmpA(pa->szProtoName, szBaseProto))
+ if (mir_strcmp(pa->szProtoName, szBaseProto))
continue;
// these protocols have no accounts, and their name match -> success
@@ -256,12 +423,13 @@ static PROTOACCOUNT* FindMyAccount(const char *szProto, const char *szBaseProto,
if (bEqual)
return pa;
}
- return pProto;
+ return (bStrict) ? NULL : pProto;
}
-void ImportAccounts()
+bool ImportAccounts()
{
int protoCount = myGetD(NULL, "Protocols", "ProtoCount", 0);
+ bool bNeedManualMerge = false;
for (int i = 0; i < protoCount; i++) {
char szSetting[100], szProto[100];
@@ -269,19 +437,28 @@ void ImportAccounts()
if (myGetS(NULL, "Protocols", szSetting, szProto))
continue;
+ itoa(800 + i, szSetting, 10);
+ ptrT tszName(myGetWs(NULL, "Protocols", szSetting));
+
// check if it's an account-based proto or an old style proto
char szBaseProto[100];
if (myGetS(NULL, szProto, "AM_BaseProto", szBaseProto)) {
- arAccountMap.insert(new AccountMap(szProto, NULL));
+ arAccountMap.insert(new AccountMap(szProto, tszName, NULL));
+ bNeedManualMerge = true;
continue;
}
- itoa(800+i, szSetting, 10);
- ptrT tszName(myGetWs(NULL, "Protocols", szSetting));
-
- PROTOACCOUNT *pa = FindMyAccount(szProto, szBaseProto, tszName);
+ // try the precise match first
+ PROTOACCOUNT *pa = FindMyAccount(szProto, szBaseProto, tszName, true);
if (pa) {
- arAccountMap.insert(new AccountMap(szProto, pa->szModuleName));
+ arAccountMap.insert(new AccountMap(szProto, tszName, pa));
+ continue;
+ }
+
+ // if fail, try to found an account by its name
+ if (pa = FindMyAccount(szProto, szBaseProto, tszName, false)) {
+ arAccountMap.insert(new AccountMap(szProto, tszName, pa));
+ bNeedManualMerge = true;
continue;
}
@@ -297,11 +474,12 @@ void ImportAccounts()
pa = ProtoCreateAccount(&newacc);
if (pa == NULL) {
- arAccountMap.insert(new AccountMap(szProto, NULL));
+ arAccountMap.insert(new AccountMap(szProto, tszName, NULL));
+ bNeedManualMerge = true;
continue;
}
- arAccountMap.insert(new AccountMap(szProto, pa->szModuleName));
+ arAccountMap.insert(new AccountMap(szProto, tszName, pa));
itoa(400 + i, szSetting, 10);
int iVal = myGetD(NULL, "Protocols", szSetting, 1);
@@ -317,6 +495,12 @@ void ImportAccounts()
CopySettings(NULL, szProto, NULL, pa->szModuleName);
}
+
+ // all accounts to be converted automatically, no need to raise a dialog
+ if (!bNeedManualMerge)
+ return true;
+
+ return DialogBox(hInst, MAKEINTRESOURCE(IDD_ACCMERGE), NULL, AccountsMatcherProc) == IDOK;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -545,8 +729,11 @@ void ImportMeta(DBCachedContact *ccSrc)
else AddMessage(LPGENT("Added metacontact"));
}
- AccountMap pda(META_PROTO, META_PROTO);
- ImportContactSettings(&pda, ccSrc->contactID, ccDst->contactID);
+ PROTOACCOUNT *pa = ProtoGetAccount(META_PROTO);
+ if (pa) {
+ AccountMap pda(META_PROTO, _T(META_PROTO), pa);
+ ImportContactSettings(&pda, ccSrc->contactID, ccDst->contactID);
+ }
arContactMap.insert(new ContactMap(ccSrc->contactID, ccDst->contactID));
}
@@ -799,7 +986,10 @@ void MirandaImport(HWND hdlg)
// Start benchmark timer
DWORD dwTimer = time(NULL);
- ImportAccounts();
+ if (!ImportAccounts()) {
+ AddMessage(LPGENT("Error mapping accounts, exiting."));
+ return;
+ }
// Import Groups
if (nImportOption == IMPORT_ALL || (nCustomOptions & IOPT_GROUPS)) {
diff --git a/plugins/Import/src/miranda.cpp b/plugins/Import/src/miranda.cpp
index d77e7ded7e..ad253f3f92 100644
--- a/plugins/Import/src/miranda.cpp
+++ b/plugins/Import/src/miranda.cpp
@@ -76,7 +76,7 @@ INT_PTR CALLBACK MirandaPageProc(HWND hwndDlg,UINT message,WPARAM wParam,LPARAM
SearchForLists(hwndDlg, pfd2, pfn);
SearchForLists(hwndDlg, pfd1, NULL);
- if (lstrcmpi(pfd, pfd2))
+ if (mir_tstrcmpi(pfd, pfd2))
SearchForLists(hwndDlg, pfd, NULL);
}
SendDlgItemMessage(hwndDlg, IDC_LIST, LB_SETCURSEL, 0, 0);
@@ -96,7 +96,7 @@ INT_PTR CALLBACK MirandaPageProc(HWND hwndDlg,UINT message,WPARAM wParam,LPARAM
MessageBox(hwndDlg, TranslateT("The given file does not exist. Please check that you have entered the name correctly."), TranslateT("Miranda Import"), MB_OK);
break;
}
- lstrcpy(importFile, filename);
+ mir_tstrcpy(importFile, filename);
PostMessage(GetParent(hwndDlg), WIZM_GOTOPAGE, IDD_OPTIONS, (LPARAM)MirandaOptionsPageProc);
break;
diff --git a/plugins/Import/src/resource.h b/plugins/Import/src/resource.h
index 469bfb0259..51b449a810 100644
--- a/plugins/Import/src/resource.h
+++ b/plugins/Import/src/resource.h
@@ -1,10 +1,11 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
-// Used by resource.rc
+// Used by d:\miranda-ng\plugins\Import\res\resource.rc
//
#define IDC_BACK 3
#define IDD_WIZARD 101
#define IDD_OPTIONS 102
+#define IDD_ACCMERGE 105
#define IDD_IMPORTTYPE 106
#define IDD_WIZARDINTRO 107
#define IDD_FINISHED 108
@@ -48,10 +49,10 @@
#define IDC_STATIC -1
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 105
+#define _APS_NEXT_RESOURCE_VALUE 106
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1041
#define _APS_NEXT_SYMED_VALUE 101
diff --git a/plugins/Import/src/utils.cpp b/plugins/Import/src/utils.cpp
index d833f2cb9e..35a5406b04 100644
--- a/plugins/Import/src/utils.cpp
+++ b/plugins/Import/src/utils.cpp
@@ -54,7 +54,7 @@ int CreateGroup(const TCHAR *group, MCONTACT hContact)
if (tszDbGroup == NULL)
break;
- if (!lstrcmp((TCHAR*)tszDbGroup+1, tszGrpName+1)) {
+ if (!mir_tstrcmp((TCHAR*)tszDbGroup+1, tszGrpName+1)) {
if (hContact)
db_set_ts(hContact, "CList", "Group", tszGrpName + 1);
else