diff options
-rw-r--r-- | plugins/Import/src/import.cpp | 130 | ||||
-rw-r--r-- | plugins/Import/src/import.h | 39 | ||||
-rw-r--r-- | plugins/Import/src/main.cpp | 3 | ||||
-rw-r--r-- | plugins/Import/src/miranda.cpp | 34 | ||||
-rw-r--r-- | plugins/Import/src/version.h | 2 |
5 files changed, 101 insertions, 107 deletions
diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp index 8d32bb715c..72c142fd9f 100644 --- a/plugins/Import/src/import.cpp +++ b/plugins/Import/src/import.cpp @@ -477,12 +477,14 @@ bool ImportAccounts() if (DialogBox(hInst, MAKEINTRESOURCE(IDD_ACCMERGE), NULL, AccountsMatcherProc) != IDOK)
return false;
+ bool bImportSysAll = (nImportOptions & IOPT_SYS_SETTINGS) != 0;
+
for (int i = 0; i < arAccountMap.getCount(); i++) {
AccountMap &p = arAccountMap[i];
if (p.pa != NULL || p.szBaseProto == NULL || !mir_strcmp(p.szSrcAcc, META_PROTO))
continue;
- if (!IsProtocolLoaded(p.szBaseProto)) {
+ if (!Proto_IsProtocolLoaded(p.szBaseProto)) {
AddMessage(LPGENT("Protocol %S is not loaded, skipping account %s creation"), p.szBaseProto, p.tszSrcName);
continue;
}
@@ -517,10 +519,12 @@ bool ImportAccounts() db_set_ts(NULL, "Protocols", szSetting, p.pa->tszAccountName);
}
- CopySettings(NULL, p.szSrcAcc, NULL, p.pa->szModuleName);
+ if (!bImportSysAll)
+ CopySettings(NULL, p.szSrcAcc, NULL, p.pa->szModuleName);
}
- CopySettings(NULL, META_PROTO, NULL, META_PROTO);
+ if (!bImportSysAll)
+ CopySettings(NULL, META_PROTO, NULL, META_PROTO);
return true;
}
@@ -847,28 +851,35 @@ static MCONTACT ImportContact(MCONTACT hSrc) }
/////////////////////////////////////////////////////////////////////////////////////////
+// copying system settings
+
+static int CopySystemSettings(const char *szModuleName, DWORD, LPARAM)
+{
+ CopySettings(NULL, szModuleName, NULL, szModuleName);
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
// contact's history import
static void ImportHistory(MCONTACT hContact, PROTOACCOUNT **protocol, int protoCount)
{
MCONTACT hDst;
- bool bIsMeta = false;
// Is it contact's history import?
if (hContact) {
+ // we ignore history import for metacontacts
+ // the metahistory will be generated automatically by gathering subs' histories
+ DBCachedContact *cc = srcDb->m_cache->GetCachedContact(hContact);
+ if (cc == NULL || cc->IsMeta())
+ return;
+
if ((hDst = MapContact(hContact)) == INVALID_CONTACT_ID) {
nSkippedContacts++;
return;
}
-
- // history for subs will be imported via metahistory
- DBCachedContact *cc = srcDb->m_cache->GetCachedContact(hContact);
- if (cc == NULL || cc->IsSub())
- return;
-
- bIsMeta = cc->IsMeta();
}
- else hDst = 0;
+ else hDst = NULL;
bool bSkipAll = false;
DWORD cbAlloc = 4096;
@@ -901,7 +912,7 @@ static void ImportHistory(MCONTACT hContact, PROTOACCOUNT **protocol, int protoC }
// custom filtering
- if (!bSkipThis && nImportOption == IMPORT_CUSTOM) {
+ if (!bSkipThis) {
BOOL sent = (dbei.flags & DBEF_SENT);
if (dbei.timestamp < (DWORD)dwSinceDate)
@@ -912,24 +923,24 @@ static void ImportHistory(MCONTACT hContact, PROTOACCOUNT **protocol, int protoC bSkipThis = 1;
switch (dbei.eventType) {
case EVENTTYPE_MESSAGE:
- if ((sent ? IOPT_MSGSENT : IOPT_MSGRECV) & nCustomOptions)
+ if ((sent ? IOPT_MSGSENT : IOPT_MSGRECV) & nImportOptions)
bSkipThis = 0;
break;
case EVENTTYPE_FILE:
- if ((sent ? IOPT_FILESENT : IOPT_FILERECV) & nCustomOptions)
+ if ((sent ? IOPT_FILESENT : IOPT_FILERECV) & nImportOptions)
bSkipThis = 0;
break;
case EVENTTYPE_URL:
- if ((sent ? IOPT_URLSENT : IOPT_URLRECV) & nCustomOptions)
+ if ((sent ? IOPT_URLSENT : IOPT_URLRECV) & nImportOptions)
bSkipThis = 0;
break;
default:
- if ((sent ? IOPT_OTHERSENT : IOPT_OTHERRECV) & nCustomOptions)
+ if ((sent ? IOPT_OTHERSENT : IOPT_OTHERRECV) & nImportOptions)
bSkipThis = 0;
break;
}
}
- else if (!(nCustomOptions & IOPT_SYSTEM))
+ else if (!(nImportOptions & IOPT_SYSTEM))
bSkipThis = 1;
}
@@ -944,15 +955,11 @@ static void ImportHistory(MCONTACT hContact, PROTOACCOUNT **protocol, int protoC if (dbei.eventType == EVENTTYPE_AUTHREQUEST || dbei.eventType == EVENTTYPE_ADDED)
dbei.flags |= DBEF_READ;
- // calculate sub's handle for metahistory
- MCONTACT hOwner = (bIsMeta) ? MapContact(srcDb->GetEventContact(hEvent)) : hDst;
- if (hOwner != INVALID_CONTACT_ID) {
- // add dbevent
- if (dstDb->AddEvent(hOwner, &dbei) != NULL)
- nMessagesCount++;
- else
- AddMessage(LPGENT("Failed to add message"));
- }
+ // add dbevent
+ if (dstDb->AddEvent(hDst, &dbei) != NULL)
+ nMessagesCount++;
+ else
+ AddMessage(LPGENT("Failed to add message"));
}
else nDupes++;
}
@@ -1020,8 +1027,12 @@ void MirandaImport(HWND hdlg) return;
}
+ // copy system settings if needed
+ if (nImportOptions & IOPT_SYS_SETTINGS)
+ srcDb->EnumModuleNames(CopySystemSettings, 0);
+
// Import Groups
- if (nImportOption == IMPORT_ALL || (nCustomOptions & IOPT_GROUPS)) {
+ if (nImportOptions & IOPT_GROUPS) {
AddMessage(LPGENT("Importing groups."));
nGroupsCount = ImportGroups();
if (nGroupsCount == -1)
@@ -1032,7 +1043,7 @@ void MirandaImport(HWND hdlg) // End of Import Groups
// Import Contacts
- if (nImportOption != IMPORT_CUSTOM || (nCustomOptions & IOPT_CONTACTS)) {
+ if (nImportOptions & IOPT_CONTACTS) {
AddMessage(LPGENT("Importing contacts."));
int i = 1;
MCONTACT hContact = srcDb->FindFirstContact();
@@ -1061,39 +1072,33 @@ void MirandaImport(HWND hdlg) AddMessage(_T(""));
// End of Import Contacts
- // Import history
- if (nImportOption != IMPORT_CONTACTS) {
- // Import NULL contact message chain
- if (nImportOption == IMPORT_ALL || (nCustomOptions & IOPT_SYSTEM)) {
- AddMessage(LPGENT("Importing system history."));
-
- int protoCount;
- PROTOACCOUNT **accs;
- CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&protoCount, (LPARAM)&accs);
+ // Import NULL contact message chain
+ if (nImportOptions & IOPT_SYSTEM) {
+ AddMessage(LPGENT("Importing system history."));
- if (protoCount > 0)
- ImportHistory(NULL, accs, protoCount);
- }
- else AddMessage(LPGENT("Skipping system history import."));
+ int protoCount;
+ PROTOACCOUNT **accs;
+ CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&protoCount, (LPARAM)&accs);
- AddMessage(_T(""));
+ if (protoCount > 0)
+ ImportHistory(NULL, accs, protoCount);
+ }
+ else AddMessage(LPGENT("Skipping system history import."));
+ AddMessage(_T(""));
- // Import other contact messages
- if (nImportOption == IMPORT_ALL || (nCustomOptions & 2046)) { // 2 - 1024 types
- AddMessage(LPGENT("Importing history."));
- MCONTACT hContact = srcDb->FindFirstContact();
- for (int i = 1; hContact != NULL; i++) {
- ImportHistory(hContact, NULL, NULL);
+ // Import other contact messages
+ if (nImportOptions & IOPT_HISTORY) {
+ AddMessage(LPGENT("Importing history."));
+ MCONTACT hContact = srcDb->FindFirstContact();
+ for (int i = 1; hContact != NULL; i++) {
+ ImportHistory(hContact, NULL, NULL);
- SetProgress(100 * i / nNumberOfContacts);
- hContact = srcDb->FindNextContact(hContact);
- }
+ SetProgress(100 * i / nNumberOfContacts);
+ hContact = srcDb->FindNextContact(hContact);
}
- else AddMessage(LPGENT("Skipping history import."));
-
- AddMessage(_T(""));
}
- // End of Import History
+ else AddMessage(LPGENT("Skipping history import."));
+ AddMessage(_T(""));
// Restore database writing mode
dstDb->SetCacheSafetyMode(TRUE);
@@ -1107,18 +1112,15 @@ void MirandaImport(HWND hdlg) // Print statistics
AddMessage(LPGENT("Import completed in %d seconds."), dwTimer);
SetProgress(100);
- AddMessage((nImportOption == IMPORT_CONTACTS) ?
+ AddMessage(nMessagesCount == 0 ?
LPGENT("Added %d contacts and %d groups.") : LPGENT("Added %d contacts, %d groups and %d events."),
nContactsCount, nGroupsCount, nMessagesCount);
- if (nImportOption != IMPORT_CONTACTS) {
- if (nSkippedContacts)
- AddMessage(LPGENT("Skipped %d contacts."), nSkippedContacts);
+ if (nSkippedContacts)
+ AddMessage(LPGENT("Skipped %d contacts."), nSkippedContacts);
- AddMessage((nImportOption == IMPORT_CUSTOM) ?
- LPGENT("Skipped %d duplicates and %d filtered events.") : LPGENT("Skipped %d duplicates."),
- nDupes, nSkippedEvents);
- }
+ if (nDupes || nSkippedEvents)
+ AddMessage(LPGENT("Skipped %d duplicates and %d filtered events."), nDupes, nSkippedEvents);
arMetas.destroy();
arAccountMap.destroy();
diff --git a/plugins/Import/src/import.h b/plugins/Import/src/import.h index 2679c16bdb..246226db47 100644 --- a/plugins/Import/src/import.h +++ b/plugins/Import/src/import.h @@ -71,26 +71,24 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define ICQCORPPROTONAME "ICQ Corp"
#define AIMPROTONAME "AIM"
-// Import type
-#define IMPORT_CONTACTS 0
-#define IMPORT_ALL 1
-#define IMPORT_CUSTOM 2
-
// Custom import options
-#define IOPT_ADDUNKNOWN 1
-#define IOPT_MSGSENT 2
-#define IOPT_MSGRECV 4
-#define IOPT_URLSENT 8
-#define IOPT_URLRECV 16
-#define IOPT_AUTHREQ 32
-#define IOPT_ADDED 64
-#define IOPT_FILESENT 128
-#define IOPT_FILERECV 256
-#define IOPT_OTHERSENT 512
-#define IOPT_OTHERRECV 1024
-#define IOPT_SYSTEM 2048
-#define IOPT_CONTACTS 4096
-#define IOPT_GROUPS 8192
+#define IOPT_ADDUNKNOWN 0x00000001
+#define IOPT_MSGSENT 0x00000002
+#define IOPT_MSGRECV 0x00000004
+#define IOPT_URLSENT 0x00000008
+#define IOPT_URLRECV 0x00000010
+#define IOPT_AUTHREQ 0x00000020
+#define IOPT_ADDED 0x00000040
+#define IOPT_FILESENT 0x00000080
+#define IOPT_FILERECV 0x00000100
+#define IOPT_OTHERSENT 0x00000200
+#define IOPT_OTHERRECV 0x00000400
+#define IOPT_SYSTEM 0x00000800
+#define IOPT_CONTACTS 0x00001000
+#define IOPT_GROUPS 0x00002000
+#define IOPT_SYS_SETTINGS 0x00004000
+
+#define IOPT_HISTORY 0x000007FE
void AddMessage(const TCHAR* fmt, ...);
@@ -107,8 +105,7 @@ int CreateGroup(const TCHAR* name, MCONTACT hContact); extern HINSTANCE hInst;
extern HWND hdlgProgress, hwndAccMerge;
-extern int nImportOption;
-extern int nCustomOptions;
+extern int nImportOptions;
extern TCHAR importFile[];
extern time_t dwSinceDate;
diff --git a/plugins/Import/src/main.cpp b/plugins/Import/src/main.cpp index a1c4824b14..04f1bc2ff2 100644 --- a/plugins/Import/src/main.cpp +++ b/plugins/Import/src/main.cpp @@ -22,8 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "import.h"
-int nImportOption;
-int nCustomOptions;
+int nImportOptions;
static HANDLE hImportService = NULL;
diff --git a/plugins/Import/src/miranda.cpp b/plugins/Import/src/miranda.cpp index 099810d16d..62dd92db0a 100644 --- a/plugins/Import/src/miranda.cpp +++ b/plugins/Import/src/miranda.cpp @@ -170,22 +170,19 @@ INT_PTR CALLBACK MirandaOptionsPageProc(HWND hwndDlg, UINT message, WPARAM wPara case IDOK:
if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_COMPLETE)) {
- nImportOption = IMPORT_CUSTOM;
- nCustomOptions = INT32_MAX;
+ nImportOptions = INT32_MAX;
PostMessage(GetParent(hwndDlg), WIZM_GOTOPAGE, IDD_PROGRESS, (LPARAM)ProgressPageProc);
break;
}
if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_ALL)) {
- nImportOption = IMPORT_ALL;
- nCustomOptions = 0;
+ nImportOptions = IOPT_HISTORY | IOPT_SYSTEM | IOPT_GROUPS | IOPT_CONTACTS;
PostMessage(GetParent(hwndDlg), WIZM_GOTOPAGE, IDD_PROGRESS, (LPARAM)ProgressPageProc);
break;
}
if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_CONTACTS)) {
- nImportOption = IMPORT_CONTACTS;
- nCustomOptions = 0;
+ nImportOptions = IOPT_CONTACTS;
PostMessage(GetParent(hwndDlg), WIZM_GOTOPAGE, IDD_PROGRESS, (LPARAM)ProgressPageProc);
break;
}
@@ -237,33 +234,32 @@ INT_PTR CALLBACK MirandaAdvOptionsPageProc(HWND hwndDlg, UINT message, WPARAM wP break;
case IDOK:
- nImportOption = IMPORT_CUSTOM;
- nCustomOptions = 0;
+ nImportOptions = 0;
if (IsDlgButtonChecked(hwndDlg, IDC_CONTACTS))
- nCustomOptions |= IOPT_CONTACTS | IOPT_GROUPS;
+ nImportOptions |= IOPT_CONTACTS | IOPT_GROUPS;
if (IsDlgButtonChecked(hwndDlg, IDC_SYSTEM))
- nCustomOptions |= IOPT_SYSTEM;
+ nImportOptions |= IOPT_SYSTEM;
// incoming
if (IsDlgButtonChecked(hwndDlg, IDC_IN_MSG))
- nCustomOptions |= IOPT_MSGRECV;
+ nImportOptions |= IOPT_MSGRECV;
if (IsDlgButtonChecked(hwndDlg, IDC_IN_URL))
- nCustomOptions |= IOPT_URLRECV;
+ nImportOptions |= IOPT_URLRECV;
if (IsDlgButtonChecked(hwndDlg, IDC_IN_FT))
- nCustomOptions |= IOPT_FILERECV;
+ nImportOptions |= IOPT_FILERECV;
if (IsDlgButtonChecked(hwndDlg, IDC_IN_OTHER))
- nCustomOptions |= IOPT_OTHERRECV;
+ nImportOptions |= IOPT_OTHERRECV;
// outgoing
if (IsDlgButtonChecked(hwndDlg, IDC_OUT_MSG))
- nCustomOptions |= IOPT_MSGSENT;
+ nImportOptions |= IOPT_MSGSENT;
if (IsDlgButtonChecked(hwndDlg, IDC_OUT_URL))
- nCustomOptions |= IOPT_URLSENT;
+ nImportOptions |= IOPT_URLSENT;
if (IsDlgButtonChecked(hwndDlg, IDC_OUT_FT))
- nCustomOptions |= IOPT_FILESENT;
+ nImportOptions |= IOPT_FILESENT;
if (IsDlgButtonChecked(hwndDlg, IDC_OUT_OTHER))
- nCustomOptions |= IOPT_OTHERSENT;
+ nImportOptions |= IOPT_OTHERSENT;
// since date
dwSinceDate = 0;
@@ -284,7 +280,7 @@ INT_PTR CALLBACK MirandaAdvOptionsPageProc(HWND hwndDlg, UINT message, WPARAM wP }
}
- if (nCustomOptions)
+ if (nImportOptions)
PostMessage(GetParent(hwndDlg), WIZM_GOTOPAGE, IDD_PROGRESS, (LPARAM)ProgressPageProc);
break;
diff --git a/plugins/Import/src/version.h b/plugins/Import/src/version.h index 53912d96e5..6eccdbd2a8 100644 --- a/plugins/Import/src/version.h +++ b/plugins/Import/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 95
#define __RELEASE_NUM 4
-#define __BUILD_NUM 1
+#define __BUILD_NUM 2
#include <stdver.h>
|