diff options
Diffstat (limited to 'plugins/Import/src/import.cpp')
-rw-r--r-- | plugins/Import/src/import.cpp | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp index 920bf8b15d..c19816d33c 100644 --- a/plugins/Import/src/import.cpp +++ b/plugins/Import/src/import.cpp @@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. struct AccountMap
{
- AccountMap(const char *_src, int _origIdx, const TCHAR *_srcName) :
+ AccountMap(const char *_src, int _origIdx, const wchar_t *_srcName) :
szSrcAcc(mir_strdup(_src)),
iSrcIndex(_origIdx),
tszSrcName(mir_tstrdup(_srcName)),
@@ -72,10 +72,10 @@ static MIDatabase *srcDb, *dstDb; /////////////////////////////////////////////////////////////////////////////////////////
-void AddMessage(const TCHAR* fmt, ...)
+void AddMessage(const wchar_t* fmt, ...)
{
va_list args;
- TCHAR msgBuf[4096];
+ wchar_t msgBuf[4096];
va_start(args, fmt);
mir_vsntprintf(msgBuf, _countof(msgBuf), TranslateTS(fmt), args);
@@ -111,7 +111,7 @@ static int myGetD(MCONTACT hContact, const char *szModule, const char *szSetting return srcDb->GetContactSetting(hContact, szModule, szSetting, &dbv) ? iDefault : dbv.dVal;
}
-static TCHAR* myGetWs(MCONTACT hContact, const char *szModule, const char *szSetting)
+static wchar_t* myGetWs(MCONTACT hContact, const char *szModule, const char *szSetting)
{
DBVARIANT dbv = { DBVT_TCHAR };
return srcDb->GetContactSettingStr(hContact, szModule, szSetting, &dbv) ? NULL : dbv.ptszVal;
@@ -138,7 +138,7 @@ static MCONTACT HContactFromNumericID(char *pszProtoName, char *pszSetting, DWOR return INVALID_CONTACT_ID;
}
-static MCONTACT HContactFromID(char *pszProtoName, char *pszSetting, TCHAR *pwszID)
+static MCONTACT HContactFromID(char *pszProtoName, char *pszSetting, wchar_t *pwszID)
{
for (MCONTACT hContact = dstDb->FindFirstContact(); hContact; hContact = dstDb->FindNextContact(hContact)) {
char *szProto = GetContactProto(hContact);
@@ -230,7 +230,7 @@ static LRESULT CALLBACK ListWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM ListView_GetSubItemRect(hwnd, hit.iItem, 1, LVIR_BOUNDS, &r);
r.top--; r.bottom--;
- TCHAR tszText[100];
+ wchar_t tszText[100];
ListView_GetItemText(hwnd, hit.iItem, 1, tszText, _countof(tszText));
LVITEM lvitem;
@@ -369,7 +369,7 @@ static bool FindDestAccount(const char *szProto) return false;
}
-static PROTOACCOUNT* FindMyAccount(const char *szProto, const char *szBaseProto, const TCHAR *ptszName, bool bStrict)
+static PROTOACCOUNT* FindMyAccount(const char *szProto, const char *szBaseProto, const wchar_t *ptszName, bool bStrict)
{
int destProtoCount;
PROTOACCOUNT **destAccs;
@@ -469,7 +469,7 @@ bool ImportAccounts(OBJLIST<char> &arSkippedModules) continue;
if (!Proto_IsProtocolLoaded(p.szBaseProto)) {
- AddMessage(LPGENT("Protocol %S is not loaded, skipping account %s creation"), p.szBaseProto, p.tszSrcName);
+ AddMessage(LPGENW("Protocol %S is not loaded, skipping account %s creation"), p.szBaseProto, p.tszSrcName);
continue;
}
@@ -480,7 +480,7 @@ bool ImportAccounts(OBJLIST<char> &arSkippedModules) p.pa = ProtoCreateAccount(&newacc);
if (p.pa == NULL) {
- AddMessage(LPGENT("Unable to create an account %s of protocol %S"), p.tszSrcName, p.szBaseProto);
+ AddMessage(LPGENW("Unable to create an account %s of protocol %S"), p.tszSrcName, p.szBaseProto);
return false;
}
@@ -525,12 +525,12 @@ static MCONTACT MapContact(MCONTACT hSrc) return (pDestContact == NULL) ? INVALID_CONTACT_ID : pDestContact->dstID;
}
-static MCONTACT AddContact(char *szProto, char *pszUniqueSetting, DBVARIANT *id, const TCHAR *pszUserID, TCHAR *nick, TCHAR *group)
+static MCONTACT AddContact(char *szProto, char *pszUniqueSetting, DBVARIANT *id, const wchar_t *pszUserID, wchar_t *nick, wchar_t *group)
{
MCONTACT hContact = CallService(MS_DB_CONTACT_ADD, 0, 0);
if (Proto_AddToContact(hContact, szProto) != 0) {
CallService(MS_DB_CONTACT_DELETE, hContact, 0);
- AddMessage(LPGENT("Failed to add %S contact %s"), szProto, pszUserID);
+ AddMessage(LPGENW("Failed to add %S contact %s"), szProto, pszUserID);
return INVALID_CONTACT_ID;
}
@@ -540,9 +540,9 @@ static MCONTACT AddContact(char *szProto, char *pszUniqueSetting, DBVARIANT *id, if (nick && *nick) {
db_set_ws(hContact, "CList", "MyHandle", nick);
- AddMessage(LPGENT("Added %S contact %s, '%s'"), szProto, pszUserID, nick);
+ AddMessage(LPGENW("Added %S contact %s, '%s'"), szProto, pszUserID, nick);
}
- else AddMessage(LPGENT("Added %S contact %s"), szProto, pszUserID);
+ else AddMessage(LPGENW("Added %S contact %s"), szProto, pszUserID);
srcDb->FreeVariant(id);
return hContact;
@@ -582,7 +582,7 @@ static int ImportGroup(const char* szSettingName, LPARAM lParam) {
int *pnGroups = (int*)lParam;
- TCHAR *tszGroup = myGetWs(NULL, "CListGroups", szSettingName);
+ wchar_t *tszGroup = myGetWs(NULL, "CListGroups", szSettingName);
if (tszGroup != NULL) {
if (CreateGroup(tszGroup + 1, NULL))
pnGroups[0]++;
@@ -659,7 +659,7 @@ void ImportMeta(DBCachedContact *ccSrc) if (ccDst == NULL) {
MCONTACT hDest = FindExistingMeta(ccSrc);
if (hDest == 0) {
- AddMessage(LPGENT("Metacontact cannot be imported due to its ambiguity."));
+ AddMessage(LPGENW("Metacontact cannot be imported due to its ambiguity."));
return;
}
@@ -714,14 +714,14 @@ void ImportMeta(DBCachedContact *ccSrc) if (tszNick && *tszNick) {
db_set_ws(hDest, "CList", "MyHandle", tszNick);
- AddMessage(LPGENT("Added metacontact '%s'"), tszNick);
+ AddMessage(LPGENW("Added metacontact '%s'"), tszNick);
}
- else AddMessage(LPGENT("Added metacontact"));
+ else AddMessage(LPGENW("Added metacontact"));
}
PROTOACCOUNT *pa = Proto_GetAccount(META_PROTO);
if (pa) {
- AccountMap pda(META_PROTO, 0, _T(META_PROTO));
+ AccountMap pda(META_PROTO, 0, META_PROTOW);
ImportContactSettings(&pda, ccSrc->contactID, ccDst->contactID);
}
@@ -735,7 +735,7 @@ static MCONTACT ImportContact(MCONTACT hSrc) // Check what protocol this contact belongs to
DBCachedContact *cc = srcDb->m_cache->GetCachedContact(hSrc);
if (cc == NULL || cc->szProto == NULL) {
- AddMessage(LPGENT("Skipping contact with no protocol"));
+ AddMessage(LPGENW("Skipping contact with no protocol"));
return NULL;
}
@@ -746,40 +746,40 @@ static MCONTACT ImportContact(MCONTACT hSrc) AccountMap *pda = arAccountMap.find((AccountMap*)&cc->szProto);
if (pda == NULL || pda->pa == NULL) {
- AddMessage(LPGENT("Skipping contact, account %S cannot be mapped."), cc->szProto);
+ AddMessage(LPGENW("Skipping contact, account %S cannot be mapped."), cc->szProto);
return NULL;
}
if (!Proto_GetAccount(pda->pa->szModuleName)) {
- AddMessage(LPGENT("Skipping contact, %S not installed."), cc->szProto);
+ AddMessage(LPGENW("Skipping contact, %S not installed."), cc->szProto);
return NULL;
}
// Skip protocols with no unique id setting (some non IM protocols return NULL)
char *pszUniqueSetting = (char*)CallProtoService(pda->pa->szModuleName, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
if (!pszUniqueSetting || (INT_PTR)pszUniqueSetting == CALLSERVICE_NOTFOUND) {
- AddMessage(LPGENT("Skipping non-IM contact (%S)"), cc->szProto);
+ AddMessage(LPGENW("Skipping non-IM contact (%S)"), cc->szProto);
return NULL;
}
DBVARIANT dbv;
if (myGet(hSrc, cc->szProto, pszUniqueSetting, &dbv)) {
- AddMessage(LPGENT("Skipping %S contact, ID not found"), cc->szProto);
+ AddMessage(LPGENW("Skipping %S contact, ID not found"), cc->szProto);
return NULL;
}
// Does the contact already exist?
- TCHAR id[40], *pszUniqueID;
+ wchar_t id[40], *pszUniqueID;
MCONTACT hDst;
switch (dbv.type) {
case DBVT_DWORD:
- pszUniqueID = _ltot(dbv.dVal, id, 10);
+ pszUniqueID = _ltow(dbv.dVal, id, 10);
hDst = HContactFromNumericID(pda->pa->szModuleName, pszUniqueSetting, dbv.dVal);
break;
case DBVT_ASCIIZ:
case DBVT_UTF8:
- pszUniqueID = NEWTSTR_ALLOCA(_A2T(dbv.pszVal));
+ pszUniqueID = NEWWSTR_ALLOCA(_A2T(dbv.pszVal));
hDst = HContactFromID(pda->pa->szModuleName, pszUniqueSetting, pszUniqueID);
break;
@@ -789,7 +789,7 @@ static MCONTACT ImportContact(MCONTACT hSrc) }
if (hDst != INVALID_CONTACT_ID) {
- AddMessage(LPGENT("Skipping duplicate %S contact %s"), cc->szProto, pszUniqueID);
+ AddMessage(LPGENW("Skipping duplicate %S contact %s"), cc->szProto, pszUniqueID);
srcDb->FreeVariant(&dbv);
arContactMap.insert(new ContactMap(hSrc, hDst));
return NULL;
@@ -801,7 +801,7 @@ static MCONTACT ImportContact(MCONTACT hSrc) hDst = AddContact(pda->pa->szModuleName, pszUniqueSetting, &dbv, pszUniqueID, tszNick, tszGroup);
if (hDst == INVALID_CONTACT_ID) {
- AddMessage(LPGENT("Unknown error while adding %S contact %s"), pda->pa->szModuleName, pszUniqueID);
+ AddMessage(LPGENW("Unknown error while adding %S contact %s"), pda->pa->szModuleName, pszUniqueID);
return INVALID_CONTACT_ID;
}
@@ -939,7 +939,7 @@ static void ImportHistory(MCONTACT hContact, PROTOACCOUNT **protocol, int protoC if (dstDb->AddEvent(hOwner, &dbei) != NULL)
nMessagesCount++;
else
- AddMessage(LPGENT("Failed to add message"));
+ AddMessage(LPGENW("Failed to add message"));
}
}
else nDupes++;
@@ -973,18 +973,18 @@ void MirandaImport(HWND hdlg) hdlgProgress = hdlg;
if ((dstDb = GetCurrentDatabase()) == NULL) {
- AddMessage(LPGENT("Error retrieving current profile, exiting."));
+ AddMessage(LPGENW("Error retrieving current profile, exiting."));
return;
}
DATABASELINK *dblink = FindDatabasePlugin(importFile);
if (dblink == NULL) {
- AddMessage(LPGENT("There's no database driver to open the input file, exiting."));
+ AddMessage(LPGENW("There's no database driver to open the input file, exiting."));
return;
}
if ((srcDb = dblink->Load(importFile, TRUE)) == NULL) {
- AddMessage(LPGENT("Error loading source file, exiting."));
+ AddMessage(LPGENW("Error loading source file, exiting."));
return;
}
@@ -999,7 +999,7 @@ void MirandaImport(HWND hdlg) // Get number of contacts
int nNumberOfContacts = srcDb->GetContactCount();
- AddMessage(LPGENT("Number of contacts in database: %d"), nNumberOfContacts);
+ AddMessage(LPGENW("Number of contacts in database: %d"), nNumberOfContacts);
AddMessage(L"");
// Configure database for fast writing
@@ -1010,7 +1010,7 @@ void MirandaImport(HWND hdlg) OBJLIST<char> arSkippedAccs(1, CompareModules);
if (!ImportAccounts(arSkippedAccs)) {
- AddMessage(LPGENT("Error mapping accounts, exiting."));
+ AddMessage(LPGENW("Error mapping accounts, exiting."));
return;
}
@@ -1021,10 +1021,10 @@ void MirandaImport(HWND hdlg) // Import Groups
if (nImportOptions & IOPT_GROUPS) {
- AddMessage(LPGENT("Importing groups."));
+ AddMessage(LPGENW("Importing groups."));
nGroupsCount = ImportGroups();
if (nGroupsCount == -1)
- AddMessage(LPGENT("Group import failed."));
+ AddMessage(LPGENW("Group import failed."));
AddMessage(L"");
}
@@ -1032,7 +1032,7 @@ void MirandaImport(HWND hdlg) // Import Contacts
if (nImportOptions & IOPT_CONTACTS) {
- AddMessage(LPGENT("Importing contacts."));
+ AddMessage(LPGENW("Importing contacts."));
int i = 1;
MCONTACT hContact = srcDb->FindFirstContact();
while (hContact != NULL) {
@@ -1056,13 +1056,13 @@ void MirandaImport(HWND hdlg) for (i = 0; i < arMetas.getCount(); i++)
ImportMeta(arMetas[i]);
}
- else AddMessage(LPGENT("Skipping new contacts import."));
+ else AddMessage(LPGENW("Skipping new contacts import."));
AddMessage(L"");
// End of Import Contacts
// Import NULL contact message chain
if (nImportOptions & IOPT_SYSTEM) {
- AddMessage(LPGENT("Importing system history."));
+ AddMessage(LPGENW("Importing system history."));
int protoCount;
PROTOACCOUNT **accs;
@@ -1071,12 +1071,12 @@ void MirandaImport(HWND hdlg) if (protoCount > 0)
ImportHistory(NULL, accs, protoCount);
}
- else AddMessage(LPGENT("Skipping system history import."));
+ else AddMessage(LPGENW("Skipping system history import."));
AddMessage(L"");
// Import other contact messages
if (nImportOptions & IOPT_HISTORY) {
- AddMessage(LPGENT("Importing history."));
+ AddMessage(LPGENW("Importing history."));
MCONTACT hContact = srcDb->FindFirstContact();
for (int i = 1; hContact != NULL; i++) {
ImportHistory(hContact, NULL, NULL);
@@ -1085,7 +1085,7 @@ void MirandaImport(HWND hdlg) hContact = srcDb->FindNextContact(hContact);
}
}
- else AddMessage(LPGENT("Skipping history import."));
+ else AddMessage(LPGENW("Skipping history import."));
AddMessage(L"");
// Restore database writing mode
@@ -1098,17 +1098,17 @@ void MirandaImport(HWND hdlg) dwTimer = time(NULL) - dwTimer;
// Print statistics
- AddMessage(LPGENT("Import completed in %d seconds."), dwTimer);
+ AddMessage(LPGENW("Import completed in %d seconds."), dwTimer);
SetProgress(100);
AddMessage(nMessagesCount == 0 ?
- LPGENT("Added %d contacts and %d groups.") : LPGENT("Added %d contacts, %d groups and %d events."),
+ LPGENW("Added %d contacts and %d groups.") : LPGENW("Added %d contacts, %d groups and %d events."),
nContactsCount, nGroupsCount, nMessagesCount);
if (nSkippedContacts)
- AddMessage(LPGENT("Skipped %d contacts."), nSkippedContacts);
+ AddMessage(LPGENW("Skipped %d contacts."), nSkippedContacts);
if (nDupes || nSkippedEvents)
- AddMessage(LPGENT("Skipped %d duplicates and %d filtered events."), nDupes, nSkippedEvents);
+ AddMessage(LPGENW("Skipped %d duplicates and %d filtered events."), nDupes, nSkippedEvents);
arMetas.destroy();
arAccountMap.destroy();
|