diff options
| -rw-r--r-- | include/delphi/m_db_int.inc | 3 | ||||
| -rw-r--r-- | include/m_db_int.h | 1 | ||||
| -rw-r--r-- | plugins/Db3x_mmap/src/dbintf.h | 3 | ||||
| -rw-r--r-- | plugins/Dbx_kv/src/dbintf.h | 1 | ||||
| -rw-r--r-- | plugins/Dbx_kyoto/src/dbintf.h | 1 | ||||
| -rw-r--r-- | plugins/Dbx_mdb/src/dbintf.h | 1 | ||||
| -rw-r--r-- | plugins/Import/src/import.cpp | 29 | 
7 files changed, 32 insertions, 7 deletions
diff --git a/include/delphi/m_db_int.inc b/include/delphi/m_db_int.inc index 29ffc6844e..9511534cae 100644 --- a/include/delphi/m_db_int.inc +++ b/include/delphi/m_db_int.inc @@ -71,6 +71,7 @@ type    TMIDatabase = record
      m_cache: PMIDatabaseCache;
 +    IsRelational:function():long; stdcall;
      SetCacheSafetyMode:procedure(val:bool); stdcall;
      GetContactCount:function():long; stdcall;
 @@ -162,7 +163,7 @@ const    EGROKPRF_UNKHEADER = 2; // header not supported, not a supported profile
    EGROKPRF_VERNEWER  = 3; // header correct, version in profile newer than reader/writer
    EGROKPRF_DAMAGED   = 4; // header/version fine, other internal data missing, damaged.
 -  EGROKPRF_OBSOLETE  = 5; // obsolete database version detected, requiring conversion 
 +  EGROKPRF_OBSOLETE  = 5; // obsolete database version detected, requiring conversion
  // makeDatabase() error codes
    EMKPRF_CREATEFAILED = 1; // for some reason CreateFile() didnt like something
 diff --git a/include/m_db_int.h b/include/m_db_int.h index a38c07f140..07dbc871fe 100644 --- a/include/m_db_int.h +++ b/include/m_db_int.h @@ -84,6 +84,7 @@ interface MIDatabase  {
  	MIDatabaseCache* m_cache;
 +	STDMETHOD_(BOOL, IsRelational)(void) PURE;
  	STDMETHOD_(void, SetCacheSafetyMode)(BOOL) PURE;
  	STDMETHOD_(LONG, GetContactCount)(void) PURE;
 diff --git a/plugins/Db3x_mmap/src/dbintf.h b/plugins/Db3x_mmap/src/dbintf.h index 761c28ede9..509f8209e4 100644 --- a/plugins/Db3x_mmap/src/dbintf.h +++ b/plugins/Db3x_mmap/src/dbintf.h @@ -208,7 +208,8 @@ struct CDb3Mmap : public MIDatabase, public MIDatabaseChecker, public MZeroedObj  	__forceinline bool usesPassword() const { return m_bUsesPassword; }
  public:
 -	STDMETHODIMP_(void)   SetCacheSafetyMode(BOOL);
 +	STDMETHODIMP_(BOOL)     IsRelational(void) { return FALSE; }
 +	STDMETHODIMP_(void)     SetCacheSafetyMode(BOOL);
  	STDMETHODIMP_(LONG)     GetContactCount(void);
  	STDMETHODIMP_(MCONTACT) FindFirstContact(const char *szProto = NULL);
 diff --git a/plugins/Dbx_kv/src/dbintf.h b/plugins/Dbx_kv/src/dbintf.h index b9decbc0c3..97c8c507d9 100644 --- a/plugins/Dbx_kv/src/dbintf.h +++ b/plugins/Dbx_kv/src/dbintf.h @@ -148,6 +148,7 @@ struct CDbxKV : public MIDatabase, public MIDatabaseChecker, public MZeroedObjec  	__forceinline bool usesPassword() const { return m_bUsesPassword; }
  public:
 +	STDMETHODIMP_(BOOL)     IsRelational(void) { return TRUE; }
  	STDMETHODIMP_(void)     SetCacheSafetyMode(BOOL);
  	STDMETHODIMP_(LONG)     GetContactCount(void);
 diff --git a/plugins/Dbx_kyoto/src/dbintf.h b/plugins/Dbx_kyoto/src/dbintf.h index e78aaff6cb..8e8dd0f7c6 100644 --- a/plugins/Dbx_kyoto/src/dbintf.h +++ b/plugins/Dbx_kyoto/src/dbintf.h @@ -149,6 +149,7 @@ struct CDbxKyoto : public MIDatabase, public MIDatabaseChecker, public MZeroedOb  	__forceinline bool usesPassword() const { return m_bUsesPassword; }
  public:
 +	STDMETHODIMP_(BOOL)     IsRelational(void) { return TRUE; }
  	STDMETHODIMP_(void)     SetCacheSafetyMode(BOOL);
  	STDMETHODIMP_(LONG)     GetContactCount(void);
 diff --git a/plugins/Dbx_mdb/src/dbintf.h b/plugins/Dbx_mdb/src/dbintf.h index 4183e6cd18..c3736f6bda 100644 --- a/plugins/Dbx_mdb/src/dbintf.h +++ b/plugins/Dbx_mdb/src/dbintf.h @@ -151,6 +151,7 @@ struct CDbxMdb : public MIDatabase, public MIDatabaseChecker, public MZeroedObje  	__forceinline bool usesPassword() const { return m_bUsesPassword; }
  public:
 +	STDMETHODIMP_(BOOL)     IsRelational(void) { return TRUE; }
  	STDMETHODIMP_(void)     SetCacheSafetyMode(BOOL);
  	STDMETHODIMP_(LONG)     GetContactCount(void);
 diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp index d3b70833e7..c9ca158b54 100644 --- a/plugins/Import/src/import.cpp +++ b/plugins/Import/src/import.cpp @@ -876,15 +876,30 @@ static int CopySystemSettings(const char *szModuleName, DWORD, LPARAM param)  static void ImportHistory(MCONTACT hContact, PROTOACCOUNT **protocol, int protoCount)
  {
  	MCONTACT hDst;
 +	bool bIsMeta = false;
 +	bool bIsRelational = srcDb->IsRelational() != 0;
  	// 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())
 +		if (cc == NULL)
  			return;
 +		// for k/v databases we read history for subs only
 +		if (bIsRelational) {
 +			if (cc->IsMeta())
 +				return;
 +		}
 +		// for mmap we read history for metas only
 +		else {
 +			if (cc->IsSub())
 +				return;
 +			
 +			bIsMeta = cc->IsMeta();
 +		}
 +
  		if ((hDst = MapContact(hContact)) == INVALID_CONTACT_ID) {
  			nSkippedContacts++;
  			return;
 @@ -967,10 +982,14 @@ static void ImportHistory(MCONTACT hContact, PROTOACCOUNT **protocol, int protoC  						dbei.flags |= DBEF_READ;
  					// add dbevent
 -					if (dstDb->AddEvent(hDst, &dbei) != NULL)
 -						nMessagesCount++;
 -					else
 -						AddMessage(LPGENT("Failed to add message"));
 +					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"));
 +					}
  				}
  				else nDupes++;
  			}
  | 
