summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-04-04 15:08:55 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-04-04 15:08:55 +0000
commit1705dfe26353057e4fa274280ff9552840ea9aab (patch)
tree6951b185f50c09ea8c6400cd96ded4866cde45fd /plugins
parent814f6082b4fa4b4c7c31edba2e1a63bfeaf71828 (diff)
Non-IM contacts:
- 64-bit adaptation; - icons migrated to icolib; - various cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@4301 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Non-IM Contact/res/resource.rc2
-rw-r--r--plugins/Non-IM Contact/src/commonheaders.h3
-rw-r--r--plugins/Non-IM Contact/src/contactinfo.cpp49
-rw-r--r--plugins/Non-IM Contact/src/dialog.cpp256
-rw-r--r--plugins/Non-IM Contact/src/main.cpp15
-rw-r--r--plugins/Non-IM Contact/src/namereplacing.cpp4
-rw-r--r--plugins/Non-IM Contact/src/resource.h1
-rw-r--r--plugins/Non-IM Contact/src/services.cpp105
8 files changed, 207 insertions, 228 deletions
diff --git a/plugins/Non-IM Contact/res/resource.rc b/plugins/Non-IM Contact/res/resource.rc
index 0385c90289..649f218618 100644
--- a/plugins/Non-IM Contact/res/resource.rc
+++ b/plugins/Non-IM Contact/res/resource.rc
@@ -116,8 +116,6 @@ STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
FONT 8, "MS Sans Serif"
BEGIN
- CONTROL "Ignore global status change",IDC_IGNORE_GLOBALSTATUS,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,28,103,10
CONTROL "Away as another status",IDC_AWAYISNOTONLINE,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,42,89,10
CONTROL "Disable timer",IDC_DISABLETIMER,"Button",
diff --git a/plugins/Non-IM Contact/src/commonheaders.h b/plugins/Non-IM Contact/src/commonheaders.h
index a512a40b06..e46847faf7 100644
--- a/plugins/Non-IM Contact/src/commonheaders.h
+++ b/plugins/Non-IM Contact/src/commonheaders.h
@@ -39,6 +39,7 @@ struct DLGTEMPLATEEX
#include <m_protomod.h>
#include <m_database.h>
#include <m_system.h>
+#include <m_icolib.h>
#include <m_protocols.h>
#include <m_userinfo.h>
#include <m_options.h>
@@ -72,7 +73,7 @@ struct DLGTEMPLATEEX
//General
extern HINSTANCE hInst;
extern int LCStatus;
-static HANDLE hWindowList=NULL;
+extern IconItem icoList[];
//Services.c
INT_PTR GetLCCaps(WPARAM wParam,LPARAM lParam);
diff --git a/plugins/Non-IM Contact/src/contactinfo.cpp b/plugins/Non-IM Contact/src/contactinfo.cpp
index 7b79a6c6f2..ac4f57cb5f 100644
--- a/plugins/Non-IM Contact/src/contactinfo.cpp
+++ b/plugins/Non-IM Contact/src/contactinfo.cpp
@@ -8,7 +8,7 @@ INT_PTR CALLBACK DlgProcContactInfo(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
HANDLE hContact = (HANDLE)((PROPSHEETPAGE*)lParam)->lParam;
char name[2048];
TranslateDialogDefault(hwnd);
- SetWindowLong(hwnd, GWLP_USERDATA, (LPARAM)(HANDLE)hContact);
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, (LPARAM)(HANDLE)hContact);
if (!db_get_static(hContact, MODNAME, "Name", name)) break;
SetDlgItemTextA(hwnd, IDC_DISPLAY_NAME, name);
@@ -26,7 +26,7 @@ INT_PTR CALLBACK DlgProcContactInfo(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
case 0:
switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
- HANDLE hContact = (HANDLE)GetWindowLong(hwnd, GWLP_USERDATA);
+ HANDLE hContact = (HANDLE)GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (GetWindowTextLength(GetDlgItem(hwnd,IDC_DISPLAY_NAME))) {
char text[512];
GetDlgItemTextA(hwnd,IDC_DISPLAY_NAME,text,sizeof(text));
@@ -37,7 +37,7 @@ INT_PTR CALLBACK DlgProcContactInfo(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
db_unset(hContact, MODNAME, "Name");
db_unset(hContact, MODNAME, "Nick");
}
-
+
if (GetWindowTextLength(GetDlgItem(hwnd,IDC_TOOLTIP))) {
char text[2048];
GetDlgItemTextA(hwnd,IDC_TOOLTIP,text,sizeof(text));
@@ -71,8 +71,7 @@ LRESULT CALLBACK ButtWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
rc.top += (rc.bottom - rc.top - 16) / 2;
if (isPressed)
OffsetRect(&rc, 1, 1);
- DrawIconEx(dc, rc.left, rc.top, (HICON)GetWindowLong(hWnd, GWLP_USERDATA),
- 16, 16, 0, 0, DI_NORMAL);
+ DrawIconEx(dc, rc.left, rc.top, (HICON)GetWindowLongPtr(hWnd, GWLP_USERDATA), 16, 16, 0, 0, DI_NORMAL);
ReleaseDC(hWnd, dc);
}
@@ -148,24 +147,24 @@ INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
char string[512];
HANDLE hContact = (HANDLE)((PROPSHEETPAGE*)lParam)->lParam;
TranslateDialogDefault(hwnd);
- SetWindowLong(hwnd, GWLP_USERDATA, (LPARAM)(HANDLE)hContact);
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, (LPARAM)(HANDLE)hContact);
if (!hContact)
break;
/* link*/
if (db_get_static(hContact, MODNAME, "ProgramString", string))
SetDlgItemTextA(hwnd, IDC_LINK, string);
+
if (db_get_static(hContact, MODNAME, "ProgramParamsString", string))
SetDlgItemTextA(hwnd, IDC_PARAMS, string);
+
/* group*/
- while (i != -1)
- {
- char str[3], name[256];
+ while (i != -1) {
+ char str[3];
wsprintfA(str, "%d", i);
- if (!DBGetContactSetting(NULL, "CListGroups", str, &dbv))
- {
- lstrcpynA(name,dbv.pszVal+1,sizeof(name));
- SendMessage(GetDlgItem(hwnd, IDC_GROUP), CB_INSERTSTRING,0, (LPARAM)name);
+ if (!db_get_ts(NULL, "CListGroups", str, &dbv)) {
+ SendMessage(GetDlgItem(hwnd, IDC_GROUP), CB_INSERTSTRING,0, LPARAM(dbv.ptszVal+1));
+ db_free(&dbv);
i++;
}
else i = -1;
@@ -175,11 +174,11 @@ INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
/* icons */
CheckRadioButton(hwnd, 40072, 40080, db_get_w(hContact, MODNAME, "Icon", ID_STATUS_ONLINE));
- SetWindowLong(GetDlgItem(hwnd, CHK_ONLINE), GWLP_USERDATA, (LONG)LoadSkinnedProtoIcon(MODNAME, ID_STATUS_ONLINE));
- g_PrevBtnWndProc = (WNDPROC)SetWindowLong(GetDlgItem(hwnd, CHK_ONLINE), GWLP_WNDPROC, (LONG)ButtWndProc);
- for (i = ID_STATUS_ONLINE; i<=ID_STATUS_OUTTOLUNCH; i++) {
- SetWindowLong(GetDlgItem(hwnd, i), GWLP_USERDATA, (LONG)LoadSkinnedProtoIcon(MODNAME, i));
- SetWindowLong(GetDlgItem(hwnd, i), GWLP_WNDPROC, (LONG)ButtWndProc);
+ SetWindowLongPtr(GetDlgItem(hwnd, CHK_ONLINE), GWLP_USERDATA, (LONG)LoadSkinnedProtoIcon(MODNAME, ID_STATUS_ONLINE));
+ g_PrevBtnWndProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwnd, CHK_ONLINE), GWLP_WNDPROC, (LPARAM)ButtWndProc);
+ for (i = ID_STATUS_ONLINE; i <= ID_STATUS_OUTTOLUNCH; i++) {
+ SetWindowLongPtr(GetDlgItem(hwnd, i), GWLP_USERDATA, (LPARAM)LoadSkinnedProtoIcon(MODNAME, i));
+ SetWindowLongPtr(GetDlgItem(hwnd, i), GWLP_WNDPROC, (LPARAM)ButtWndProc);
}
db_free(&dbv);
/* timer */
@@ -209,7 +208,7 @@ INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
switch(LOWORD(wParam)) {
case IDC_ALWAYS_VISIBLE:
if (IsDlgButtonChecked(hwnd, IDC_ALWAYS_VISIBLE)) {
- HANDLE hContact = (HANDLE)GetWindowLong(hwnd, GWLP_USERDATA);
+ HANDLE hContact = (HANDLE)GetWindowLongPtr(hwnd, GWLP_USERDATA);
EnableWindow(GetDlgItem(hwnd, IDC_VISIBLE_UNLESS_OFFLINE),1);
CheckDlgButton(hwnd, IDC_VISIBLE_UNLESS_OFFLINE, db_get_b(hContact, MODNAME ,"VisibleUnlessOffline", 1));
}
@@ -218,7 +217,7 @@ INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
case CHK_USE_TIMER:
if (IsDlgButtonChecked(hwnd, CHK_USE_TIMER)) {
- HANDLE hContact = (HANDLE)GetWindowLong(hwnd, GWLP_USERDATA);
+ HANDLE hContact = (HANDLE)GetWindowLongPtr(hwnd, GWLP_USERDATA);
char string[4];
EnableWindow(GetDlgItem(hwnd, IDC_TIMER), 1);
SetDlgItemTextA(hwnd, IDC_TIMER, _itoa(db_get_w(hContact, MODNAME ,"Timer", 15), string, 10));
@@ -252,7 +251,7 @@ INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
int status = GetLCStatus(0,0);
- HANDLE hContact = (HANDLE)GetWindowLong(hwnd, GWLP_USERDATA);
+ HANDLE hContact = (HANDLE)GetWindowLongPtr(hwnd, GWLP_USERDATA);
int i;
if (GetWindowTextLength(GetDlgItem(hwnd,IDC_LINK)))
{
@@ -339,7 +338,7 @@ INT_PTR CALLBACK DlgProcCopy(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
HANDLE hContact = (HANDLE)((PROPSHEETPAGE*)lParam)->lParam;
TranslateDialogDefault(hwnd);
- SetWindowLong(hwnd, GWLP_USERDATA, (LPARAM)(HANDLE)hContact);
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, (LPARAM)(HANDLE)hContact);
}
return TRUE;
@@ -347,7 +346,7 @@ INT_PTR CALLBACK DlgProcCopy(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
switch(LOWORD(wParam)) {
case IDC_EXPORT:
- ExportContact((HANDLE)GetWindowLong(hwnd, GWLP_USERDATA));
+ ExportContact((HANDLE)GetWindowLongPtr(hwnd, GWLP_USERDATA));
break;
case IDC_DOIT:
@@ -357,7 +356,7 @@ INT_PTR CALLBACK DlgProcCopy(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
char dbVar1[2000], dbVar2[2000];
int i=0,j=0, k=0;
char *string = oldString[k];
- HANDLE hContact1 = (HANDLE)GetWindowLong(hwnd, GWLP_USERDATA), hContact2;
+ HANDLE hContact1 = (HANDLE)GetWindowLongPtr(hwnd, GWLP_USERDATA), hContact2;
GetDlgItemTextA(hwnd, IDC_STRING_REPLACE, replace, GetWindowTextLength(GetDlgItem(hwnd, IDC_STRING_REPLACE)) +1);
if (db_get_static(hContact1, MODNAME, "Name", dbVar1)) {
// get the list of replace strings
@@ -434,7 +433,7 @@ INT_PTR CALLBACK DlgProcCopy(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
else {
char dbVar1[2000];
- HANDLE hContact1 = (HANDLE)GetWindowLong(hwnd, GWLP_USERDATA), hContact2;
+ HANDLE hContact1 = (HANDLE)GetWindowLongPtr(hwnd, GWLP_USERDATA), hContact2;
if (db_get_static(hContact1, MODNAME, "Name", dbVar1)) {
if (!(hContact2 =(HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0))) {
msg("contact did not get created","");
diff --git a/plugins/Non-IM Contact/src/dialog.cpp b/plugins/Non-IM Contact/src/dialog.cpp
index cf3aa6a977..168caa6482 100644
--- a/plugins/Non-IM Contact/src/dialog.cpp
+++ b/plugins/Non-IM Contact/src/dialog.cpp
@@ -1,145 +1,5 @@
#include "commonheaders.h"
-int CALLBACK PropSheetProc(HWND hwnd, UINT uMsg, LPARAM lParam);
-
-void DoPropertySheet(HANDLE hContact, HINSTANCE hInst)
-{
- char title[256], nick[256];
- PROPSHEETPAGEA psp[4];
- PROPSHEETHEADERA psh;
-
- /* contact info */
- ZeroMemory(&psp[0], sizeof(PROPSHEETPAGE));
- psp[0].dwSize = sizeof(PROPSHEETPAGE);
- psp[0].dwFlags = PSP_USEICONID | PSP_USETITLE;
- psp[0].hInstance = hInst;
- psp[0].pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_INFO);
- psp[0].pszIcon = NULL;
- psp[0].pfnDlgProc = DlgProcContactInfo;
- psp[0].pszTitle = "Contacts Display Info";
- psp[0].lParam = (LPARAM)(HANDLE)hContact;
- psp[0].pfnCallback = NULL;
-
- /* other settings */
- ZeroMemory(&psp[1], sizeof(PROPSHEETPAGE));
- psp[1].dwSize = sizeof(PROPSHEETPAGE);
- psp[1].dwFlags = PSP_USEICONID | PSP_USETITLE;
- psp[1].hInstance = hInst;
- psp[1].pszTemplate = MAKEINTRESOURCEA(IDD_OTHER_STUFF);
- psp[1].pszIcon = NULL;
- psp[1].pfnDlgProc = DlgProcOtherStuff;
- psp[1].pszTitle = "Link and CList Settings";
- psp[1].lParam = (LPARAM)(HANDLE)hContact;
- psp[1].pfnCallback = NULL;
-
- /* files */
- ZeroMemory(&psp[3], sizeof(PROPSHEETPAGE));
- psp[3].dwSize = sizeof(PROPSHEETPAGE);
- psp[3].dwFlags = PSP_USEICONID | PSP_USETITLE;
- psp[3].hInstance = hInst;
- psp[3].pszTemplate = MAKEINTRESOURCEA(IDD_ADD_FILE);
- psp[3].pszIcon = NULL;
- psp[3].pfnDlgProc = DlgProcFiles;
- psp[3].pszTitle = "Files";
- psp[3].lParam = 0;
- psp[3].pfnCallback = NULL;
-
- /* copy contact */
- ZeroMemory(&psp[2], sizeof(PROPSHEETPAGE));
- psp[2].dwSize = sizeof(PROPSHEETPAGE);
- psp[2].dwFlags = PSP_USEICONID | PSP_USETITLE;
- psp[2].hInstance = hInst;
- psp[2].pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_COPYEXPORT);
- psp[2].pszIcon = NULL;
- psp[2].pfnDlgProc = DlgProcCopy;
- psp[2].pszTitle = "Copy Contact";
- psp[2].lParam = (LPARAM)(HANDLE)hContact;
- psp[2].pfnCallback = NULL;
-
-
- /* propery sheet header.. dont touch !!!! */
- ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
- psh.dwSize = sizeof(PROPSHEETHEADER);
- psh.dwFlags = PSH_USEICONID | PSH_PROPSHEETPAGE | PSH_USECALLBACK;
- psh.hwndParent = NULL;
- psh.hInstance = hInst;
- psh.pszIcon = MAKEINTRESOURCEA(IDI_MAIN);
- db_get_static(hContact, MODNAME, "Nick", nick);
- wsprintfA(title, "Edit Non-IM Contact \"%s\"", nick);
- psh.pszCaption = title;
- psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
- psh.nStartPage = 0;
- psh.ppsp = (LPCPROPSHEETPAGEA) &psp;
- psh.pfnCallback = PropSheetProc;
-
- // Now do it and return
- PropertySheetA(&psh);
-}
-
-INT_PTR addContact(WPARAM wParam,LPARAM lParam)
-{
- char tmp[256];
- HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0);
- CallService(MS_PROTO_ADDTOCONTACT,(WPARAM)hContact,(LPARAM)MODNAME);
- CallService(MS_IGNORE_IGNORE, (WPARAM)hContact, IGNOREEVENT_USERONLINE);
- db_set_s(hContact, MODNAME, "Nick", Translate("New Non-IM Contact"));
- DoPropertySheet(hContact, hInst);
- if (!db_get_static(hContact, MODNAME, "Name", tmp))
- CallService(MS_DB_CONTACT_DELETE,(WPARAM)hContact,0);
- replaceAllStrings(hContact);
- return 0;
-}
-
-INT_PTR editContact(WPARAM wParam,LPARAM lParam)
-{
- HANDLE hContact = (HANDLE)wParam;
- char tmp[256];
- if (!hContact)
- {
- hContact =(HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0);
- CallService(MS_PROTO_ADDTOCONTACT,(WPARAM)hContact,(LPARAM)MODNAME);
- CallService(MS_IGNORE_IGNORE, (WPARAM)hContact, IGNOREEVENT_USERONLINE);
- db_set_s(hContact, MODNAME, "Nick", Translate("New Non-IM Contact"));
- }
- DoPropertySheet(hContact, hInst);
- if (!db_get_static(hContact, MODNAME, "Name", tmp))
- CallService(MS_DB_CONTACT_DELETE,(WPARAM)hContact,0);
- replaceAllStrings(hContact);
- return 0;
-}
-
-int CALLBACK PropSheetProc(HWND hwnd, UINT uMsg, LPARAM lParam)
-{
- if (uMsg == PSCB_PRECREATE)
- {
- // Remove the DS_CONTEXTHELP style from the
- // dialog box template
- if (((DLGTEMPLATEEX*)lParam)->signature == 0xFFFF)
- {
- ((DLGTEMPLATEEX*)lParam)->style
- &= ~DS_CONTEXTHELP;
- }
- else {
- ((LPDLGTEMPLATE)lParam)->style
- &= ~DS_CONTEXTHELP;
- }
- return TRUE;
- }
-
- /* prob not the best way but it works... i hope */
- switch (lParam) {
- case PSBTN_OK:
- break;
- case PSBTN_CANCEL:
- break;
- case PSBTN_FINISH:
- break;
- case PSBTN_APPLYNOW:
- break;
- }
- return 0;
-}
-
INT_PTR CALLBACK DlgProcNimcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg) {
@@ -147,7 +7,6 @@ INT_PTR CALLBACK DlgProcNimcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
{
char tmp[5];
TranslateDialogDefault(hwnd);
- CheckDlgButton(hwnd, IDC_IGNORE_GLOBALSTATUS, db_get_b(NULL, MODNAME, "IgnoreGlobalStatusChange", 0));
CheckDlgButton(hwnd, IDC_AWAYISNOTONLINE, db_get_b(NULL, MODNAME, "AwayAsStatus", 0));
if (db_get_w(NULL, MODNAME, "Timer", 1))
{
@@ -192,7 +51,6 @@ INT_PTR CALLBACK DlgProcNimcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
char tmp[5];
- db_set_b(NULL, MODNAME, "IgnoreGlobalStatusChange", (BYTE)IsDlgButtonChecked(hwnd, IDC_IGNORE_GLOBALSTATUS));
db_set_b(NULL, MODNAME, "AwayAsStatus", (BYTE)IsDlgButtonChecked(hwnd, IDC_AWAYISNOTONLINE));
if (!IsDlgButtonChecked(hwnd, IDC_DISABLETIMER) && GetWindowTextLength(GetDlgItem(hwnd, IDC_TIMER_INT))) {
GetDlgItemTextA(hwnd, IDC_TIMER_INT, tmp, 4);
@@ -366,3 +224,117 @@ INT_PTR LoadFilesDlg(WPARAM wParam, LPARAM lParam)
CreateDialog(hInst,MAKEINTRESOURCE(IDD_ADD_FILE),0,DlgProcFiles);
return 0;
}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static int CALLBACK PropSheetProc(HWND hwnd, UINT uMsg, LPARAM lParam)
+{
+ if (uMsg == PSCB_PRECREATE) {
+ // Remove the DS_CONTEXTHELP style from the
+ // dialog box template
+ if (((DLGTEMPLATEEX*)lParam)->signature == 0xFFFF)
+ ((DLGTEMPLATEEX*)lParam)->style &= ~DS_CONTEXTHELP;
+ else
+ ((LPDLGTEMPLATE)lParam)->style &= ~DS_CONTEXTHELP;
+
+ return TRUE;
+ }
+
+ return 0;
+}
+
+void DoPropertySheet(HANDLE hContact, HINSTANCE hInst)
+{
+ char title[256], nick[256];
+ PROPSHEETPAGEA psp[4] = { 0 };
+
+ /* contact info */
+ psp[0].dwSize = sizeof(PROPSHEETPAGE);
+ psp[0].dwFlags = PSP_USEICONID | PSP_USETITLE;
+ psp[0].hInstance = hInst;
+ psp[0].pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_INFO);
+ psp[0].pszIcon = NULL;
+ psp[0].pfnDlgProc = DlgProcContactInfo;
+ psp[0].pszTitle = "Contacts Display Info";
+ psp[0].lParam = (LPARAM)hContact;
+ psp[0].pfnCallback = NULL;
+
+ /* other settings */
+ psp[1].dwSize = sizeof(PROPSHEETPAGE);
+ psp[1].dwFlags = PSP_USEICONID | PSP_USETITLE;
+ psp[1].hInstance = hInst;
+ psp[1].pszTemplate = MAKEINTRESOURCEA(IDD_OTHER_STUFF);
+ psp[1].pszIcon = NULL;
+ psp[1].pfnDlgProc = DlgProcOtherStuff;
+ psp[1].pszTitle = "Link and CList Settings";
+ psp[1].lParam = (LPARAM)hContact;
+ psp[1].pfnCallback = NULL;
+
+ /* copy contact */
+ psp[2].dwSize = sizeof(PROPSHEETPAGE);
+ psp[2].dwFlags = PSP_USEICONID | PSP_USETITLE;
+ psp[2].hInstance = hInst;
+ psp[2].pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_COPYEXPORT);
+ psp[2].pszIcon = NULL;
+ psp[2].pfnDlgProc = DlgProcCopy;
+ psp[2].pszTitle = "Copy Contact";
+ psp[2].lParam = (LPARAM)hContact;
+ psp[2].pfnCallback = NULL;
+
+ /* files */
+ psp[3].dwSize = sizeof(PROPSHEETPAGE);
+ psp[3].dwFlags = PSP_USEICONID | PSP_USETITLE;
+ psp[3].hInstance = hInst;
+ psp[3].pszTemplate = MAKEINTRESOURCEA(IDD_ADD_FILE);
+ psp[3].pszIcon = NULL;
+ psp[3].pfnDlgProc = DlgProcFiles;
+ psp[3].pszTitle = "Files";
+ psp[3].lParam = 0;
+ psp[3].pfnCallback = NULL;
+
+ /* propery sheet header.. dont touch !!!! */
+ PROPSHEETHEADERA psh = { sizeof(psh) };
+ psh.dwFlags = PSH_USEICONID | PSH_PROPSHEETPAGE | PSH_USECALLBACK;
+ psh.hInstance = hInst;
+ psh.pszIcon = MAKEINTRESOURCEA(IDI_MAIN);
+ db_get_static(hContact, MODNAME, "Nick", nick);
+ wsprintfA(title, "Edit Non-IM Contact \"%s\"", nick);
+ psh.pszCaption = title;
+ psh.nPages = SIZEOF(psp);
+ psh.ppsp = (LPCPROPSHEETPAGEA)&psp;
+ psh.pfnCallback = PropSheetProc;
+
+ // Now do it and return
+ PropertySheetA(&psh);
+}
+
+INT_PTR addContact(WPARAM wParam,LPARAM lParam)
+{
+ char tmp[256];
+ HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0);
+ CallService(MS_PROTO_ADDTOCONTACT,(WPARAM)hContact,(LPARAM)MODNAME);
+ CallService(MS_IGNORE_IGNORE, (WPARAM)hContact, IGNOREEVENT_USERONLINE);
+ db_set_s(hContact, MODNAME, "Nick", Translate("New Non-IM Contact"));
+ DoPropertySheet(hContact, hInst);
+ if (!db_get_static(hContact, MODNAME, "Name", tmp))
+ CallService(MS_DB_CONTACT_DELETE,(WPARAM)hContact,0);
+ replaceAllStrings(hContact);
+ return 0;
+}
+
+INT_PTR editContact(WPARAM wParam,LPARAM lParam)
+{
+ HANDLE hContact = (HANDLE)wParam;
+ char tmp[256];
+ if (!hContact) {
+ hContact = (HANDLE)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ CallService(MS_PROTO_ADDTOCONTACT,(WPARAM)hContact,(LPARAM)MODNAME);
+ CallService(MS_IGNORE_IGNORE, (WPARAM)hContact, IGNOREEVENT_USERONLINE);
+ db_set_s(hContact, MODNAME, "Nick", Translate("New Non-IM Contact"));
+ }
+ DoPropertySheet(hContact, hInst);
+ if (!db_get_static(hContact, MODNAME, "Name", tmp))
+ CallService(MS_DB_CONTACT_DELETE,(WPARAM)hContact,0);
+ replaceAllStrings(hContact);
+ return 0;
+}
diff --git a/plugins/Non-IM Contact/src/main.cpp b/plugins/Non-IM Contact/src/main.cpp
index a41aa8500b..ebefd3ce12 100644
--- a/plugins/Non-IM Contact/src/main.cpp
+++ b/plugins/Non-IM Contact/src/main.cpp
@@ -114,10 +114,17 @@ int ModulesLoaded(WPARAM wParam,LPARAM lParam)
// Description : Called when plugin is loaded into Miranda
//=====================================================
+IconItem icoList[] =
+{
+ { LPGEN("Main Icon"), MODNAME, IDI_MAIN },
+};
+
extern "C" __declspec(dllexport) int Load()
{
mir_getLP(&pluginInfoEx);
+ Icon_Register(hInst, LPGEN("Non-IM Contact"), icoList, SIZEOF(icoList));
+
HookEvent(ME_CLIST_DOUBLECLICKED, (MIRANDAHOOK)doubleClick);
HookEvent(ME_OPT_INITIALISE,NimcOptInit);
HookEvent(ME_CLIST_STATUSMODECHANGE, SetLCStatus);
@@ -140,18 +147,18 @@ extern "C" __declspec(dllexport) int Load()
CreateServiceFunction("NIM_Contact/DoubleClick", doubleClick);
CLISTMENUITEM mi = { sizeof(mi) };
+ mi.flags = CMIF_ICONFROMICOLIB;
mi.position = 600090000;
mi.pszPopupName = LPGEN("&Non-IM Contact");
mi.popupPosition = 600090000;
mi.pszName = LPGEN("&Add Non-IM Contact");
mi.pszService = "AddLCcontact";
- mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_MAIN));
+ mi.icolibItem = icoList[0].hIcolib;
Menu_AddMainMenuItem(&mi);
mi.position = 600090001;
mi.pszName = LPGEN("&View/Edit Files");
mi.pszService = "LoadFilesDlg";
- mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_MAIN));
Menu_AddMainMenuItem(&mi);
if (db_get_b(NULL, MODNAME, "Beta",0)) {
@@ -176,11 +183,9 @@ extern "C" __declspec(dllexport) int Load()
mi.pszContactOwner = MODNAME;
mi.pszName = LPGEN("E&dit Contact Settings");
mi.pszService = "EditLCcontact";
- mi.hIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_MAIN));
Menu_AddMainMenuItem(&mi);
- hWindowList = (HWND)CallService(MS_UTILS_ALLOCWINDOWLIST,0,0);
- HookEvent(ME_SYSTEM_MODULESLOADED,ModulesLoaded);
+ HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
// known modules list
db_set_s(NULL, "KnownModules","Non-IM Contact", MODNAME);
diff --git a/plugins/Non-IM Contact/src/namereplacing.cpp b/plugins/Non-IM Contact/src/namereplacing.cpp
index 8f3f07e82e..622126ff64 100644
--- a/plugins/Non-IM Contact/src/namereplacing.cpp
+++ b/plugins/Non-IM Contact/src/namereplacing.cpp
@@ -7,7 +7,7 @@ int readFileIntoArray(int fileNumber, char *FileContents[])
DBVARIANT dbv;
char tszFileName[MAX_PATH];
- if (db_get_ts(NULL,MODNAME, dbSetting, &dbv))
+ if (db_get_ts(NULL, MODNAME, dbSetting, &dbv))
return 0;
if (!strncmp("http://", tszFileName, 7))
@@ -245,7 +245,7 @@ void checkStringForSave(HANDLE hContact, char* str)
B = strtok(NULL, ",\")");
j = B - &copyOfStr[i] + strlen(B)+1;
if (A && B)
- db_set_s(hContact,MODNAME, A, B);
+ db_set_s(hContact, MODNAME, A, B);
else strncat(newStr, &str[i], j);
i += j;
diff --git a/plugins/Non-IM Contact/src/resource.h b/plugins/Non-IM Contact/src/resource.h
index 928cde8564..c423077863 100644
--- a/plugins/Non-IM Contact/src/resource.h
+++ b/plugins/Non-IM Contact/src/resource.h
@@ -38,7 +38,6 @@
#define IDC_EXPORT 1027
#define IDC_ALWAYS_VISIBLE 1028
#define IDC_VISIBLE_UNLESS_OFFLINE 1029
-#define IDC_IGNORE_GLOBALSTATUS 1030
#define IDC_DISABLETIMER 1031
#define IDC_TIMER_INT 1036
#define IDC_AWAYISNOTONLINE 1037
diff --git a/plugins/Non-IM Contact/src/services.cpp b/plugins/Non-IM Contact/src/services.cpp
index 1e547fb80c..d3aff868ba 100644
--- a/plugins/Non-IM Contact/src/services.cpp
+++ b/plugins/Non-IM Contact/src/services.cpp
@@ -50,13 +50,20 @@ INT_PTR GetLCName(WPARAM wParam,LPARAM lParam)
//=======================================================
INT_PTR LoadLCIcon(WPARAM wParam,LPARAM lParam)
{
- UINT id;
+ if (LOWORD(wParam) == PLI_PROTOCOL) {
+ if (wParam & PLIF_ICOLIBHANDLE)
+ return (INT_PTR)icoList[0].hIcolib;
- switch(wParam & 0xFFFF) {
- case PLI_PROTOCOL: id=IDI_MAIN; break; // IDI_MAIN is the main icon for the protocol
- default: return (int)(HICON)NULL;
+ HICON hIcon = Skin_GetIconByHandle(icoList[0].hIcolib, (wParam & PLIF_SMALL) == 0);
+ if (wParam & PLIF_ICOLIB)
+ return (INT_PTR)hIcon;
+
+ HICON hIcon2 = CopyIcon(hIcon);
+ Skin_ReleaseIcon(hIcon);
+ return (INT_PTR)hIcon2;
}
- return (int)LoadImage(hInst,MAKEINTRESOURCE(id),IMAGE_ICON,GetSystemMetrics(wParam&PLIF_SMALL?SM_CXSMICON:SM_CXICON),GetSystemMetrics(wParam&PLIF_SMALL?SM_CYSMICON:SM_CYICON),0);
+
+ return NULL;
}
//=======================================================
@@ -64,56 +71,54 @@ INT_PTR LoadLCIcon(WPARAM wParam,LPARAM lParam)
//=======================================================
int SetLCStatus(WPARAM wParam,LPARAM lParam)
{
- int oldStatus;
- HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
- const char* szProto = (const char*)lParam;
- if (szProto && strcmp(szProto, MODNAME)) return 0; // not nimc so ignore anyway...
- else if (!szProto && db_get_b(NULL, MODNAME, "IgnoreGlobalStatusChange",0)) return 0; // global change and being ignored
- else {
- oldStatus = LCStatus;
- LCStatus = wParam;
- db_set_w(NULL, MODNAME, "Status", (WORD)wParam);
- db_set_w(NULL, MODNAME, "timerCount",0);
- if (LCStatus == ID_STATUS_OFFLINE || (LCStatus == ID_STATUS_AWAY && !db_get_b(NULL, MODNAME, "AwayAsStatus", 0)) || !db_get_w(NULL, MODNAME, "Timer",1)) killTimer();
- else if (db_get_w(NULL, MODNAME, "Timer",1))
- startTimer(TIMER);
- while (hContact) {
- char* proto = GetContactProto(hContact);
- if (proto && !strcmp(proto, MODNAME)) {
- if (LCStatus != ID_STATUS_OFFLINE) replaceAllStrings(hContact);
- switch (LCStatus) {
- case ID_STATUS_OFFLINE:
- if (db_get_b(hContact, MODNAME, "AlwaysVisible",0) && !db_get_b(hContact, MODNAME, "VisibleUnlessOffline",1))
- db_set_w(hContact,MODNAME, "Status",(WORD)db_get_w(hContact,MODNAME, "Icon",ID_STATUS_ONLINE));
- else
- db_set_w(hContact,MODNAME, "Status", ID_STATUS_OFFLINE);
- break;
- case ID_STATUS_ONLINE:
- db_set_w(hContact,MODNAME, "Status",(WORD)db_get_w(hContact,MODNAME, "Icon",ID_STATUS_ONLINE));
- break;
- case ID_STATUS_AWAY:
- if (db_get_b(NULL, MODNAME, "AwayAsStatus", 0) && (db_get_b(hContact, MODNAME, "AlwaysVisible",0) || (db_get_w(hContact,MODNAME, "Icon",ID_STATUS_ONLINE)==ID_STATUS_AWAY)) )
- db_set_w(hContact,MODNAME, "Status",(WORD)(WORD)db_get_w(hContact,MODNAME, "Icon",ID_STATUS_ONLINE));
- else if (!db_get_b(NULL, MODNAME, "AwayAsStatus", 0))
- db_set_w(hContact,MODNAME, "Status",(WORD)db_get_w(hContact,MODNAME, "Icon",ID_STATUS_ONLINE));
- else
- db_set_w(hContact,MODNAME, "Status", ID_STATUS_OFFLINE);
- break;
- default:
- if (db_get_b(hContact, MODNAME, "AlwaysVisible",0) || LCStatus == db_get_w(hContact,MODNAME, "Icon",ID_STATUS_ONLINE))
- db_set_w(hContact,MODNAME, "Status",(WORD)db_get_w(hContact,MODNAME, "Icon",ID_STATUS_ONLINE));
- break;
- }
- }
- hContact = db_find_next(hContact);
+ int oldStatus = LCStatus;
+ LCStatus = wParam;
+ db_set_w(NULL, MODNAME, "Status", (WORD)wParam);
+ db_set_w(NULL, MODNAME, "timerCount",0);
+ if (LCStatus == ID_STATUS_OFFLINE || (LCStatus == ID_STATUS_AWAY && !db_get_b(NULL, MODNAME, "AwayAsStatus", 0)) || !db_get_w(NULL, MODNAME, "Timer",1)) killTimer();
+ else if (db_get_w(NULL, MODNAME, "Timer",1))
+ startTimer(TIMER);
+
+ for (HANDLE hContact = db_find_first(MODNAME); hContact; hContact = db_find_next(hContact)) {
+ char *proto = GetContactProto(hContact);
+ if (proto == NULL || strcmp(proto, MODNAME))
+ continue;
+
+ if (LCStatus != ID_STATUS_OFFLINE)
+ replaceAllStrings(hContact);
+
+ switch (LCStatus) {
+ case ID_STATUS_OFFLINE:
+ if (db_get_b(hContact, MODNAME, "AlwaysVisible",0) && !db_get_b(hContact, MODNAME, "VisibleUnlessOffline",1))
+ db_set_w(hContact, MODNAME, "Status",(WORD)db_get_w(hContact, MODNAME, "Icon",ID_STATUS_ONLINE));
+ else
+ db_set_w(hContact, MODNAME, "Status", ID_STATUS_OFFLINE);
+ break;
+
+ case ID_STATUS_ONLINE:
+ db_set_w(hContact, MODNAME, "Status",(WORD)db_get_w(hContact, MODNAME, "Icon",ID_STATUS_ONLINE));
+ break;
+
+ case ID_STATUS_AWAY:
+ if (db_get_b(NULL, MODNAME, "AwayAsStatus", 0) && (db_get_b(hContact, MODNAME, "AlwaysVisible",0) || (db_get_w(hContact, MODNAME, "Icon",ID_STATUS_ONLINE)==ID_STATUS_AWAY)) )
+ db_set_w(hContact, MODNAME, "Status",(WORD)(WORD)db_get_w(hContact, MODNAME, "Icon",ID_STATUS_ONLINE));
+ else if (!db_get_b(NULL, MODNAME, "AwayAsStatus", 0))
+ db_set_w(hContact, MODNAME, "Status",(WORD)db_get_w(hContact, MODNAME, "Icon",ID_STATUS_ONLINE));
+ else
+ db_set_w(hContact, MODNAME, "Status", ID_STATUS_OFFLINE);
+ break;
+
+ default:
+ if (db_get_b(hContact, MODNAME, "AlwaysVisible",0) || LCStatus == db_get_w(hContact, MODNAME, "Icon",ID_STATUS_ONLINE))
+ db_set_w(hContact, MODNAME, "Status",(WORD)db_get_w(hContact, MODNAME, "Icon",ID_STATUS_ONLINE));
+ break;
}
- ProtoBroadcastAck(MODNAME,NULL,ACKTYPE_STATUS,ACKRESULT_SUCCESS,(HANDLE)oldStatus,wParam);
}
+
+ ProtoBroadcastAck(MODNAME,NULL,ACKTYPE_STATUS,ACKRESULT_SUCCESS,(HANDLE)oldStatus,wParam);
return 0;
}
-
-
//=======================================================
//GetStatus
//=======================================================