diff options
author | George Hazan <george.hazan@gmail.com> | 2014-08-11 15:17:20 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-08-11 15:17:20 +0000 |
commit | f1e6c9b63fc90e6fbbcfcef52912ad0fda768302 (patch) | |
tree | 0760375443d3e186253ed2367d54817fc6d91ea4 | |
parent | e54f5144d2be315ee14ea7ae42a2a38f53e1162a (diff) |
import: clearance
git-svn-id: http://svn.miranda-ng.org/main/trunk@10156 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/Import/src/import.cpp | 53 | ||||
-rw-r--r-- | plugins/Import/src/import.h | 6 | ||||
-rw-r--r-- | plugins/Import/src/main.cpp | 17 | ||||
-rw-r--r-- | plugins/Import/src/miranda.cpp | 5 | ||||
-rw-r--r-- | plugins/Import/src/progress.cpp | 6 | ||||
-rw-r--r-- | plugins/Import/src/utils.cpp | 30 | ||||
-rw-r--r-- | plugins/Import/src/wizard.cpp | 2 |
7 files changed, 65 insertions, 54 deletions
diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp index 6a3c21ff37..5a4e1fbfe2 100644 --- a/plugins/Import/src/import.cpp +++ b/plugins/Import/src/import.cpp @@ -63,30 +63,25 @@ static void mySet(MCONTACT hContact, const char *module, const char *var, DBVARI static MCONTACT HContactFromNumericID(char *pszProtoName, char *pszSetting, DWORD dwID)
{
- MCONTACT hContact = dstDb->FindFirstContact();
- while (hContact != NULL) {
- if ( db_get_dw((MCONTACT)hContact, pszProtoName, pszSetting, 0) == dwID) {
- char* szProto = GetContactProto((MCONTACT)hContact);
+ for (MCONTACT hContact = dstDb->FindFirstContact(); hContact; hContact = dstDb->FindNextContact(hContact)) {
+ if (db_get_dw(hContact, pszProtoName, pszSetting, 0) == dwID) {
+ char* szProto = GetContactProto(hContact);
if (szProto != NULL && !lstrcmpA(szProto, pszProtoName))
return hContact;
}
- hContact = dstDb->FindNextContact((MCONTACT)hContact);
}
return INVALID_CONTACT_ID;
}
static MCONTACT HContactFromID(char *pszProtoName, char *pszSetting, TCHAR *pwszID)
{
- MCONTACT hContact = dstDb->FindFirstContact();
- while (hContact != NULL) {
- char* szProto = GetContactProto((MCONTACT)hContact);
- if ( !lstrcmpA(szProto, pszProtoName)) {
- ptrW id(db_get_tsa((MCONTACT)hContact, pszProtoName, pszSetting));
- if ( !lstrcmp(pwszID, id))
+ for (MCONTACT hContact = dstDb->FindFirstContact(); hContact; hContact = dstDb->FindNextContact(hContact)) {
+ char *szProto = GetContactProto(hContact);
+ if (!lstrcmpA(szProto, pszProtoName)) {
+ ptrW id(db_get_tsa(hContact, pszProtoName, pszSetting));
+ if (!lstrcmp(pwszID, id))
return hContact;
}
-
- hContact = (MCONTACT)dstDb->FindNextContact(hContact);
}
return INVALID_CONTACT_ID;
}
@@ -95,7 +90,7 @@ static MCONTACT HistoryImportFindContact(HWND hdlgProgress, char* szModuleName, {
MCONTACT hContact = HContactFromNumericID(szModuleName, "UIN", uin);
if (hContact == NULL) {
- AddMessage( LPGENT("Ignored event from/to self"));
+ AddMessage(LPGENT("Ignored event from/to self"));
return INVALID_CONTACT_ID;
}
@@ -105,10 +100,10 @@ static MCONTACT HistoryImportFindContact(HWND hdlgProgress, char* szModuleName, if (!addUnknown)
return INVALID_CONTACT_ID;
- hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ hContact = CallService(MS_DB_CONTACT_ADD, 0, 0);
CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)szModuleName);
- db_set_dw((MCONTACT)hContact, szModuleName, "UIN", uin);
- AddMessage( LPGENT("Added contact %u (found in history)"), uin );
+ db_set_dw(hContact, szModuleName, "UIN", uin);
+ AddMessage(LPGENT("Added contact %u (found in history)"), uin);
return hContact;
}
@@ -116,7 +111,7 @@ static MCONTACT HistoryImportFindContact(HWND hdlgProgress, char* szModuleName, static MCONTACT AddContact(HWND hdlgProgress, char* szProto, char* pszUniqueSetting, DBVARIANT* id, const TCHAR* pszUserID, TCHAR *nick, TCHAR *group)
{
- MCONTACT hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ MCONTACT hContact = CallService(MS_DB_CONTACT_ADD, 0, 0);
if (CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)szProto) != 0) {
CallService(MS_DB_CONTACT_DELETE, hContact, 0);
AddMessage(LPGENT("Failed to add %S contact %s"), szProto, pszUserID);
@@ -125,10 +120,10 @@ static MCONTACT AddContact(HWND hdlgProgress, char* szProto, char* pszUniqueSett mySet(hContact, szProto, pszUniqueSetting, id);
- CreateGroup(group, (MCONTACT)hContact);
+ CreateGroup(group, hContact);
if (nick && *nick) {
- db_set_ws((MCONTACT)hContact, "CList", "MyHandle", nick);
+ db_set_ws(hContact, "CList", "MyHandle", nick);
AddMessage(LPGENT("Added %S contact %s, '%s'"), szProto, pszUserID, nick);
}
else AddMessage(LPGENT("Added %S contact %s"), szProto, pszUserID);
@@ -139,11 +134,11 @@ static MCONTACT AddContact(HWND hdlgProgress, char* szProto, char* pszUniqueSett static int ImportGroup(const char* szSettingName, LPARAM lParam)
{
- int* pnGroups = (int*)lParam;
+ int *pnGroups = (int*)lParam;
TCHAR* tszGroup = myGetWs(NULL, "CListGroups", szSettingName);
if (tszGroup != NULL) {
- if ( CreateGroup( tszGroup+1, NULL ))
+ if (CreateGroup(tszGroup + 1, NULL))
pnGroups[0]++;
mir_free(tszGroup);
}
@@ -167,7 +162,7 @@ static int ImportGroups() static MCONTACT ImportContact(MCONTACT hSrc)
{
MCONTACT hDst;
- TCHAR id[ 40 ], *pszUniqueID;
+ TCHAR id[40], *pszUniqueID;
char szProto[100];
// Check what protocol this contact belongs to
@@ -182,7 +177,7 @@ static MCONTACT ImportContact(MCONTACT hSrc) }
// Skip protocols with no unique id setting (some non IM protocols return NULL)
- char* pszUniqueSetting = (char*)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
+ char *pszUniqueSetting = (char*)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
if (!pszUniqueSetting || (INT_PTR)pszUniqueSetting == CALLSERVICE_NOTFOUND) {
AddMessage(LPGENT("Skipping non-IM contact (%S)"), szProto);
return NULL;
@@ -403,15 +398,14 @@ static void ImportHistory(MCONTACT hContact, PROTOACCOUNT **protocol, int protoC if (!skip) {
// Check for duplicate entries
- if (!IsDuplicateEvent((MCONTACT)hDst, dbei)) {
+ if (!IsDuplicateEvent(hDst, dbei)) {
// Add dbevent
if (dstDb->AddEvent(hDst, &dbei) != NULL)
nMessagesCount++;
else
AddMessage(LPGENT("Failed to add message"));
}
- else
- nDupes++;
+ else nDupes++;
}
}
@@ -438,9 +432,6 @@ static void ImportHistory(MCONTACT hContact, PROTOACCOUNT **protocol, int protoC void MirandaImport(HWND hdlg)
{
- DWORD dwTimer;
- char* pszModuleName = NULL;
-
// Just to keep the macros happy
hdlgProgress = hdlg;
if ((dstDb = GetCurrentDatabase()) == NULL) {
@@ -477,7 +468,7 @@ void MirandaImport(HWND hdlg) dstDb->SetCacheSafetyMode(FALSE);
// Start benchmark timer
- dwTimer = time(NULL);
+ DWORD dwTimer = time(NULL);
// Import Groups
if (nImportOption == IMPORT_ALL || (nCustomOptions & IOPT_GROUPS)) {
diff --git a/plugins/Import/src/import.h b/plugins/Import/src/import.h index c61299ead5..5733527f3c 100644 --- a/plugins/Import/src/import.h +++ b/plugins/Import/src/import.h @@ -109,10 +109,12 @@ bool IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO dbei); int CreateGroup(const TCHAR* name, MCONTACT hContact);
extern HINSTANCE hInst;
-extern HANDLE hIcoHandle;
extern HWND hdlgProgress;
-extern void (*DoImport)(HWND);
extern int nImportOption;
extern int nCustomOptions;
extern TCHAR importFile[];
extern time_t dwSinceDate;
+
+HICON GetIcon(int iIconId);
+HANDLE GetIconHandle(int iIconId);
+void RegisterIcons(void);
diff --git a/plugins/Import/src/main.cpp b/plugins/Import/src/main.cpp index e7dcc6432d..1c90c5c792 100644 --- a/plugins/Import/src/main.cpp +++ b/plugins/Import/src/main.cpp @@ -28,7 +28,6 @@ int nCustomOptions; static HANDLE hImportService = NULL;
HINSTANCE hInst;
-HANDLE hIcoHandle;
INT_PTR CALLBACK WizardDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam);
static HWND hwndWizard = NULL;
@@ -105,22 +104,18 @@ static int OnExit(WPARAM wParam, LPARAM lParam) return 0;
}
-static IconItem iconList[] = {
- { LPGEN("Import..."), "import_main", IDI_IMPORT }
-};
-
extern "C" __declspec(dllexport) int Load(void)
{
mir_getLP( &pluginInfo );
hImportService = CreateServiceFunction(IMPORT_SERVICE, ImportCommand);
- // icon
- Icon_Register(hInst, "Import", iconList, SIZEOF(iconList));
+ RegisterIcons();
// menu item
- CLISTMENUITEM mi = { sizeof(mi) };
- mi.icolibItem = iconList[0].hIcolib;
+ CLISTMENUITEM mi = { 0 };
+ mi.cbSize = sizeof(mi);
+ mi.icolibItem = GetIconHandle(IDI_IMPORT);
mi.pszName = LPGEN("&Import...");
mi.position = 500050000;
mi.pszService = IMPORT_SERVICE;
@@ -141,8 +136,6 @@ extern "C" __declspec(dllexport) int Load(void) extern "C" __declspec(dllexport) int Unload(void)
{
- if (hImportService)
- DestroyServiceFunction(hImportService);
-
+ DestroyServiceFunction(hImportService);
return 0;
}
diff --git a/plugins/Import/src/miranda.cpp b/plugins/Import/src/miranda.cpp index 071ba4dc33..0a24d97d5e 100644 --- a/plugins/Import/src/miranda.cpp +++ b/plugins/Import/src/miranda.cpp @@ -22,8 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "import.h"
-void MirandaImport(HWND hdlgProgress);
-
// =====================
// == LOCAL VARIABLES ==
// =====================
@@ -173,7 +171,6 @@ INT_PTR CALLBACK MirandaOptionsPageProc(HWND hdlg, UINT message, WPARAM wParam, if (IsDlgButtonChecked(hdlg, IDC_RADIO_ALL)) {
nImportOption = IMPORT_ALL;
nCustomOptions = 0;//IOPT_MSGSENT|IOPT_MSGRECV|IOPT_URLSENT|IOPT_URLRECV;
- DoImport = MirandaImport;
PostMessage(GetParent(hdlg), WIZM_GOTOPAGE, IDD_PROGRESS, (LPARAM)ProgressPageProc);
break;
}
@@ -181,7 +178,6 @@ INT_PTR CALLBACK MirandaOptionsPageProc(HWND hdlg, UINT message, WPARAM wParam, if (IsDlgButtonChecked(hdlg, IDC_RADIO_CONTACTS)) {
nImportOption = IMPORT_CONTACTS;
nCustomOptions = 0;
- DoImport = MirandaImport;
PostMessage(GetParent(hdlg), WIZM_GOTOPAGE, IDD_PROGRESS, (LPARAM)ProgressPageProc);
break;
}
@@ -233,7 +229,6 @@ INT_PTR CALLBACK MirandaAdvOptionsPageProc(HWND hdlg, UINT message, WPARAM wPara break;
case IDOK:
- DoImport = MirandaImport;
nImportOption = IMPORT_CUSTOM;
nCustomOptions = 0;
diff --git a/plugins/Import/src/progress.cpp b/plugins/Import/src/progress.cpp index 168cb0a14c..a6f8360636 100644 --- a/plugins/Import/src/progress.cpp +++ b/plugins/Import/src/progress.cpp @@ -24,9 +24,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define PROGM_START (WM_USER+100)
-INT_PTR CALLBACK FinishedPageProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lParam);
+void MirandaImport(HWND);
-void (*DoImport)(HWND);
+INT_PTR CALLBACK FinishedPageProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lParam);
INT_PTR CALLBACK ProgressPageProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
{
@@ -52,7 +52,7 @@ INT_PTR CALLBACK ProgressPageProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM break;
case PROGM_START:
- DoImport(hdlg);
+ MirandaImport(hdlg);
SendMessage(GetParent(hdlg), WIZM_ENABLEBUTTON, 1, 0);
SendMessage(GetParent(hdlg), WIZM_ENABLEBUTTON, 2, 0);
break;
diff --git a/plugins/Import/src/utils.cpp b/plugins/Import/src/utils.cpp index b3e3d7d6ed..8ab913ecf9 100644 --- a/plugins/Import/src/utils.cpp +++ b/plugins/Import/src/utils.cpp @@ -221,3 +221,33 @@ bool IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO dbei) hPreviousContact = INVALID_CONTACT_ID;
return FALSE;
}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// icons
+
+static IconItem iconList[] = {
+ { LPGEN("Import..."), "import_main", IDI_IMPORT }
+};
+
+HICON GetIcon(int iIconId)
+{
+ for (int i = 0; i < SIZEOF(iconList); i++)
+ if (iconList[i].defIconID == iIconId)
+ return Skin_GetIconByHandle(iconList[i].hIcolib);
+
+ return NULL;
+}
+
+HANDLE GetIconHandle(int iIconId)
+{
+ for (int i = 0; i < SIZEOF(iconList); i++)
+ if (iconList[i].defIconID == iIconId)
+ return iconList[i].hIcolib;
+
+ return NULL;
+}
+
+void RegisterIcons()
+{
+ Icon_Register(hInst, "Import", iconList, SIZEOF(iconList));
+}
diff --git a/plugins/Import/src/wizard.cpp b/plugins/Import/src/wizard.cpp index 936ba18ee8..2bbde58e64 100644 --- a/plugins/Import/src/wizard.cpp +++ b/plugins/Import/src/wizard.cpp @@ -99,7 +99,7 @@ INT_PTR CALLBACK WizardDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lP SetWindowPos(hwndPage, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
ShowWindow(hwndPage, SW_SHOW);
ShowWindow(hdlg, SW_SHOW);
- SendMessage(hdlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_GetIconByHandle(hIcoHandle));
+ SendMessage(hdlg, WM_SETICON, ICON_BIG, (LPARAM)GetIcon(IDI_IMPORT));
return TRUE;
case WIZM_GOTOPAGE:
|