summaryrefslogtreecommitdiff
path: root/plugins/Import/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-10-15 21:06:35 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-10-15 21:06:35 +0000
commite2aa05a51283cd80febe5aa150568dd127d14bea (patch)
tree65dd8475a6d12e2ac0f1ab5c5f7347de1e09cc4f /plugins/Import/src
parent7f3a660fe4e1f22c46c4a148f055e977f1f625f7 (diff)
fix for some import issues
git-svn-id: http://svn.miranda-ng.org/main/trunk@1951 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Import/src')
-rw-r--r--plugins/Import/src/import.cpp51
1 files changed, 34 insertions, 17 deletions
diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp
index e78062c6f2..5b6ac6f7b8 100644
--- a/plugins/Import/src/import.cpp
+++ b/plugins/Import/src/import.cpp
@@ -79,14 +79,14 @@ static HANDLE HContactFromNumericID(char* szProto, char* pszSetting, DWORD dwID)
return INVALID_HANDLE_VALUE;
}
-static HANDLE HContactFromID(char* szProto, char* pszSetting, char* pszID)
+static HANDLE HContactFromID(char* szProto, char* pszSetting, TCHAR* pwszID)
{
HANDLE hContact = dstDb->FindFirstContact();
while (hContact != NULL) {
char* szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
if ( !lstrcmpA(szProto, szProto)) {
- mir_ptr<char> id( db_get_sa(hContact, szProto, pszSetting));
- if ( !lstrcmpA(pszID, id))
+ mir_ptr<WCHAR> id( db_get_tsa(hContact, szProto, pszSetting));
+ if ( !lstrcmp(pwszID, id))
return hContact;
}
@@ -176,8 +176,8 @@ static int ImportGroups()
static HANDLE ImportContact(HANDLE hSrc)
{
HANDLE hDst;
- char* pszUserName;
- char id[ 40 ], szProto[100];
+ TCHAR id[ 40 ], *pszUserName;
+ char szProto[100];
// Check what protocol this contact belongs to
if ( myGetS(hSrc, "Protocol", "p", szProto)) {
@@ -204,17 +204,25 @@ static HANDLE ImportContact(HANDLE hSrc)
}
// Does the contact already exist?
- if ( dbv.type == DBVT_DWORD ) {
- pszUserName = _ltoa(dbv.dVal, id, 10);
+ switch (dbv.type) {
+ case DBVT_DWORD:
+ pszUserName = _ltot(dbv.dVal, id, 10);
hDst = HContactFromNumericID( szProto, pszUniqueSetting, dbv.dVal );
- }
- else {
- pszUserName = NEWSTR_ALLOCA(dbv.pszVal);
- hDst = HContactFromID( szProto, pszUniqueSetting, dbv.pszVal );
+ break;
+
+ case DBVT_ASCIIZ:
+ pszUserName = NEWTSTR_ALLOCA( _A2T(dbv.pszVal));
+ hDst = HContactFromID(szProto, pszUniqueSetting, pszUserName);
+ break;
+
+ case DBVT_WCHAR:
+ pszUserName = NEWTSTR_ALLOCA(dbv.ptszVal);
+ hDst = HContactFromID(szProto, pszUniqueSetting, pszUserName);
+ break;
}
if (hDst != INVALID_HANDLE_VALUE) {
- AddMessage( LPGEN("Skipping duplicate %s contact %s"), szProto, pszUserName );
+ AddMessage( LPGEN("Skipping duplicate %s contact %S"), szProto, pszUserName );
srcDb->FreeVariant( &dbv );
return NULL;
}
@@ -275,7 +283,7 @@ static HANDLE ImportContact(HANDLE hSrc)
srcDb->FreeVariant(&dbv);
}
}
- else AddMessage( LPGEN("Unknown error while adding %s contact %s"), szProto, pszUserName );
+ else AddMessage( LPGEN("Unknown error while adding %s contact %S"), szProto, pszUserName );
return hDst;
}
@@ -304,10 +312,19 @@ static HANDLE convertContact(HANDLE hContact)
if ( pszUniqueSetting && ( INT_PTR )pszUniqueSetting != CALLSERVICE_NOTFOUND ) {
DBVARIANT dbv;
if ( !myGet(hContact, szProto, pszUniqueSetting, &dbv)) {
- if ( dbv.type == DBVT_DWORD )
- hDst = HContactFromNumericID(szProto, pszUniqueSetting, dbv.dVal);
- else
- hDst = HContactFromID(szProto, pszUniqueSetting, dbv.pszVal);
+ switch (dbv.type) {
+ case DBVT_DWORD:
+ hDst = HContactFromNumericID( szProto, pszUniqueSetting, dbv.dVal );
+ break;
+
+ case DBVT_ASCIIZ:
+ hDst = HContactFromID(szProto, pszUniqueSetting, _A2T(dbv.pszVal));
+ break;
+
+ case DBVT_WCHAR:
+ hDst = HContactFromID(szProto, pszUniqueSetting, dbv.ptszVal);
+ break;
+ }
srcDb->FreeVariant( &dbv );
}
}