diff options
Diffstat (limited to 'plugins/BasicHistory/src')
-rw-r--r-- | plugins/BasicHistory/src/ExportManager.cpp | 21 | ||||
-rw-r--r-- | plugins/BasicHistory/src/ExportManager.h | 2 | ||||
-rw-r--r-- | plugins/BasicHistory/src/HistoryWindow.cpp | 58 | ||||
-rw-r--r-- | plugins/BasicHistory/src/version.h | 2 |
4 files changed, 68 insertions, 15 deletions
diff --git a/plugins/BasicHistory/src/ExportManager.cpp b/plugins/BasicHistory/src/ExportManager.cpp index 897561ef26..83c4a2ba7e 100644 --- a/plugins/BasicHistory/src/ExportManager.cpp +++ b/plugins/BasicHistory/src/ExportManager.cpp @@ -249,7 +249,7 @@ int ExportManager::Import(IImport::ImportType type, const std::vector<HANDLE>& c return t;
}
-bool ExportManager::Import(IImport::ImportType type, std::vector<IImport::ExternalMessage>& eventList, std::wstring* err)
+bool ExportManager::Import(IImport::ImportType type, std::vector<IImport::ExternalMessage>& eventList, std::wstring* err, bool* differentContact, std::vector<HANDLE>* contacts)
{
IImport* imp = NULL;
switch(type)
@@ -281,18 +281,33 @@ bool ExportManager::Import(IImport::ImportType type, std::vector<IImport::Extern v.push_back(hContact);
bool ret = true;
int contInFile = imp->IsContactInFile(v);
- if(contInFile != 0 && contInFile != -3)
+ if(contInFile == -1)
{
ret = false;
if(err != NULL)
*err = TranslateT("File do not contain selected contact");
+ if(contacts != NULL && differentContact != NULL)
+ {
+ contInFile = imp->IsContactInFile(*contacts);
+ if(contInFile >= 0)
+ {
+ *differentContact = true;
+ hContact = (*contacts)[contInFile];
+ }
+ }
}
- else
+ else if(contInFile == 0 || contInFile == -3)
{
ret = imp->GetEventList(eventList);
if(!ret && err != NULL)
*err = TranslateT("File is corrupted");
}
+ else
+ {
+ ret = false;
+ if(err != NULL)
+ *err = TranslateT("File is corrupted");
+ }
stream->close();
delete stream;
delete imp;
diff --git a/plugins/BasicHistory/src/ExportManager.h b/plugins/BasicHistory/src/ExportManager.h index d99ff077a6..17ed0bb8ef 100644 --- a/plugins/BasicHistory/src/ExportManager.h +++ b/plugins/BasicHistory/src/ExportManager.h @@ -53,7 +53,7 @@ public: void SetDeleteWithoutExportEvents(int _deltaTime, DWORD _now);
void DeleteExportedEvents();
int Import(IImport::ImportType type, const std::vector<HANDLE>& contacts);
- bool Import(IImport::ImportType type, std::vector<IImport::ExternalMessage>& eventList, std::wstring* err = NULL);
+ bool Import(IImport::ImportType type, std::vector<IImport::ExternalMessage>& eventList, std::wstring* err = NULL, bool* differentContact = NULL, std::vector<HANDLE>* contacts = NULL);
static const TCHAR* GetExt(IImport::ImportType type);
};
diff --git a/plugins/BasicHistory/src/HistoryWindow.cpp b/plugins/BasicHistory/src/HistoryWindow.cpp index a8dfcefd14..f7ef91a056 100644 --- a/plugins/BasicHistory/src/HistoryWindow.cpp +++ b/plugins/BasicHistory/src/HistoryWindow.cpp @@ -2195,23 +2195,61 @@ void HistoryWindow::DoImport(IImport::ImportType type) ExportManager exp(hWnd, hContact, GetFilterNr());
std::vector<IImport::ExternalMessage> messages;
std::wstring err;
- if(exp.Import(type, messages, &err))
+ std::vector<HANDLE> contacts;
+ HANDLE _hContact = db_find_first();
+ while(_hContact)
{
- int act = MessageBox(hWnd, TranslateT("Do you want save imported messages to local profile?"), TranslateT("Import"), MB_ICONQUESTION | MB_YESNOCANCEL | MB_DEFBUTTON2);
- if(act == IDYES)
+ contacts.push_back(_hContact);
+ _hContact = db_find_next(hContact);
+ }
+
+ bool changeContact = false;
+ HANDLE lastContact = hContact;
+ int i = 1;
+ do
+ {
+ bool differentContact = false;
+ if(exp.Import(type, messages, &err, &differentContact, &contacts))
+ {
+ int act = MessageBox(hWnd, TranslateT("Do you want save imported messages to local profile?"), TranslateT("Import"), MB_ICONQUESTION | MB_YESNOCANCEL | MB_DEFBUTTON2);
+ if(act == IDYES)
+ {
+ MargeMessages(messages);
+ if(!changeContact)
+ {
+ HistoryWindow::RebuildEvents(hContact);
+ }
+ }
+ else if(act == IDNO)
+ {
+ EventList::AddImporter(hContact, type, exp.GetFileName());
+ if(!changeContact)
+ {
+ HistoryWindow::RebuildEvents(hContact);
+ }
+ }
+ }
+ else if(differentContact)
{
- MargeMessages(messages);
- HistoryWindow::RebuildEvents(hContact);
+ int act = MessageBox(hWnd, TranslateT("File contain history for different contact. Do you want to change contact and import?"), TranslateT("Error"), MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2);
+ if(act == IDYES)
+ {
+ changeContact = true;
+ hContact = exp.hContact;
+ }
}
- else if(act == IDNO)
+ else if(!err.empty())
{
- EventList::AddImporter(hContact, type, exp.GetFileName());
- HistoryWindow::RebuildEvents(hContact);
+ MessageBox(hWnd, err.c_str(), TranslateT("Error"), MB_ICONERROR);
}
}
- else if(!err.empty())
+ while(changeContact && i--);
+ if(changeContact)
{
- MessageBox(hWnd, err.c_str(), TranslateT("Error"), MB_ICONERROR);
+ hContact = lastContact;
+ ReloadContacts();
+ SelectContact(exp.hContact);
+ HistoryWindow::RebuildEvents(exp.hContact);
}
}
diff --git a/plugins/BasicHistory/src/version.h b/plugins/BasicHistory/src/version.h index d2d290a8c5..d3520c5830 100644 --- a/plugins/BasicHistory/src/version.h +++ b/plugins/BasicHistory/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 1
#define __MINOR_VERSION 0
#define __RELEASE_NUM 1
-#define __BUILD_NUM 8
+#define __BUILD_NUM 9
#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
#define __FILEVERSION_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM
|