diff options
author | Gluzskiy Alexandr <sss123next@list.ru> | 2010-09-26 21:46:33 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss123next@list.ru> | 2010-09-26 21:46:33 +0300 |
commit | dcf36bc803916561f01febeedb76501d3fe3f729 (patch) | |
tree | 904d682ba3d6077ce0c585514827b14294ff67a9 | |
parent | fa9565edd129e41bc45e5e7012a15de1456448eb (diff) |
modified: messages.cpp
modified: options.cpp
modified: replacer.suo
-rw-r--r-- | messages.cpp | 67 | ||||
-rw-r--r-- | options.cpp | 30 | ||||
-rw-r--r-- | replacer.suo | bin | 54272 -> 55296 bytes |
3 files changed, 82 insertions, 15 deletions
diff --git a/messages.cpp b/messages.cpp index 16cac57..7b2424e 100644 --- a/messages.cpp +++ b/messages.cpp @@ -43,6 +43,8 @@ int RecvMsgSvc(WPARAM w, LPARAM l) return CallService(MS_PROTO_CHAINRECV, w, l); } +char *send_msg = NULL; + int SendMsgSvc(WPARAM w, LPARAM l) { CCSDATA *ccs = (CCSDATA*)l; @@ -55,6 +57,71 @@ int SendMsgSvc(WPARAM w, LPARAM l) HANDLE hContact = ccs->hContact; if(isProtoMetaContacts(hContact)) hContact = metaGetMostOnline(hContact); + + TCHAR *tmp = mir_a2t(msg); + wstring str = tmp; + mir_free(tmp); + + int i = 0; + char setting[32]; + mir_snprintf(setting, 31, "szSourceWord%d", i); + TCHAR *buf = UniGetContactSettingUtf(NULL, szReplacerModuleName, setting, _T("")); + wstring::size_type p1 = 0; + while(_tcslen(buf) > 0) + { + mir_snprintf(setting, 31, "szTargetWords%d", i); + TCHAR *buf2 = UniGetContactSettingUtf(NULL, szReplacerModuleName, setting, _T("")); + wstring tmp = buf2; + mir_free(buf2); + wstring::size_type p1 = 0, p2 = 0, end = 0; + p1 = tmp.find(_T("†")); //nice delimiter + int c = 0; + TCHAR *words[1024]; //fucked msvc does not support variable massive size ( + for(;;) + { + if(p1 == wstring::npos) + break; + if(!c) + { + words[c] = mir_wstrdup(tmp.substr(0, p1).c_str()); + p2 = end = p1; + } + else + { + p2 = tmp.find(_T("†"), p1+1); + if(p2 < end || p2 == p1) + break; + else if(p2 == wstring::npos) + break; + p1++; + words[c] = mir_wstrdup(tmp.substr(p1, p2-p1).c_str()); + end = p2; + } + p1 = p2; + c++; + } + if(c) + { + p1 = 0; + wstring::size_type end = 0; + while((p1 = str.find(buf), p1) != wstring::npos) + { + if(p1 < end) + break; + int p = (c>1)?(rand()%(c-1)):0; + str.replace(p1, (wstring::size_type)_tcslen(buf), words[p]); + p1+=_tcslen(words[p]); + end = p1; + } + } + mir_free(buf); + for(int cc = 0; cc < c; cc++) + mir_free(words[cc]); + i++; + mir_snprintf(setting, 31, "szSourceWord%d", i); + buf = UniGetContactSettingUtf(NULL, szReplacerModuleName, setting, _T("")); + } + ccs->lParam = (LPARAM)mir_utf8encodeW(str.c_str()); return CallService(MS_PROTO_CHAINSEND, w, l); } diff --git a/options.cpp b/options.cpp index 2c8f774..b0e640b 100644 --- a/options.cpp +++ b/options.cpp @@ -81,7 +81,7 @@ static BOOL CALLBACK DlgProcReplacerOpts(HWND hwndDlg, UINT msg, WPARAM wParam, col.cx = 80; ListView_InsertColumn(hwndList2, 0, &col); int i = 0, iRow = 0; - char *setting = new char [32]; + char setting[32]; TCHAR *buf = NULL; mir_snprintf(setting, 31, "szSourceWord%d", i); buf = UniGetContactSettingUtf(NULL, szReplacerModuleName, setting, _T("")); @@ -119,7 +119,6 @@ static BOOL CALLBACK DlgProcReplacerOpts(HWND hwndDlg, UINT msg, WPARAM wParam, EnableWindow(GetDlgItem(hwndDlg, IDC_ADD), 0); EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE), 0); EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), 0); - delete [] setting; return TRUE; } @@ -132,24 +131,12 @@ static BOOL CALLBACK DlgProcReplacerOpts(HWND hwndDlg, UINT msg, WPARAM wParam, { bEdit = false; ShowWordEditDialog(); -/* if(hwnd_list_p == hwndList1) - { - } - else if(hwnd_list_p == hwndList2) - { - } */ } break; case IDC_CHANGE: { bEdit = true; ShowWordEditDialog(); -/* if(hwnd_list_p == hwndList1) - { - } - else if(hwnd_list_p == hwndList2) - { - } */ } break; case IDC_DELETE: @@ -353,7 +340,20 @@ static BOOL CALLBACK DlgProcWordEditDialog(HWND hwndDlg, UINT msg, WPARAM wParam TCHAR str[512]; GetDlgItemText(hwndDlg, IDC_EDIT_WORD, str, 511); if(bTargetWord) - ; + { + char setting[32]; + setting[0] = '\0'; + mir_snprintf(setting, 31, "szTargetWords%d", item_num_1); + TCHAR *buf = UniGetContactSettingUtf(NULL, szReplacerModuleName, setting, _T("")); + wstring data = buf; + mir_free(buf); + TCHAR tmp[128]; + ListView_GetItemText(hwnd_list_p, item_num_2, 0,tmp, 127); + wstring::size_type p1 = data.find(tmp); + data.replace(p1, (wstring::size_type)_tcslen(tmp), str); + DBWriteContactSettingTString(NULL, szReplacerModuleName, setting, data.c_str()); + ListView_SetItemText(hwnd_list_p, item_num_2, 0, str); + } else { char setting[32]; diff --git a/replacer.suo b/replacer.suo Binary files differindex 26b6863..2a185f9 100644 --- a/replacer.suo +++ b/replacer.suo |