summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nohtml/filter.cpp34
-rw-r--r--nohtml/nohtml.rc5
-rw-r--r--nohtml/nohtml_8.sln (renamed from nohtml/nohtml.sln)2
-rw-r--r--nohtml/nohtml_8.vcproj (renamed from nohtml/nohtml.vcproj)0
-rw-r--r--nohtml/options.cpp3
-rw-r--r--nohtml/options.h1
-rw-r--r--nohtml/resource.h1
7 files changed, 37 insertions, 9 deletions
diff --git a/nohtml/filter.cpp b/nohtml/filter.cpp
index 4d3ed77..11229cd 100644
--- a/nohtml/filter.cpp
+++ b/nohtml/filter.cpp
@@ -5,15 +5,34 @@
int FilterSendMessage(WPARAM wParam, LPARAM lParam) {
CCSDATA *ccs = (CCSDATA *) lParam;
- char *message = (char *)ccs->lParam;
-
- // TODO: process 'message' and/or 'messagew' below
- if(ccs->wParam & PREF_UNICODE) {
- wchar_t *messagew = (wchar_t *)&message[strlen(message)+1];
- } else {
+ char *old_message = (char *)ccs->lParam;
+
+ char *buf = 0;
+ if(options.html) {
+ if(ccs->wParam & PREF_UNICODE) {
+ wchar_t *messagew = (wchar_t *)&old_message[strlen(old_message)+1];
+ wchar_t* smsg=strip_carrots(messagew);
+ wchar_t* html_msg=bbcodes_to_html(smsg);
+ delete[] smsg;
+
+ buf=(char *)malloc(wcslen(html_msg)*3+3);
+ WideCharToMultiByte( CP_ACP, 0,html_msg, -1,buf,wcslen(html_msg)+1, NULL, NULL);
+ memcpy(&buf[strlen(buf)+1],html_msg,lstrlen(buf)*2+2);
+ delete[] html_msg;
+ } else {
+ char* smsg=strip_carrots(old_message);
+ char* html_msg=bbcodes_to_html(smsg);
+ delete[] smsg;
+ buf = strdup(html_msg);
+ delete[] html_msg;
+ }
+ ccs->lParam = (LPARAM)buf;
}
- return CallService(MS_PROTO_CHAINSEND, wParam, lParam);
+ int ret = CallService(MS_PROTO_CHAINSEND, wParam, lParam);
+ ccs->lParam = (LPARAM)old_message;
+ if(buf) free(buf);
+ return ret;
}
int FilterSendMessageW(WPARAM wParam, LPARAM lParam) {
@@ -72,6 +91,7 @@ int FilterRecvMessage(WPARAM wParam, LPARAM lParam) {
int ret = CallService(MS_PROTO_CHAINRECV, wParam, lParam);
pre->szMessage = old_message;
+ if(buf) free(buf);
return ret;
}
diff --git a/nohtml/nohtml.rc b/nohtml/nohtml.rc
index 1389299..3c1052e 100644
--- a/nohtml/nohtml.rc
+++ b/nohtml/nohtml.rc
@@ -30,7 +30,10 @@ IDD_OPT1 DIALOGEX 0, 0, 246, 179
STYLE DS_SETFONT | WS_POPUP
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
- CONTROL "Replace HTML with BBCodes",IDC_CHK_BBCODES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,65,74,111,10
+ CONTROL "Replace HTML with BBCodes",IDC_CHK_BBCODES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,41,39,111,10
+ GROUPBOX "Incoming Messages",IDC_STATIC,15,15,165,54
+ CONTROL "Replace BBCodes with HTML",IDC_CHK_HTML,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,41,97,111,10
+ GROUPBOX "Outgoing Messages",IDC_STATIC,15,73,165,54
END
diff --git a/nohtml/nohtml.sln b/nohtml/nohtml_8.sln
index dfd1856..e0aec2b 100644
--- a/nohtml/nohtml.sln
+++ b/nohtml/nohtml_8.sln
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nohtml", "nohtml.vcproj", "{35961A10-6297-47AA-A6D9-1713389AC5F9}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nohtml", "nohtml_8.vcproj", "{35961A10-6297-47AA-A6D9-1713389AC5F9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
diff --git a/nohtml/nohtml.vcproj b/nohtml/nohtml_8.vcproj
index fcd5a30..fcd5a30 100644
--- a/nohtml/nohtml.vcproj
+++ b/nohtml/nohtml_8.vcproj
diff --git a/nohtml/options.cpp b/nohtml/options.cpp
index 3eb06ca..927260b 100644
--- a/nohtml/options.cpp
+++ b/nohtml/options.cpp
@@ -6,10 +6,12 @@ Options options;
void LoadOptions() {
DBWriteContactSettingDword(0, MODULE, "BBCodes", options.bbcodes ? 1 : 0);
+ DBWriteContactSettingDword(0, MODULE, "HTML", options.html ? 1 : 0);
}
void SaveOptions() {
options.bbcodes = (DBGetContactSettingDword(0, MODULE, "BBCodes", 0) != 0);
+ options.html = (DBGetContactSettingDword(0, MODULE, "HTML", 0) != 0);
}
BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
@@ -28,6 +30,7 @@ BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
case PSN_APPLY:
options.bbcodes = IsDlgButtonChecked(hwndDlg, IDC_CHK_BBCODES);
+ options.html = IsDlgButtonChecked(hwndDlg, IDC_CHK_HTML);
SaveOptions();
break;
}
diff --git a/nohtml/options.h b/nohtml/options.h
index f679ad6..d5c7dba 100644
--- a/nohtml/options.h
+++ b/nohtml/options.h
@@ -3,6 +3,7 @@
typedef struct {
bool bbcodes;
+ bool html;
} Options;
extern Options options;
diff --git a/nohtml/resource.h b/nohtml/resource.h
index ebcf9c7..d8ab8e5 100644
--- a/nohtml/resource.h
+++ b/nohtml/resource.h
@@ -4,6 +4,7 @@
//
#define IDD_OPT1 109
#define IDC_CHK_BBCODES 1001
+#define IDC_CHK_HTML 1002
// Next default values for new objects
//