diff options
author | George Hazan <george.hazan@gmail.com> | 2012-07-24 19:46:34 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-07-24 19:46:34 +0000 |
commit | afb1914145f007e970787d9c37a9fb5f5aff2354 (patch) | |
tree | d46d9e2c5e578255bd605945aa1cacbdbdacf578 /plugins/Import | |
parent | e26440954f80b88d374559ab7f33821e8c78aa1e (diff) |
git-svn-id: http://svn.miranda-ng.org/main/trunk@1171 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Import')
-rw-r--r-- | plugins/Import/src/import.cpp | 93 | ||||
-rw-r--r-- | plugins/Import/src/import.h | 5 | ||||
-rw-r--r-- | plugins/Import/src/utils.cpp | 43 |
3 files changed, 69 insertions, 72 deletions
diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp index 552beeefc5..6940b9c011 100644 --- a/plugins/Import/src/import.cpp +++ b/plugins/Import/src/import.cpp @@ -30,6 +30,8 @@ HWND hdlgProgress; static DWORD nDupes, nContactsCount, nMessagesCount, nGroupsCount, nSkippedEvents, nSkippedContacts;
static MIDatabase *srcDb, *dstDb;
+/////////////////////////////////////////////////////////////////////////////////////////
+
static int myGet(HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv)
{
dbv->type = 0;
@@ -51,7 +53,7 @@ static char* myGetS(HANDLE hContact, const char *szModule, const char *szSetting return ( srcDb->GetContactSettingStr(hContact, &dgs)) ? NULL : dbv.pszVal;
}
-void mySet(HANDLE hContact, const char *module, const char *var, DBVARIANT *dbv)
+static void mySet(HANDLE hContact, const char *module, const char *var, DBVARIANT *dbv)
{
DBCONTACTWRITESETTING dbw;
dbw.szModule = module;
@@ -60,32 +62,23 @@ void mySet(HANDLE hContact, const char *module, const char *var, DBVARIANT *dbv) dstDb->WriteContactSetting(hContact, &dbw);
}
-static int ImportGroup(const char* szSettingName, LPARAM lParam)
-{
- int* pnGroups = (int*)lParam;
+/////////////////////////////////////////////////////////////////////////////////////////
- TCHAR* tszGroup = myGetWs(NULL, "CListGroups", szSettingName);
- if (tszGroup != NULL) {
- if ( CreateGroup( tszGroup, NULL ))
- pnGroups[0]++;
- mir_free(tszGroup);
- }
- return 0;
-}
-
-static int ImportGroups()
+static HANDLE HContactFromNumericID(char* pszProtoName, char* pszSetting, DWORD dwID)
{
- int nGroups = 0;
-
- DBCONTACTENUMSETTINGS param = { 0 };
- param.szModule = "CListGroups";
- param.pfnEnumProc = ImportGroup;
- param.lParam = (LPARAM)&nGroups;
- srcDb->EnumContactSettings(NULL, ¶m);
- return nGroups;
+ HANDLE hContact = dstDb->FindFirstContact();
+ while (hContact != NULL) {
+ if ( db_get_dw(hContact, pszProtoName, pszSetting, 0) == dwID) {
+ char* szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ if (szProto != NULL && !lstrcmpA(szProto, pszProtoName))
+ return hContact;
+ }
+ hContact = dstDb->FindNextContact(hContact);
+ }
+ return INVALID_HANDLE_VALUE;
}
-HANDLE HContactFromID(char* pszProtoName, char* pszSetting, char* pszID)
+static HANDLE HContactFromID(char* pszProtoName, char* pszSetting, char* pszID)
{
HANDLE hContact = dstDb->FindFirstContact();
while (hContact != NULL) {
@@ -101,7 +94,30 @@ HANDLE HContactFromID(char* pszProtoName, char* pszSetting, char* pszID) return INVALID_HANDLE_VALUE;
}
-HANDLE AddContact(HWND hdlgProgress, char* pszProtoName, char* pszUniqueSetting, DBVARIANT* id, TCHAR *nick, TCHAR *group)
+static HANDLE HistoryImportFindContact(HWND hdlgProgress, char* szModuleName, DWORD uin, int addUnknown)
+{
+ HANDLE hContact = HContactFromNumericID(szModuleName, "UIN", uin);
+ if (hContact == NULL) {
+ AddMessage( LPGEN("Ignored event from/to self"));
+ return INVALID_HANDLE_VALUE;
+ }
+
+ if (hContact != INVALID_HANDLE_VALUE)
+ return hContact;
+
+ if (!addUnknown)
+ return INVALID_HANDLE_VALUE;
+
+ hContact = (HANDLE)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)szModuleName);
+ DBWriteContactSettingDword(hContact, szModuleName, "UIN", uin);
+ AddMessage( LPGEN("Added contact %u (found in history)"), uin );
+ return hContact;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static HANDLE AddContact(HWND hdlgProgress, char* pszProtoName, char* pszUniqueSetting, DBVARIANT* id, TCHAR *nick, TCHAR *group)
{
HANDLE hContact;
char szid[ 40 ];
@@ -129,6 +145,33 @@ HANDLE AddContact(HWND hdlgProgress, char* pszProtoName, char* pszUniqueSetting, return hContact;
}
+static int ImportGroup(const char* szSettingName, LPARAM lParam)
+{
+ int* pnGroups = (int*)lParam;
+
+ TCHAR* tszGroup = myGetWs(NULL, "CListGroups", szSettingName);
+ if (tszGroup != NULL) {
+ if ( CreateGroup( tszGroup, NULL ))
+ pnGroups[0]++;
+ mir_free(tszGroup);
+ }
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static int ImportGroups()
+{
+ int nGroups = 0;
+
+ DBCONTACTENUMSETTINGS param = { 0 };
+ param.szModule = "CListGroups";
+ param.pfnEnumProc = ImportGroup;
+ param.lParam = (LPARAM)&nGroups;
+ srcDb->EnumContactSettings(NULL, ¶m);
+ return nGroups;
+}
+
static HANDLE ImportContact(HANDLE hSrc)
{
HANDLE hDst;
@@ -371,6 +414,8 @@ static void ImportHistory(HANDLE hContact, PROTOACCOUNT **protocol, int protoCou }
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
void MirandaImport(HWND hdlg)
{
DWORD dwTimer;
diff --git a/plugins/Import/src/import.h b/plugins/Import/src/import.h index 43effb7a0f..da42985a32 100644 --- a/plugins/Import/src/import.h +++ b/plugins/Import/src/import.h @@ -111,11 +111,6 @@ INT_PTR CALLBACK MirandaOptionsPageProc(HWND hdlg,UINT message,WPARAM wParam,LPA INT_PTR CALLBACK MirandaAdvOptionsPageProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lParam);
INT_PTR CALLBACK FinishedPageProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam);
-HANDLE HContactFromNumericID(char* pszProtoName, char* pszSetting, DWORD dwID);
-HANDLE HContactFromID(char* pszProtoName, char* pszSetting, char* pszID);
-
-HANDLE AddContact(HWND hdlgProgress, char* pszProtoName, char* pszUniqueSetting, DBVARIANT* id, TCHAR *nick, TCHAR *group);
-
BOOL IsProtocolLoaded(char* pszProtocolName);
BOOL IsDuplicateEvent(HANDLE hContact, DBEVENTINFO dbei);
diff --git a/plugins/Import/src/utils.cpp b/plugins/Import/src/utils.cpp index 522a987e02..9d51d0f47c 100644 --- a/plugins/Import/src/utils.cpp +++ b/plugins/Import/src/utils.cpp @@ -24,11 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "version.h"
#include "resource.h"
-int cICQAccounts = 0;
-char ** szICQModuleName = NULL;
-TCHAR ** tszICQAccountName = NULL;
-int iICQAccount = 0;
-
/////////////////////////////////////////////////////////////////////////////////////////
BOOL IsProtocolLoaded(char* pszProtocolName)
@@ -36,44 +31,6 @@ BOOL IsProtocolLoaded(char* pszProtocolName) return CallService(MS_PROTO_ISPROTOCOLLOADED, 0, (LPARAM)pszProtocolName) ? TRUE : FALSE;
}
-HANDLE HContactFromNumericID(char* pszProtoName, char* pszSetting, DWORD dwID)
-{
- char* szProto;
- HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
- while (hContact != NULL)
- {
- if (DBGetContactSettingDword(hContact, pszProtoName, pszSetting, 0) == dwID)
- {
- szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
- if (szProto != NULL && !strcmp(szProto, pszProtoName))
- return hContact;
- }
- hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0);
- }
- return INVALID_HANDLE_VALUE;
-}
-
-HANDLE HistoryImportFindContact(HWND hdlgProgress, char* szModuleName, DWORD uin, int addUnknown)
-{
- HANDLE hContact = HContactFromNumericID(szModuleName, "UIN", uin);
- if (hContact == NULL) {
- AddMessage( LPGEN("Ignored event from/to self"));
- return INVALID_HANDLE_VALUE;
- }
-
- if (hContact != INVALID_HANDLE_VALUE)
- return hContact;
-
- if (!addUnknown)
- return INVALID_HANDLE_VALUE;
-
- hContact = (HANDLE)CallService(MS_DB_CONTACT_ADD, 0, 0);
- CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)szModuleName);
- DBWriteContactSettingDword(hContact, szModuleName, "UIN", uin);
- AddMessage( LPGEN("Added contact %u (found in history)"), uin );
- return hContact;
-}
-
// ------------------------------------------------
// Creates a group with a specified name in the
// Miranda contact list.
|